# HG changeset patch # User truelight # Date 1174227806 0 # Node ID 8b688e6517d0709e663cefc97205d7bc1ef8584d # Parent 2a4c4340233d37dfba41a64458b861b3650b5779 (svn r9276) [NoAI] -Fix: make NoAI and SQNoAI run their code again, by simulating a GameLoop() diff -r 2a4c4340233d -r 8b688e6517d0 bin/ai/SQNoAI/main.nut --- 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()); diff -r 2a4c4340233d -r 8b688e6517d0 src/ai/NoAI/NoAI.cpp --- 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; diff -r 2a4c4340233d -r 8b688e6517d0 src/ai/NoAI/NoAI.hpp --- 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 {