Codechange: use GSCompanyMode::IsValid, IsDeity, and the precondition helpers

Direct 1:1 replacements in the code, and comments now refer to either
GSCompanyMode::IsValid or GSCompanyMode::IsDeity instead of several variations
on "company mode active" or "no company mode active".
This commit is contained in:
Rubidium
2023-03-02 19:44:13 +01:00
committed by rubidium42
parent cada2ca310
commit 83946ca31d
46 changed files with 227 additions and 226 deletions

View File

@@ -30,7 +30,7 @@
/* AIs have only access to engines they can purchase or still have in use.
* Deity has access to all engined that will be or were available ever. */
CompanyID company = ScriptObject::GetCompany();
return company == OWNER_DEITY || ::IsEngineBuildable(engine_id, e->type, company) || ::Company::Get(company)->group_all[e->type].num_engines[engine_id] > 0;
return ScriptCompanyMode::IsDeity() || ::IsEngineBuildable(engine_id, e->type, company) || ::Company::Get(company)->group_all[e->type].num_engines[engine_id] > 0;
}
/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)
@@ -277,7 +277,7 @@
{
company = ScriptCompany::ResolveCompanyID(company);
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforceDeityMode(false);
EnforcePrecondition(false, IsValidEngine(engine_id));
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
@@ -288,7 +288,7 @@
{
company = ScriptCompany::ResolveCompanyID(company);
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforceDeityMode(false);
EnforcePrecondition(false, IsValidEngine(engine_id));
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);