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 /src/being/localplayer.cpp | |
parent | bd6ced98dfbe93fce5c143cdcd6fa6e8c3f4f6a8 (diff) | |
download | manaverse-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.gz manaverse-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.bz2 manaverse-0e3549dd92ac1eac1916b3f5110036ab59fe2fec.tar.xz manaverse-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.
Diffstat (limited to 'src/being/localplayer.cpp')
-rw-r--r-- | src/being/localplayer.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
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) |