OpenTTD Source 20250312-master-gcdcc6b491d
airport.cpp File Reference

Functions related to airports. More...

#include "stdafx.h"
#include "station_base.h"
#include "table/strings.h"
#include "table/airport_movement.h"
#include "table/airporttile_ids.h"
#include "safeguards.h"
#include "table/airport_defaults.h"

Go to the source code of this file.

Macros

#define AIRPORT_GENERIC(name, terminals, num_helipads, flags, delta_z)
 Define a generic airport.
 
#define AIRPORT(name, num_helipads, short_strip)    AIRPORT_GENERIC(name, _airport_terminal_ ## name, num_helipads, AirportFTAClass::Flags({AirportFTAClass::Flag::Airplanes, AirportFTAClass::Flag::Helicopters}) | (short_strip ? AirportFTAClass::Flags{AirportFTAClass::Flag::ShortStrip} : AirportFTAClass::Flags{}), 0)
 Define an airport.
 
#define HELIPORT(name, num_helipads, delta_z)    AIRPORT_GENERIC(name, nullptr, num_helipads, AirportFTAClass::Flag::Helicopters, delta_z)
 Define a heliport.
 

Functions

static uint16_t AirportGetNofElements (const AirportFTAbuildup *apFA)
 Get the number of elements of a source Airport state automata Since it is actually just a big array of AirportFTA types, we only know one element from the other by differing 'position' identifiers.
 
static void AirportBuildAutomata (std::vector< AirportFTA > &layout, uint8_t nofelements, const AirportFTAbuildup *apFA)
 Construct the FTA given a description.
 
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.
 

Detailed Description

Functions related to airports.

Definition in file airport.cpp.

Macro Definition Documentation

◆ AIRPORT

#define AIRPORT (   name,
  num_helipads,
  short_strip 
)     AIRPORT_GENERIC(name, _airport_terminal_ ## name, num_helipads, AirportFTAClass::Flags({AirportFTAClass::Flag::Airplanes, AirportFTAClass::Flag::Helicopters}) | (short_strip ? AirportFTAClass::Flags{AirportFTAClass::Flag::ShortStrip} : AirportFTAClass::Flags{}), 0)

Define an airport.

Parameters
nameSuffix of the names of the airport data.
num_helipadsNumber of heli pads.
short_stripAirport has a short land/take-off strip.

Definition at line 37 of file airport.cpp.

◆ AIRPORT_GENERIC

#define AIRPORT_GENERIC (   name,
  terminals,
  num_helipads,
  flags,
  delta_z 
)
Value:
static const AirportFTAClass _airportfta_ ## name(_airport_moving_data_ ## name, terminals, \
num_helipads, _airport_entries_ ## name, flags, _airport_fta_ ## name, delta_z);
Finite sTate mAchine (FTA) of an airport.
Definition airport.h:158

Define a generic airport.

Parameters
nameSuffix of the names of the airport data.
terminalsThe terminals.
num_helipadsNumber of heli pads.
flagsInformation about the class of FTA.
delta_zHeight of the airport above the land.

Definition at line 27 of file airport.cpp.

◆ HELIPORT

#define HELIPORT (   name,
  num_helipads,
  delta_z 
)     AIRPORT_GENERIC(name, nullptr, num_helipads, AirportFTAClass::Flag::Helicopters, delta_z)

Define a heliport.

Parameters
nameSuffix of the names of the helipad data.
num_helipadsNumber of heli pads.
delta_zHeight of the airport above the land.

Definition at line 46 of file airport.cpp.

Function Documentation

◆ AirportBuildAutomata()

static void AirportBuildAutomata ( std::vector< AirportFTA > &  layout,
uint8_t  nofelements,
const AirportFTAbuildup apFA 
)
static

Construct the FTA given a description.

Parameters
layoutThe vector to write the automata to.
nofelementsThe number of elements in the FTA.
apFAThe description of the FTA.

Definition at line 162 of file airport.cpp.

References AirportFTA::next, AirportFTA::position, and AirportFTAbuildup::position.

◆ AirportGetNofElements()

static uint16_t AirportGetNofElements ( const AirportFTAbuildup apFA)
static

Get the number of elements of a source Airport state automata Since it is actually just a big array of AirportFTA types, we only know one element from the other by differing 'position' identifiers.

Definition at line 137 of file airport.cpp.

References MAX_ELEMENTS, and AirportFTAbuildup::position.

◆ 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 185 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 196 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
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::flags, TILE_SIZE, AirportMovingData::x, and AirportMovingData::y.

Referenced by AircraftController().