# aircraft.h File Reference

Base for aircraft. More...

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

Go to the source code of this file.

## Data Structures

struct | AircraftCache
| Cached oftenly queried (NewGRF) values. More...
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)

## Enumerations

enum | AircraftSubType { AIR_HELICOPTER = 0, AIR_AIRCRAFT = 2, AIR_SHADOW = 4, AIR_ROTOR = 6 }
| An aircraft can be one ot those types. More...

## Functions

void | CcBuildAircraft (bool success, TileIndex tile, uint32 p1, uint32 p2)
| This is the Callback method after the construction attempt of an aircraft.
void | HandleAircraftEnterHangar (Aircraft *v)
| Handle Aircraft specific tasks when a 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
void | SetAircraftPosition (Aircraft *v, int x, int y, int z)
byte | GetAircraftFlyingAltitude (const Aircraft *v)
| Gets the cruise altitude of an aircraft.
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 AircraftSubType

An aircraft can be one ot 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 23 of file aircraft.h.

## Function Documentation

void CcBuildAircraft | ( | bool | success,
|  | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

This is the Callback method after the construction attempt of an aircraft.

Parameters:

  | success | indicates completion (or not) of the operation
  | tile | of depot where aircraft is built
  | p1 | unused
  | p2 | unused

Definition at line 113 of file aircraft_gui.cpp.

References RestoreVehicleOrders(), and ShowVehicleViewWindow().

byte GetAircraftFlyingAltitude | ( | const Aircraft * | v | ) |

Gets the cruise altitude of an aircraft.

The cruise altitude is determined by the velocity of the vehicle and the direction it is moving

Parameters:

  | v | The vehicle. Should be an aircraft

Returns:
  Altitude in pixel units

Definition at line 771 of file aircraft_cmd.cpp.

References DIR_E, DIR_N, DIR_NE, DIR_SE, and min().

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

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 221 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 1966 of file aircraft_cmd.cpp.

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

Referenced by AircraftNextAirportPos_and_Order(), and MapAircraftMovementState().

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

Handle Aircraft specific tasks when a an Aircraft enters a hangar.

Parameters:

  | *v | Vehicle that enters the hangar

Definition at line 658 of file aircraft_cmd.cpp.

References SpecializedVehicle< T, Type >::Next().

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

Update cached values of an aircraft.

Currently caches callback 36 max speed.

Parameters:

  | v | Vehicle

Definition at line 682 of file aircraft_cmd.cpp.

References Aircraft::acache, AircraftCache::cached_max_speed, and PROP_AIRCRAFT_SPEED.

Referenced by AfterLoadVehicles(), AircraftController(), CmdBuildAircraft(), StateGameLoop(), and UpdateAirplanesOnNewStation().

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

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

Parameters:

  | st | Station been updated

Definition at line 1980 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, AircraftGetEntryPoint(), Station::Airport(), GetAircraftFlyingAltitude(), GetNewVehiclePos(), AirportFTA::heading, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Aircraft::IsNormalAircraft(), AirportFTAClass::layout, AirportFTAClass::nofelements, Aircraft::pos, AirportFTA::position, Aircraft::previous_pos, Aircraft::state, Aircraft::targetairport, UpdateAircraftCache(), GetNewVehiclePosResult::x, and GetNewVehiclePosResult::y.

Referenced by CmdBuildAirport().