diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-19 21:24:36 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-19 21:24:36 +0000 |
commit | 7ac7d0e030464f744546b4e6183a7242f640d5d3 (patch) | |
tree | f19831b29511d46e8aba45ace6017c8e6afe815b /src/localplayer.cpp | |
parent | b7cfcffd7a156e19dfa9882d67426f4fa6edef57 (diff) | |
download | mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.gz mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.bz2 mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.tar.xz mana-7ac7d0e030464f744546b4e6183a7242f640d5d3.zip |
Separated sprite definition from playback.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
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); } |