summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-07-01 22:57:29 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-13 22:31:20 +0200
commit421cfc174dca220ad092759f013fa413efb07294 (patch)
tree18a660d3b2024a5ad3ae1adc8f4c8d66ec3f2622 /src/localplayer.cpp
parentacc647ed2767df17c856931f721c88deef9765c8 (diff)
downloadmana-client-421cfc174dca220ad092759f013fa413efb07294.tar.gz
mana-client-421cfc174dca220ad092759f013fa413efb07294.tar.bz2
mana-client-421cfc174dca220ad092759f013fa413efb07294.tar.xz
mana-client-421cfc174dca220ad092759f013fa413efb07294.zip
Made the delay between to keyboard move calls functional.
It has been fixed and be made adapted to the being movement speed. Now, for instance, the client sends 3x times less move calls to the tA server, and roughly 20x times for the Manaserv's one. Resolves: Mana-Mantis #346. Reviewed-by: o11c.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 1a7f20e1..78395438 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -58,11 +58,6 @@
#include <cassert>
-// This is the minimal delay between to permitted
-// setDestination() calls using the keyboard.
-// TODO: This can fine tuned later on when running is added...
-const short walkingKeyboardDelay = 1000;
-
#define AWAY_LIMIT_TIMER 60
LocalPlayer *player_node = NULL;
@@ -79,6 +74,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mWalkingDir(0),
mPathSetByMouse(false),
mLocalWalkTime(-1),
+ mKeyboardMoveDelay(500),
mMessageTime(0),
mShowIp(false),
mAwayDialog(0),
@@ -741,8 +737,9 @@ void LocalPlayer::setWalkingDir(int dir)
// If the delay to send another walk message to the server hasn't expired,
// don't do anything or we could get disconnected for spamming the server
- if (get_elapsed_time(mLocalWalkTime) < walkingKeyboardDelay)
+ if (get_elapsed_time(mLocalWalkTime) < mKeyboardMoveDelay)
return;
+ mLocalWalkTime = tick_time;
mWalkingDir = dir;
@@ -808,6 +805,12 @@ void LocalPlayer::stopWalking(bool sendToServer)
clearPath();
}
+void LocalPlayer::setMoveSpeed(const Vector& speed)
+{
+ Being::setMoveSpeed(speed);
+ mKeyboardMoveDelay = Net::getPlayerHandler()->getKeyboardMoveDelay(speed);
+}
+
void LocalPlayer::toggleSit()
{
if (mLastAction != -1)