diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2008-04-17 16:23:36 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2008-04-17 16:23:36 +0000 |
commit | c93e1faa1034519c26ef4481c7cfd0bd465a6d85 (patch) | |
tree | 78bce6818146f358b63a586196030d5a4f021ad0 /src/localplayer.cpp | |
parent | 1f639454d986ea0d44b563eaa71019d9f1c01c24 (diff) | |
download | mana-client-c93e1faa1034519c26ef4481c7cfd0bd465a6d85.tar.gz mana-client-c93e1faa1034519c26ef4481c7cfd0bd465a6d85.tar.bz2 mana-client-c93e1faa1034519c26ef4481c7cfd0bd465a6d85.tar.xz mana-client-c93e1faa1034519c26ef4481c7cfd0bd465a6d85.zip |
Added input type parameter to the LocalPlayer::SetDestination methods in order to keep control over
message flooding to the server with mouse dragging. (I need feedback !)
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 78dac6f8..e4c2624e 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -66,6 +66,7 @@ LocalPlayer::LocalPlayer(): mTrading(false), mLastAction(-1), mWalkingDir(0), mDestX(0), mDestY(0), + mLocalWalkTime(-1), mExpMessageTime(0) { } @@ -222,7 +223,8 @@ void LocalPlayer::pickUp(FloorItem *item) Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF); mPickUpTarget = NULL; } else { - setDestination(item->getX() * 32 + 16, item->getY() * 32 + 16); + setDestination(item->getX() * 32 + 16, item->getY() * 32 + 16, + BY_SYSTEM); mPickUpTarget = item; } } @@ -262,7 +264,7 @@ void LocalPlayer::walk(unsigned char dir) // Walk to where the player can actually go if ((dx || dy) && mMap->getWalk((mX + dx) / 32, (mY + dy) / 32, getWalkMask())) { - setDestination(mX + dx, mY + dy); + setDestination(mX + dx, mY + dy, BY_SYSTEM); } else if (dir) { @@ -272,7 +274,7 @@ void LocalPlayer::walk(unsigned char dir) } } -void LocalPlayer::setDestination(Uint16 x, Uint16 y) +void LocalPlayer::setDestination(Uint16 x, Uint16 y, InputType inputType) { // Fix coordinates so that the player does not seem to dig into walls. int tx = x / 32, ty = y / 32, fx = x % 32, fy = y % 32; @@ -285,6 +287,14 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) // Only send a new message to the server when destination changes if (x != mDestX || y != mDestY) { + // Using mouse, Walkings are allowed twice per second + if (inputType == BY_MOUSE && get_elapsed_time(mLocalWalkTime) < 500) return; + + // Using keyboard, Walkings are allowed ten times per second + if (inputType == BY_KEYBOARD && get_elapsed_time(mLocalWalkTime) < 100) return; + + mLocalWalkTime = tick_time; + mDestX = x; mDestY = y; @@ -292,8 +302,8 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) particleEngine->addEffect("graphics/particles/hit.particle.xml", x, y); } - mPickUpTarget = NULL; Being::setDestination(x, y); + mPickUpTarget = NULL; } void LocalPlayer::setWalkingDir(int dir) |