OpenTTD Source: src/airport.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Typedefs | Enumerations | Functions | Variables
airport.h File Reference

Various declarations for airports. More...

`#include "direction_type.h"`
`#include "tile_type.h"`

Go to the source code of this file.

## Data Structures
struct | AirportMovingData
| A single location on an airport where aircraft can move to. More...
struct | AirportFTA
| Internal structure used in openttd - Finite sTate mAchine --> FTA. More...
struct | AirportFTAClass
| Finite sTate mAchine (FTA) of an airport. More...

## Typedefs
using | AirportMovingDataFlags = EnumBitSet< AirportMovingDataFlag, uint16_t >
using | AirportBlocks = EnumBitSet< AirportBlock, uint64_t >

## Enumerations
enum | AirportTypes : uint8_t { AT_SMALL = 0 , AT_LARGE = 1 , AT_HELIPORT = 2 , AT_METROPOLITAN = 3 , AT_INTERNATIONAL = 4 , AT_COMMUTER = 5 , AT_HELIDEPOT = 6 , AT_INTERCON = 7 , AT_HELISTATION = 8 , AT_OILRIG = 9 , NEW_AIRPORT_OFFSET = 10 , NUM_AIRPORTS_PER_GRF = 128 , NUM_AIRPORTS = 128 , AT_INVALID = 254 , AT_DUMMY = 255 }
| Airport types. More...
enum class | AirportMovingDataFlag : uint8_t { NoSpeedClamp , Takeoff , SlowTurn , Land , ExactPosition , Brake , HeliRaise , HeliLower , Hold }
| Flags for airport movement data. More...
enum | AirportMovementStates : uint8_t { TO_ALL = 0 , HANGAR = 1 , TERM1 = 2 , TERM2 = 3 , TERM3 = 4 , TERM4 = 5 , TERM5 = 6 , TERM6 = 7 , HELIPAD1 = 8 , HELIPAD2 = 9 , TAKEOFF = 10 , STARTTAKEOFF = 11 , ENDTAKEOFF = 12 , HELITAKEOFF = 13 , FLYING = 14 , LANDING = 15 , ENDLANDING = 16 , HELILANDING = 17 , HELIENDLANDING = 18 , TERM7 = 19 , TERM8 = 20 , HELIPAD3 = 21 , MAX_HEADINGS = 21 , TERMGROUP = 255 }
| Movement States on Airports (headings target) More...
enum class | AirportBlock : uint8_t { Term1 = 0 , Term2 = 1 , Term3 = 2 , Term4 = 3 , Term5 = 4 , Term6 = 5 , Helipad1 = 6 , Helipad2 = 7 , RunwayInOut = 8 , RunwayIn = 8 , AirportBusy = 8 , RunwayOut = 9 , TaxiwayBusy = 10 , OutWay = 11 , InWay = 12 , AirportEntrance = 13 , TermGroup1 = 14 , TermGroup2 = 15 , Hangar2Area = 16 , TermGroup2Enter1 = 17 , TermGroup2Enter2 = 18 , TermGroup2Exit1 = 19 , TermGroup2Exit2 = 20 , PreHelipad = 21 , Term7 = 22 , Term8 = 23 , Helipad3 = 24 , Hangar1Area = 26 , OutWay2 = 27 , InWay2 = 28 , RunwayIn2 = 29 , RunwayOut2 = 10 , HelipadGroup = 13 , OutWay3 = 31 , Nothing = 30 , Zeppeliner = 62 , AirportClosed = 63 }
| Movement Blocks on Airports blocks (eg_airport_flags). More...

## Functions
AirportMovingData | RotateAirportMovingData (const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y)
| Rotate the airport moving data to another rotation.
const AirportFTAClass * | GetAirport (const uint8_t airport_type)
| Get the finite state machine of an airport type.
uint8_t | GetVehiclePosOnBuild (TileIndex hangar_tile)
| Get the vehicle position when an aircraft is build at the given tile.

## Variables
static const uint | MAX_TERMINALS = 8
| Some airport-related constants.
static const uint | MAX_HELIPADS = 3
| maximum number of helipads per airport
static const uint | MAX_ELEMENTS = 255
| maximum number of aircraft positions at airport
static const uint | NUM_AIRPORTTILES_PER_GRF = 255
| Number of airport tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
static const uint | NUM_AIRPORTTILES = 256
| Total number of airport tiles.
static const uint | NEW_AIRPORTTILE_OFFSET = 74
| offset of first newgrf airport tile
static const uint | INVALID_AIRPORTTILE = NUM_AIRPORTTILES
| id for an invalid airport tile

## Detailed Description

Various declarations for airports.

Definition in file airport.h.

## Typedef Documentation

## ◆ AirportBlocks

using AirportBlocks = EnumBitSet<AirportBlock, uint64_t>

Definition at line 133 of file airport.h.

## ◆ AirportMovingDataFlags

using AirportMovingDataFlags = EnumBitSet<AirportMovingDataFlag, uint16_t>

Definition at line 59 of file airport.h.

## Enumeration Type Documentation

## ◆ AirportBlock

enum class AirportBlock : uint8_t
| strong

Movement Blocks on Airports blocks (eg_airport_flags).

Enumerator
Term1 | Block belonging to terminal 1.
Term2 | Block belonging to terminal 2.
Term3 | Block belonging to terminal 3.
Term4 | Block belonging to terminal 4.
Term5 | Block belonging to terminal 5.
Term6 | Block belonging to terminal 6.
Helipad1 | Block belonging to helipad 1.
Helipad2 | Block belonging to helipad 2.
Term7 | Block belonging to terminal 7.
Term8 | Block belonging to terminal 8.
Helipad3 | Block belonging to helipad 3.
RunwayOut2 | Note re-uses AirportBlock::TaxiwayBusy
HelipadGroup | Note re-uses AirportBlock::AirportEntrance
Zeppeliner | Block for the zeppeliner disaster vehicle.
AirportClosed | Dummy block for indicating a closed airport.

Definition at line 90 of file airport.h.

## ◆ AirportMovementStates

enum AirportMovementStates : uint8_t

Movement States on Airports (headings target)

Enumerator
TO_ALL | Go in this direction for every target.
HANGAR | Heading for hangar.
TERM1 | Heading for terminal 1.
TERM2 | Heading for terminal 2.
TERM3 | Heading for terminal 3.
TERM4 | Heading for terminal 4.
TERM5 | Heading for terminal 5.
TERM6 | Heading for terminal 6.
HELIPAD1 | Heading for helipad 1.
HELIPAD2 | Heading for helipad 2.
TAKEOFF | Airplane wants to leave the airport.
STARTTAKEOFF | Airplane has arrived at a runway for take-off.
ENDTAKEOFF | Airplane has reached end-point of the take-off runway.
HELITAKEOFF | Helicopter wants to leave the airport.
FLYING | Vehicle is flying in the air.
LANDING | Airplane wants to land.
ENDLANDING | Airplane wants to finish landing.
HELILANDING | Helicopter wants to land.
HELIENDLANDING | Helicopter wants to finish landing.
TERM7 | Heading for terminal 7.
TERM8 | Heading for terminal 8.
HELIPAD3 | Heading for helipad 3.
MAX_HEADINGS | Last valid target to head for.
TERMGROUP | Aircraft is looking for a free terminal in a terminalgroup.

Definition at line 62 of file airport.h.

## ◆ AirportMovingDataFlag

enum class AirportMovingDataFlag : uint8_t
| strong

Flags for airport movement data.

Enumerator
NoSpeedClamp | No speed restrictions.
Takeoff | Takeoff movement.
SlowTurn | Turn slowly (mostly used in the air).
Land | Landing onto landing strip.
ExactPosition | Go exactly to the destination coordinates.
Brake | Taxiing at the airport.
HeliRaise | Helicopter take-off.
HeliLower | Helicopter landing.
Hold | Holding pattern movement (above the airport).

Definition at line 47 of file airport.h.

## ◆ AirportTypes

enum AirportTypes : uint8_t

Airport types.

Enumerator
AT_SMALL | Small airport.
AT_LARGE | Large airport.
AT_HELIPORT | Heli port.
AT_METROPOLITAN | Metropolitan airport.
AT_INTERNATIONAL | International airport.
AT_COMMUTER | Commuter airport.
AT_HELIDEPOT | Heli depot.
AT_INTERCON | Intercontinental airport.
AT_HELISTATION | Heli station airport.
AT_OILRIG | Oilrig airport.
NEW_AIRPORT_OFFSET | Number of the first newgrf airport.
NUM_AIRPORTS_PER_GRF | Maximal number of airports per NewGRF.
NUM_AIRPORTS | Maximal number of airports in total.
AT_INVALID | Invalid airport.
AT_DUMMY | Dummy airport.

Definition at line 28 of file airport.h.

## Function Documentation

## ◆ GetAirport()

const AirportFTAClass * GetAirport | ( | const uint8_t | airport_type | ) |

Get the finite state machine of an airport type.

Parameters

  airport_type | Airport type to query FTA from.

See also
  AirportTypes

Returns
  Finite state machine of the airport.

Definition at line 186 of file airport.cpp.

References AT_DUMMY, AirportSpec::fsm, and AirportSpec::Get().

Referenced by AircraftController(), AircraftNextAirportPos_and_Order(), and CmdBuildAirport().

## ◆ GetVehiclePosOnBuild()

uint8_t GetVehiclePosOnBuild | ( | TileIndex | hangar_tile | ) |

Get the vehicle position when an aircraft is build at the given tile.

Parameters

  hangar_tile | The tile on which the vehicle is build

Returns
  The position (index in airport node array) where the aircraft ends up

Definition at line 197 of file airport.cpp.

References Station::airport, BaseStation::GetByTile(), Airport::GetFTA(), Airport::GetHangarTile(), HANGAR, and AirportFTAClass::layout.

Referenced by CmdBuildAircraft().

## ◆ RotateAirportMovingData()

AirportMovingData RotateAirportMovingData | ( | const AirportMovingData * | orig,
|  | Direction | rotation,
|  | uint | num_tiles_x,
|  | uint | num_tiles_y
| ) |  |

Rotate the airport moving data to another rotation.

Parameters

  orig | Pointer to the moving data to rotate.
  rotation | How to rotate the moving data.
  num_tiles_x | Number of tiles in x direction.
  num_tiles_y | Number of tiles in y direction.

Returns
  The rotated moving data.

Definition at line 81 of file airport.cpp.

References ChangeDir(), DIR_E, DIR_N, DIR_S, DIR_W, AirportMovingData::direction, AirportMovingData::flags, TILE_SIZE, AirportMovingData::x, and AirportMovingData::y.

Referenced by AircraftController().

## Variable Documentation

## ◆ INVALID_AIRPORTTILE

const uint INVALID_AIRPORTTILE = NUM_AIRPORTTILES
| static

id for an invalid airport tile

Definition at line 25 of file airport.h.

Referenced by AirportChangeInfo(), GetAirportTileIDAtOffset(), and GetTranslatedAirportTileID().

## ◆ MAX_ELEMENTS

const uint MAX_ELEMENTS = 255
| static

maximum number of aircraft positions at airport

Definition at line 19 of file airport.h.

Referenced by AirportGetNofElements().

## ◆ MAX_HELIPADS

const uint MAX_HELIPADS = 3
| static

maximum number of helipads per airport

Definition at line 18 of file airport.h.

## ◆ MAX_TERMINALS

const uint MAX_TERMINALS = 8
| static

Some airport-related constants.

maximum number of terminals per airport

Definition at line 17 of file airport.h.

Referenced by AirportFindFreeHelipad().

## ◆ NEW_AIRPORTTILE_OFFSET

const uint NEW_AIRPORTTILE_OFFSET = 74
| static

offset of first newgrf airport tile

Definition at line 24 of file airport.h.

Referenced by GetAirportTileIDAtOffset().

## ◆ NUM_AIRPORTTILES

const uint NUM_AIRPORTTILES = 256
| static

Total number of airport tiles.

Definition at line 23 of file airport.h.

## ◆ NUM_AIRPORTTILES_PER_GRF

const uint NUM_AIRPORTTILES_PER_GRF = 255
| static

Number of airport tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.

Definition at line 21 of file airport.h.