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

Method GetCapacity

src/script/api/script_engine.cpp:83–104  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

81
82
83/* static */ SQInteger ScriptEngine::GetCapacity(EngineID engine_id)
84{
85 if (!IsValidEngine(engine_id)) return -1;
86
87 const Engine *e = ::Engine::Get(engine_id);
88 switch (e->type) {
89 case VEH_ROAD:
90 case VEH_TRAIN: {
91 CargoArray capacities = GetCapacityOfArticulatedParts(engine_id);
92 for (uint &cap : capacities) {
93 if (cap != 0) return cap;
94 }
95 return -1;
96 }
97
98 case VEH_SHIP:
99 case VEH_AIRCRAFT:
100 return e->GetDisplayDefaultCapacity();
101
102 default: NOT_REACHED();
103 }
104}
105
106/* static */ SQInteger ScriptEngine::GetReliability(EngineID engine_id)
107{

Callers 1

UpdateLogScrollMethod · 0.45

Calls 3

NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected