diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-17 02:21:53 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-17 03:55:25 +0200 |
commit | abeb003b88cc49ba70cdadd2e3adec6eca1751ec (patch) | |
tree | c0f93a83772ef372f3d610948b6f995acd5bf6ce /src | |
parent | 59dc0bffc0f754de8daed29bce3a48e90ea6b4fb (diff) | |
download | manaplus-abeb003b88cc49ba70cdadd2e3adec6eca1751ec.tar.gz manaplus-abeb003b88cc49ba70cdadd2e3adec6eca1751ec.tar.bz2 manaplus-abeb003b88cc49ba70cdadd2e3adec6eca1751ec.tar.xz manaplus-abeb003b88cc49ba70cdadd2e3adec6eca1751ec.zip |
Fix other players move animation.
As dirty hack added delayed direction.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 3 | ||||
-rw-r--r-- | src/being.h | 8 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 48 |
3 files changed, 45 insertions, 14 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2f2e69d16..e66f3284b 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -187,6 +187,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mAction(STAND), mSubType(0xFFFF), mDirection(DOWN), + mDirectionDelayed(0), mSpriteDirection(DIRECTION_DOWN), mDispName(0), mShowName(false), @@ -947,6 +948,8 @@ void Being::setDirection(Uint8 direction) mDirection = direction; + mDirectionDelayed = 0; + // if the direction does not change much, keep the common component int mFaceDirection = mDirection & direction; if (!mFaceDirection) diff --git a/src/being.h b/src/being.h index 1d5ca7c19..1dc2fd8f8 100644 --- a/src/being.h +++ b/src/being.h @@ -452,6 +452,12 @@ class Being : public ActorSprite, public ConfigListener */ virtual void setDirection(Uint8 direction); + virtual void setDirectionDelayed(Uint8 direction) + { mDirectionDelayed = direction; } + + Uint8 getDirectionDelayed() + { return mDirectionDelayed; } + /** * Returns the direction the being is facing. */ @@ -677,6 +683,8 @@ class Being : public ActorSprite, public ConfigListener Uint16 mSubType; /**< Subtype (graphical view, basically) */ Uint8 mDirection; /**< Facing direction */ + Uint8 mDirectionDelayed; /**< Facing direction */ + Uint8 mSpriteDirection; /**< Facing direction */ std::string mName; /**< Name of character */ std::string mPartyName; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 2d0ae3c70..fb3ac44be 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -168,6 +168,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) int hairStyle, hairColor, flag; int hp, maxHP, oldHP; unsigned char colors[9]; + Uint8 dir; switch (msg.getId()) { @@ -859,6 +860,13 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) break; } + dir = dstBeing->getDirectionDelayed(); + if (dir) + { + if (dir != dstBeing->getDirection()) + dstBeing->setDirection(dir); + } + if (Party *party = player_node->getParty()) { if (party->isMember(id)) @@ -941,18 +949,26 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) // because server dont send direction in move packet, // we fixing it - int dir = 0; - if (dstX > srcX) - dir |= Being::RIGHT; - else if (dstX < srcX) - dir |= Being::LEFT; - if (dstY > srcY) - dir |= Being::DOWN; - else if (dstY < srcY) - dir |= Being::UP; - - if (dir) - dstBeing->setDirection(dir); + if (srcX != dstX || srcY != dstY) + { + int dir = 0; + if (dstX > srcX) + dir |= Being::RIGHT; + else if (dstX < srcX) + dir |= Being::LEFT; + if (dstY > srcY) + dir |= Being::DOWN; + else if (dstY < srcY) + dir |= Being::UP; + + if (dir && dstBeing->getDirection() != dir) + { + dstBeing->setDirectionDelayed(dir); +// dstBeing->clearPath(); +// dstBeing->reset(); + } + } + if (player_node->getCurrentAction() != Being::STAND) player_node->imitateAction(dstBeing, Being::STAND); @@ -1023,8 +1039,12 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // unknown - dstBeing->setActionTime(tick_time); - dstBeing->reset(); + if (dstBeing->getType() != Being::PLAYER + || msg.getId() != SMSG_PLAYER_MOVE) + { + dstBeing->setActionTime(tick_time); +// dstBeing->reset(); + } dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); |