(svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower. noai
authortruebrain
Sat, 21 Jun 2008 13:35:29 +0000
branchnoai
changeset 11043 e44adcf4ed4d
parent 11042 b16e983214c3
child 11044 097ea3e7ec56
(svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
src/ai/api/ai_controller.cpp
src/ai/api/ai_controller.hpp
--- a/src/ai/api/ai_controller.cpp	Sat Jun 21 13:30:37 2008 +0000
+++ b/src/ai/api/ai_controller.cpp	Sat Jun 21 13:35:29 2008 +0000
@@ -62,8 +62,12 @@
 #include "ai_vehicle.hpp.sq"
 #include "ai_vehiclelist.hpp.sq"
 
-/* static */ void AIController::Sleep(uint ticks)
+/* static */ void AIController::Sleep(int ticks)
 {
+	if (ticks <= 0) {
+		AILog::Warning("Sleep() value should be > 0. Assuming value 1.");
+		ticks = 1;
+	}
 	AI_SuspendPlayer(_current_player, ticks);
 }
 
--- a/src/ai/api/ai_controller.hpp	Sat Jun 21 13:30:37 2008 +0000
+++ b/src/ai/api/ai_controller.hpp	Sat Jun 21 13:35:29 2008 +0000
@@ -59,10 +59,11 @@
 	 *   are passed. Mind that an AI tick is different from in-game ticks and
 	 *   differ per AI speed.
 	 * @param ticks the ticks to wait
+	 * @pre ticks > 0.
 	 * @post the value of GetTick() will be changed exactly 'ticks' in value after
 	 *   calling this.
 	 */
-	static void Sleep(uint ticks);
+	static void Sleep(int ticks);
 
 	/**
 	 * When Squirrel triggers a print, this function is called.