(svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick) noai
authortruebrain
Sat, 23 Feb 2008 16:43:22 +0000
branchnoai
changeset 9747 7e8f23e8d0c8
parent 9746 e4ab7ea8d897
child 9748 4584f8cd00e8
(svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
bin/ai/wrightai/main.nut
--- 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;
 	}
 }