From 421cfc174dca220ad092759f013fa413efb07294 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 1 Jul 2011 22:57:29 +0200 Subject: 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. --- src/localplayer.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/localplayer.cpp') 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 -// 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) -- cgit v1.2.3-70-g09d2