summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-26 23:40:37 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-26 23:40:37 +0200
commit2d0e84449b14615bdacb6f897791628662bbfd39 (patch)
tree08019ae6c24c6da25e25da027d04ad008c25d6a2 /src/map.cpp
parent42605753159d7b63276351311e0fd43874a3366b (diff)
parent0056412ed33b941d72a175dcd3f025abcd8fc02b (diff)
downloadmana-client-2d0e84449b14615bdacb6f897791628662bbfd39.tar.gz
mana-client-2d0e84449b14615bdacb6f897791628662bbfd39.tar.bz2
mana-client-2d0e84449b14615bdacb6f897791628662bbfd39.tar.xz
mana-client-2d0e84449b14615bdacb6f897791628662bbfd39.zip
Made the client use a unique kind of movement code.
This is fixng many issues and (hopefully) will make the movement rendering much smoother. Merge branch 'master' of gitorious.org:~bertram/mana/mana-movement-code-merge Conflicts: src/being.cpp src/net/manaserv/beinghandler.cpp Resolves: TMW-Mantis #946. Reviewed-by: Thorbjorn.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 151cbf53..da962253 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -604,6 +604,15 @@ bool Map::occupied(int x, int y) const
return false;
}
+Vector Map::getTileCenter(int x, int y)
+{
+ Vector tileCenterPos;
+
+ tileCenterPos.x = x * mTileWidth + mTileWidth / 2;
+ tileCenterPos.y = y * mTileHeight + mTileHeight / 2;
+ return tileCenterPos;
+}
+
bool Map::contains(int x, int y) const
{
return x >= 0 && y >= 0 && x < mWidth && y < mHeight;
@@ -707,6 +716,30 @@ Position Map::checkNodeOffsets(int radius, unsigned char walkMask,
return Position(tx * 32 + fx, ty * 32 + fy);
}
+Path Map::findTilePath(int startPixelX, int startPixelY, int endPixelX,
+ int endPixelY, unsigned char walkMask, int maxCost)
+{
+ Path myPath = findPath(startPixelX / mTileWidth, startPixelY / mTileHeight,
+ endPixelX / mTileWidth, endPixelY / mTileHeight,
+ walkMask, maxCost);
+
+ // Don't compute empty coordinates.
+ if (myPath.empty())
+ return myPath;
+
+ // Convert the map path to pixels from the tile position
+ Path::iterator it = myPath.begin();
+ while (it != myPath.end())
+ {
+ // The new pixel position will be the tile center.
+ *it = Position(it->x * mTileWidth + mTileWidth / 2,
+ it->y * mTileHeight + mTileHeight / 2);
+ ++it;
+ }
+
+ return myPath;
+}
+
Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX,
int endPixelY,
int radius, unsigned char walkMask, int maxCost)