summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp18
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)