diff options
author | Yexo <Yexo@openttd.org> | 2009-01-27 13:11:11 +0000 |
---|---|---|
committer | Yexo <Yexo@openttd.org> | 2009-01-27 13:11:11 +0000 |
commit | 283a265d8a43e25339e4af36833dd4c23c0938a3 (patch) | |
tree | a8a23b4e93094f3d598dfff2c05d909542830c84 /src/ai | |
parent | 6891d8f2e8a4a728f648063f2fed0e99f365e375 (diff) | |
download | openttd-283a265d8a43e25339e4af36833dd4c23c0938a3.tar.xz |
(svn r15284) -Fix [FS#2582] (r15045): Parameters were popped from the squirrel stack twice.
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai_instance.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 1d719b503..5ad763ae9 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -606,6 +606,7 @@ void AIInstance::Load(int version) return; } HSQUIRRELVM vm = this->engine->GetVM(); + SQInteger old_top = sq_gettop(vm); SlObject(NULL, _ai_byte); /* Check if there was anything saved at all. */ @@ -624,12 +625,17 @@ void AIInstance::Load(int version) if (this->engine->MethodExists(*this->instance, "Load")) { sq_call(vm, 3, SQFalse, SQFalse); + + /* Pop 1) the object instance, 2) the (null) result. */ + sq_pop(vm, 2); } else { AILog::Warning("Loading failed: there was data for the AI to load, but the AI does not have a Load() function."); + + /* Pop 1) the object instance, 2) the function name, 3) the instance again, 4) the version */ + sq_pop(vm, 4); } - /* Pop 1) the object instance, 2) the function name, 3) the instance again, 4) the (null) result. */ - sq_pop(vm, 4); + assert(sq_gettop(vm) == old_top); AIObject::SetAllowDoCommand(true); return; |