(svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
--- 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.