diff options
author | Bertram <bertram@cegetel.net> | 2009-10-09 17:34:25 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-10-09 17:34:25 +0200 |
commit | 3d035402ebffd2da05421125501d2ef4990d5bd7 (patch) | |
tree | 9f7c3e3008c5d280d56d9a77a0c259c757af4749 /src/game-server/map.hpp | |
parent | 1102bdc2e5a9e52b621cf58d68d0065faba2b84c (diff) | |
download | manaserv-3d035402ebffd2da05421125501d2ef4990d5bd7.tar.gz manaserv-3d035402ebffd2da05421125501d2ef4990d5bd7.tar.bz2 manaserv-3d035402ebffd2da05421125501d2ef4990d5bd7.tar.xz manaserv-3d035402ebffd2da05421125501d2ef4990d5bd7.zip |
Mostly synced the client and server code for path finding.
Diffstat (limited to 'src/game-server/map.hpp')
-rw-r--r-- | src/game-server/map.hpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/game-server/map.hpp b/src/game-server/map.hpp index 90d8ff33..4de34f08 100644 --- a/src/game-server/map.hpp +++ b/src/game-server/map.hpp @@ -29,14 +29,23 @@ const unsigned int DEFAULT_TILE_WIDTH = 32; const unsigned int DEFAULT_TILE_HEIGHT = 32; -struct PATH_NODE { - PATH_NODE(unsigned short u, unsigned short v) - : x(u), y(v) - {} +/** + * A position along a being's path. + * Used to compute each Path Nodes of the path. + */ +struct Position +{ + Position(int x, int y): + x(x), y(y) + { } - unsigned short x, y; + int x; + int y; }; +typedef std::list<Position> Path; +typedef Path::iterator PathIterator; + /** * A meta tile stores additional information about a location on a tile map. * This is information that doesn't need to be repeated for each tile in each @@ -131,6 +140,11 @@ class Map bool getWalk(int x, int y, char walkmask = BLOCKMASK_WALL) const; /** + * Tells if a tile location is within the map range. + */ + bool contains(int x, int y) const; + + /** * Returns the width of this map. */ int getWidth() const @@ -168,7 +182,7 @@ class Map /** * Find a path from one location to the next. */ - std::list<PATH_NODE> findPath(int startX, int startY, + Path findPath(int startX, int startY, int destX, int destY, unsigned char walkmask, int maxCost = 20); @@ -176,7 +190,7 @@ class Map /** * Finds a simple path from location to the next. */ - std::list<PATH_NODE> findSimplePath(int startX, int startY, + Path findSimplePath(int startX, int startY, int destX, int destY, unsigned char walkmask); |