Codechange: Replace ScriptObject::[SG]etAllowDoCommand with ScriptObject::DisableDoCommandScope

This commit is contained in:
glx22
2025-06-03 00:47:48 +02:00
committed by Loïc Guilloux
parent 4beb23af30
commit 31fbb17c5b
5 changed files with 28 additions and 57 deletions
+3 -9
View File
@@ -88,11 +88,9 @@ protected:
sq_push(vm, 2);
}
/* Don't allow docommand from a Valuator, as we can't resume in
/* Don't allow docommand from a filter, as we can't resume in
* mid C++-code. */
bool backup_allow = ScriptObject::GetAllowDoCommand();
ScriptObject::SetAllowDoCommand(false);
ScriptObject::DisableDoCommandScope disabler{};
if (nparam < 1) {
ScriptList::FillList<T>(list, item_valid);
@@ -101,7 +99,7 @@ protected:
SQOpsLimiter limiter(vm, MAX_VALUATE_OPS, "list filter function");
ScriptList::FillList<T>(list, item_valid,
[vm, nparam, backup_allow](const T *item) {
[vm, nparam](const T *item) {
/* Push the root table as instance object, this is what squirrel does for meta-functions. */
sq_pushroottable(vm);
/* Push all arguments for the valuator function. */
@@ -112,7 +110,6 @@ protected:
/* 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);
throw static_cast<SQInteger>(SQ_ERROR);
}
@@ -125,7 +122,6 @@ protected:
break;
default:
ScriptObject::SetAllowDoCommand(backup_allow);
throw sq_throwerror(vm, "return value of filter is not valid (not bool)");
}
@@ -139,8 +135,6 @@ protected:
/* Pop the filter function */
sq_poptop(vm);
}
ScriptObject::SetAllowDoCommand(backup_allow);
}
template <typename T>