diff options
author | yexo <yexo@openttd.org> | 2009-02-10 19:22:09 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-02-10 19:22:09 +0000 |
commit | 8ef2024b9673586b8eba9b4f3599bc966348db03 (patch) | |
tree | 035036289bb46372fcd255af1b34730f2a1f827e /src/ai/api | |
parent | 2c317b7321534d185776f9da0f360b5f3da6c94d (diff) | |
download | openttd-8ef2024b9673586b8eba9b4f3599bc966348db03.tar.xz |
(svn r15440) -Fix: Backup AIObject::GetAllowDoCommand and restore the old value so AIs can't work around it.
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_abstractlist.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ai/api/ai_abstractlist.cpp b/src/ai/api/ai_abstractlist.cpp index 5fa0a1b23..f878933da 100644 --- a/src/ai/api/ai_abstractlist.cpp +++ b/src/ai/api/ai_abstractlist.cpp @@ -759,6 +759,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) { /* Don't allow docommand from a Valuator, as we can't resume in * mid-code */ + bool backup_allow = AIObject::GetAllowDoCommand(); AIObject::SetAllowDoCommand(false); sq_addref(vm, &obj_func); @@ -788,7 +789,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) { /* Call the function */ if (SQ_FAILED(sq_call(vm, nparam + 2, SQTrue, SQTrue))) { - AIObject::SetAllowDoCommand(true); + AIObject::SetAllowDoCommand(backup_allow); return SQ_ERROR; } @@ -810,7 +811,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) { sq_release(vm, &obj_func); for (int i = 0; i < nparam; i++) sq_release(vm, &obj_params[i]); - AIObject::SetAllowDoCommand(true); + AIObject::SetAllowDoCommand(backup_allow); return sq_throwerror(vm, _SC("return value of valuator is not valid (not integer/bool)")); } } @@ -826,6 +827,6 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) { sq_release(vm, &obj_func); for (int i = 0; i < nparam; i++) sq_release(vm, &obj_params[i]); - AIObject::SetAllowDoCommand(true); + AIObject::SetAllowDoCommand(backup_allow); return 0; } |