Data Structures | Defines | Enumerations | Functions

# aircraft.h File Reference

Base for aircraft. More...

`#include "station_map.h"`
`#include "vehicle_base.h"`

Go to the source code of this file.

## Data Structures
struct | Aircraft
| Aircraft, helicopters, rotors and their shadows belong to this class. More...
## Defines
#define | FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
| Macro for iterating over all aircrafts.
## Enumerations
enum | AircraftFlyingAltitude { AIRCRAFT_MIN_FLYING_ALTITUDE = 120, AIRCRAFT_MAX_FLYING_ALTITUDE = 360, PLANE_HOLD_MAX_FLYING_ALTITUDE = 150, HELICOPTER_HOLD_MAX_FLYING_ALTITUDE = 184 }
| Minimal, maximal and holding flying altitude above ground while a plane is in flight and not starting or landing, i.e. More...
enum | AircraftSubType { AIR_HELICOPTER = 0, AIR_AIRCRAFT = 2, AIR_SHADOW = 4, AIR_ROTOR = 6 }
| An aircraft can be one of those types. More...
## Functions
void | HandleAircraftEnterHangar (Aircraft *v)
| Handle Aircraft specific tasks when an Aircraft enters a hangar.
void | GetAircraftSpriteSize (EngineID engine, uint &width, uint &height)
| Get the size of the sprite of an aircraft sprite heading west (used for lists).
void | UpdateAirplanesOnNewStation (const Station *st)
| Updates the status of the Aircraft heading or in the station.
void | UpdateAircraftCache (Aircraft *v)
| Update cached values of an aircraft.
void | AircraftLeaveHangar (Aircraft *v)
void | AircraftNextAirportPos_and_Order (Aircraft *v)
| set the right pos when heading to other airports after takeoff
uint | GetAircraftMinAltitude (int x_pos, int y_pos, int offset)
| Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start increasing it's altitude, to prevent aircraft crashing in higher terrain ahead.
uint | GetAircraftMaxAltitude (int x_pos, int y_pos, int offset)
| Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start decreasing it's altitude, to prevent aircraft taking off to space.
uint | GetAircraftHoldMaxAltitude (const Aircraft *v)
| Checks the flightpath height of the aircraft, in pixels, from level 0, dependant on terrain below, after adjusting height.
void | SetAircraftPosition (Aircraft *v, int x, int y, int z)
| Set aircraft position.
void | FindBreakdownDestination (Aircraft *v)
| Send a broken plane that needs to visit a depot to the correct location.
SpriteID | GetRotorImage (const Aircraft *v)
Station * | GetTargetAirportIfValid (const Aircraft *v)
| Returns aircraft's target station if v->target_airport is a valid station with airport.

## Detailed Description

Base for aircraft.

Definition in file aircraft.h.

## Enumeration Type Documentation

enum AircraftFlyingAltitude

Minimal, maximal and holding flying altitude above ground while a plane is in flight and not starting or landing, i.e.

in the state SLOWTURN & NOSPDCLAMP. Under certain circumstances, the actual flying altitude is higher, because certain offsets are added.

Enumerator:

  AIRCRAFT_MIN_FLYING_ALTITUDE | minimal flying altitude above tile.
  AIRCRAFT_MAX_FLYING_ALTITUDE | maximal flying altitude above tile.
  PLANE_HOLD_MAX_FLYING_ALTITUDE | holding flying altitude above tile of planes.
  HELICOPTER_HOLD_MAX_FLYING_ALTITUDE | holding flying altitude above tile of helicopters. // check if disaster vehicles behave the same. ifnot make it so ...

Definition at line 24 of file aircraft.h.

enum AircraftSubType

An aircraft can be one of those types.

Enumerator:

  AIR_HELICOPTER | an helicopter
  AIR_AIRCRAFT | an airplane
  AIR_SHADOW | shadow of the aircraft
  AIR_ROTOR | rotor of an helicopter

Definition at line 34 of file aircraft.h.

## Function Documentation

void FindBreakdownDestination | ( | Aircraft * | v | ) |

Send a broken plane that needs to visit a depot to the correct location.

Parameters:

  | v | Airplane in question.

Definition at line 1164 of file aircraft_cmd.cpp.

References AircraftNextAirportPos_and_Order(), BREAKDOWN_AIRCRAFT_DEPOT, BREAKDOWN_AIRCRAFT_EM_LANDING, Vehicle::breakdown_ctr, Vehicle::breakdown_type, CrashAirplane(), Vehicle::current_order, Aircraft::FindClosestDepot(), FindNearestHangar(), Order::GetDestination(), Order::MakeGoToDepot(), ODTFB_BREAKDOWN, Aircraft::targetairport, and VEH_AIRCRAFT.

Referenced by Vehicle::HandleBreakdown().

uint GetAircraftHoldMaxAltitude | ( | const Aircraft * | v | ) |

Checks the flightpath height of the aircraft, in pixels, from level 0, dependant on terrain below, after adjusting height.

Parameters:

  | v | The aircraft that may or may not need to decrease its altitude.

Returns:
  Maximal aircraft holding altitude, while in normal flight, in pixels.

Definition at line 764 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, GetTileHeightBelowAircraft(), Vehicle::subtype, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AircraftController().

uint GetAircraftMaxAltitude | ( | int | x_pos,
|  | int | y_pos,
|  | int | offset |
| ) |  |  |

Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start decreasing it's altitude, to prevent aircraft taking off to space.

Parameters:

  | x_pos | x position of the aircraft's shadow on the map.
  | y_pos | y position of the aircraft's shadow on the map.
  | offset | offset to add to returned altitude.

Returns:
  Maximal aircraft flying altitude above ground, while in normal flight, in pixels.

Definition at line 750 of file aircraft_cmd.cpp.

References AIRCRAFT_MAX_FLYING_ALTITUDE, and GetTileHeightBelowAircraft().

Referenced by AfterLoadGame(), AircraftController(), and UpdateOldAircraft().

uint GetAircraftMinAltitude | ( | int | x_pos,
|  | int | y_pos,
|  | int | offset |
| ) |  |  |

Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start increasing it's altitude, to prevent aircraft crashing in higher terrain ahead.

Parameters:

  | x_pos | x position of the aircraft's shadow on the map.
  | y_pos | y position of the aircraft's shadow on the map.
  | offset | offset to add to returned altitude.

Returns:
  Minimal aircraft flying altitude above ground, while in normal flight, in pixels.

Definition at line 733 of file aircraft_cmd.cpp.

References AIRCRAFT_MIN_FLYING_ALTITUDE, and GetTileHeightBelowAircraft().

Referenced by AircraftController(), Disaster_Helicopter_Init(), Disaster_Small_Ufo_Init(), and Disaster_Zeppeliner_Init().

void GetAircraftSpriteSize | ( | EngineID | engine,
|  | uint & | width,
|  | uint & | height |
| ) |  |  |

Get the size of the sprite of an aircraft sprite heading west (used for lists).

Parameters:

  | engine | The engine to get the sprite from
  | width | The width of the sprite
  | height | The height of the sprite

Definition at line 233 of file aircraft_cmd.cpp.

References Sprite::height, ST_NORMAL, and Sprite::width.

Station* GetTargetAirportIfValid | ( | const Aircraft * | v | ) |

Returns aircraft's target station if v->target_airport is a valid station with airport.

Parameters:

  | v | vehicle to get target airport for

Returns:
  pointer to target station, NULL if invalid

Definition at line 2092 of file aircraft_cmd.cpp.

References Station::airport, SpecializedStation< Station, false >::GetIfValid(), INVALID_TILE, Aircraft::targetairport, TileArea::tile, and VEH_AIRCRAFT.

Referenced by AfterLoadGame(), AircraftNextAirportPos_and_Order(), CrashAirplane(), Aircraft::FindClosestDepot(), Vehicle::HandleBreakdown(), HandleCrashedAircraft(), MapAircraftMovementState(), and Vehicle::PreDestructor().

void HandleAircraftEnterHangar | ( | Aircraft * | v | ) |

Handle Aircraft specific tasks when an Aircraft enters a hangar.

Parameters:

  | *v | Vehicle that enters the hangar

Definition at line 548 of file aircraft_cmd.cpp.

References Vehicle::cur_speed, SpecializedVehicle< T, Type >::Next(), Vehicle::progress, SetAircraftPosition(), Vehicle::subspeed, Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by VehicleEnterDepot().

void SetAircraftPosition | ( | Aircraft * | v,
|  | int | x,
|  | int | y,
|  | int | z |
| ) |  |  |

Set aircraft position.

Parameters:

  | v | Aircraft to position.
  | x | New X position.
  | y | New y position.
  | z | New z position.

Definition at line 512 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, Clamp(), Vehicle::cur_image, MapMaxX(), MapMaxY(), SpecializedVehicle< T, Type >::Next(), ROTOR_Z_OFFSET, Vehicle::subtype, TILE_SIZE, SpecializedVehicle< T, Type >::UpdateViewport(), VehicleMove(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by AfterLoadGame(), AircraftController(), HandleAircraftEnterHangar(), HandleCrashedAircraft(), and UpdateOldAircraft().

void UpdateAircraftCache | ( | Aircraft * | v | ) |

Update cached values of an aircraft.

Currently caches callback 36 max speed.

Parameters:

  | v | Vehicle

Definition at line 577 of file aircraft_cmd.cpp.

References VehicleCache::cached_max_speed, Vehicle::engine_type, PROP_AIRCRAFT_SPEED, and Vehicle::vcache.

Referenced by AfterLoadGame(), AfterLoadVehicles(), AircraftController(), CheckCaches(), CmdBuildAircraft(), UpdateAirplanesOnNewStation(), and UpdateOldAircraft().

void UpdateAirplanesOnNewStation | ( | const Station * | st | ) |

Updates the status of the Aircraft heading or in the station.

Parameters:

  | st | Station been updated

Definition at line 2106 of file aircraft_cmd.cpp.

References AircraftGetEntryPoint(), Station::airport, DIR_N, FLYING, FOR_ALL_AIRCRAFT, Airport::GetFTA(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, Aircraft::IsNormalAircraft(), Aircraft::pos, Aircraft::previous_pos, Airport::rotation, Aircraft::state, Aircraft::targetairport, TileArea::tile, and UpdateAircraftCache().

Referenced by CmdBuildAirport().