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

Method GetState

src/script/api/script_vehicle.cpp:351–364  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

349}
350
351/* static */ ScriptVehicle::VehicleState ScriptVehicle::GetState(VehicleID vehicle_id)
352{
353 if (!IsValidVehicle(vehicle_id)) return ScriptVehicle::VS_INVALID;
354
355 const Vehicle *v = ::Vehicle::Get(vehicle_id);
356 VehStates vehstatus = v->vehstatus;
357
358 if (vehstatus.Test(::VehState::Crashed)) return ScriptVehicle::VS_CRASHED;
359 if (v->breakdown_ctr != 0) return ScriptVehicle::VS_BROKEN;
360 if (v->IsStoppedInDepot()) return ScriptVehicle::VS_IN_DEPOT;
361 if (vehstatus.Test(::VehState::Stopped)) return ScriptVehicle::VS_STOPPED;
362 if (v->current_order.IsType(OT_LOADING)) return ScriptVehicle::VS_AT_STATION;
363 return ScriptVehicle::VS_RUNNING;
364}
365
366/* static */ Money ScriptVehicle::GetRunningCost(VehicleID vehicle_id)
367{

Callers 13

UpdateFilterStateMethod · 0.45
SignNameFilterMethod · 0.45
BuildDisplayListMethod · 0.45
TagNameFilterMethod · 0.45
BuildSortTownListMethod · 0.45
ClassTagNameFilterFunction · 0.45
TypeTagNameFilterFunction · 0.45
FilterByTextMethod · 0.45
BadgeTextFilterMethod · 0.45
OnInvalidateDataMethod · 0.45
TagNameFilterMethod · 0.45

Calls 3

TestMethod · 0.80
IsTypeMethod · 0.80
IsStoppedInDepotMethod · 0.45

Tested by

no test coverage detected