summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-30 17:50:58 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-30 17:53:18 +0300
commit0af4b6dd0f616564a55447c7ce5318c72f68e590 (patch)
tree44757fc069d389f968c0b9bad36840362c3238f1
parent8caabaeaf267d617ae04f13454bb587c3dbfa427 (diff)
downloadmanaverse-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.gz
manaverse-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.bz2
manaverse-0af4b6dd0f616564a55447c7ce5318c72f68e590.tar.xz
manaverse-0af4b6dd0f616564a55447c7ce5318c72f68e590.zip
eathena: add support for get full moving path from server.
-rw-r--r--src/net/ea/beinghandler.cpp50
-rw-r--r--src/net/ea/beinghandler.h2
-rw-r--r--src/net/eathena/beinghandler.cpp11
-rw-r--r--src/net/eathena/packets.h2
-rw-r--r--src/net/eathena/protocol.h1
-rw-r--r--src/net/eathena/serverfeatures.cpp2
-rw-r--r--src/net/tmwa/beinghandler.cpp48
-rw-r--r--src/net/tmwa/beinghandler.h2
8 files changed, 64 insertions, 54 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;
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 447e7fc4a..2973a791c 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -119,6 +119,7 @@ BeingHandler::BeingHandler(const bool enableSync) :
SMSG_BEING_FAKE_NAME,
SMSG_BEING_STAT_UPDATE_1,
SMSG_MOB_INFO,
+ SMSG_BEING_MOVE3,
0
};
handledMessages = _messages;
@@ -324,6 +325,10 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
processMobInfo(msg);
break;
+ case SMSG_BEING_MOVE3:
+ processBeingMove3(msg);
+ break;
+
default:
break;
}
@@ -1230,7 +1235,8 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
msg.readInt8("ys");
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
+ if (!serverFeatures->haveMove3())
+ dstBeing->setDestination(dstX, dstY);
// because server don't send direction in move packet, we fixing it
@@ -1517,7 +1523,8 @@ void BeingHandler::processBeingMove2(Net::MessageIn &msg)
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
+ if (!serverFeatures->haveMove3())
+ dstBeing->setDestination(dstX, dstY);
if (dstBeing->getType() == ActorType::Player)
dstBeing->setMoveTime();
BLOCK_END("BeingHandler::processBeingMove2")
diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h
index 69b0239be..36d31329c 100644
--- a/src/net/eathena/packets.h
+++ b/src/net/eathena/packets.h
@@ -279,7 +279,7 @@ int16_t packet_lengths[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// #0x0B00
- 16, -1, 10, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 16, -1, 10, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index 469cdb77c..94c620efd 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -110,6 +110,7 @@
#define SMSG_BEING_MOVE 0x0914 /**< A nearby monster moves */
#define SMSG_BEING_SPAWN 0x090f /**< A being spawns nearby */
#define SMSG_BEING_MOVE2 0x0086 /**< New eAthena being moves */
+#define SMSG_BEING_MOVE3 0x0b04
#define SMSG_BEING_REMOVE 0x0080
#define SMSG_BEING_REMOVE_SKILL 0x0120
#define SMSG_BEING_CHANGE_LOOKS 0x00c3
diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp
index 596623fbb..d0557b03f 100644
--- a/src/net/eathena/serverfeatures.cpp
+++ b/src/net/eathena/serverfeatures.cpp
@@ -112,7 +112,7 @@ bool ServerFeatures::haveServerIgnore() const
bool ServerFeatures::haveMove3() const
{
- return false;
+ return serverVersion >= 3;
}
bool ServerFeatures::haveItemColors() const
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index fd9c04dfc..a076d4140 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -899,54 +899,6 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
BLOCK_END("BeingHandler::processPlayerMoveUpdate")
}
-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")
-}
-
void BeingHandler::processBeingVisible(Net::MessageIn &msg)
{
BLOCK_START("BeingHandler::processBeingVisibleOrMove")
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index cb366d8a1..24d559b2f 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -62,8 +62,6 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
static void processPlayerMove(Net::MessageIn &msg);
- static void processBeingMove3(Net::MessageIn &msg);
-
static void processBeingSpawn(Net::MessageIn &msg);
static void processSkillCasting(Net::MessageIn &msg);