1
0
Fork 0

(svn r13809) -Fix: memory leak each time a "new ai" got (re)started.

release/0.7
rubidium 2008-07-23 20:42:13 +00:00
parent 1560fe3298
commit a050a78525
1 changed files with 9 additions and 5 deletions

View File

@ -12,6 +12,7 @@
#include "../player_base.h" #include "../player_base.h"
#include "ai.h" #include "ai.h"
#include "default/default.h" #include "default/default.h"
#include "trolly/trolly.h"
#include "../signal_func.h" #include "../signal_func.h"
AIStruct _ai; AIStruct _ai;
@ -225,6 +226,13 @@ void AI_PlayerDied(PlayerID player)
{ {
/* Called if this AI died */ /* Called if this AI died */
_ai_player[player].active = false; _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() void AI_Uninitialize()
{ {
const Player* p; for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) AI_PlayerDied(p);
FOR_ALL_PLAYERS(p) {
if (p->is_ai) AI_PlayerDied(p->index);
}
} }