summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-22 22:09:02 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-22 22:09:02 +0300
commit51c9a63a660fe88cfa44d93028e6ae2448fb889d (patch)
tree8c4b1db548208737a43d52fbe28b99cb5060f017 /src
parentbce511aaf8b9d2b5d447f67ba0c05e2f9a92b7ca (diff)
downloadplus-51c9a63a660fe88cfa44d93028e6ae2448fb889d.tar.gz
plus-51c9a63a660fe88cfa44d93028e6ae2448fb889d.tar.bz2
plus-51c9a63a660fe88cfa44d93028e6ae2448fb889d.tar.xz
plus-51c9a63a660fe88cfa44d93028e6ae2448fb889d.zip
Not allow moving from sit state if server not support it.
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp10
-rw-r--r--src/actions/move.cpp8
-rw-r--r--src/being/localplayer.cpp7
-rw-r--r--src/being/localplayer.h2
-rw-r--r--src/game.cpp12
-rw-r--r--src/gui/viewport.cpp7
-rw-r--r--src/net/eathena/serverfeatures.cpp5
-rw-r--r--src/net/eathena/serverfeatures.h2
-rw-r--r--src/net/serverfeatures.h2
-rw-r--r--src/net/tmwa/serverfeatures.cpp5
-rw-r--r--src/net/tmwa/serverfeatures.h2
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