diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-13 01:16:52 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-13 01:16:52 +0000 |
commit | ab9debf3fa91f3b36c6739f4affbdc187e78113d (patch) | |
tree | 4e22c94c0c3fd70c7741e98a7d81d0150ff57fba /src/map.cpp | |
parent | d0c5ab3fe88e1248f755a764248037960f7bed35 (diff) | |
download | mana-ab9debf3fa91f3b36c6739f4affbdc187e78113d.tar.gz mana-ab9debf3fa91f3b36c6739f4affbdc187e78113d.tar.bz2 mana-ab9debf3fa91f3b36c6739f4affbdc187e78113d.tar.xz mana-ab9debf3fa91f3b36c6739f4affbdc187e78113d.zip |
* Moved Being public char *speech to private std::string speech
* Moved Being public PATH_NODE *path to private std::list<PATH_NODE> path
* Fixed warping issue which corrupted player (which also applies to respawning)
* Got rid of sound error in Setup window
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/map.cpp b/src/map.cpp index d4fb9dde..9419233d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -272,13 +272,17 @@ int Map::getTileHeight() return tileHeight; } -PATH_NODE *Map::findPath(int startX, int startY, int destX, int destY) +std::list<PATH_NODE> Map::findPath( + int startX, int startY, int destX, int destY) { + // Path to be built up (empty by default) + std::list<PATH_NODE> path; + // Declare open list, a list with open tiles sorted on F cost std::priority_queue<Location> openList; // Return when destination not walkable - if (!getWalk(destX, destY)) return NULL; + if (!getWalk(destX, destY)) return path; // Reset starting tile's G cost to 0 MetaTile *startTile = getMetaTile(startX, startY); @@ -402,26 +406,20 @@ PATH_NODE *Map::findPath(int startX, int startY, int destX, int destY) // to extract it. if (foundPath) { - PATH_NODE *path = new PATH_NODE(destX, destY); int pathX = destX; int pathY = destY; while (pathX != startX || pathY != startY) { + // Add the new path node to the start of the path list + path.push_front(PATH_NODE(pathX, pathY)); + // Find out the next parent MetaTile *tile = getMetaTile(pathX, pathY); pathX = tile->parentX; pathY = tile->parentY; - - // Add the new path node to the start of the path list - PATH_NODE *pn = new PATH_NODE(pathX, pathY); - pn->next = path; - path = pn; } - - return path; } - // No path found - return NULL; + return path; } |