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

View File

@@ -63,6 +63,10 @@ ScriptObject::ActiveInstance::~ActiveInstance()
ScriptObject::ActiveInstance::active = this->last_active;
}
ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
: AutoRestoreBackup(GetStorage()->allow_do_command, false)
{}
/* static */ ScriptInstance &ScriptObject::GetActiveInstance()
{
assert(ScriptObject::ActiveInstance::active != nullptr);
@@ -205,16 +209,6 @@ ScriptObject::ActiveInstance::~ActiveInstance()
return GetStorage()->last_cmd_ret;
}
/* static */ void ScriptObject::SetAllowDoCommand(bool allow)
{
GetStorage()->allow_do_command = allow;
}
/* static */ bool ScriptObject::GetAllowDoCommand()
{
return GetStorage()->allow_do_command;
}
/* static */ void ScriptObject::SetCompany(::CompanyID company)
{
if (GetStorage()->root_company == INVALID_OWNER) GetStorage()->root_company = company;