summaryrefslogtreecommitdiff
path: root/src/being/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-03 01:36:20 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-03 01:36:20 +0300
commit238da37720dbb56a7a8c3c7f30acd8c9fbab65b2 (patch)
tree7ec63126599236c4602fb0336c1c1fc60eaccb82 /src/being/localplayer.cpp
parentdc763262307a526fc4c55f23ceb30f804ae6fd29 (diff)
downloadmv-238da37720dbb56a7a8c3c7f30acd8c9fbab65b2.tar.gz
mv-238da37720dbb56a7a8c3c7f30acd8c9fbab65b2.tar.bz2
mv-238da37720dbb56a7a8c3c7f30acd8c9fbab65b2.tar.xz
mv-238da37720dbb56a7a8c3c7f30acd8c9fbab65b2.zip
Fix desync between client and server while moving.
Sadly to fix it need warp player to real position, because this while moving, player some times twitch a bit.
Diffstat (limited to 'src/being/localplayer.cpp')
-rw-r--r--src/being/localplayer.cpp100
1 files changed, 51 insertions, 49 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 6b883040c..9336edae7 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -2043,61 +2043,59 @@ void LocalPlayer::updateCoords()
updateMusic();
}
- if (mShowNavigePath)
+ if (mMap && (mX != mOldTileX || mY != mOldTileY))
{
- if (mMap && (mX != mOldTileX || mY != mOldTileY))
- {
- SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
- return;
+ SpecialLayer *const tmpLayer = mMap->getTempLayer();
+ if (!tmpLayer)
+ return;
- const int x = CAST_S32(playerPos.x - mapTileSize / 2)
- / mapTileSize;
- const int y = CAST_S32(playerPos.y - mapTileSize)
- / mapTileSize;
- if (mNavigateId != BeingId_zero)
+ const int x = CAST_S32(playerPos.x - mapTileSize / 2)
+ / mapTileSize;
+ const int y = CAST_S32(playerPos.y - mapTileSize)
+ / mapTileSize;
+ if (mNavigateId != BeingId_zero)
+ {
+ if (!actorManager)
{
- if (!actorManager)
- {
- navigateClean();
- return;
- }
-
- const Being *const being = actorManager
- ->findBeing(mNavigateId);
- if (!being)
- {
- navigateClean();
- return;
- }
- mNavigateX = being->getTileX();
- mNavigateY = being->getTileY();
+ navigateClean();
+ return;
}
- if (mNavigateX == x && mNavigateY == y)
+ const Being *const being = actorManager
+ ->findBeing(mNavigateId);
+ if (!being)
{
navigateClean();
return;
}
- else
+ mNavigateX = being->getTileX();
+ mNavigateY = being->getTileY();
+ }
+
+ if (mNavigateX == x && mNavigateY == y)
+ {
+ navigateClean();
+ return;
+ }
+ else
+ {
+ for (Path::const_iterator i = mNavigatePath.begin(),
+ i_fend = mNavigatePath.end();
+ i != i_fend;
+ ++i)
{
- for (Path::const_iterator i = mNavigatePath.begin(),
- i_fend = mNavigatePath.end();
- i != i_fend;
- ++i)
+ if ((*i).x == mX && (*i).y == mY)
{
- if ((*i).x == mX && (*i).y == mY)
- {
- mNavigatePath.pop_front();
- break;
- }
+ mNavigatePath.pop_front();
+ fixPos(6);
+ break;
}
+ }
- if (mDrawPath)
- {
- tmpLayer->clean();
- tmpLayer->addRoad(mNavigatePath);
- }
+ if (mDrawPath && mShowNavigePath)
+ {
+ tmpLayer->clean();
+ tmpLayer->addRoad(mNavigatePath);
}
}
}
@@ -2468,11 +2466,13 @@ void LocalPlayer::fixPos(const int maxDist)
const int dest = (dx * dx) + (dy * dy);
const int time = cur_time;
- if (dest > maxDist && mActivityTime
- && (time < mActivityTime || time - mActivityTime > 2))
+ if (dest > maxDist)
+// if (dest > maxDist && mActivityTime
+// && (time < mActivityTime || time - mActivityTime > 2))
{
mActivityTime = time;
- setDestination(mCrossX, mCrossY);
+ setTileCoords(mCrossX, mCrossY);
+// setDestination(mCrossX, mCrossY);
}
}
@@ -2484,8 +2484,6 @@ void LocalPlayer::setRealPos(const int x, const int y)
SpecialLayer *const layer = mMap->getTempLayer();
if (layer)
{
- fixPos(1);
-
if ((mCrossX || mCrossY)
&& layer->getTile(mCrossX, mCrossY)
&& layer->getTile(mCrossX, mCrossY)->getType()
@@ -2505,8 +2503,12 @@ void LocalPlayer::setRealPos(const int x, const int y)
}
}
- mCrossX = x;
- mCrossY = y;
+ if (mCrossX != x || mCrossY != y)
+ {
+ mCrossX = x;
+ mCrossY = y;
+ fixPos(6);
+ }
}
if (mMap->isCustom())
mMap->setWalk(x, y);