diff options
-rw-r--r-- | src/actions/commands.cpp | 10 | ||||
-rw-r--r-- | src/actions/move.cpp | 8 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 7 | ||||
-rw-r--r-- | src/being/localplayer.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 12 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 7 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.h | 2 |
11 files changed, 52 insertions, 10 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 1c57bd677..529025481 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -459,8 +459,11 @@ impHandler(follow) impHandler(navigate) { - if (!localPlayer) + if (!localPlayer || + !localPlayer->canMove()) + { return false; + } int x = 0; int y = 0; @@ -474,8 +477,11 @@ impHandler(navigate) impHandler(navigateTo) { - if (!localPlayer) + if (!localPlayer || + !localPlayer->canMove()) + { return false; + } const std::string args = event.args; if (args.empty()) diff --git a/src/actions/move.cpp b/src/actions/move.cpp index 2c9a3b692..789556910 100644 --- a/src/actions/move.cpp +++ b/src/actions/move.cpp @@ -71,6 +71,8 @@ impHandler(moveUp) return petDirectUp(event); else if (inputManager.isActionActive(InputAction::STOP_ATTACK)) return petMoveUp(event); + else if (!localPlayer->canMove()) + return directUp(event); if (popupMenu->isPopupVisible()) { popupMenu->moveUp(); @@ -87,6 +89,8 @@ impHandler(moveDown) return petDirectDown(event); else if (inputManager.isActionActive(InputAction::STOP_ATTACK)) return petMoveDown(event); + else if (!localPlayer->canMove()) + return directDown(event); if (popupMenu->isPopupVisible()) { popupMenu->moveDown(); @@ -110,6 +114,8 @@ impHandler(moveLeft) return petDirectLeft(event); else if (inputManager.isActionActive(InputAction::STOP_ATTACK)) return petMoveLeft(event); + else if (!localPlayer->canMove()) + return directLeft(event); return closeMoveNpcDialog(false); } @@ -128,6 +134,8 @@ impHandler(moveRight) return petDirectRight(event); else if (inputManager.isActionActive(InputAction::STOP_ATTACK)) return petMoveRight(event); + else if (!localPlayer->canMove()) + return directRight(event); return closeMoveNpcDialog(false); } diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index e2450610c..ec62fe735 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2703,3 +2703,10 @@ void LocalPlayer::playerDeath() recalcSpritesOrder(); } } + +bool LocalPlayer::canMove() const +{ + return mAction != BeingAction::DEAD && + (serverFeatures->haveMoveWhileSit() || + mAction != BeingAction::SIT); +} diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 3c0ed4286..732c27c7f 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -421,6 +421,8 @@ class LocalPlayer final : public Being, bool getRename() const { return mAllowRename; } + bool canMove() const; + protected: void updateCoords() override final; diff --git a/src/game.cpp b/src/game.cpp index c59103bb6..0474dad33 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -852,12 +852,12 @@ void Game::handleMove() } // Moving player around - if (localPlayer->isAlive() - && chatWindow - && !chatWindow->isInputFocused() - && !InventoryWindow::isAnyInputFocused() - && !quitDialog - && !popupMenu->isPopupVisible()) + if (chatWindow && + !quitDialog && + localPlayer->canMove() && + !chatWindow->isInputFocused() && + !InventoryWindow::isAnyInputFocused() && + !popupMenu->isPopupVisible()) { NpcDialog *const dialog = NpcDialog::getActive(); if (dialog) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 815aa82a8..9c4eaf713 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -500,7 +500,8 @@ bool Viewport::leftMouseAction() return true; } // Just walk around - else if (!inputManager.isActionActive(InputAction::ATTACK)) + else if (!inputManager.isActionActive(InputAction::ATTACK) && + localPlayer->canMove()) { validateSpeed(); localPlayer->stopAttack(); @@ -756,7 +757,9 @@ void Viewport::mouseDragged(MouseEvent &event) mPlayerFollowMouse = false; return; } - if (mMouseClicked) + if (mMouseClicked && + localPlayer && + localPlayer->canMove()) { if (abs(event.getX() - mMousePressX) > 32 || abs(event.getY() - mMousePressY) > 32) diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index a830acc5f..f995f55ad 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -290,4 +290,9 @@ bool ServerFeatures::haveFamily() const return true; } +bool ServerFeatures::haveMoveWhileSit() const +{ + return serverVersion > 0; +} + } // namespace EAthena diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h index 2753003da..3206f1adf 100644 --- a/src/net/eathena/serverfeatures.h +++ b/src/net/eathena/serverfeatures.h @@ -135,6 +135,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveServerPets() const override final; bool haveFamily() const override final; + + bool haveMoveWhileSit() const override final; }; } // namespace EAthena diff --git a/src/net/serverfeatures.h b/src/net/serverfeatures.h index 8f690b3ed..eead64f72 100644 --- a/src/net/serverfeatures.h +++ b/src/net/serverfeatures.h @@ -132,6 +132,8 @@ class ServerFeatures notfinal virtual bool haveServerPets() const = 0; virtual bool haveFamily() const = 0; + + virtual bool haveMoveWhileSit() const = 0; }; } // namespace Net diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp index d6f785915..b533301a7 100644 --- a/src/net/tmwa/serverfeatures.cpp +++ b/src/net/tmwa/serverfeatures.cpp @@ -288,4 +288,9 @@ bool ServerFeatures::haveFamily() const return false; } +bool ServerFeatures::haveMoveWhileSit() const +{ + return true; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h index 9ce160ac1..747b1ab93 100644 --- a/src/net/tmwa/serverfeatures.h +++ b/src/net/tmwa/serverfeatures.h @@ -135,6 +135,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveServerPets() const override final A_CONST; bool haveFamily() const override final A_CONST; + + bool haveMoveWhileSit() const override final A_CONST; }; } // namespace TmwAthena |