summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2011-08-24 22:42:17 +0200
committerReid <reidyaro@gmail.com>2011-08-24 22:42:17 +0200
commit43c19a8321bd0c4bcf36655d74e895397aff7eea (patch)
treec8f7933367ae1e757a3166a04772274896d58c9c /src/gui/viewport.cpp
parentc1ec2b921389cb5c44d9ae572ea4851891cf8bc9 (diff)
parent9505e3789cc9db6a10a68b9794a586604271b76f (diff)
downloadplus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.gz
plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.bz2
plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.xz
plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index ba8414699..a5b541a8e 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -36,7 +36,7 @@
#include "gui/beingpopup.h"
#include "gui/chatwindow.h"
#include "gui/gui.h"
-#include "gui/ministatus.h"
+#include "gui/ministatuswindow.h"
#include "gui/popupmenu.h"
#include "gui/statuspopup.h"
#include "gui/textpopup.h"
@@ -145,8 +145,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
if (mScrollLaziness < 1)
mScrollLaziness = 1; // Avoids division by zero
+ int cnt = 0;
+
// Apply lazy scrolling
- while (lastTick < tick_time)
+ while (lastTick < tick_time && cnt < 32)
{
if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
{
@@ -172,19 +174,26 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
- static_cast<int>(mPixelViewY) + mScrollRadius) /
static_cast<float>(mScrollLaziness);
}
- lastTick++;
+ lastTick ++;
+ cnt ++;
}
// Auto center when player is off screen
- if (player_x - static_cast<int>(mPixelViewX) > graphics->mWidth / 2
- || static_cast<int>(mPixelViewX) - player_x > graphics->mWidth / 2
- || static_cast<int>(mPixelViewY) - player_y
- > graphics->getHeight() / 2
- || player_y - static_cast<int>(mPixelViewY)
- > graphics->getHeight() / 2)
+ if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
+ > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
+ - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
+ - player_y > graphics->getHeight() / 2 || player_y
+ - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
{
mPixelViewX = static_cast<float>(player_x);
mPixelViewY = static_cast<float>(player_y);
+ if (player_x <= 0 || player_y <= 0)
+ {
+ if (debugChatTab)
+ debugChatTab->chatLog("incorrect player position!");
+ logger->log("incorrect player position: %d, %d",
+ player_x, player_y);
+ }
};
// Don't move camera so that the end of the map is on screen
@@ -684,7 +693,8 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
const int y = getMouseY() + static_cast<int>(mPixelViewY);
mHoverBeing = actorSpriteManager->findBeingByPixel(x, y, true);
- if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER)
+ if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER
+ || mHoverBeing->getType() == Being::NPC))
{
mTextPopup->setVisible(false);
if (mShowBeingPopup)