mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-16 15:49:43 +00:00
Codechange: Replace ScriptObject::[SG]etAllowDoCommand with ScriptObject::DisableDoCommandScope
This commit is contained in:
@@ -910,8 +910,7 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
|
||||
/* Don't allow docommand from a Valuator, as we can't resume in
|
||||
* mid C++-code. */
|
||||
bool backup_allow = ScriptObject::GetAllowDoCommand();
|
||||
ScriptObject::SetAllowDoCommand(false);
|
||||
ScriptObject::DisableDoCommandScope disabler{};
|
||||
|
||||
/* Limit the total number of ops that can be consumed by a valuate operation */
|
||||
SQOpsLimiter limiter(vm, MAX_VALUATE_OPS, "valuator function");
|
||||
@@ -933,7 +932,6 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
|
||||
/* Call the function. Squirrel pops all parameters and pushes the return value. */
|
||||
if (SQ_FAILED(sq_call(vm, nparam + 1, SQTrue, SQFalse))) {
|
||||
ScriptObject::SetAllowDoCommand(backup_allow);
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
||||
@@ -956,7 +954,6 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
/* See below for explanation. The extra pop is the return value. */
|
||||
sq_pop(vm, nparam + 4);
|
||||
|
||||
ScriptObject::SetAllowDoCommand(backup_allow);
|
||||
return sq_throwerror(vm, "return value of valuator is not valid (not integer/bool)");
|
||||
}
|
||||
}
|
||||
@@ -966,7 +963,6 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
/* See below for explanation. The extra pop is the return value. */
|
||||
sq_pop(vm, nparam + 4);
|
||||
|
||||
ScriptObject::SetAllowDoCommand(backup_allow);
|
||||
return sq_throwerror(vm, "modifying valuated list outside of valuator function");
|
||||
}
|
||||
|
||||
@@ -984,6 +980,5 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
* 4. The ScriptList instance object. */
|
||||
sq_pop(vm, nparam + 3);
|
||||
|
||||
ScriptObject::SetAllowDoCommand(backup_allow);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user