summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/being.h2
-rw-r--r--src/being/localplayer.cpp37
-rw-r--r--src/being/localplayer.h3
3 files changed, 39 insertions, 3 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
*/