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

Method GetNumWagons

src/script/api/script_vehicle.cpp:53–65  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

51}
52
53/* static */ SQInteger ScriptVehicle::GetNumWagons(VehicleID vehicle_id)
54{
55 if (!IsValidVehicle(vehicle_id)) return -1;
56
57 int num = 1;
58
59 const Train *v = ::Train::GetIfValid(vehicle_id);
60 if (v != nullptr) {
61 while ((v = v->GetNextUnit()) != nullptr) num++;
62 }
63
64 return num;
65}
66
67/* static */ SQInteger ScriptVehicle::GetLength(VehicleID vehicle_id)
68{

Callers

nothing calls this directly

Calls 1

GetNextUnitMethod · 0.80

Tested by

no test coverage detected