(svn r12515) [NoAI] -Fix: when an AI dies on its own, don't kill the AI-script, just mark it as dead and don't do anything until the company dies with it
--- a/src/ai/ai_threads.cpp Mon Mar 31 15:29:57 2008 +0000
+++ b/src/ai/ai_threads.cpp Mon Mar 31 16:07:36 2008 +0000
@@ -96,7 +96,6 @@
DEBUG(ai, 1, "We've got a suicidal AI for player %d", this->fiber_id);
/* The AI stopped on it's own */
this->state = STOPPED;
- AI_PlayerDied((PlayerID)this->fiber_id);
} else {
this->state = STOPPED;
}
@@ -166,6 +165,9 @@
public:
void RunTick()
{
+ /* If we already stopped, don't do anything */
+ if (this->state == STOPPED) return;
+
/* Should be called from main fiber only */
assert(CurrentThread() == stFind(MAIN_THREAD));
/* Only AI fibers should be resumed this way */
@@ -395,6 +397,9 @@
public:
/*virtual*/ void Stop()
{
+ /* If we already stopped, don't do anything */
+ if (this->state == STOPPED) return;
+
AIThread_MT *cur = stCurrentFiber();
/* The AI stopping itself */
if (cur == this) {
@@ -583,6 +588,9 @@
public:
virtual void Stop()
{
+ /* If we already stopped, don't do anything */
+ if (this->state == STOPPED) return;
+
AIThread_Fiber *cur = stCurrentFiber();
/* The AI stopping itself? */
if (cur == this) {