OpenTTD Source 20241224-master-gf74b0cf984
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  AirportFTAClass
 Finite sTate mAchine (FTA) of an airport. More...
 
struct  AirportFTA
 Internal structure used in openttd - Finite sTate mAchine --> FTA. More...
 

Enumerations

enum  AirportTypes {
  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  AirportMovingDataFlags {
  AMED_NOSPDCLAMP = 1 << 0 , AMED_TAKEOFF = 1 << 1 , AMED_SLOWTURN = 1 << 2 , AMED_LAND = 1 << 3 ,
  AMED_EXACTPOS = 1 << 4 , AMED_BRAKE = 1 << 5 , AMED_HELI_RAISE = 1 << 6 , AMED_HELI_LOWER = 1 << 7 ,
  AMED_HOLD = 1 << 8
}
 Flags for airport movement data. More...
 
enum  AirportMovementStates {
  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...
 

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 AirportFTAClassGetAirport (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
 
static const uint64_t TERM1_block = 1ULL << 0
 Movement Blocks on Airports blocks (eg_airport_flags).
 
static const uint64_t TERM2_block = 1ULL << 1
 Block belonging to terminal 2.
 
static const uint64_t TERM3_block = 1ULL << 2
 Block belonging to terminal 3.
 
static const uint64_t TERM4_block = 1ULL << 3
 Block belonging to terminal 4.
 
static const uint64_t TERM5_block = 1ULL << 4
 Block belonging to terminal 5.
 
static const uint64_t TERM6_block = 1ULL << 5
 Block belonging to terminal 6.
 
static const uint64_t HELIPAD1_block = 1ULL << 6
 Block belonging to helipad 1.
 
static const uint64_t HELIPAD2_block = 1ULL << 7
 Block belonging to helipad 2.
 
static const uint64_t RUNWAY_IN_OUT_block = 1ULL << 8
 
static const uint64_t RUNWAY_IN_block = 1ULL << 8
 
static const uint64_t AIRPORT_BUSY_block = 1ULL << 8
 
static const uint64_t RUNWAY_OUT_block = 1ULL << 9
 
static const uint64_t TAXIWAY_BUSY_block = 1ULL << 10
 
static const uint64_t OUT_WAY_block = 1ULL << 11
 
static const uint64_t IN_WAY_block = 1ULL << 12
 
static const uint64_t AIRPORT_ENTRANCE_block = 1ULL << 13
 
static const uint64_t TERM_GROUP1_block = 1ULL << 14
 
static const uint64_t TERM_GROUP2_block = 1ULL << 15
 
static const uint64_t HANGAR2_AREA_block = 1ULL << 16
 
static const uint64_t TERM_GROUP2_ENTER1_block = 1ULL << 17
 
static const uint64_t TERM_GROUP2_ENTER2_block = 1ULL << 18
 
static const uint64_t TERM_GROUP2_EXIT1_block = 1ULL << 19
 
static const uint64_t TERM_GROUP2_EXIT2_block = 1ULL << 20
 
static const uint64_t PRE_HELIPAD_block = 1ULL << 21
 
static const uint64_t TERM7_block = 1ULL << 22
 Block belonging to terminal 7.
 
static const uint64_t TERM8_block = 1ULL << 23
 Block belonging to terminal 8.
 
static const uint64_t HELIPAD3_block = 1ULL << 24
 Block belonging to helipad 3.
 
static const uint64_t HANGAR1_AREA_block = 1ULL << 26
 
static const uint64_t OUT_WAY2_block = 1ULL << 27
 
static const uint64_t IN_WAY2_block = 1ULL << 28
 
static const uint64_t RUNWAY_IN2_block = 1ULL << 29
 
static const uint64_t RUNWAY_OUT2_block = 1ULL << 10
 
static const uint64_t HELIPAD_GROUP_block = 1ULL << 13
 
static const uint64_t OUT_WAY_block2 = 1ULL << 31
 
static const uint64_t NOTHING_block = 1ULL << 30
 
static const uint64_t AIRPORT_CLOSED_block = 1ULL << 63
 Dummy block for indicating a closed airport.
 

Detailed Description

Various declarations for airports.

Definition in file airport.h.

Enumeration Type Documentation

◆ AirportMovementStates

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 60 of file airport.h.

◆ AirportMovingDataFlags

Flags for airport movement data.

Enumerator
AMED_NOSPDCLAMP 

No speed restrictions.

AMED_TAKEOFF 

Takeoff movement.

AMED_SLOWTURN 

Turn slowly (mostly used in the air).

AMED_LAND 

Landing onto landing strip.

AMED_EXACTPOS 

Go exactly to the destination coordinates.

AMED_BRAKE 

Taxiing at the airport.

AMED_HELI_RAISE 

Helicopter take-off.

AMED_HELI_LOWER 

Helicopter landing.

AMED_HOLD 

Holding pattern movement (above the airport).

Definition at line 47 of file airport.h.

◆ AirportTypes

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_typeAirport type to query FTA from.
See also
AirportTypes
Returns
Finite state machine of the airport.

Definition at line 207 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_tileThe tile on which the vehicle is build
Returns
The position (index in airport node array) where the aircraft ends up

Definition at line 218 of file airport.cpp.

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

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
origPointer to the moving data to rotate.
rotationHow to rotate the moving data.
num_tiles_xNumber of tiles in x direction.
num_tiles_yNumber of tiles in y direction.
Returns
The rotated moving data.

Definition at line 80 of file airport.cpp.

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

Referenced by AircraftController().

Variable Documentation

◆ AIRPORT_BUSY_block

const uint64_t AIRPORT_BUSY_block = 1ULL << 8
static

Definition at line 99 of file airport.h.

◆ AIRPORT_CLOSED_block

const uint64_t AIRPORT_CLOSED_block = 1ULL << 63
static

Dummy block for indicating a closed airport.

Definition at line 128 of file airport.h.

Referenced by CmdOpenCloseAirport(), and StationViewWindow::OnPaint().

◆ AIRPORT_ENTRANCE_block

const uint64_t AIRPORT_ENTRANCE_block = 1ULL << 13
static

Definition at line 104 of file airport.h.

◆ HANGAR1_AREA_block

const uint64_t HANGAR1_AREA_block = 1ULL << 26
static

Definition at line 118 of file airport.h.

◆ HANGAR2_AREA_block

const uint64_t HANGAR2_AREA_block = 1ULL << 16
static

Definition at line 107 of file airport.h.

◆ HELIPAD1_block

const uint64_t HELIPAD1_block = 1ULL << 6
static

Block belonging to helipad 1.

Definition at line 95 of file airport.h.

◆ HELIPAD2_block

const uint64_t HELIPAD2_block = 1ULL << 7
static

Block belonging to helipad 2.

Definition at line 96 of file airport.h.

◆ HELIPAD3_block

const uint64_t HELIPAD3_block = 1ULL << 24
static

Block belonging to helipad 3.

Definition at line 117 of file airport.h.

◆ HELIPAD_GROUP_block

const uint64_t HELIPAD_GROUP_block = 1ULL << 13
static
Note
re-uses AIRPORT_ENTRANCE_block

Definition at line 123 of file airport.h.

◆ IN_WAY2_block

const uint64_t IN_WAY2_block = 1ULL << 28
static

Definition at line 120 of file airport.h.

◆ IN_WAY_block

const uint64_t IN_WAY_block = 1ULL << 12
static

Definition at line 103 of file airport.h.

◆ 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().

◆ NOTHING_block

const uint64_t NOTHING_block = 1ULL << 30
static

Definition at line 127 of file airport.h.

◆ 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.

◆ OUT_WAY2_block

const uint64_t OUT_WAY2_block = 1ULL << 27
static

Definition at line 119 of file airport.h.

◆ OUT_WAY_block

const uint64_t OUT_WAY_block = 1ULL << 11
static

Definition at line 102 of file airport.h.

◆ OUT_WAY_block2

const uint64_t OUT_WAY_block2 = 1ULL << 31
static

Definition at line 124 of file airport.h.

◆ PRE_HELIPAD_block

const uint64_t PRE_HELIPAD_block = 1ULL << 21
static

Definition at line 112 of file airport.h.

◆ RUNWAY_IN2_block

const uint64_t RUNWAY_IN2_block = 1ULL << 29
static

Definition at line 121 of file airport.h.

◆ RUNWAY_IN_block

const uint64_t RUNWAY_IN_block = 1ULL << 8
static

Definition at line 98 of file airport.h.

◆ RUNWAY_IN_OUT_block

const uint64_t RUNWAY_IN_OUT_block = 1ULL << 8
static

Definition at line 97 of file airport.h.

◆ RUNWAY_OUT2_block

const uint64_t RUNWAY_OUT2_block = 1ULL << 10
static
Note
re-uses TAXIWAY_BUSY_block

Definition at line 122 of file airport.h.

◆ RUNWAY_OUT_block

const uint64_t RUNWAY_OUT_block = 1ULL << 9
static

Definition at line 100 of file airport.h.

◆ TAXIWAY_BUSY_block

const uint64_t TAXIWAY_BUSY_block = 1ULL << 10
static

Definition at line 101 of file airport.h.

◆ TERM1_block

const uint64_t TERM1_block = 1ULL << 0
static

Movement Blocks on Airports blocks (eg_airport_flags).

Block belonging to terminal 1.

Definition at line 89 of file airport.h.

◆ TERM2_block

const uint64_t TERM2_block = 1ULL << 1
static

Block belonging to terminal 2.

Definition at line 90 of file airport.h.

◆ TERM3_block

const uint64_t TERM3_block = 1ULL << 2
static

Block belonging to terminal 3.

Definition at line 91 of file airport.h.

◆ TERM4_block

const uint64_t TERM4_block = 1ULL << 3
static

Block belonging to terminal 4.

Definition at line 92 of file airport.h.

◆ TERM5_block

const uint64_t TERM5_block = 1ULL << 4
static

Block belonging to terminal 5.

Definition at line 93 of file airport.h.

◆ TERM6_block

const uint64_t TERM6_block = 1ULL << 5
static

Block belonging to terminal 6.

Definition at line 94 of file airport.h.

◆ TERM7_block

const uint64_t TERM7_block = 1ULL << 22
static

Block belonging to terminal 7.

Definition at line 115 of file airport.h.

◆ TERM8_block

const uint64_t TERM8_block = 1ULL << 23
static

Block belonging to terminal 8.

Definition at line 116 of file airport.h.

◆ TERM_GROUP1_block

const uint64_t TERM_GROUP1_block = 1ULL << 14
static

Definition at line 105 of file airport.h.

◆ TERM_GROUP2_block

const uint64_t TERM_GROUP2_block = 1ULL << 15
static

Definition at line 106 of file airport.h.

◆ TERM_GROUP2_ENTER1_block

const uint64_t TERM_GROUP2_ENTER1_block = 1ULL << 17
static

Definition at line 108 of file airport.h.

◆ TERM_GROUP2_ENTER2_block

const uint64_t TERM_GROUP2_ENTER2_block = 1ULL << 18
static

Definition at line 109 of file airport.h.

◆ TERM_GROUP2_EXIT1_block

const uint64_t TERM_GROUP2_EXIT1_block = 1ULL << 19
static

Definition at line 110 of file airport.h.

◆ TERM_GROUP2_EXIT2_block

const uint64_t TERM_GROUP2_EXIT2_block = 1ULL << 20
static

Definition at line 111 of file airport.h.