summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/beingrecv.cpp57
-rw-r--r--src/net/eathena/beingrecv.cpp8
-rw-r--r--src/net/tmwa/beingrecv.cpp4
3 files changed, 66 insertions, 3 deletions
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp
index fa1f47c69..0a8168c6c 100644
--- a/src/net/ea/beingrecv.cpp
+++ b/src/net/ea/beingrecv.cpp
@@ -45,6 +45,8 @@
#include "net/messagein.h"
#include "net/serverfeatures.h"
+#include "utils/checkutils.h"
+
#include "debug.h"
namespace Ea
@@ -440,6 +442,9 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg)
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(x, y);
+ if (dstBeing == localPlayer)
+ return;
+
const unsigned char *moves = msg.readBytes(len, "moving path");
Path path;
if (moves)
@@ -458,8 +463,60 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg)
logger->log("bad move packet: %d", dir);
}
}
+ const int x1 = dstBeing->getCachedX();
+ const int y1 = dstBeing->getCachedY();
+ if (x1 != x || y1 != y)
+ {
+// reportAlways("Found desync being move. "
+// "Calculated target (%d,%d). "
+// "Actual target (%d,%d).",
+// static_cast<int>(x),
+// static_cast<int>(y),
+// static_cast<int>(x1),
+// static_cast<int>(y1));
+ if (len > 0)
+ {
+ const unsigned char dir = moves[0];
+ uint16_t x0 = x;
+ uint16_t y0 = y;
+
+ if (dir <= 7)
+ {
+ x0 -= dirx[0];
+ y0 -= diry[0];
+ if (x1 == x0 && y1 == y0)
+ {
+ path.erase(path.begin());
+ logger->log("Fixed being moving desync by "
+ "removing one tile");
+ }
+ else
+ {
+ x0 = x;
+ y0 = y;
+ if (abs(x0 - x1) < 2 && abs(y0 - y1) < 2)
+ {
+ path.push_back(Position(x1, y1));
+ logger->log("Fixed being moving desync by "
+ "adding one tile");
+ }
+ else
+ {
+ reportAlways("Error: being moving desync. "
+ "Calculated target (%d,%d). "
+ "Actual target (%d,%d).",
+ static_cast<int>(x),
+ static_cast<int>(y),
+ static_cast<int>(x1),
+ static_cast<int>(y1));
+ }
+ }
+ }
+ }
+ }
delete [] moves;
}
+
dstBeing->setPath(path);
BLOCK_END("BeingRecv::processBeingMove3")
}
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 85c276e46..5c5e18ce8 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -597,7 +597,9 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing->setTileCoords(srcX, srcY);
if (localPlayer)
localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
- if (!serverFeatures->haveMove3())
+ if (serverFeatures->haveMove3())
+ dstBeing->setCachedDestination(dstX, dstY);
+ else
dstBeing->setDestination(dstX, dstY);
// because server don't send direction in move packet, we fixing it
@@ -956,7 +958,9 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg)
dstBeing->setTileCoords(srcX, srcY);
if (localPlayer)
localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
- if (!serverFeatures->haveMove3())
+ if (serverFeatures->haveMove3())
+ dstBeing->setCachedDestination(dstX, dstY);
+ else
dstBeing->setDestination(dstX, dstY);
if (dstBeing->getType() == ActorType::Player)
dstBeing->setMoveTime();
diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp
index d5f1dbd6f..04c4a0444 100644
--- a/src/net/tmwa/beingrecv.cpp
+++ b/src/net/tmwa/beingrecv.cpp
@@ -1019,7 +1019,9 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
{
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
- if (!serverFeatures->haveMove3())
+ if (serverFeatures->haveMove3())
+ dstBeing->setCachedDestination(dstX, dstY);
+ else
dstBeing->setDestination(dstX, dstY);
}