OpenTTD Source 20250312-master-gcdcc6b491d
airport.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef AIRPORT_H
11#define AIRPORT_H
12
13#include "direction_type.h"
14#include "tile_type.h"
15
17static const uint MAX_TERMINALS = 8;
18static const uint MAX_HELIPADS = 3;
19static const uint MAX_ELEMENTS = 255;
20
21static const uint NUM_AIRPORTTILES_PER_GRF = 255;
22
23static const uint NUM_AIRPORTTILES = 256;
24static const uint NEW_AIRPORTTILE_OFFSET = 74;
26
45
58
60
88
90enum class AirportBlock : uint8_t {
91 Term1 = 0,
92 Term2 = 1,
93 Term3 = 2,
94 Term4 = 3,
95 Term5 = 4,
96 Term6 = 5,
97 Helipad1 = 6,
98 Helipad2 = 7,
99 RunwayInOut = 8,
100 RunwayIn = 8,
101 AirportBusy = 8,
102 RunwayOut = 9,
103 TaxiwayBusy = 10,
104 OutWay = 11,
105 InWay = 12,
106 AirportEntrance = 13,
107 TermGroup1 = 14,
108 TermGroup2 = 15,
109 Hangar2Area = 16,
110 TermGroup2Enter1 = 17,
111 TermGroup2Enter2 = 18,
112 TermGroup2Exit1 = 19,
113 TermGroup2Exit2 = 20,
114 PreHelipad = 21,
115
116 /* blocks for new airports */
117 Term7 = 22,
118 Term8 = 23,
119 Helipad3 = 24,
120 Hangar1Area = 26,
121 OutWay2 = 27,
122 InWay2 = 28,
123 RunwayIn2 = 29,
124 RunwayOut2 = 10,
125 HelipadGroup = 13,
126 OutWay3 = 31,
127 /* end of new blocks */
128
129 Nothing = 30,
130 AirportClosed = 63,
131};
133
141
142AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);
143
144struct AirportFTAbuildup;
145
149
150 std::unique_ptr<AirportFTA> next;
152 uint8_t position;
154 uint8_t heading;
155};
156
159public:
161 enum class Flag : uint8_t {
162 Airplanes = 0,
163 Helicopters = 1,
164 ShortStrip = 2,
165 };
166 using Flags = EnumBitSet<Flag, uint8_t>;
167
170 const uint8_t *terminals,
171 const uint8_t num_helipads,
172 const uint8_t *entry_points,
173 Flags flags,
174 const AirportFTAbuildup *apFA,
175 uint8_t delta_z
176 );
177
183 const AirportMovingData *MovingData(uint8_t position) const
184 {
185 assert(position < nofelements);
186 return &moving_data[position];
187 }
188
190 std::vector<AirportFTA> layout;
191 const uint8_t *terminals;
192 const uint8_t num_helipads;
194 uint8_t nofelements;
195 const uint8_t *entry_points;
196 uint8_t delta_z;
197};
198
199
200const AirportFTAClass *GetAirport(const uint8_t airport_type);
201uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile);
202
203#endif /* AIRPORT_H */
static const uint MAX_HELIPADS
maximum number of helipads per airport
Definition airport.h:18
static const uint MAX_ELEMENTS
maximum number of aircraft positions at airport
Definition airport.h:19
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
Definition airport.h:25
static const uint MAX_TERMINALS
Some airport-related constants.
Definition airport.h:17
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
Definition airport.h:24
AirportBlock
Movement Blocks on Airports blocks (eg_airport_flags).
Definition airport.h:90
@ Term2
Block belonging to terminal 2.
@ AirportClosed
Dummy block for indicating a closed airport.
@ Term5
Block belonging to terminal 5.
@ Term6
Block belonging to terminal 6.
@ Term4
Block belonging to terminal 4.
@ Helipad3
Block belonging to helipad 3.
@ Term7
Block belonging to terminal 7.
@ Helipad1
Block belonging to helipad 1.
@ Term3
Block belonging to terminal 3.
@ Term1
Block belonging to terminal 1.
@ Helipad2
Block belonging to helipad 2.
@ Term8
Block belonging to terminal 8.
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile)
Get the vehicle position when an aircraft is build at the given tile.
Definition airport.cpp:196
static const uint NUM_AIRPORTTILES_PER_GRF
Number of airport tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte l...
Definition airport.h:21
const AirportFTAClass * GetAirport(const uint8_t airport_type)
Get the finite state machine of an airport type.
Definition airport.cpp:185
AirportMovingDataFlag
Flags for airport movement data.
Definition airport.h:47
@ SlowTurn
Turn slowly (mostly used in the air).
Definition airport.h:50
@ Takeoff
Takeoff movement.
Definition airport.h:49
@ Land
Landing onto landing strip.
Definition airport.h:51
@ HeliLower
Helicopter landing.
Definition airport.h:55
@ Hold
Holding pattern movement (above the airport).
Definition airport.h:56
@ NoSpeedClamp
No speed restrictions.
Definition airport.h:48
@ Brake
Taxiing at the airport.
Definition airport.h:53
@ HeliRaise
Helicopter take-off.
Definition airport.h:54
@ ExactPosition
Go exactly to the destination coordinates.
Definition airport.h:52
AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y)
Rotate the airport moving data to another rotation.
Definition airport.cpp:80
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition airport.h:23
AirportMovementStates
Movement States on Airports (headings target)
Definition airport.h:62
@ HELITAKEOFF
Helicopter wants to leave the airport.
Definition airport.h:76
@ TERM4
Heading for terminal 4.
Definition airport.h:68
@ STARTTAKEOFF
Airplane has arrived at a runway for take-off.
Definition airport.h:74
@ HELIPAD2
Heading for helipad 2.
Definition airport.h:72
@ ENDTAKEOFF
Airplane has reached end-point of the take-off runway.
Definition airport.h:75
@ TERM5
Heading for terminal 5.
Definition airport.h:69
@ TERM6
Heading for terminal 6.
Definition airport.h:70
@ TERM3
Heading for terminal 3.
Definition airport.h:67
@ TERM8
Heading for terminal 8.
Definition airport.h:83
@ HELIPAD3
Heading for helipad 3.
Definition airport.h:84
@ HELIPAD1
Heading for helipad 1.
Definition airport.h:71
@ TERM2
Heading for terminal 2.
Definition airport.h:66
@ HANGAR
Heading for hangar.
Definition airport.h:64
@ FLYING
Vehicle is flying in the air.
Definition airport.h:77
@ TAKEOFF
Airplane wants to leave the airport.
Definition airport.h:73
@ HELILANDING
Helicopter wants to land.
Definition airport.h:80
@ TO_ALL
Go in this direction for every target.
Definition airport.h:63
@ ENDLANDING
Airplane wants to finish landing.
Definition airport.h:79
@ HELIENDLANDING
Helicopter wants to finish landing.
Definition airport.h:81
@ MAX_HEADINGS
Last valid target to head for.
Definition airport.h:85
@ TERM1
Heading for terminal 1.
Definition airport.h:65
@ LANDING
Airplane wants to land.
Definition airport.h:78
@ TERM7
Heading for terminal 7.
Definition airport.h:82
@ TERMGROUP
Aircraft is looking for a free terminal in a terminalgroup.
Definition airport.h:86
AirportTypes
Airport types.
Definition airport.h:28
@ AT_SMALL
Small airport.
Definition airport.h:29
@ AT_HELIDEPOT
Heli depot.
Definition airport.h:35
@ AT_INVALID
Invalid airport.
Definition airport.h:42
@ AT_METROPOLITAN
Metropolitan airport.
Definition airport.h:32
@ NUM_AIRPORTS
Maximal number of airports in total.
Definition airport.h:41
@ AT_LARGE
Large airport.
Definition airport.h:30
@ AT_HELISTATION
Heli station airport.
Definition airport.h:37
@ AT_DUMMY
Dummy airport.
Definition airport.h:43
@ AT_HELIPORT
Heli port.
Definition airport.h:31
@ NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
Definition airport.h:39
@ NUM_AIRPORTS_PER_GRF
Maximal number of airports per NewGRF.
Definition airport.h:40
@ AT_INTERCON
Intercontinental airport.
Definition airport.h:36
@ AT_INTERNATIONAL
International airport.
Definition airport.h:33
@ AT_COMMUTER
Commuter airport.
Definition airport.h:34
@ AT_OILRIG
Oilrig airport.
Definition airport.h:38
Different types to 'show' directions.
Direction
Defines the 8 directions on the map.
Finite sTate mAchine (FTA) of an airport.
Definition airport.h:158
const uint8_t num_helipads
Number of helipads on this airport. When 0 helicopters will go to normal terminals.
Definition airport.h:192
const AirportMovingData * MovingData(uint8_t position) const
Get movement data at a position.
Definition airport.h:183
Flag
Bitmask of airport flags.
Definition airport.h:161
@ Airplanes
Can planes land on this airport type?
@ ShortStrip
This airport has a short landing strip, dangerous for fast aircraft.
@ Helicopters
Can helicopters land on this airport type?
uint8_t delta_z
Z adjustment for helicopter pads.
Definition airport.h:196
std::vector< AirportFTA > layout
state machine for airport
Definition airport.h:190
const uint8_t * terminals
Array with the number of terminal groups, followed by the number of terminals in each group.
Definition airport.h:191
const uint8_t * entry_points
when an airplane arrives at this airport, enter it at position entry_point, index depends on directio...
Definition airport.h:195
uint8_t nofelements
number of positions the airport consists of
Definition airport.h:194
Flags flags
Flags for this airport type.
Definition airport.h:193
const AirportMovingData * moving_data
Movement data.
Definition airport.h:189
Internal structure used in openttd - Finite sTate mAchine --> FTA.
Definition airport.h:147
std::unique_ptr< AirportFTA > next
possible extra movement choices from this position
Definition airport.h:150
uint8_t heading
heading (current orders), guiding an airplane to its target on an airport
Definition airport.h:154
AirportBlocks blocks
bitmap of blocks that could be reserved
Definition airport.h:151
uint8_t position
the position that an airplane is at
Definition airport.h:152
uint8_t next_position
next position from this position
Definition airport.h:153
State machine input struct (from external file, etc.) Finite sTate mAchine --> FTA.
A single location on an airport where aircraft can move to.
Definition airport.h:135
int16_t x
x-coordinate of the destination.
Definition airport.h:136
AirportMovingDataFlags flags
special flags when moving towards the destination.
Definition airport.h:138
int16_t y
y-coordinate of the destination.
Definition airport.h:137
Direction direction
Direction to turn the aircraft after reaching the destination.
Definition airport.h:139
Types related to tiles.