OpenTTD Source: Airport Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Data Fields | Private Member Functions
Airport Struct Reference

All airport-related information. More...

`#include <station_base.h>`

Inheritance diagram for Airport:

## Public Member Functions
const AirportSpec * | GetSpec () const
| Get the AirportSpec that from the airport type of this airport.
const AirportFTAClass * | GetFTA () const
| Get the finite-state machine for this airport or the finite-state machine for the dummy airport in case this isn't an airport.
bool | HasHangar () const
| Check if this airport has at least one hangar.
TileIndex | GetRotatedTileFromOffset (TileIndexDiffC tidc) const
| Add the tileoffset to the base tile of this airport but rotate it first.
TileIndex | GetHangarTile (uint hangar_num) const
| Get the first tile of the given hangar.
Direction | GetHangarExitDirection (TileIndex tile) const
| Get the exit direction of the hangar at a specific tile.
uint | GetHangarNum (TileIndex tile) const
| Get the hangar number of the hangar at a specific tile.
uint | GetNumHangars () const
| Get the number of hangars on this airport.
Public Member Functions inherited from OrthogonalTileArea
| OrthogonalTileArea (TileIndex tile=INVALID_TILE, uint16_t w=0, uint16_t h=0)
| Construct this tile area with some set values.
| OrthogonalTileArea (TileIndex start, TileIndex end)
| Construct this tile area based on two points.
void | Add (TileIndex to_add)
| Add a single tile to a tile area; enlarge if needed.
void | Clear ()
| Clears the 'tile area', i.e.
bool | Intersects (const OrthogonalTileArea &ta) const
| Does this tile area intersect with another?
bool | Contains (TileIndex tile) const
| Does this tile area contain a tile?
OrthogonalTileArea & | Expand (int rad)
| Expand a tile area by rad tiles in each direction, keeping within map bounds.
void | ClampToMap ()
| Clamp the tile area to map borders.
TileIndex | GetCenterTile () const
| Get the center tile.
OrthogonalTileIterator | begin () const
| Returns an iterator to the beginning of the tile area.
OrthogonalTileIterator | end () const
| Returns an iterator to the end of the tile area.

## Data Fields
AirportBlocks | blocks {}
| stores which blocks on the airport are taken. was 16 bit earlier on, then 32
uint8_t | type = 0
| Type of this airport,.
uint8_t | layout = 0
| Airport layout number.
Direction | rotation = INVALID_DIR
| How this airport is rotated.
PersistentStorage * | psa = nullptr
| Persistent storage for NewGRF airports.
Data Fields inherited from OrthogonalTileArea
TileIndex | tile
| The base tile of the area.
uint16_t | w
| The width of the area.
uint16_t | h
| The height of the area.

## Private Member Functions
const HangarTileTable * | GetHangarDataByTile (TileIndex tile) const
| Retrieve hangar information of a hangar at a given tile.

## Detailed Description

All airport-related information.

Only valid if tile != INVALID_TILE.

Definition at line 351 of file station_base.h.

## Constructor & Destructor Documentation

## ◆ Airport()

Airport::Airport | ( |  | ) |
| inline

Definition at line 352 of file station_base.h.

## Member Function Documentation

## ◆ GetFTA()

const AirportFTAClass * Airport::GetFTA | ( |  | ) | const
| inline

Get the finite-state machine for this airport or the finite-state machine for the dummy airport in case this isn't an airport.

Precondition
  this->type < NEW_AIRPORT_OFFSET.

Returns
  The state machine for this airport.

Definition at line 378 of file station_base.h.

References AirportSpec::fsm, and GetSpec().

Referenced by AircraftController(), AircraftNextAirportPos_and_Order(), CanVehicleUseStation(), CheckOrders(), FloodVehicleProc(), GetVehiclePosOnBuild(), MapAircraftMovementState(), MaybeCrashAirplane(), Vehicle::PreDestructor(), and UpdateAirplanesOnNewStation().

## ◆ GetHangarDataByTile()

const HangarTileTable * Airport::GetHangarDataByTile | ( | TileIndex | tile | ) | const
| inlineprivate

Retrieve hangar information of a hangar at a given tile.

Parameters

  tile | Tile containing the hangar.

Returns
  The requested hangar information.

Precondition
  The tile must be at a hangar tile at an airport.

Definition at line 475 of file station_base.h.

References AirportSpec::depots, GetRotatedTileFromOffset(), GetSpec(), and OrthogonalTileArea::tile.

Referenced by GetHangarExitDirection(), and GetHangarNum().

## ◆ GetHangarExitDirection()

Direction Airport::GetHangarExitDirection | ( | TileIndex | tile | ) | const
| inline

Get the exit direction of the hangar at a specific tile.

Parameters

  tile | The tile to query.

Precondition
  IsHangarTile(tile).

Returns
  The exit direction of the hangar, taking airport rotation into account.

Definition at line 435 of file station_base.h.

References ChangeDir(), HangarTileTable::dir, DirDifference(), GetHangarDataByTile(), GetSpec(), AirportSpec::layouts, and OrthogonalTileArea::tile.

Referenced by AircraftEventHandler_InHangar().

## ◆ GetHangarNum()

uint Airport::GetHangarNum | ( | TileIndex | tile | ) | const
| inline

Get the hangar number of the hangar at a specific tile.

Parameters

  tile | The tile to query.

Precondition
  IsHangarTile(tile).

Returns
  The hangar number of the hangar at the given tile.

Definition at line 448 of file station_base.h.

References GetHangarDataByTile(), HangarTileTable::hangar_num, and OrthogonalTileArea::tile.

## ◆ GetHangarTile()

TileIndex Airport::GetHangarTile | ( | uint | hangar_num | ) | const
| inline

Get the first tile of the given hangar.

Parameters

  hangar_num | The hangar to get the location of.

Precondition
  hangar_num < GetNumHangars().

Returns
  A tile with the given hangar.

Definition at line 419 of file station_base.h.

References AirportSpec::depots, GetRotatedTileFromOffset(), and GetSpec().

Referenced by AircraftController(), GetVehiclePosOnBuild(), and RemoveAirport().

## ◆ GetNumHangars()

uint Airport::GetNumHangars | ( |  | ) | const
| inline

Get the number of hangars on this airport.

Definition at line 455 of file station_base.h.

References AirportSpec::depots, GetSpec(), HasBit(), and SetBit().

Referenced by RemoveAirport().

## ◆ GetRotatedTileFromOffset()

TileIndex Airport::GetRotatedTileFromOffset | ( | TileIndexDiffC | tidc | ) | const
| inline

Add the tileoffset to the base tile of this airport but rotate it first.

The base tile is the northernmost tile of this airport. This function helps to make sure that getting the tile of a hangar works even for rotated airport layouts without requiring a rotated array of hangar tiles.

Parameters

  tidc | The tilediff to add to the airport tile.

Returns
  The tile of this airport plus the rotated offset.

Definition at line 397 of file station_base.h.

References DIR_E, DIR_N, DIR_S, DIR_W, GetSpec(), AirportSpec::size_x, AirportSpec::size_y, OrthogonalTileArea::tile, TileDiffXY(), ToTileIndexDiff(), TileIndexDiffC::x, and TileIndexDiffC::y.

Referenced by GetHangarDataByTile(), GetHangarTile(), and IsHangar().

## ◆ GetSpec()

const AirportSpec * Airport::GetSpec | ( |  | ) | const
| inline

Get the AirportSpec that from the airport type of this airport.

If there is no airport (`tile` == INVALID_TILE) then return the dummy AirportSpec.

Returns
  The AirportSpec for this airport.

Definition at line 366 of file station_base.h.

References AirportSpec::dummy, AirportSpec::Get(), INVALID_TILE, and OrthogonalTileArea::tile.

Referenced by AirportGetNearestTown(), Station::GetCatchmentRadius(), GetFTA(), GetHangarDataByTile(), GetHangarExitDirection(), GetHangarTile(), GetNumHangars(), GetRotatedTileFromOffset(), GetTileCatchmentRadius(), HasHangar(), IsHangar(), and RemoveAirport().

## ◆ HasHangar()

bool Airport::HasHangar | ( |  | ) | const
| inline

Check if this airport has at least one hangar.

Definition at line 384 of file station_base.h.

References AirportSpec::depots, and GetSpec().

Referenced by AircraftController(), AircraftEventHandler_AtTerminal(), CmdInsertOrder(), Aircraft::FindClosestDepot(), and UpdateAirplanesOnNewStation().

## Field Documentation

## ◆ blocks

AirportBlocks Airport::blocks {}

stores which blocks on the airport are taken. was 16 bit earlier on, then 32

Definition at line 354 of file station_base.h.

Referenced by AircraftController(), AirportFindFreeTerminal(), AirportHasBlock(), AirportSetBlocks(), CmdBuildAirport(), CmdOpenCloseAirport(), DisasterTick_Zeppeliner(), FreeTerminal(), HandleCrashedAircraft(), StationViewWindow::OnPaint(), and Vehicle::PreDestructor().

## ◆ layout

uint8_t Airport::layout = 0

Airport layout number.

Definition at line 356 of file station_base.h.

Referenced by CmdBuildAirport(), and NIHAirport::Resolve().

## ◆ psa

PersistentStorage* Airport::psa = nullptr

Persistent storage for NewGRF airports.

Definition at line 359 of file station_base.h.

Referenced by NIHAirport::GetPSA(), AirportScopeResolver::GetVariable(), RemoveAirport(), AirportScopeResolver::StorePSA(), and Station::~Station().

## ◆ rotation

Direction Airport::rotation = INVALID_DIR

How this airport is rotated.

Definition at line 357 of file station_base.h.

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

## ◆ type

uint8_t Airport::type = 0

Type of this airport,.

See also
  AirportTypes

Definition at line 355 of file station_base.h.

Referenced by AircraftController(), AirportTileScopeResolver::AirportTileScopeResolver(), CmdBuildAirport(), and NIHAirport::Resolve().

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

- src/station_base.h