diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-07 20:01:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-07 20:01:53 +0300 |
commit | 387d06f36504e65a9ce82984944fc844181c80fe (patch) | |
tree | dd1a9e1e49831e47d2ff27dd53a331296b3de82f | |
parent | 1708cce0de3c195b0ecaa8a5f8383712dc0d4c13 (diff) | |
download | mv-387d06f36504e65a9ce82984944fc844181c80fe.tar.gz mv-387d06f36504e65a9ce82984944fc844181c80fe.tar.bz2 mv-387d06f36504e65a9ce82984944fc844181c80fe.tar.xz mv-387d06f36504e65a9ce82984944fc844181c80fe.zip |
Change desync detection to simpler way.
Also use "sync move" option to enable/disable short/long range desync fix.
-rw-r--r-- | src/being/localplayer.cpp | 26 | ||||
-rw-r--r-- | src/being/localplayer.h | 2 |
2 files changed, 8 insertions, 20 deletions
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 |