From ae8c3e89728ddc1f8e91e6e54ded039fd1fa600f Mon Sep 17 00:00:00 2001 From: Bertram Date: Fri, 16 Oct 2009 01:12:09 +0200 Subject: Made the keyboard walking pixel exact again. What's left is working on player corner handling and directions while walking. --- src/gui/viewport.cpp | 1 + src/localplayer.cpp | 12 +++++++++--- src/localplayer.h | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 7010ced6..cf21288c 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -378,6 +378,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) mLocalWalkTime = tick_time; player_node->setDestination(event.getX() + (int) mPixelViewX, event.getY() + (int) mPixelViewY); + player_node->pathSetByMouse(); } #else player_node->setDestination(tilex, tiley); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 65f1fcc7..78988aa1 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -103,6 +103,7 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mTrading(false), mGoingToTarget(false), mKeepAttacking(false), mLastAction(-1), mWalkingDir(0), + mPathSetByMouse(false), mDestX(0), mDestY(0), mInventory(new Inventory(INVENTORY_SIZE)), #ifdef TMWSERV_SUPPORT @@ -538,10 +539,12 @@ void LocalPlayer::setWalkingDir(int dir) player_node->stopWalking(false); // Else, he is not pressing a key, - // And the current path is over. Then, stop (sending to server). - else if (!dir && mPath.empty()) + // and the current path hasn't been sent by mouse, + // then, stop (sending to server). + else if (!dir) { - player_node->stopWalking(true); + if (!mPathSetByMouse) + player_node->stopWalking(true); return; } @@ -641,6 +644,9 @@ void LocalPlayer::stopWalking(bool sendToServer) setAction(STAND); } + // No path set anymore, so we reset the path by mouse flag + mPathSetByMouse = false; + clearPath(); } diff --git a/src/localplayer.h b/src/localplayer.h index 28a1c286..9229c583 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -367,6 +367,10 @@ class LocalPlayer : public Player std::pair getExperience(int skill); + /** Tells the path has been set by mouse */ + void pathSetByMouse() + { mPathSetByMouse = true; } + bool mUpdateName; /** Whether or not the name settings have changed */ bool mMapInitialized; /** Whether or not the map is available yet */ @@ -424,6 +428,7 @@ class LocalPlayer : public Player bool mKeepAttacking; /** Whether or not to continue to attack */ int mLastAction; /**< Time stamp of the last action, -1 if none. */ int mWalkingDir; /**< The direction the player is walking in. */ + bool mPathSetByMouse; /**< Tells if the path was set using mouse */ int mDestX; /**< X coordinate of destination. */ int mDestY; /**< Y coordinate of destination. */ -- cgit v1.2.3-70-g09d2