summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-03-13 07:29:30 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-03-13 07:29:30 +0000
commitfe474eb4fae9d89e3797d0ceaae6613798ce491f (patch)
tree2a91b2f17636ae7b20eea06a28a89942f6f36d39 /src/localplayer.cpp
parent3a275cc81fe9aa1cb6736cdf12211e13e93cf2cf (diff)
downloadmana-fe474eb4fae9d89e3797d0ceaae6613798ce491f.tar.gz
mana-fe474eb4fae9d89e3797d0ceaae6613798ce491f.tar.bz2
mana-fe474eb4fae9d89e3797d0ceaae6613798ce491f.tar.xz
mana-fe474eb4fae9d89e3797d0ceaae6613798ce491f.zip
Synchronized pathfinding algorithmns with those used by the server to avoid asynchronisation.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 1614b7e7..aa3bb6ba 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -233,17 +233,17 @@ void LocalPlayer::walk(unsigned char dir)
dx += 32;
// Prevent skipping corners over colliding tiles
- if (dx && mMap->tileCollides((mX + dx) / 32, mY / 32))
+ if (dx && !mMap->getWalk((mX + dx) / 32, mY / 32, getWalkMask()))
dx = 16 - mX % 32;
- if (dy && mMap->tileCollides(mX / 32, (mY + dy) / 32))
+ if (dy && !mMap->getWalk(mX / 32, (mY + dy) / 32, getWalkMask()))
dy = 16 - mY % 32;
// Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk((mX + dx) / 32, (mY + dy) / 32))
+ if (dx && dy && !mMap->getWalk((mX + dx) / 32, (mY + dy) / 32, getWalkMask()))
dx = 16 - mX % 32;
// Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk((mX + dx) / 32, (mY + dy) / 32))
+ if ((dx || dy) && mMap->getWalk((mX + dx) / 32, (mY + dy) / 32, getWalkMask()))
{
setDestination(mX + dx, mY + dy);
}
@@ -259,9 +259,9 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
{
// Fix coordinates so that the player does not seem to dig into walls.
int tx = x / 32, ty = y / 32, fx = x % 32, fy = y % 32;
- if (fx != 16 && mMap->tileCollides(tx + fx / 16 * 2 - 1, ty)) fx = 16;
- if (fy != 16 && mMap->tileCollides(tx, ty + fy / 16 * 2 - 1)) fy = 16;
- if (fx != 16 && fy != 16 && mMap->tileCollides(tx + fx / 16 * 2 - 1, ty + fy / 16 * 2 - 1)) fx = 16;
+ if (fx != 16 && !mMap->getWalk(tx + fx / 16 * 2 - 1, ty, getWalkMask())) fx = 16;
+ if (fy != 16 && !mMap->getWalk(tx, ty + fy / 16 * 2 - 1, getWalkMask())) fy = 16;
+ if (fx != 16 && fy != 16 && !mMap->getWalk(tx + fx / 16 * 2 - 1, ty + fy / 16 * 2 - 1, getWalkMask())) fx = 16;
x = tx * 32 + fx;
y = ty * 32 + fy;