diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-14 04:35:05 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-14 04:35:05 +0200 |
commit | e8bc0d9fd1be148f111f2c560e563e0552fc9f50 (patch) | |
tree | dd6e68087e2fbd166f54fe9fd4013223864b0612 | |
parent | 81639ccbd66d225c86998d6127dd8c7ca2b5e745 (diff) | |
download | manaverse-e8bc0d9fd1be148f111f2c560e563e0552fc9f50.tar.gz manaverse-e8bc0d9fd1be148f111f2c560e563e0552fc9f50.tar.bz2 manaverse-e8bc0d9fd1be148f111f2c560e563e0552fc9f50.tar.xz manaverse-e8bc0d9fd1be148f111f2c560e563e0552fc9f50.zip |
Fixing direction bug in moving.
While player moving server dont send player direction.
This autofixing in nextTile method, but if this method was not
called, then player have incorrect direction.
Also move checking direction 8 from beinghandler.cpp
to messagein.cpp like was done in mana client.
-rw-r--r-- | src/net/messagein.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 28 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.h | 2 |
3 files changed, 26 insertions, 12 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 805861870..e39a443f1 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -25,6 +25,7 @@ #include "net/packetcounters.h" #include "log.h" +#include "net.h" #include "utils/stringutils.h" @@ -113,7 +114,14 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) case 7: direction = 9; break; + case 8: + if (Net::getNetworkType() == ServerInfo::TMWATHENA) + { + direction = 8; + break; + } default: + logger->log("incorrect direction: %d", (int)direction); // OOPSIE! Impossible or unknown direction = 0; } diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 6196afb09..2d0ae3c70 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -348,7 +348,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } - dstBeing->setDirection(getDirection(dir)); + dstBeing->setDirection(dir); } msg.readInt8(); // unknown @@ -825,7 +825,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readInt16(); // unused - unsigned char dir = getDirection(msg.readInt8()); + unsigned char dir = msg.readInt8(); dstBeing->setDirection(dir); if (player_node) player_node->imitateDirection(dstBeing, dir); @@ -938,6 +938,22 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); + // 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 (player_node->getCurrentAction() != Being::STAND) player_node->imitateAction(dstBeing, Being::STAND); if (player_node->getDirection() != dstBeing->getDirection()) @@ -952,7 +968,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) Uint16 x, y; msg.readCoordinates(x, y, dir); dstBeing->setTileCoords(x, y); - dir = getDirection(dir); dstBeing->setDirection(dir); player_node->imitateDirection(dstBeing, dir); @@ -1142,13 +1157,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } -Uint8 BeingHandler::getDirection(Uint8 dir) -{ - if (dir == 0) - dir = 8; - return dir; -} - void BeingHandler::undress(Being *being) { being->setSprite(SPRITE_BOTTOMCLOTHES, 0); diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index ec3f79bdf..1484567fd 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -42,8 +42,6 @@ class BeingHandler : public MessageHandler, public Net::BeingHandler virtual void undress(Being *being); - Uint8 getDirection(Uint8 dir); - private: // Should we honor server "Stop Walking" packets bool mSync; |