diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-30 17:50:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-30 17:53:18 +0300 |
commit | 0af4b6dd0f616564a55447c7ce5318c72f68e590 (patch) | |
tree | 44757fc069d389f968c0b9bad36840362c3238f1 /src/net/ea | |
parent | 8caabaeaf267d617ae04f13454bb587c3dbfa427 (diff) | |
download | plus-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.gz plus-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.bz2 plus-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.xz plus-0af4b6dd0f616564a55447c7ce5318c72f68e590.zip |
eathena: add support for get full moving path from server.
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 50 | ||||
-rw-r--r-- | src/net/ea/beinghandler.h | 2 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 5f835047d..4ca872196 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -40,6 +40,8 @@ #include "resources/map/map.h" +#include "net/serverfeatures.h" + #include "debug.h" namespace Ea @@ -492,4 +494,52 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) BLOCK_END("BeingHandler::processNameResponse2") } +void BeingHandler::processBeingMove3(Net::MessageIn &msg) +{ + BLOCK_START("BeingHandler::processBeingMove3") + if (!serverFeatures->haveMove3()) + { + BLOCK_END("BeingHandler::processBeingMove3") + return; + } + + static const int16_t dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; + static const int16_t diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; + + const int len = msg.readInt16("len") - 14; + Being *const dstBeing = actorManager->findBeing( + msg.readInt32("being id")); + if (!dstBeing) + { + BLOCK_END("BeingHandler::processBeingMove3") + return; + } + const int16_t speed = msg.readInt16("speed"); + dstBeing->setWalkSpeed(Vector(speed, speed, 0)); + int16_t x = msg.readInt16("x"); + int16_t y = msg.readInt16("y"); + const unsigned char *moves = msg.readBytes(len, "moving path"); + Path path; + if (moves) + { + for (int f = 0; f < len; f ++) + { + const unsigned char dir = moves[f]; + if (dir <= 7) + { + x += dirx[dir]; + y += diry[dir]; + path.push_back(Position(x, y)); + } + else + { + logger->log("bad move packet: %d", dir); + } + } + delete [] moves; + } + dstBeing->setPath(path); + BLOCK_END("BeingHandler::processBeingMove3") +} + } // namespace Ea diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h index 9ac9fc39d..a87117ffe 100644 --- a/src/net/ea/beinghandler.h +++ b/src/net/ea/beinghandler.h @@ -70,6 +70,8 @@ class BeingHandler notfinal : public Net::BeingHandler static void processNameResponse2(Net::MessageIn &msg); + static void processBeingMove3(Net::MessageIn &msg); + // Should we honor server "Stop Walking" packets static int mSpawnId; static bool mSync; |