- fixed a bad memory leak in the pathfinder

This commit is contained in:
Mark Vejvoda 2010-07-30 01:05:52 +00:00
parent 6d3f6dcaf4
commit ed8c08de2f

View File

@ -42,17 +42,22 @@ PathFinder::PathFinder(){
} }
PathFinder::PathFinder(const Map *map){ PathFinder::PathFinder(const Map *map){
init(map);
nodePool= NULL; nodePool= NULL;
init(map);
} }
void PathFinder::init(const Map *map){ void PathFinder::init(const Map *map){
if(nodePool != NULL) {
delete [] nodePool;
nodePool = NULL;
}
nodePool= new Node[pathFindNodesMax]; nodePool= new Node[pathFindNodesMax];
this->map= map; this->map= map;
} }
PathFinder::~PathFinder(){ PathFinder::~PathFinder(){
delete [] nodePool; delete [] nodePool;
nodePool = NULL;
} }
TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos){ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos){