Codechange: Replace GroupStatistics' num_engines with std::map. (#11849)

This removes manual memory management with calloc/free calls, and prevents potentially large arrays being allocated for each group.
This commit is contained in:
Peter Nelson
2024-01-21 14:09:44 +00:00
committed by GitHub
parent c0ab436077
commit 8797cc7ef2
3 changed files with 19 additions and 19 deletions

View File

@@ -32,7 +32,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 ScriptCompanyMode::IsDeity() || ::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].GetNumEngines(engine_id) > 0;
}
/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)