mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
8bd5f10a2c
commit
e1b1fd18b5
|
@ -6,6 +6,7 @@
|
||||||
#include "ai_abstractlist.hpp"
|
#include "ai_abstractlist.hpp"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../core/alloc_func.hpp"
|
#include "../../core/alloc_func.hpp"
|
||||||
|
#include "../../script/squirrel.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for any AIAbstractList sorter.
|
* Base class for any AIAbstractList sorter.
|
||||||
|
@ -818,6 +819,8 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) {
|
||||||
|
|
||||||
(*iter).second = (int32)value;
|
(*iter).second = (int32)value;
|
||||||
this->buckets[(int32)value].insert((*iter).first);
|
this->buckets[(int32)value].insert((*iter).first);
|
||||||
|
|
||||||
|
Squirrel::DecreaseOps(vm, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
sq_release(vm, &obj_func);
|
sq_release(vm, &obj_func);
|
||||||
|
|
|
@ -454,3 +454,8 @@ void Squirrel::InsertResult(int result)
|
||||||
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
||||||
vm->Pop();
|
vm->Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ void Squirrel::DecreaseOps(HSQUIRRELVM vm, int ops)
|
||||||
|
{
|
||||||
|
vm->DecreaseOps(ops);
|
||||||
|
}
|
||||||
|
|
|
@ -186,6 +186,11 @@ public:
|
||||||
* Release a SQ object.
|
* Release a SQ object.
|
||||||
*/
|
*/
|
||||||
void ReleaseObject(HSQOBJECT *ptr) { sq_release(this->vm, ptr); }
|
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 */
|
#endif /* SQUIRREL_HPP */
|
||||||
|
|
Loading…
Reference in New Issue