diff options
author | Yexo <Yexo@openttd.org> | 2009-01-20 14:11:58 +0000 |
---|---|---|
committer | Yexo <Yexo@openttd.org> | 2009-01-20 14:11:58 +0000 |
commit | 2abfbafaf24f61a3c9ec462cce9a041dad73b889 (patch) | |
tree | 5db8c69e705f0e04ba8a13cd9f5454fd9eb67c3a /src/script | |
parent | e7af36ae79eb4bd66292abb023d3649d45c5fd14 (diff) | |
download | openttd-2abfbafaf24f61a3c9ec462cce9a041dad73b889.tar.xz |
(svn r15167) -Fix [FS#2558]: The top of the stack was resetted after executing the first Ai tick causing random AI crashes.
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/squirrel.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index b75833f65..22e39562e 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -192,8 +192,9 @@ bool Squirrel::CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT sq_pushobject(this->vm, instance); sq_call(this->vm, 1, ret == NULL ? SQFalse : SQTrue, SQTrue, suspend); if (ret != NULL) sq_getstackobj(vm, -1, ret); - /* Reset the top */ - sq_settop(this->vm, top); + /* Reset the top, but don't do so for the AI main function, as we need + * a correct stack when resuming. */ + if (this->vm->_suspended == 0) sq_settop(this->vm, top); return this->vm->_suspended != 0; } |