From 0eafefa3d40cf730749cd7fdfb94f73313e1a159 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 4 Sep 2013 23:44:48 +0300 Subject: add support for getting full move path from server (evol only). Also change netcode version to 10. Some times still movement bit wrong. --- src/net/tmwa/beinghandler.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/net/tmwa/beinghandler.cpp') diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 678be6cc4..6bbdac2e9 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -29,6 +29,7 @@ #include "guild.h" #include "guildmanager.h" #include "party.h" +#include "position.h" #include "being/localplayer.h" #include "being/playerrelations.h" @@ -95,6 +96,7 @@ BeingHandler::BeingHandler(const bool enableSync) : SMSG_BEING_IP_RESPONSE, SMSG_PVP_MAP_MODE, SMSG_PVP_SET, + SMSG_BEING_MOVE3, 0 }; handledMessages = _messages; @@ -121,6 +123,10 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) processBeingMove2(msg); break; + case SMSG_BEING_MOVE3: + processBeingMove3(msg); + break; + case SMSG_BEING_SPAWN: processBeingSpawn(msg); break; @@ -658,4 +664,40 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setMoveTime(); } +void BeingHandler::processBeingMove3(Net::MessageIn &msg) const +{ + if (serverVersion < 10) + return; + + const static int dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; + const static int diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; + + const int len = msg.readInt16() - 14; + Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32()); + if (!dstBeing) + return; + const int16_t speed = msg.readInt16(); + dstBeing->setWalkSpeed(Vector(speed, speed, 0)); + int16_t x = msg.readInt16(); + int16_t y = msg.readInt16(); + const unsigned char *moves = msg.readBytes(len); + Path path; + 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); + } + } + + dstBeing->setPath(path); +} + } // namespace TmwAthena -- cgit v1.2.3-60-g2f50