OpenTTD Source 20241224-master-gf74b0cf984
AirportSpec Struct Reference

Defines the data structure for an airport. More...

#include <newgrf_airport.h>

Inheritance diagram for AirportSpec:
NewGRFSpecBase< AirportClassID >

Public Member Functions

bool IsAvailable () const
 Check whether this airport is available to build.
 
bool IsWithinMapBounds (uint8_t table, TileIndex index) const
 Check if the airport would be within the map bounds at the given tile.
 
uint8_t GetIndex () const
 Get the index of this spec.
 

Static Public Member Functions

static const AirportSpecGet (uint8_t type)
 Retrieve airport spec for the given airport.
 
static AirportSpecGetWithoutOverride (uint8_t type)
 Retrieve airport spec for the given airport.
 
static void ResetAirports ()
 This function initializes the airportspec array.
 

Data Fields

const struct AirportFTAClassfsm
 the finite statemachine for the default airports
 
std::vector< AirportTileLayoutlayouts
 List of layouts composing the airport.
 
std::span< const HangarTileTabledepots
 Position of the depots on the airports.
 
uint8_t size_x
 size of airport in x direction
 
uint8_t size_y
 size of airport in y direction
 
uint8_t noise_level
 noise that this airport generates
 
uint8_t catchment
 catchment area of this airport
 
TimerGameCalendar::Year min_year
 first year the airport is available
 
TimerGameCalendar::Year max_year
 last year the airport is available
 
StringID name
 name of this airport
 
TTDPAirportType ttd_airport_type
 ttdpatch airport type (Small/Large/Helipad/Oilrig)
 
SpriteID preview_sprite
 preview sprite for this airport
 
uint16_t maintenance_cost
 maintenance cost multiplier
 
bool enabled
 Entity still available (by default true). Newgrf can disable it, though.
 
struct GRFFileProps grf_prop
 Properties related to the grf file.
 
- Data Fields inherited from NewGRFSpecBase< AirportClassID >
AirportClassID class_index
 Class index of this spec, invalid until class is allocated.
 
uint16_t index
 Index within class of this spec, invalid until inserted into class.
 

Static Public Attributes

static const AirportSpec dummy = AS_GENERIC(&_airportfta_dummy, {}, {}, 0, 0, 0, 0, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false)
 The dummy airport.
 

Static Private Attributes

static AirportSpec specs [NUM_AIRPORTS]
 Specs of the airports.
 

Detailed Description

Defines the data structure for an airport.

Definition at line 105 of file newgrf_airport.h.

Member Function Documentation

◆ Get()

const AirportSpec * AirportSpec::Get ( uint8_t  type)
static

Retrieve airport spec for the given airport.

If an override is available it is returned.

Parameters
typeindex of airport
Returns
A pointer to the corresponding AirportSpec

Definition at line 55 of file newgrf_airport.cpp.

References AT_INVALID, enabled, OverrideManagerBase::GetGRFID(), OverrideManagerBase::GetSubstituteID(), grf_prop, lengthof, NEW_AIRPORT_OFFSET, GRFFileProps::override, and specs.

Referenced by CmdBuildAirport(), GetAirport(), NIHAirport::GetGRFID(), Airport::GetSpec(), NIHAirport::GetSpec(), NIHAirport::IsInspectable(), NIHAirport::Resolve(), and BuildAirportWindow::UpdateWidgetSize().

◆ GetIndex()

uint8_t AirportSpec::GetIndex ( ) const
inline

Get the index of this spec.

Definition at line 132 of file newgrf_airport.h.

References specs.

◆ GetWithoutOverride()

AirportSpec * AirportSpec::GetWithoutOverride ( uint8_t  type)
static

Retrieve airport spec for the given airport.

Even if an override is available the base spec is returned.

Parameters
typeindex of airport
Returns
A pointer to the corresponding AirportSpec

Definition at line 75 of file newgrf_airport.cpp.

References lengthof, and specs.

Referenced by AirportChangeInfo(), and BindAirportSpecs().

◆ IsAvailable()

bool AirportSpec::IsAvailable ( ) const

Check whether this airport is available to build.

Definition at line 82 of file newgrf_airport.cpp.

References _settings_game, enabled, max_year, min_year, StationSettings::never_expire_airports, GameSettings::station, and TimerGameCalendar::year.

Referenced by CmdBuildAirport().

◆ IsWithinMapBounds()

bool AirportSpec::IsWithinMapBounds ( uint8_t  table,
TileIndex  tile 
) const

Check if the airport would be within the map bounds at the given tile.

Parameters
tableSelected layout table. This affects airport rotation, and therefore dimensions.
tileTop corner of the airport.
Returns
true iff the airport would be within the map bounds at the given tile.

Definition at line 96 of file newgrf_airport.cpp.

References DIR_E, DIR_W, layouts, size_x, size_y, Map::SizeX(), Map::SizeY(), Swap(), TileX(), and TileY().

Referenced by CmdBuildAirport().

◆ ResetAirports()

void AirportSpec::ResetAirports ( )
static

This function initializes the airportspec array.

Definition at line 111 of file newgrf_airport.cpp.

References NEW_AIRPORT_OFFSET, OverrideManagerBase::ResetOverride(), and specs.

Referenced by ResetNewGRFData().

Field Documentation

◆ catchment

uint8_t AirportSpec::catchment

catchment area of this airport

Definition at line 112 of file newgrf_airport.h.

Referenced by Station::GetCatchmentRadius(), and GetTileCatchmentRadius().

◆ depots

std::span<const HangarTileTable> AirportSpec::depots

Position of the depots on the airports.

Definition at line 108 of file newgrf_airport.h.

Referenced by Airport::GetHangarDataByTile(), Airport::GetHangarTile(), Airport::GetNumHangars(), Airport::HasHangar(), and IsHangar().

◆ dummy

const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, {}, {}, 0, 0, 0, 0, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false)
static

The dummy airport.

Definition at line 138 of file newgrf_airport.h.

Referenced by Airport::GetSpec().

◆ enabled

bool AirportSpec::enabled

Entity still available (by default true). Newgrf can disable it, though.

Definition at line 120 of file newgrf_airport.h.

Referenced by AirportChangeInfo(), BindAirportSpecs(), FinaliseAirportsArray(), Get(), and IsAvailable().

◆ fsm

const struct AirportFTAClass* AirportSpec::fsm

the finite statemachine for the default airports

Definition at line 106 of file newgrf_airport.h.

Referenced by GetAirport(), and Airport::GetFTA().

◆ grf_prop

struct GRFFileProps AirportSpec::grf_prop

◆ layouts

std::vector<AirportTileLayout> AirportSpec::layouts

List of layouts composing the airport.

Definition at line 107 of file newgrf_airport.h.

Referenced by CmdBuildAirport(), Airport::GetHangarExitDirection(), and IsWithinMapBounds().

◆ maintenance_cost

uint16_t AirportSpec::maintenance_cost

maintenance cost multiplier

Definition at line 118 of file newgrf_airport.h.

◆ max_year

TimerGameCalendar::Year AirportSpec::max_year

last year the airport is available

Definition at line 114 of file newgrf_airport.h.

Referenced by IsAvailable().

◆ min_year

TimerGameCalendar::Year AirportSpec::min_year

first year the airport is available

Definition at line 113 of file newgrf_airport.h.

Referenced by IsAvailable().

◆ name

StringID AirportSpec::name

name of this airport

Definition at line 115 of file newgrf_airport.h.

◆ noise_level

uint8_t AirportSpec::noise_level

noise that this airport generates

Definition at line 111 of file newgrf_airport.h.

Referenced by GetAirportNoiseLevelForDistance().

◆ preview_sprite

SpriteID AirportSpec::preview_sprite

preview sprite for this airport

Definition at line 117 of file newgrf_airport.h.

◆ size_x

uint8_t AirportSpec::size_x

size of airport in x direction

Definition at line 109 of file newgrf_airport.h.

Referenced by AirportGetNearestTown(), CmdBuildAirport(), Airport::GetRotatedTileFromOffset(), and IsWithinMapBounds().

◆ size_y

uint8_t AirportSpec::size_y

size of airport in y direction

Definition at line 110 of file newgrf_airport.h.

Referenced by AirportGetNearestTown(), CmdBuildAirport(), Airport::GetRotatedTileFromOffset(), and IsWithinMapBounds().

◆ specs

AirportSpec AirportSpec::specs
staticprivate

Specs of the airports.

Airport specifications.

Definition at line 141 of file newgrf_airport.h.

Referenced by Get(), GetIndex(), GetWithoutOverride(), and ResetAirports().

◆ ttd_airport_type

TTDPAirportType AirportSpec::ttd_airport_type

ttdpatch airport type (Small/Large/Helipad/Oilrig)

Definition at line 116 of file newgrf_airport.h.


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