(svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs. noai
authortruebrain
Mon, 09 Jun 2008 21:24:10 +0000
branchnoai
changeset 10885 415791bee9d7
parent 10884 879d4205a9d0
child 10887 5c81038449f2
(svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
src/ai/api/ai_controller.cpp
--- a/src/ai/api/ai_controller.cpp	Mon Jun 09 14:38:23 2008 +0000
+++ b/src/ai/api/ai_controller.cpp	Mon Jun 09 21:24:10 2008 +0000
@@ -170,13 +170,18 @@
 		this->engine = NULL;
 		return;
 	}
-	if (this->engine->MethodExists(*this->SQ_instance, "constructor"))
-		this->engine->CallMethod(*this->SQ_instance, "constructor");
 }
 
 void AIController::Start()
 {
-	if (this->engine != NULL) this->engine->CallMethod(*this->SQ_instance, "Start");
+	if (this->engine == NULL) return;
+
+	/* Run the constructor first */
+	if (this->engine->MethodExists(*this->SQ_instance, "constructor")) {
+		this->engine->CallMethod(*this->SQ_instance, "constructor");
+	}
+	/* When that is done, start the Start() function */
+	this->engine->CallMethod(*this->SQ_instance, "Start");
 }
 
 AIController::~AIController()