Public Member Functions | Data Fields

# 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.
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, EngineImageType image_type) 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.
int | GetSpeedOldUnits () const
int | GetCurrentMaxSpeed () const
| Calculates the maximum speed of the vehicle under its current conditions.
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.
bool | IsNormalAircraft () const
| Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.
uint16 | GetRange () const
| Get the range of this aircraft.
## Data Fields
uint16 | crashed_counter
| Timer for handling crash animations.
byte | pos
| Next desired position of the aircraft.
byte | previous_pos
| Previous desired position of the aircraft.
StationID | targetairport
| Airport to go to next.
byte | state
| State of the airport.
DirectionByte | last_direction
byte | number_consecutive_turns
| Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
byte | turn_counter
| Ticks between each turn to prevent > 45 degree turns.
byte | flags
| Aircraft flags.
AircraftCache | acache

## Detailed Description

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

Definition at line 53 of file aircraft.h.

## Constructor & Destructor Documentation

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

We want to 'destruct' the right class.

Definition at line 69 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 1144 of file aircraft_cmd.cpp.

References crashed_counter.

Referenced by CrashAirplane().

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

References Station::airport, FindNearestHangar(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), GetTargetAirportIfValid(), Airport::HasHangar(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and BaseStation::xy.

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

Calculates the maximum speed of the vehicle under its current conditions.

Returns:
  Current maximum speed in native units.

Reimplemented from Vehicle.

Definition at line 79 of file aircraft.h.

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 77 of file aircraft.h.

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

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 76 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 73 of file aircraft.h.

References EXPENSES_AIRCRAFT_INC.

SpriteID Aircraft::GetImage | ( | Direction | direction,
|  | EngineImageType | image_type |
| ) |  |  | 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 152 of file aircraft_cmd.cpp.

References Vehicle::GetEngine(), Engine::original_image_index, and Vehicle::spritenum.

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

References AircraftNextAirportPos_and_Order(), FLYING, and state.

uint16 Aircraft::GetRange | ( |  | ) | const`[inline]`

Get the range of this aircraft.

Returns:
  Range in tiles or 0 if unlimited range.

Definition at line 112 of file aircraft.h.

References AircraftCache::cached_max_range.

Referenced by DrawOrderString(), and VehicleDetailsWindow::DrawWidget().

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

Gets the running cost of a vehicle.

Returns:
  the vehicle's running cost

Reimplemented from Vehicle.

Definition at line 402 of file aircraft_cmd.cpp.

References Vehicle::GetEngine(), Engine::GetGRF(), GetPrice(), and PROP_AIRCRAFT_RUNNING_COST_FACTOR.

Referenced by OnNewDay().

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 82 of file aircraft.h.

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

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 100 of file aircraft.h.

References Vehicle::subtype.

Referenced by AfterLoadGame(), CalculateCompanyValue(), Vehicle::HasEngineType(), Vehicle::IsEngineCountable(), IsPrimaryVehicle(), LoadUnloadVehicle(), NewVehicleAvailable(), 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 1137 of file aircraft_cmd.cpp.

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

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

Calls the tick handler of the vehicle.

Returns:
  is this vehicle still valid?

Reimplemented from Vehicle.

Definition at line 1925 of file aircraft_cmd.cpp.

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

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

References AIR_AIRCRAFT, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, ENDTAKEOFF, FLYING, HELILANDING, LANDING, state, Vehicle::subtype, Vehicle::x_extent, Vehicle::x_offs, Vehicle::y_extent, Vehicle::y_offs, and Vehicle::z_extent.

Referenced by AircraftLandAirplane(), and CmdBuildAircraft().

## Field Documentation

byte Aircraft::flags

Aircraft flags.

See also:
  VehicleAirFlags

Definition at line 62 of file aircraft.h.

Referenced by AircraftHandleDestTooFar().

byte Aircraft::state

State of the airport.

See also:
  AirportMovementStates

Definition at line 58 of file aircraft.h.

Referenced by AfterLoadGame(), AircraftController(), AircraftEventHandler_AtTerminal(), AircraftEventHandler_EnterHangar(), AircraftEventHandler_InHangar(), CmdBuildAircraft(), CmdStartStopVehicle(), FreeTerminal(), GetOrderStationLocation(), MapAircraftMovementAction(), MapAircraftMovementState(), RemoveAirport(), Vehicle::SendToDepot(), UpdateAirplanesOnNewStation(), UpdateDeltaXY(), UpdateOldAircraft(), and UpdateOrderDest().

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

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