summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_object.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-09-11 17:18:06 +0000
committeryexo <yexo@openttd.org>2009-09-11 17:18:06 +0000
commit8ef7b80719a4c3837b24157a0c65222011f1898d (patch)
treee20ff2578364bb2c7b1e403cc74e7e548cbdf8e3 /src/ai/api/ai_object.cpp
parentc9a25c88fa522fa778c2de827d98cce46700d1f6 (diff)
downloadopenttd-8ef7b80719a4c3837b24157a0c65222011f1898d.tar.xz
(svn r17500) -Fix (r16502): The wrong value was restored to SetAllowDoCommand possible resulting in an AI that wasn't allowed to do any actions
Diffstat (limited to 'src/ai/api/ai_object.cpp')
-rw-r--r--src/ai/api/ai_object.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ai/api/ai_object.cpp b/src/ai/api/ai_object.cpp
index 5f9031442..45012c20c 100644
--- a/src/ai/api/ai_object.cpp
+++ b/src/ai/api/ai_object.cpp
@@ -170,6 +170,11 @@ void AIObject::SetAllowDoCommand(bool allow)
bool AIObject::GetAllowDoCommand()
{
+ return GetStorage()->allow_do_command;
+}
+
+bool AIObject::CanSuspend()
+{
Squirrel *squirrel = Company::Get(_current_company)->ai_instance->engine;
return GetStorage()->allow_do_command && squirrel->CanSuspend();
}
@@ -197,7 +202,7 @@ int AIObject::GetCallbackVariable(int index)
bool AIObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text, AISuspendCallbackProc *callback)
{
- if (AIObject::GetAllowDoCommand() == false) {
+ if (!AIObject::CanSuspend()) {
throw AI_FatalError("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.");
}