mirror of https://github.com/OpenTTD/OpenTTD
(svn r25305) -Fix [FS#5561]: Game Script APIs that execute a DoCommand were returning the same result as in TestMode during world generation
parent
2547523c0f
commit
a58427115c
|
@ -300,7 +300,12 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||||
|
|
||||||
if (_generating_world) {
|
if (_generating_world) {
|
||||||
IncreaseDoCommandCosts(res.GetCost());
|
IncreaseDoCommandCosts(res.GetCost());
|
||||||
if (callback != NULL) callback(GetActiveInstance());
|
if (callback != NULL) {
|
||||||
|
/* Insert return value into to stack and throw a control code that
|
||||||
|
* the return value in the stack should be used. */
|
||||||
|
callback(GetActiveInstance());
|
||||||
|
throw SQInteger(1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (_networking) {
|
} else if (_networking) {
|
||||||
/* Suspend the script till the command is really executed. */
|
/* Suspend the script till the command is really executed. */
|
||||||
|
|
|
@ -541,15 +541,19 @@ Squirrel::~Squirrel()
|
||||||
void Squirrel::InsertResult(bool result)
|
void Squirrel::InsertResult(bool result)
|
||||||
{
|
{
|
||||||
sq_pushbool(this->vm, result);
|
sq_pushbool(this->vm, result);
|
||||||
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
if (this->IsSuspended()) { // Called before resuming a suspended script?
|
||||||
vm->Pop();
|
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
||||||
|
vm->Pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Squirrel::InsertResult(int result)
|
void Squirrel::InsertResult(int result)
|
||||||
{
|
{
|
||||||
sq_pushinteger(this->vm, result);
|
sq_pushinteger(this->vm, result);
|
||||||
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
if (this->IsSuspended()) { // Called before resuming a suspended script?
|
||||||
vm->Pop();
|
vm->GetAt(vm->_stackbase + vm->_suspended_target) = vm->GetUp(-1);
|
||||||
|
vm->Pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void Squirrel::DecreaseOps(HSQUIRRELVM vm, int ops)
|
/* static */ void Squirrel::DecreaseOps(HSQUIRRELVM vm, int ops)
|
||||||
|
|
Loading…
Reference in New Issue