summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 635f7d04..6f4b6303 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -505,6 +505,21 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
if (!mMap->getWalk(x / 32, y / 32))
return;
+ // check if we're finding a path to the seeked destination
+ // If the path is empty... and isn't on the same tile,
+ // then, it's an unvalid one.
+ Vector playerPosition = getPosition();
+ if (((int)(playerPosition.x / 32) != x / 32)
+ || (((int)playerPosition.y / 32) != y / 32))
+ {
+ Path evaluatedPath = mMap->findPath(playerPosition.x / 32,
+ playerPosition.y / 32,
+ x / 32, y / 32,
+ getWalkMask());
+ if (evaluatedPath.empty())
+ return;
+ }
+
// Fix coordinates so that the player does not seem to dig into walls.
const int tx = x / 32;
const int ty = y / 32;