(svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
--- a/bin/ai/wrightai/main.nut Sat Feb 23 16:21:10 2008 +0000
+++ b/bin/ai/wrightai/main.nut Sat Feb 23 16:43:22 2008 +0000
@@ -316,9 +316,13 @@
/* We need our local ticker, as GetTick() will skip ticks */
local ticker = 0;
+ /* Determine time we may sleep */
+ local sleepingtime = 100;
+ if (this.delay_build_airport_route < sleepingtime)
+ sleepingtime = this.delay_build_airport_route;
+
/* Let's go on for ever */
while (true) {
- ticker++;
/* Once in a while, with enough money, try to build something */
if (ticker % this.delay_build_airport_route == 0 && this.HasMoney(100000)) {
local ret = this.BuildAirportRoute();
@@ -340,7 +344,8 @@
this.HandleEvents();
}
/* Make sure we do not create infinite loops */
- Sleep(1);
+ Sleep(sleepingtime);
+ ticker += sleepingtime;
}
}