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

Method GetWagonEngineType

src/script/api/script_vehicle.cpp:284–294  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

282}
283
284/* static */ EngineID ScriptVehicle::GetWagonEngineType(VehicleID vehicle_id, SQInteger wagon)
285{
286 if (!IsValidVehicle(vehicle_id)) return ::EngineID::Invalid();
287 if (wagon >= GetNumWagons(vehicle_id)) return ::EngineID::Invalid();
288
289 const Vehicle *v = ::Vehicle::Get(vehicle_id);
290 if (v->type == VEH_TRAIN) {
291 while (wagon-- > 0) v = ::Train::From(v)->GetNextUnit();
292 }
293 return v->engine_type;
294}
295
296/* static */ SQInteger ScriptVehicle::GetUnitNumber(VehicleID vehicle_id)
297{

Callers

nothing calls this directly

Calls 2

InvalidFunction · 0.85
GetNextUnitMethod · 0.80

Tested by

no test coverage detected