MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / airplaneGetNewStatus

Method airplaneGetNewStatus

src/OpenLoco/src/Vehicles/VehicleHead.cpp:2021–2106  ·  view source on GitHub ↗

0x004273DF

Source from the content-addressed store, hash-verified

2019
2020 // 0x004273DF
2021 std::pair<Status, Speed16> VehicleHead::airplaneGetNewStatus()
2022 {
2023 Vehicle train(head);
2024 if (stationId == StationId::null || airportMovementEdge == kAirportMovementNodeNull)
2025 {
2026 auto veh2 = train.veh2;
2027 auto targetSpeed = veh2->maxSpeed;
2028 if (veh2->has73Flags(Flags73::isBrokenDown))
2029 {
2030 targetSpeed = veh2->rackRailMaxSpeed;
2031 }
2032
2033 return std::make_pair(Status::travelling, targetSpeed);
2034 }
2035
2036 auto station = StationManager::get(stationId);
2037
2038 Pos3 loc = station->airportStartPos;
2039
2040 auto tile = World::TileManager::get(loc);
2041 for (auto& el : tile)
2042 {
2043 auto* elStation = el.as<World::StationElement>();
2044 if (elStation == nullptr)
2045 {
2046 continue;
2047 }
2048
2049 if (elStation->baseZ() != loc.z / 4)
2050 {
2051 continue;
2052 }
2053
2054 auto airportObject = ObjectManager::get<AirportObject>(elStation->objectId());
2055 const auto movementEdges = airportObject->getMovementEdges();
2056
2057 uint8_t al = movementEdges[airportMovementEdge].var_03;
2058 uint8_t cl = movementEdges[airportMovementEdge].var_00;
2059
2060 auto veh2 = train.veh2;
2061 if (al != 0)
2062 {
2063 if (cl == 1 || al != 2)
2064 {
2065 if (al == 1)
2066 {
2067 return std::make_pair(Status::landing, veh2->rackRailMaxSpeed);
2068 }
2069 else if (al == 3)
2070 {
2071 return std::make_pair(Status::landing, 0_mph);
2072 }
2073 else if (al == 4)
2074 {
2075 return std::make_pair(Status::taxiing1, 20_mph);
2076 }
2077 else
2078 {

Callers

nothing calls this directly

Calls 5

has73FlagsMethod · 0.80
baseZMethod · 0.80
getMovementEdgesMethod · 0.80
getFunction · 0.50
objectIdMethod · 0.45

Tested by

no test coverage detected