# HG changeset patch # User truebrain # Date 1212964709 0 # Node ID f730e50984717abdec9796c86a1bc2911fd05e9d # Parent 705f4caa0796d9008710807420bbee418c661b82 (svn r13426) [NoAI] -Fix: in the unlikely case an AI is killed before his ->Start() was started, an assert was triggered diff -r 705f4caa0796 -r f730e5098471 src/ai/ai_threads.cpp --- a/src/ai/ai_threads.cpp Sun Jun 08 22:37:29 2008 +0000 +++ b/src/ai/ai_threads.cpp Sun Jun 08 22:38:29 2008 +0000 @@ -275,15 +275,17 @@ AIFiber *main = stFind(MAIN_FIBER); main->SwitchToState(RUNNING); - /* Start up the AI (this should be an infinite loop) */ - this->controller->Start(); + if (this->state != STOPPING) { + /* Start up the AI (this should be an infinite loop) */ + this->controller->Start(); - /* If we come here, the AI exited because it wanted to */ - DEBUG(ai, 1, "We've got a suicidal AI for player %d", this->fiber_id); + /* If we come here, the AI exited because it wanted to */ + DEBUG(ai, 1, "We've got a suicidal AI for player %d", this->fiber_id); - /* Wait until we are killed nicely by the game */ - while (this->state != STOPPING) { - main->SwitchToState(RUNNING); + /* Wait until we are killed nicely by the game */ + while (this->state != STOPPING) { + main->SwitchToState(RUNNING); + } } /* Suspend, and exit */