summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-17 00:02:23 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-17 00:02:23 +0100
commit452dc7f163749de0b5d698af2f022ca22c1aabb0 (patch)
tree5a84201f77bb71bc2ee2e1a4adb37220756d32b1 /src/being.cpp
parent6846acdcf0159423c188b56fc4a5f4c19f123eb7 (diff)
downloadmana-client-452dc7f163749de0b5d698af2f022ca22c1aabb0.tar.gz
mana-client-452dc7f163749de0b5d698af2f022ca22c1aabb0.tar.bz2
mana-client-452dc7f163749de0b5d698af2f022ca22c1aabb0.tar.xz
mana-client-452dc7f163749de0b5d698af2f022ca22c1aabb0.zip
Now the client centers the pixel positions when using tA.
I made it so that the behaviour can be changed with only a boolean setting in the playerhandler.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 2c8414d8..6b971dbf 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -198,21 +198,37 @@ void Being::setDestination(int dstX, int dstY)
return;
// If the destination is unwalkable, don't bother trying to get there
- if (!mMap->getWalk(dstX / 32, dstY / 32))
+ int tileWidth = mMap->getTileWidth();
+ int tileHeight = mMap->getTileHeight();
+ if (!mMap->getWalk(dstX / tileWidth, dstY / tileHeight))
return;
- Position dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(),
- dstX, dstY);
- Path thisPath = mMap->findPixelPath((int) mPos.x, (int) mPos.y,
- dest.x, dest.y,
- getCollisionRadius(), getWalkMask());
+ Position dest(dstX, dstY);
+ Path thisPath;
+ if (Net::getPlayerHandler()->usePixelPrecision())
+ {
+ dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(),
+ dstX, dstY);
+ thisPath = mMap->findPixelPath((int) mPos.x, (int) mPos.y,
+ dest.x, dest.y,
+ getCollisionRadius(), getWalkMask());
+ }
+ else
+ {
+ // We center the destination.
+ dest.x = (dstX / tileWidth) * tileWidth + tileWidth / 2;
+ dest.y = (dstY / tileHeight) * tileHeight + tileHeight / 2;
+ // and find a tile centered pixel path
+ thisPath = mMap->findTilePath((int) mPos.x, (int) mPos.y,
+ dest.x, dest.y, getWalkMask());
+ }
if (thisPath.empty())
{
// If there is no path but the destination is on the same walkable tile,
// we accept it.
- if ((int)mPos.x / 32 == dest.x / 32
- && (int)mPos.y / 32 == dest.y / 32)
+ if ((int)mPos.x / tileWidth == dest.x / tileWidth
+ && (int)mPos.y / tileHeight == dest.y / tileHeight)
{
mDest.x = dest.x;
mDest.y = dest.y;