# Aircraft Struct Reference

Aircraft, helicopters, rotors and their shadows belong to this class. More...

`#include <aircraft.h>`

Inheritance diagram for Aircraft:

## Public Member Functions

| Aircraft ()
| We don't want GCC to zero our struct! It already is zeroed and has an index!
virtual | ~Aircraft ()
| We want to 'destruct' the right class.
const char * | GetTypeString () const
| Get a string 'representation' of the vehicle type.
void | MarkDirty ()
| Marks the vehicles to be redrawn and updates cached variables.
void | UpdateDeltaXY (Direction direction)
| Updates the x and y offsets and the size of the sprite used for this vehicle.
ExpensesType | GetExpenseType (bool income) const
| Sets the expense type associated to this vehicle type.
bool | IsPrimaryVehicle () const
| Whether this is the primary vehicle in the chain.
SpriteID | GetImage (Direction direction) const
| Gets the sprite to show for the given direction.
int | GetDisplaySpeed () const
| Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
int | GetDisplayMaxSpeed () const
| Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Money | GetRunningCost () const
| Gets the running cost of a vehicle.
bool | IsInDepot () const
| Check whether the vehicle is in the depot.
bool | Tick ()
| Calls the tick handler of the vehicle.
void | OnNewDay ()
| Calls the new day handler of the vehicle.
uint | Crash (bool flooded=false)
| Crash the (whole) vehicle chain.
TileIndex | GetOrderStationLocation (StationID station)
| Determine the location for the station where the vehicle goes to next.
bool | FindClosestDepot (TileIndex *location, DestinationID *destination, bool *reverse)
| Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should reverse.
FORCEINLINE bool | IsNormalAircraft () const
| Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.

## Data Fields

AircraftCache | acache
| Cache of often used calculated values.
uint16 | crashed_counter
byte | pos
byte | previous_pos
StationID | targetairport
byte | state
DirectionByte | last_direction
byte | number_consecutive_turns
byte | turn_counter
| Ticks between each turn to prevent > 45 degree turns.

## Detailed Description

Aircraft, helicopters, rotors and their shadows belong to this class.

Definition at line 66 of file aircraft.h.

## Constructor & Destructor Documentation

virtual Aircraft::~Aircraft | ( |  | ) | `[inline, virtual]`

We want to 'destruct' the right class.

Definition at line 83 of file aircraft.h.

References Vehicle::PreDestructor().

## Member Function Documentation

uint Aircraft::Crash | ( | bool | flooded = `false` | ) | `[virtual]`

Crash the (whole) vehicle chain.

Parameters:

  | flooded | whether the cause of the crash is flooding or not.

Returns:
  the number of lost souls.

Reimplemented from Vehicle.

Definition at line 1240 of file aircraft_cmd.cpp.

bool Aircraft::FindClosestDepot | ( | TileIndex * | location,
|  | DestinationID * | destination,
|  | bool * | reverse |
| ) |  |  | `[virtual]`

Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should reverse.

Parameters:

  | location | where do we go to?
  | destination | what hangar do we go to?
  | reverse | should the vehicle be reversed?

Returns:
  true if a depot could be found.

Reimplemented from Vehicle.

Definition at line 423 of file aircraft_cmd.cpp.

References FindNearestHangar(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), GetTargetAirportIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, AirportSpec::nof_depots, and BaseStation::xy.

int Aircraft::GetDisplayMaxSpeed | ( |  | ) | const`[inline, virtual]`

Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.

Returns:
  the vehicle's maximum speed

Reimplemented from Vehicle.

Definition at line 92 of file aircraft.h.

References Vehicle::max_speed.

int Aircraft::GetDisplaySpeed | ( |  | ) | const`[inline, virtual]`

Gets the speed in km-ish/h that can be sent into SetDParam for string processing.

Returns:
  the vehicle's speed

Reimplemented from Vehicle.

Definition at line 91 of file aircraft.h.

References Vehicle::cur_speed.

ExpensesType Aircraft::GetExpenseType | ( | bool | income | ) | const`[inline, virtual]`

Sets the expense type associated to this vehicle type.

Parameters:

  | income | whether this is income or (running) expenses of the vehicle

Reimplemented from Vehicle.

Definition at line 88 of file aircraft.h.

References EXPENSES_AIRCRAFT_INC, and EXPENSES_AIRCRAFT_RUN.

SpriteID Aircraft::GetImage | ( | Direction | direction | ) | const`[virtual]`

Gets the sprite to show for the given direction.

Parameters:

  | direction | the direction the vehicle is facing

Returns:
  the sprite for the given vehicle in the given direction

Reimplemented from Vehicle.

Definition at line 160 of file aircraft_cmd.cpp.

References SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get().

TileIndex Aircraft::GetOrderStationLocation | ( | StationID | station | ) | `[virtual]`

Determine the location for the station where the vehicle goes to next.

Things done for example are allocating slots in a road stop or exact location of the platform is determined for ships.

Parameters:

  | station | the station to make the next location of the vehicle.

Returns:
  the location (tile) to aim for.

Reimplemented from Vehicle.

Definition at line 1222 of file aircraft_cmd.cpp.

References AircraftNextAirportPos_and_Order().

Money Aircraft::GetRunningCost | ( |  | ) | const`[virtual]`

Gets the running cost of a vehicle.

Returns:
  the vehicle's running cost

Reimplemented from Vehicle.

Definition at line 531 of file aircraft_cmd.cpp.

References SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), GetPrice(), and PROP_AIRCRAFT_RUNNING_COST_FACTOR.

Referenced by OnNewDay().

const char* Aircraft::GetTypeString | ( |  | ) | const`[inline, virtual]`

Get a string 'representation' of the vehicle type.

Returns:
  the string representation.

Reimplemented from Vehicle.

Definition at line 85 of file aircraft.h.

bool Aircraft::IsInDepot | ( |  | ) | const`[inline, virtual]`

Check whether the vehicle is in the depot.

Returns:
  true if and only if the vehicle is in the depot.

Reimplemented from Vehicle.

Definition at line 94 of file aircraft.h.

References IsHangarTile(), Vehicle::tile, and Vehicle::vehstatus.

FORCEINLINE bool Aircraft::IsNormalAircraft | ( |  | ) | const`[inline]`

Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.

Returns:
  Returns true if the aircraft is a helicopter/airplane and false if it is a shadow or a rotor

Definition at line 107 of file aircraft.h.

References AIR_AIRCRAFT, and Vehicle::subtype.

Referenced by CalculateCompanyValue(), Vehicle::IsEngineCountable(), IsPrimaryVehicle(), LoadUnloadVehicle(), OnNewDay(), RemoveAirport(), Tick(), UpdateAirplanesOnNewStation(), UpdateOldAircraft(), and Station::~Station().

void Aircraft::MarkDirty | ( |  | ) | `[virtual]`

Marks the vehicles to be redrawn and updates cached variables.

This method marks the area of the vehicle on the screen as dirty. It can be use to repaint the vehicle.

Reimplemented from Vehicle.

Definition at line 1233 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Next(), Vehicle::subtype, and Vehicle::UpdateViewport().

bool Aircraft::Tick | ( |  | ) | `[virtual]`

Calls the tick handler of the vehicle.

Returns:
  is this vehicle still valid?

Reimplemented from Vehicle.

Definition at line 1936 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, Vehicle::current_order_time, IsNormalAircraft(), Vehicle::running_ticks, Vehicle::subtype, and Vehicle::vehstatus.

void Aircraft::UpdateDeltaXY | ( | Direction | direction | ) | `[virtual]`

Updates the x and y offsets and the size of the sprite used for this vehicle.

Parameters:

  | direction | the direction the vehicle is facing

Reimplemented from Vehicle.

Definition at line 43 of file aircraft_cmd.cpp.

References AIR_AIRCRAFT, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, GB(), and Vehicle::subtype.

Referenced by CmdBuildAircraft().

## Field Documentation

byte Aircraft::turn_counter

Ticks between each turn to prevent > 45 degree turns.

Definition at line 78 of file aircraft.h.

Referenced by AircraftController().

The documentation for this struct was generated from the following files:

- src/aircraft.h
- src/aircraft_cmd.cpp