diff options
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1a8231780..e0d5d217f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -491,13 +491,16 @@ bool Viewport::leftMouseAction() } else if (stopAttack) { - const int mouseTileX = (mMouseX + mPixelViewX) - / mMap->getTileWidth(); - const int mouseTileY = (mMouseY + mPixelViewY) - / mMap->getTileHeight(); - inputManager.executeChatCommand(InputAction::PET_MOVE, - strprintf("%d %d", mouseTileX, mouseTileY), - nullptr); + if (mMap) + { + const int mouseTileX = (mMouseX + mPixelViewX) + / mMap->getTileWidth(); + const int mouseTileY = (mMouseY + mPixelViewY) + / mMap->getTileHeight(); + inputManager.executeChatCommand(InputAction::PET_MOVE, + strprintf("%d %d", mouseTileX, mouseTileY), + nullptr); + } return true; } // Just walk around @@ -587,6 +590,8 @@ void Viewport::getMouseTile(int &destX, int &destY) void Viewport::getMouseTile(const int x, const int y, int &destX, int &destY) const { + if (!mMap) + return; const int tw = mMap->getTileWidth(); const int th = mMap->getTileHeight(); destX = CAST_S32(x + mPixelViewX) |