Mercurial > hg > openttd
changeset 11065:9b1699d5a2bc draft
(svn r15406) -Fix: make Valuate actually cost a few opcodes to not make it a single opcode method of doing lots of the same thing. This should resolve most of the hiccups caused by AIs.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 08 Feb 2009 01:51:48 +0000 |
parents | 388ca17e8ab1 |
children | dc14bcf4630a |
files | src/ai/api/ai_abstractlist.cpp src/script/squirrel.cpp src/script/squirrel.hpp |
diffstat | 3 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/api/ai_abstractlist.cpp +++ b/src/ai/api/ai_abstractlist.cpp @@ -6,6 +6,7 @@ #include "ai_abstractlist.hpp" #include "../../debug.h" #include "../../core/alloc_func.hpp" +#include "../../script/squirrel.hpp" /** * Base class for any AIAbstractList sorter. @@ -818,6 +819,8 @@ (*iter).second = (int32)value; this->buckets[(int32)value].insert((*iter).first); + + Squirrel::DecreaseOps(vm, 5); } sq_release(vm, &obj_func);
--- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -454,3 +454,8 @@ vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1); vm->Pop(); } + +/* static */ void Squirrel::DecreaseOps(HSQUIRRELVM vm, int ops) +{ + vm->DecreaseOps(ops); +}
--- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -186,6 +186,11 @@ * Release a SQ object. */ void ReleaseObject(HSQOBJECT *ptr) { sq_release(this->vm, ptr); } + + /** + * Tell the VM to remove \c amount ops from the number of ops till suspend. + */ + static void DecreaseOps(HSQUIRRELVM vm, int amount); }; #endif /* SQUIRREL_HPP */