(svn r9276) [NoAI] -Fix: make NoAI and SQNoAI run their code again, by simulating a GameLoop() noai
authortruelight
Sun, 18 Mar 2007 14:23:26 +0000
branchnoai
changeset 9449 8b688e6517d0
parent 9448 2a4c4340233d
child 9450 d675836e865c
(svn r9276) [NoAI] -Fix: make NoAI and SQNoAI run their code again, by simulating a GameLoop()
bin/ai/SQNoAI/main.nut
src/ai/NoAI/NoAI.cpp
src/ai/NoAI/NoAI.hpp
--- a/bin/ai/SQNoAI/main.nut	Sun Mar 18 00:00:51 2007 +0000
+++ b/bin/ai/SQNoAI/main.nut	Sun Mar 18 14:23:26 2007 +0000
@@ -19,16 +19,20 @@
 
 	function Start();
 	function Stop();
+	function GameLoop();
+}
+
+function SQNoAI::Start()
+{
+	while (!this.stop) {
+		this.Sleep(1);
+		this.GameLoop();
+	}
 }
 
 /* Define the GameLoop. This is called every tick. */
-function SQNoAI::Start()
+function SQNoAI::GameLoop()
 {
-	while (!this.stop) {
-		print("Look at me!" + this.GetTick());
-		this.Sleep(50);
-	}
-	return;
 	if (this.GetTick() == 1) {
 		if (!this.company.SetCompanyName("SQNoAI")) {
 			this.company.SetCompanyName("SQNoAI " + this.base.Random());
--- a/src/ai/NoAI/NoAI.cpp	Sun Mar 18 00:00:51 2007 +0000
+++ b/src/ai/NoAI/NoAI.cpp	Sun Mar 18 14:23:26 2007 +0000
@@ -6,14 +6,9 @@
 
 static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play.
 
-/* virtual */ void NoAI::Start()
+/* Define the GameLoop. This is called every tick. */
+void NoAI::GameLoop()
 {
-	this->stop = false;
-	while (!stop) {
-		printf("Start NoAI %d\n", this->GetTick());
-		this->Sleep(50);
-	}
-	return;
 	if (this->GetTick() == 1) {
 		if (!this->company.SetCompanyName("NoAI")) {
 			char name[32];
@@ -68,6 +63,15 @@
 	}
 }
 
+/* virtual */ void NoAI::Start()
+{
+	this->stop = false;
+	while (!stop) {
+		this->Sleep(1);
+		this->GameLoop();
+	}
+}
+
 /* virtual */ void NoAI::Stop()
 {
 	this->stop = true;
--- a/src/ai/NoAI/NoAI.hpp	Sun Mar 18 00:00:51 2007 +0000
+++ b/src/ai/NoAI/NoAI.hpp	Sun Mar 18 14:23:26 2007 +0000
@@ -27,6 +27,7 @@
 public:
 	/* virtual */ void Start();
 	/* virtual */ void Stop();
+	void GameLoop();
 };
 
 class FNoAI: public AIFactory<FNoAI> {