From 387d06f36504e65a9ce82984944fc844181c80fe Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 7 Mar 2016 20:01:53 +0300 Subject: Change desync detection to simpler way. Also use "sync move" option to enable/disable short/long range desync fix. --- src/being/localplayer.cpp | 26 +++++++------------------- src/being/localplayer.h | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) (limited to 'src/being') diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index e7139642b..a14bd3383 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2090,7 +2090,7 @@ void LocalPlayer::updateCoords() if ((*i).x == mX && (*i).y == mY) { mNavigatePath.pop_front(); - fixPos(6); + fixPos(); break; } } @@ -2452,34 +2452,22 @@ bool LocalPlayer::allowAction() return true; } -/* -bool LocalPlayer::allowMove() const -{ - if (mIsServerBuggy) - { - if (mAction == MOVE) - return false; - } - return true; -} -*/ - -void LocalPlayer::fixPos(const int maxDist) +void LocalPlayer::fixPos() { if (!mCrossX && !mCrossY) return; const int dx = abs(mX - mCrossX); const int dy = abs(mY - mCrossY); - const int dest = (dx * dx) + (dy * dy); + const int dist = dx > dy ? dx : dy; const int time = cur_time; + const int maxDist = mSyncPlayerMove ? 2 : 5; - if (dest > maxDist) -// if (dest > maxDist && mActivityTime -// && (time < mActivityTime || time - mActivityTime > 2)) + if (dist > maxDist) { mActivityTime = time; setTileCoords(mCrossX, mCrossY); +// alternative way to fix, move to real position // setDestination(mCrossX, mCrossY); } } @@ -2514,7 +2502,7 @@ void LocalPlayer::setRealPos(const int x, const int y) { mCrossX = x; mCrossY = y; - fixPos(6); + fixPos(); } } if (mMap->isCustom()) diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 7244664fb..3c0ed4286 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -272,7 +272,7 @@ class LocalPlayer final : public Being, bool isServerBuggy() const A_WARN_UNUSED { return mIsServerBuggy; } - void fixPos(const int maxDist = 1); + void fixPos(); /** * Sets the map the being is on -- cgit v1.2.3-70-g09d2