summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-07-23 20:42:13 +0000
committerrubidium <rubidium@openttd.org>2008-07-23 20:42:13 +0000
commit4396b7c68c9a84f5dd1253b87c009916759756f9 (patch)
treef395601c6ebf0129504500af1c44cfbe1c36ff09 /src/ai
parent7e7647f8728abc57ccbbef6f783f06b314100daa (diff)
downloadopenttd-4396b7c68c9a84f5dd1253b87c009916759756f9.tar.xz
(svn r13809) -Fix: memory leak each time a "new ai" got (re)started.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp
index 1bf72f805..182831702 100644
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -12,6 +12,7 @@
#include "../player_base.h"
#include "ai.h"
#include "default/default.h"
+#include "trolly/trolly.h"
#include "../signal_func.h"
AIStruct _ai;
@@ -225,6 +226,13 @@ void AI_PlayerDied(PlayerID player)
{
/* Called if this AI died */
_ai_player[player].active = false;
+
+ if (_players_ainew[player].pathfinder == NULL) return;
+
+ AyStarMain_Free(_players_ainew[player].pathfinder);
+ delete _players_ainew[player].pathfinder;
+ _players_ainew[player].pathfinder = NULL;
+
}
/**
@@ -246,9 +254,5 @@ void AI_Initialize()
*/
void AI_Uninitialize()
{
- const Player* p;
-
- FOR_ALL_PLAYERS(p) {
- if (p->is_ai) AI_PlayerDied(p->index);
- }
+ for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) AI_PlayerDied(p);
}