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

Function HandleMissingAircraftOrders

src/aircraft_cmd.cpp:1285–1312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1283}
1284
1285void HandleMissingAircraftOrders(Aircraft *v)
1286{
1287 /*
1288 * We do not have an order. This can be divided into two cases:
1289 * 1) we are heading to an invalid station. In this case we must
1290 * find another airport to go to. If there is nowhere to go,
1291 * we will destroy the aircraft as it otherwise will enter
1292 * the holding pattern for the first airport, which can cause
1293 * the plane to go into an undefined state when building an
1294 * airport with the same StationID.
1295 * 2) we are (still) heading to a (still) valid airport, then we
1296 * can continue going there. This can happen when you are
1297 * changing the aircraft's orders while in-flight or in for
1298 * example a depot. However, when we have a current order to
1299 * go to a depot, we have to keep that order so the aircraft
1300 * actually stops.
1301 */
1302 const Station *st = GetTargetAirportIfValid(v);
1303 if (st == nullptr) {
1304 Backup<CompanyID> cur_company(_current_company, v->owner);
1305 CommandCost ret = Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag{}, {});
1306 cur_company.Restore();
1307
1308 if (ret.Failed()) CrashAirplane(v);
1309 } else if (!v->current_order.IsType(OT_GOTO_DEPOT)) {
1310 v->current_order.Free();
1311 }
1312}
1313
1314
1315TileIndex Aircraft::GetOrderStationLocation(StationID)

Callers 1

ProcessOrdersFunction · 0.85

Calls 6

GetTargetAirportIfValidFunction · 0.85
CrashAirplaneFunction · 0.85
FailedMethod · 0.80
IsTypeMethod · 0.80
RestoreMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected