* 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
| 724 | * @param[out] max_level The maximum bounds for flight level. |
| 725 | */ |
| 726 | void 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, |
no test coverage detected