diff options
author | Andrei Karas <akaras@inbox.ru> | 2019-03-20 22:14:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2019-03-21 01:36:40 +0300 |
commit | 0e3549dd92ac1eac1916b3f5110036ab59fe2fec (patch) | |
tree | 85011f9be2576f4daeaae9513be24d50a5dae93a | |
parent | bd6ced98dfbe93fce5c143cdcd6fa6e8c3f4f6a8 (diff) | |
download | manaplus-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.gz manaplus-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.bz2 manaplus-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.xz manaplus-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.zip |
Possible fix for desync in moving
Handle player stop packet always.
Check desync always if tile changed client side.
Check desync always if server move response packet received.
Removed unused configuration option.
-rw-r--r-- | src/being/being.h | 2 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 37 | ||||
-rw-r--r-- | src/being/localplayer.h | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/beinghandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/beingrecv.cpp | 3 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/generalhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/messagein.cpp | 27 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/generalhandler.cpp | 2 |
14 files changed, 65 insertions, 29 deletions
diff --git a/src/being/being.h b/src/being/being.h index 553dbcb64..f42cae281 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -176,7 +176,7 @@ class Being notfinal : public ActorSprite, /** * Sets the tile x and y coord */ - void setTileCoords(const int x, const int y) restrict2; + virtual void setTileCoords(const int x, const int y) restrict2; /** * Puts a "speech balloon" above this being for the specified amount diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index e5d1ff725..840417803 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -480,14 +480,21 @@ void LocalPlayer::nextTile() if (mPath.empty()) { if (mNavigatePath.empty() || mAction != BeingAction::MOVE) + { setAction(BeingAction::STAND, 0); + // +++ probably sync position here always? + } else + { mNextStep = true; + } } else { Being::nextTile(); } + + fixPos(); } bool LocalPlayer::pickUp(FloorItem *const item) @@ -2577,8 +2584,8 @@ void LocalPlayer::fixPos() if ((mCrossX == 0) && (mCrossY == 0)) return; - const int dx = abs(mX - mCrossX); - const int dy = abs(mY - mCrossY); + const int dx = (mX >= mCrossX) ? mX - mCrossX : mCrossX - mX; + const int dy = (mY >= mCrossY) ? mY - mCrossY : mCrossY - mY; const int dist = dx > dy ? dx : dy; const time_t time = cur_time; const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7; @@ -2586,12 +2593,34 @@ void LocalPlayer::fixPos() if (dist > maxDist) { mActivityTime = time; +#ifdef ENABLEDEBUGLOG + logger->dlog(strprintf("Fix position from (%d,%d) to (%d,%d)", + mX, mY, + mCrossX, mCrossY)); +#endif setTileCoords(mCrossX, mCrossY); +/* + if (mNavigateX != 0 || mNavigateY != 0) + { +#ifdef ENABLEDEBUGLOG + logger->dlog(strprintf("Renavigate to (%d,%d)", + mNavigateX, mNavigateY)); +#endif + navigateTo(mNavigateX, mNavigateY); + } +*/ // alternative way to fix, move to real position // setDestination(mCrossX, mCrossY); } } +void LocalPlayer::setTileCoords(const int x, const int y) restrict2 +{ + Being::setTileCoords(x, y); + mCrossX = x; + mCrossY = y; +} + void LocalPlayer::setRealPos(const int x, const int y) { if (mMap == nullptr) @@ -2630,11 +2659,14 @@ void LocalPlayer::setRealPos(const int x, const int y) { mCrossX = x; mCrossY = y; + // +++ possible configuration option + fixPos(); } } if (mMap->isCustom()) mMap->setWalk(x, y); } + void LocalPlayer::fixAttackTarget() { if ((mMap == nullptr) || (mTarget == nullptr)) @@ -2693,6 +2725,7 @@ void LocalPlayer::updateNavigateList() void LocalPlayer::failMove(const int x A_UNUSED, const int y A_UNUSED) { + fixPos(); } void LocalPlayer::waitFor(const std::string &nick) diff --git a/src/being/localplayer.h b/src/being/localplayer.h index d8b3bdf92..9847f7970 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -277,6 +277,9 @@ class LocalPlayer final : public Being, void fixPos(); + void setTileCoords(const int x, + const int y) restrict2 override final; + /** * Sets the map the being is on */ diff --git a/src/defaults.cpp b/src/defaults.cpp index 7b5190fe2..337d1e89a 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -175,7 +175,6 @@ void setConfigDefaults(Configuration &cfg) AddDEF("screenshotDirectory3", ""); AddDEF("useScreenshotDirectorySuffix", true); AddDEF("screenshotDirectorySuffix", ""); - AddDEF("EnableSync", false); AddDEF("joystickEnabled", false); AddDEF("upTolerance", 100); AddDEF("downTolerance", 100); diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 2870bc85b..511154fd5 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -29,10 +29,9 @@ namespace Ea { -BeingHandler::BeingHandler(const bool enableSync) : +BeingHandler::BeingHandler() : Net::BeingHandler() { - BeingRecv::mSync = enableSync; BeingRecv::mSpawnId = BeingId_zero; } diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h index a151601bc..8c90dbf01 100644 --- a/src/net/ea/beinghandler.h +++ b/src/net/ea/beinghandler.h @@ -34,7 +34,7 @@ class BeingHandler notfinal : public Net::BeingHandler A_DELETE_COPY(BeingHandler) protected: - explicit BeingHandler(const bool enableSync); + explicit BeingHandler(); }; } // namespace Ea diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp index 4ac1f90eb..ed6e031b6 100644 --- a/src/net/ea/beingrecv.cpp +++ b/src/net/ea/beingrecv.cpp @@ -54,7 +54,6 @@ namespace Ea namespace BeingRecv { - bool mSync = false; BeingId mSpawnId = BeingId_zero; } // namespace BeingRecv @@ -345,7 +344,7 @@ void BeingRecv::processPlayerStop(Net::MessageIn &msg) const BeingId id = msg.readBeingId("account id"); - if (mSync || id != localPlayer->getId()) +// if (mSync || id != localPlayer->getId()) { Being *const dstBeing = actorManager->findBeing(id); if (dstBeing != nullptr) diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 7e8dc43e2..c132609e3 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -34,8 +34,8 @@ extern int serverVersion; namespace EAthena { -BeingHandler::BeingHandler(const bool enableSync) : - Ea::BeingHandler(enableSync) +BeingHandler::BeingHandler() : + Ea::BeingHandler() { beingHandler = this; } diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index 6372ea336..41dafb6aa 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -31,7 +31,7 @@ namespace EAthena class BeingHandler final : public Ea::BeingHandler { public: - explicit BeingHandler(const bool enableSync); + explicit BeingHandler(); A_DELETE_COPY(BeingHandler) diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index ff420092d..1226e03f9 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -83,7 +83,7 @@ namespace EAthena GeneralHandler::GeneralHandler() : mAdminHandler(new AdminHandler), - mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))), + mBeingHandler(new BeingHandler), mBuySellHandler(new BuySellHandler), mCharServerHandler(new CharServerHandler), mChatHandler(new ChatHandler), diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index bdac098c5..22d0510ce 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -473,20 +473,23 @@ unsigned char *MessageIn::readBytes(int length, const char *const dstr) mPos += length; #ifdef ENABLEDEBUGLOG - std::string str; - for (int f = 0; f < length; f ++) - str.append(strprintf("%02x", CAST_U32(buf[f]))); - str += " "; - for (int f = 0; f < length; f ++) + if (!mIgnore) { - if (buf[f] != 0U) - str.append(strprintf("%c", buf[f])); - else - str.append("_"); + std::string str; + for (int f = 0; f < length; f ++) + str.append(strprintf("%02x", CAST_U32(buf[f]))); + str += " "; + for (int f = 0; f < length; f ++) + { + if (buf[f] != 0U) + str.append(strprintf("%c", buf[f])); + else + str.append("_"); + } + if (dstr != nullptr) + logger->dlog(dstr); + logger->dlog("ReadBytes: " + str); } - if (dstr != nullptr) - logger->dlog(dstr); - logger->dlog("ReadBytes: " + str); #endif // ENABLEDEBUGLOG PacketCounters::incInBytes(length); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index e944fa835..f3d3acdf8 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -31,8 +31,8 @@ namespace TmwAthena { -BeingHandler::BeingHandler(const bool enableSync) : - Ea::BeingHandler(enableSync) +BeingHandler::BeingHandler() : + Ea::BeingHandler() { beingHandler = this; } diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index ed486c9ee..32e01db1f 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -31,7 +31,7 @@ namespace TmwAthena class BeingHandler final : public Ea::BeingHandler { public: - explicit BeingHandler(const bool enableSync); + explicit BeingHandler(); A_DELETE_COPY(BeingHandler) diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 994be2ce7..7e5eb70de 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -82,7 +82,7 @@ namespace TmwAthena GeneralHandler::GeneralHandler() : mAdminHandler(new AdminHandler), - mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))), + mBeingHandler(new BeingHandler), mBuySellHandler(new BuySellHandler), mCharServerHandler(new CharServerHandler), mChatHandler(new ChatHandler), |