MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsValidEngine

Method IsValidEngine

src/script/api/script_engine.cpp:27–37  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

25#include "../../safeguards.h"
26
27/* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id)
28{
29 EnforceDeityOrCompanyModeValid(false);
30 const Engine *e = ::Engine::GetIfValid(engine_id);
31 if (e == nullptr || !e->IsEnabled()) return false;
32
33 /* AIs have only access to engines they can purchase or still have in use.
34 * Deity has access to all engined that will be or were available ever. */
35 ::CompanyID company = ScriptObject::GetCompany();
36 return ScriptCompanyMode::IsDeity() || ::IsEngineBuildable(engine_id, e->type, company) || ::Company::Get(company)->group_all[e->type].GetNumEngines(engine_id) > 0;
37}
38
39/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)
40{

Callers

nothing calls this directly

Calls 3

IsEngineBuildableFunction · 0.85
IsEnabledMethod · 0.45
GetNumEnginesMethod · 0.45

Tested by

no test coverage detected