- fixed a bad memory leak in the pathfinder
This commit is contained in:
parent
6d3f6dcaf4
commit
ed8c08de2f
|
@ -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){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user