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

Function GetAircraftFlightLevelBounds

src/aircraft_cmd.cpp:726–752  ·  view source on GitHub ↗

* Get the 'flight level' bounds, in pixels from 'z_pos' 0 for a particular * vehicle for normal flight situation. * When the maximum is reached the vehicle should consider descending. * When the minimum is reached the vehicle should consider ascending. * * @param v The vehicle to get the flight levels for. * @param[out] min_level The minimum bounds for flight level. * @param[ou

Source from the content-addressed store, hash-verified

724 * @param[out] max_level The maximum bounds for flight level.
725 */
726void GetAircraftFlightLevelBounds(const Vehicle *v, int *min_level, int *max_level)
727{
728 int base_altitude = GetTileHeightBelowAircraft(v);
729 if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->subtype == AIR_HELICOPTER) {
730 base_altitude += HELICOPTER_HOLD_MAX_FLYING_ALTITUDE - PLANE_HOLD_MAX_FLYING_ALTITUDE;
731 }
732
733 /* Make sure eastbound and westbound planes do not "crash" into each
734 * other by providing them with vertical separation
735 */
736 switch (v->direction) {
737 case DIR_N:
738 case DIR_NE:
739 case DIR_E:
740 case DIR_SE:
741 base_altitude += 10;
742 break;
743
744 default: break;
745 }
746
747 /* Make faster planes fly higher so that they can overtake slower ones */
748 base_altitude += std::min(20 * (v->vcache.cached_max_speed / 200) - 90, 0);
749
750 if (min_level != nullptr) *min_level = base_altitude + AIRCRAFT_MIN_FLYING_ALTITUDE;
751 if (max_level != nullptr) *max_level = base_altitude + AIRCRAFT_MAX_FLYING_ALTITUDE;
752}
753
754/**
755 * Gets the maximum 'flight level' for the holding pattern of the aircraft,

Callers 6

GetAircraftFlightLevelFunction · 0.85
AircraftControllerFunction · 0.85
DisasterVehicleMethod · 0.85
ReleaseDisasterVehicleFunction · 0.85
AfterLoadGameFunction · 0.85
UpdateOldAircraftFunction · 0.85

Calls 1

Tested by

no test coverage detected