From 7ac7d0e030464f744546b4e6183a7242f640d5d3 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 19 Nov 2006 21:24:36 +0000 Subject: Separated sprite definition from playback. --- src/localplayer.cpp | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'src/localplayer.cpp') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 802da92f..46348efc 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -82,9 +82,19 @@ void LocalPlayer::logic() void LocalPlayer::nextStep() { - if (mPath.empty() && mPickUpTarget) { - pickUp(mPickUpTarget); + if (mPath.empty()) + { + if (mPickUpTarget) + { + pickUp(mPickUpTarget); + } + + if (mWalkingDir) + { + walk(mWalkingDir); + } } + Player::nextStep(); } @@ -171,10 +181,15 @@ void LocalPlayer::pickUp(FloorItem *item) void LocalPlayer::walk(unsigned char dir) { + if (mWalkingDir != dir) + { + mWalkingDir = dir; + } + if (!mMap || !dir) return; - if (mAction == WALK) + if (mAction == WALK && !mPath.empty()) { // Just finish the current action, otherwise we get out of sync Being::setDestination(mX, mY); @@ -218,14 +233,20 @@ void LocalPlayer::walk(unsigned char dir) void LocalPlayer::setDestination(Uint16 x, Uint16 y) { - char temp[3]; - MessageOut outMsg(mNetwork); - set_coordinates(temp, x, y, mDirection); - outMsg.writeInt16(0x0085); - outMsg.writeString(temp, 3); + // Only send a new message to the server when destination changes + if (x != destX || y != destY) + { + destX = x; + destY = y; - mPickUpTarget = NULL; + char temp[3]; + MessageOut outMsg(mNetwork); + set_coordinates(temp, x, y, mDirection); + outMsg.writeInt16(0x0085); + outMsg.writeString(temp, 3); + } + mPickUpTarget = NULL; Being::setDestination(x, y); } -- cgit v1.2.3-70-g09d2