(svn r13426) [NoAI] -Fix: in the unlikely case an AI is killed before his ->Start() was started, an assert was triggered
--- 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 */