diff options
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 30 |
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) |