OpenTTD Source  20241108-master-g80f628063a
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 
17 static const uint MAX_TERMINALS = 8;
18 static const uint MAX_HELIPADS = 3;
19 static const uint MAX_ELEMENTS = 255;
20 
21 static const uint NUM_AIRPORTTILES_PER_GRF = 255;
22 
23 static const uint NUM_AIRPORTTILES = 256;
24 static const uint NEW_AIRPORTTILE_OFFSET = 74;
26 
29  AT_SMALL = 0,
30  AT_LARGE = 1,
38  AT_OILRIG = 9,
41  NUM_AIRPORTS = 128,
42  AT_INVALID = 254,
43  AT_DUMMY = 255,
44 };
45 
48  AMED_NOSPDCLAMP = 1 << 0,
49  AMED_TAKEOFF = 1 << 1,
50  AMED_SLOWTURN = 1 << 2,
51  AMED_LAND = 1 << 3,
52  AMED_EXACTPOS = 1 << 4,
53  AMED_BRAKE = 1 << 5,
54  AMED_HELI_RAISE = 1 << 6,
55  AMED_HELI_LOWER = 1 << 7,
56  AMED_HOLD = 1 << 8,
57 };
58 
61  TO_ALL = 0,
62  HANGAR = 1,
63  TERM1 = 2,
64  TERM2 = 3,
65  TERM3 = 4,
66  TERM4 = 5,
67  TERM5 = 6,
68  TERM6 = 7,
69  HELIPAD1 = 8,
70  HELIPAD2 = 9,
71  TAKEOFF = 10,
72  STARTTAKEOFF = 11,
73  ENDTAKEOFF = 12,
74  HELITAKEOFF = 13,
75  FLYING = 14,
76  LANDING = 15,
77  ENDLANDING = 16,
78  HELILANDING = 17,
80  TERM7 = 19,
81  TERM8 = 20,
82  HELIPAD3 = 21,
83  MAX_HEADINGS = 21,
84  TERMGROUP = 255,
85 };
86 
88 static const uint64_t
89  TERM1_block = 1ULL << 0,
90  TERM2_block = 1ULL << 1,
91  TERM3_block = 1ULL << 2,
92  TERM4_block = 1ULL << 3,
93  TERM5_block = 1ULL << 4,
94  TERM6_block = 1ULL << 5,
95  HELIPAD1_block = 1ULL << 6,
96  HELIPAD2_block = 1ULL << 7,
97  RUNWAY_IN_OUT_block = 1ULL << 8,
98  RUNWAY_IN_block = 1ULL << 8,
99  AIRPORT_BUSY_block = 1ULL << 8,
100  RUNWAY_OUT_block = 1ULL << 9,
101  TAXIWAY_BUSY_block = 1ULL << 10,
102  OUT_WAY_block = 1ULL << 11,
103  IN_WAY_block = 1ULL << 12,
104  AIRPORT_ENTRANCE_block = 1ULL << 13,
105  TERM_GROUP1_block = 1ULL << 14,
106  TERM_GROUP2_block = 1ULL << 15,
107  HANGAR2_AREA_block = 1ULL << 16,
108  TERM_GROUP2_ENTER1_block = 1ULL << 17,
109  TERM_GROUP2_ENTER2_block = 1ULL << 18,
110  TERM_GROUP2_EXIT1_block = 1ULL << 19,
111  TERM_GROUP2_EXIT2_block = 1ULL << 20,
112  PRE_HELIPAD_block = 1ULL << 21,
113 
114  /* blocks for new airports */
115  TERM7_block = 1ULL << 22,
116  TERM8_block = 1ULL << 23,
117  HELIPAD3_block = 1ULL << 24,
118  HANGAR1_AREA_block = 1ULL << 26,
119  OUT_WAY2_block = 1ULL << 27,
120  IN_WAY2_block = 1ULL << 28,
121  RUNWAY_IN2_block = 1ULL << 29,
122  RUNWAY_OUT2_block = 1ULL << 10,
123  HELIPAD_GROUP_block = 1ULL << 13,
124  OUT_WAY_block2 = 1ULL << 31,
125  /* end of new blocks */
126 
127  NOTHING_block = 1ULL << 30,
128  AIRPORT_CLOSED_block = 1ULL << 63;
129 
132  int16_t x;
133  int16_t y;
134  uint16_t flag;
136 };
137 
138 AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);
139 
140 struct AirportFTAbuildup;
141 
144 public:
146  enum Flags {
147  AIRPLANES = 0x1,
148  HELICOPTERS = 0x2,
150  SHORT_STRIP = 0x4,
151  };
152 
155  const uint8_t *terminals,
156  const uint8_t num_helipads,
157  const uint8_t *entry_points,
158  Flags flags,
159  const AirportFTAbuildup *apFA,
160  uint8_t delta_z
161  );
162 
163  ~AirportFTAClass();
164 
170  const AirportMovingData *MovingData(uint8_t position) const
171  {
172  assert(position < nofelements);
173  return &moving_data[position];
174  }
175 
177  struct AirportFTA *layout;
178  const uint8_t *terminals;
179  const uint8_t num_helipads;
181  uint8_t nofelements;
182  const uint8_t *entry_points;
183  uint8_t delta_z;
184 };
185 
187 
188 
189 
190 struct AirportFTA {
192  uint64_t block;
193  uint8_t position;
194  uint8_t next_position;
195  uint8_t heading;
196 };
197 
198 const AirportFTAClass *GetAirport(const uint8_t airport_type);
199 uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile);
200 
201 #endif /* AIRPORT_H */
static const uint64_t TERM7_block
Block belonging to terminal 7.
Definition: airport.h:115
static const uint64_t TERM4_block
Block belonging to terminal 4.
Definition: airport.h:92
static const uint MAX_HELIPADS
maximum number of helipads per airport
Definition: airport.h:18
static const uint64_t HELIPAD_GROUP_block
Definition: airport.h:123
static const uint MAX_ELEMENTS
maximum number of aircraft positions at airport
Definition: airport.h:19
static const uint64_t TERM2_block
Block belonging to terminal 2.
Definition: airport.h:90
static const uint64_t TERM1_block
Movement Blocks on Airports blocks (eg_airport_flags).
Definition: airport.h:89
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
Definition: airport.h:25
static const uint64_t TERM5_block
Block belonging to terminal 5.
Definition: airport.h:93
static const uint64_t TERM3_block
Block belonging to terminal 3.
Definition: airport.h:91
static const uint64_t TERM8_block
Block belonging to terminal 8.
Definition: airport.h:116
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
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
AirportMovingDataFlags
Flags for airport movement data.
Definition: airport.h:47
@ AMED_BRAKE
Taxiing at the airport.
Definition: airport.h:53
@ AMED_HOLD
Holding pattern movement (above the airport).
Definition: airport.h:56
@ AMED_SLOWTURN
Turn slowly (mostly used in the air).
Definition: airport.h:50
@ AMED_HELI_LOWER
Helicopter landing.
Definition: airport.h:55
@ AMED_LAND
Landing onto landing strip.
Definition: airport.h:51
@ AMED_NOSPDCLAMP
No speed restrictions.
Definition: airport.h:48
@ AMED_TAKEOFF
Takeoff movement.
Definition: airport.h:49
@ AMED_EXACTPOS
Go exactly to the destination coordinates.
Definition: airport.h:52
@ AMED_HELI_RAISE
Helicopter take-off.
Definition: airport.h:54
const AirportFTAClass * GetAirport(const uint8_t airport_type)
Get the finite state machine of an airport type.
Definition: airport.cpp:207
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile)
Get the vehicle position when an aircraft is build at the given tile.
Definition: airport.cpp:218
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
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 uint64_t AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
Definition: airport.h:128
static const uint64_t HELIPAD2_block
Block belonging to helipad 2.
Definition: airport.h:96
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition: airport.h:23
static const uint64_t TERM6_block
Block belonging to terminal 6.
Definition: airport.h:94
static const uint64_t HELIPAD3_block
Block belonging to helipad 3.
Definition: airport.h:117
static const uint64_t HELIPAD1_block
Block belonging to helipad 1.
Definition: airport.h:95
AirportMovementStates
Movement States on Airports (headings target)
Definition: airport.h:60
@ HELITAKEOFF
Helicopter wants to leave the airport.
Definition: airport.h:74
@ TERM4
Heading for terminal 4.
Definition: airport.h:66
@ STARTTAKEOFF
Airplane has arrived at a runway for take-off.
Definition: airport.h:72
@ HELIPAD2
Heading for helipad 2.
Definition: airport.h:70
@ ENDTAKEOFF
Airplane has reached end-point of the take-off runway.
Definition: airport.h:73
@ TERM5
Heading for terminal 5.
Definition: airport.h:67
@ TERM6
Heading for terminal 6.
Definition: airport.h:68
@ TERM3
Heading for terminal 3.
Definition: airport.h:65
@ TERM8
Heading for terminal 8.
Definition: airport.h:81
@ HELIPAD3
Heading for helipad 3.
Definition: airport.h:82
@ HELIPAD1
Heading for helipad 1.
Definition: airport.h:69
@ TERM2
Heading for terminal 2.
Definition: airport.h:64
@ HANGAR
Heading for hangar.
Definition: airport.h:62
@ FLYING
Vehicle is flying in the air.
Definition: airport.h:75
@ TAKEOFF
Airplane wants to leave the airport.
Definition: airport.h:71
@ HELILANDING
Helicopter wants to land.
Definition: airport.h:78
@ TO_ALL
Go in this direction for every target.
Definition: airport.h:61
@ ENDLANDING
Airplane wants to finish landing.
Definition: airport.h:77
@ HELIENDLANDING
Helicopter wants to finish landing.
Definition: airport.h:79
@ MAX_HEADINGS
Last valid target to head for.
Definition: airport.h:83
@ TERM1
Heading for terminal 1.
Definition: airport.h:63
@ LANDING
Airplane wants to land.
Definition: airport.h:76
@ TERM7
Heading for terminal 7.
Definition: airport.h:80
@ TERMGROUP
Aircraft is looking for a free terminal in a terminalgroup.
Definition: airport.h:84
static const uint64_t RUNWAY_OUT2_block
Definition: airport.h:122
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Different types to 'show' directions.
Direction
Defines the 8 directions on the map.
Finite sTate mAchine (FTA) of an airport.
Definition: airport.h:143
struct AirportFTA * layout
state machine for airport
Definition: airport.h:177
const uint8_t num_helipads
Number of helipads on this airport. When 0 helicopters will go to normal terminals.
Definition: airport.h:179
uint8_t delta_z
Z adjustment for helicopter pads.
Definition: airport.h:183
const uint8_t * terminals
Array with the number of terminal groups, followed by the number of terminals in each group.
Definition: airport.h:178
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:182
uint8_t nofelements
number of positions the airport consists of
Definition: airport.h:181
const AirportMovingData * MovingData(uint8_t position) const
Get movement data at a position.
Definition: airport.h:170
Flags flags
Flags for this airport type.
Definition: airport.h:180
Flags
Bitmask of airport flags.
Definition: airport.h:146
@ AIRPLANES
Can planes land on this airport type?
Definition: airport.h:147
@ ALL
Mask to check for both planes and helicopters.
Definition: airport.h:149
@ SHORT_STRIP
This airport has a short landing strip, dangerous for fast aircraft.
Definition: airport.h:150
@ HELICOPTERS
Can helicopters land on this airport type?
Definition: airport.h:148
const AirportMovingData * moving_data
Movement data.
Definition: airport.h:176
Internal structure used in openttd - Finite sTate mAchine --> FTA.
Definition: airport.h:190
AirportFTA * next
possible extra movement choices from this position
Definition: airport.h:191
uint8_t heading
heading (current orders), guiding an airplane to its target on an airport
Definition: airport.h:195
uint64_t block
64 bit blocks (st->airport.flags), should be enough for the most complex airports
Definition: airport.h:192
uint8_t position
the position that an airplane is at
Definition: airport.h:193
uint8_t next_position
next position from this position
Definition: airport.h:194
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:131
uint16_t flag
special flags when moving towards the destination.
Definition: airport.h:134
int16_t x
x-coordinate of the destination.
Definition: airport.h:132
int16_t y
y-coordinate of the destination.
Definition: airport.h:133
Direction direction
Direction to turn the aircraft after reaching the destination.
Definition: airport.h:135
Types related to tiles.