(svn r13426) [NoAI] -Fix: in the unlikely case an AI is killed before his ->Start() was started, an assert was triggered noai
authortruebrain
Sun, 08 Jun 2008 22:38:29 +0000
branchnoai
changeset 10875 f730e5098471
parent 10874 705f4caa0796
child 10876 63ac5bfb1a84
(svn r13426) [NoAI] -Fix: in the unlikely case an AI is killed before his ->Start() was started, an assert was triggered
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 */