From ed8c08de2f67e7417dfdfbd6d1657b51abbded46 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 30 Jul 2010 01:05:52 +0000 Subject: [PATCH] - fixed a bad memory leak in the pathfinder --- source/glest_game/ai/path_finder.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index f0b280d7..4a05dea4 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -42,17 +42,22 @@ PathFinder::PathFinder(){ } PathFinder::PathFinder(const Map *map){ - init(map); nodePool= NULL; + init(map); } void PathFinder::init(const Map *map){ + if(nodePool != NULL) { + delete [] nodePool; + nodePool = NULL; + } nodePool= new Node[pathFindNodesMax]; this->map= map; } PathFinder::~PathFinder(){ delete [] nodePool; + nodePool = NULL; } TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos){