OpenTTD

airport.h
Go to the documentation of this file.
1 /* $Id: airport.h 25841 2013-10-12 16:34:59Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef AIRPORT_H
13 #define AIRPORT_H
14
15 #include "direction_type.h"
16 #include "tile_type.h"
17
19 static const uint MAX_TERMINALS = 8;
20 static const uint MAX_HELIPADS = 3;
21 static const uint MAX_ELEMENTS = 255;
22
23 static const uint NUM_AIRPORTTILES_PER_GRF = 255;
24
25 static const uint NUM_AIRPORTTILES = 256;
26 static const uint NEW_AIRPORTTILE_OFFSET = 74;
27 static const uint INVALID_AIRPORTTILE = NUM_AIRPORTTILES;
28
30 enum AirportTypes {
31 AT_SMALL = 0,
32 AT_LARGE = 1,
33 AT_HELIPORT = 2,
34 AT_METROPOLITAN = 3,
35 AT_INTERNATIONAL = 4,
36 AT_COMMUTER = 5,
37 AT_HELIDEPOT = 6,
38 AT_INTERCON = 7,
39 AT_HELISTATION = 8,
40 AT_OILRIG = 9,
41 NEW_AIRPORT_OFFSET = 10,
42 NUM_AIRPORTS_PER_GRF = 128,
43 NUM_AIRPORTS = 128,
44 AT_INVALID = 254,
45 AT_DUMMY = 255,
46 };
47
49 enum AirportMovingDataFlags {
50 AMED_NOSPDCLAMP = 1 << 0,
51 AMED_TAKEOFF = 1 << 1,
52 AMED_SLOWTURN = 1 << 2,
53 AMED_LAND = 1 << 3,
54 AMED_EXACTPOS = 1 << 4,
55 AMED_BRAKE = 1 << 5,
56 AMED_HELI_RAISE = 1 << 6,
57 AMED_HELI_LOWER = 1 << 7,
58 AMED_HOLD = 1 << 8,
59 };
60
62 enum AirportMovementStates {
63 TO_ALL = 0,
64 HANGAR = 1,
65 TERM1 = 2,
66 TERM2 = 3,
67 TERM3 = 4,
68 TERM4 = 5,
69 TERM5 = 6,
70 TERM6 = 7,
71 HELIPAD1 = 8,
72 HELIPAD2 = 9,
73 TAKEOFF = 10,
74 STARTTAKEOFF = 11,
75 ENDTAKEOFF = 12,
76 HELITAKEOFF = 13,
77 FLYING = 14,
78 LANDING = 15,
79 ENDLANDING = 16,
80 HELILANDING = 17,
81 HELIENDLANDING = 18,
82 TERM7 = 19,
83 TERM8 = 20,
84 HELIPAD3 = 21,
85 MAX_HEADINGS = 21,
86 };
87
89 static const uint64
90 TERM1_block = 1ULL << 0,
91 TERM2_block = 1ULL << 1,
92 TERM3_block = 1ULL << 2,
93 TERM4_block = 1ULL << 3,
94 TERM5_block = 1ULL << 4,
95 TERM6_block = 1ULL << 5,
96 HELIPAD1_block = 1ULL << 6,
97 HELIPAD2_block = 1ULL << 7,
98 RUNWAY_IN_OUT_block = 1ULL << 8,
99 RUNWAY_IN_block = 1ULL << 8,
100 AIRPORT_BUSY_block = 1ULL << 8,
101 RUNWAY_OUT_block = 1ULL << 9,
102 TAXIWAY_BUSY_block = 1ULL << 10,
103 OUT_WAY_block = 1ULL << 11,
104 IN_WAY_block = 1ULL << 12,
105 AIRPORT_ENTRANCE_block = 1ULL << 13,
106 TERM_GROUP1_block = 1ULL << 14,
107 TERM_GROUP2_block = 1ULL << 15,
108 HANGAR2_AREA_block = 1ULL << 16,
109 TERM_GROUP2_ENTER1_block = 1ULL << 17,
110 TERM_GROUP2_ENTER2_block = 1ULL << 18,
111 TERM_GROUP2_EXIT1_block = 1ULL << 19,
112 TERM_GROUP2_EXIT2_block = 1ULL << 20,
113 PRE_HELIPAD_block = 1ULL << 21,
114
115 /* blocks for new airports */
116 TERM7_block = 1ULL << 22,
117 TERM8_block = 1ULL << 23,
118 HELIPAD3_block = 1ULL << 24,
119 HANGAR1_AREA_block = 1ULL << 26,
120 OUT_WAY2_block = 1ULL << 27,
121 IN_WAY2_block = 1ULL << 28,
122 RUNWAY_IN2_block = 1ULL << 29,
123 RUNWAY_OUT2_block = 1ULL << 10,
124 HELIPAD_GROUP_block = 1ULL << 13,
125 OUT_WAY_block2 = 1ULL << 31,
126 /* end of new blocks */
127
128 NOTHING_block = 1ULL << 30,
129 AIRPORT_CLOSED_block = 1ULL << 63;
130
132 struct AirportMovingData {
133 int16 x;
134 int16 y;
135 uint16 flag;
136 DirectionByte direction;
137 };
138
139 AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y);
140
141 struct AirportFTAbuildup;
142
144 struct AirportFTAClass {
145 public:
147 enum Flags {
148 AIRPLANES = 0x1,
149 HELICOPTERS = 0x2,
150 ALL = AIRPLANES | HELICOPTERS,
151 SHORT_STRIP = 0x4,
152 };
153
154 AirportFTAClass(
155 const AirportMovingData *moving_data,
156 const byte *terminals,
157 const byte num_helipads,
158 const byte *entry_points,
159 Flags flags,
160 const AirportFTAbuildup *apFA,
161 byte delta_z
162 );
163
164 ~AirportFTAClass();
165
171 const AirportMovingData *MovingData(byte position) const
172 {
173 assert(position < nofelements);
174 return &moving_data[position];
175 }
176
177 const AirportMovingData *moving_data;
178 struct AirportFTA *layout;
179 const byte *terminals;
180 const byte num_helipads;
181 Flags flags;
182 byte nofelements;
183 const byte *entry_points;
184 byte delta_z;
185 };
186
187 DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
188
189
190
191 struct AirportFTA {
192 AirportFTA *next;
193 uint64 block;
194 byte position;
195 byte next_position;
196 byte heading;
197 };
198
199 const AirportFTAClass *GetAirport(const byte airport_type);
200 byte GetVehiclePosOnBuild(TileIndex hangar_tile);
201
202 #endif /* AIRPORT_H */
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
TAKEOFF
Airplane wants to leave the airport.
Definition: airport.h:73
direction_type.h
Different types to &#39;show&#39; directions.
HANGAR
Heading for hangar.
Definition: airport.h:64
TERM1
Heading for terminal 1.
Definition: airport.h:65
ENDTAKEOFF
Airplane has reached end-point of the take-off runway.
Definition: airport.h:75
AirportFTAClass
Finite sTate mAchine (FTA) of an airport.
Definition: airport.h:144
HELIPAD2
Heading for helipad 2.
Definition: airport.h:72
AirportFTAClass::nofelements
byte nofelements
number of positions the airport consists of
Definition: airport.h:182
AMED_TAKEOFF
Takeoff movement.
Definition: airport.h:51
AirportFTA::next_position
byte next_position
next position from this position
Definition: airport.h:195
MAX_HEADINGS
Last valid target to head for.
Definition: airport.h:85
HELIPAD1_block
static const uint64 HELIPAD1_block
Block belonging to helipad 1.
Definition: airport.h:96
AirportMovingData
A single location on an airport where aircraft can move to.
Definition: airport.h:132
TERM6_block
static const uint64 TERM6_block
Block belonging to terminal 6.
Definition: airport.h:95
AMED_NOSPDCLAMP
No speed restrictions.
Definition: airport.h:50
AT_DUMMY
Dummy airport.
Definition: airport.h:45
TERM6
Heading for terminal 6.
Definition: airport.h:70
AMED_HELI_LOWER
Helicopter landing.
Definition: airport.h:57
AT_LARGE
Large airport.
Definition: airport.h:32
AMED_BRAKE
Taxiing at the airport.
Definition: airport.h:55
AirportFTAClass::entry_points
const byte * entry_points
when an airplane arrives at this airport, enter it at position entry_point, index depends on directio...
Definition: airport.h:183
INVALID_AIRPORTTILE
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
Definition: airport.h:27
AirportFTAbuildup
State machine input struct (from external file, etc.) Finite sTate mAchine –> FTA.
Definition: airport_movement.h:20
AirportFTAClass::flags
Flags flags
Flags for this airport type.
Definition: airport.h:181
AirportMovingData::y
int16 y
y-coordinate of the destination.
Definition: airport.h:134
FLYING
Vehicle is flying in the air.
Definition: airport.h:77
AirportMovingDataFlags
AirportMovingDataFlags
Flags for airport movement data.
Definition: airport.h:49
HELIPAD3_block
static const uint64 HELIPAD3_block
Block belonging to helipad 3.
Definition: airport.h:118
HELILANDING
Helicopter wants to land.
Definition: airport.h:80
AT_HELISTATION
Heli station airport.
Definition: airport.h:39
AMED_EXACTPOS
Go exactly to the destination coordinates.
Definition: airport.h:54
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:26
GetVehiclePosOnBuild
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
Get the vehicle position when an aircraft is build at the given tile.
Definition: airport.cpp:220
AMED_HOLD
Holding pattern movement (above the airport).
Definition: airport.h:58
HELIPAD2_block
static const uint64 HELIPAD2_block
Block belonging to helipad 2.
Definition: airport.h:97
AT_INVALID
Invalid airport.
Definition: airport.h:44
AT_COMMUTER
Commuter airport.
Definition: airport.h:36
NUM_AIRPORTS
Maximal number of airports in total.
Definition: airport.h:43
AirportFTAClass::Flags
Flags
Bitmask of airport flags.
Definition: airport.h:147
AMED_SLOWTURN
Turn slowly (mostly used in the air).
Definition: airport.h:52
NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
Definition: airport.h:41
AirportFTA
Internal structure used in openttd - Finite sTate mAchine –> FTA.
Definition: airport.h:191
TERM7
Heading for terminal 7.
Definition: airport.h:82
TERM2
Heading for terminal 2.
Definition: airport.h:66
AirportFTAClass::num_helipads
const byte num_helipads
Number of helipads on this airport. When 0 helicopters will go to normal terminals.
Definition: airport.h:180
AIRPORT_CLOSED_block
static const uint64 AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
Definition: airport.h:129
AT_METROPOLITAN
Metropolitan airport.
Definition: airport.h:34
AirportFTAClass::layout
struct AirportFTA * layout
state machine for airport
Definition: airport.h:178
NUM_AIRPORTTILES_PER_GRF
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:23
NUM_AIRPORTTILES
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition: airport.h:25
GetAirport
const AirportFTAClass * GetAirport(const byte airport_type)
Get the finite state machine of an airport type.
Definition: airport.cpp:209
HELIPAD3
Heading for helipad 3.
Definition: airport.h:84
TERM3
Heading for terminal 3.
Definition: airport.h:67
STARTTAKEOFF
Airplane has arrived at a runway for take-off.
Definition: airport.h:74
AirportFTAClass::MovingData
const AirportMovingData * MovingData(byte position) const
Get movement data at a position.
Definition: airport.h:171
RotateAirportMovingData
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:82
AirportFTAClass::moving_data
const AirportMovingData * moving_data
Movement data.
Definition: airport.h:177
TinyEnumT< Direction >
AirportMovementStates
AirportMovementStates
Movement States on Airports (headings target)
Definition: airport.h:62
MAX_HELIPADS
static const uint MAX_HELIPADS
maximum number of helipads per airport
Definition: airport.h:20
AT_SMALL
Small airport.
Definition: airport.h:31
MAX_TERMINALS
static const uint MAX_TERMINALS
Some airport-related constants.
Definition: airport.h:19
AT_HELIDEPOT
Heli depot.
Definition: airport.h:37
TO_ALL
Go in this direction for every target.
Definition: airport.h:63
MAX_ELEMENTS
static const uint MAX_ELEMENTS
maximum number of aircraft positions at airport
Definition: airport.h:21
NUM_AIRPORTS_PER_GRF
Maximal number of airports per NewGRF.
Definition: airport.h:42
TERM7_block
static const uint64 TERM7_block
Block belonging to terminal 7.
Definition: airport.h:116
AT_OILRIG
Oilrig airport.
Definition: airport.h:40
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
LANDING
Airplane wants to land.
Definition: airport.h:78
TERM1_block
static const uint64 TERM1_block
Movement Blocks on Airports blocks (eg_airport_flags).
Definition: airport.h:90
AirportFTA::block
uint64 block
64 bit blocks (st->airport.flags), should be enough for the most complex airports ...
Definition: airport.h:193
AT_HELIPORT
Heli port.
Definition: airport.h:33
TERM8
Heading for terminal 8.
Definition: airport.h:83
TERM8_block
static const uint64 TERM8_block
Block belonging to terminal 8.
Definition: airport.h:117
AirportMovingData::x
int16 x
x-coordinate of the destination.
Definition: airport.h:133
AirportFTA::next
AirportFTA * next
possible extra movement choices from this position
Definition: airport.h:192
TERM4_block
static const uint64 TERM4_block
Block belonging to terminal 4.
Definition: airport.h:93
TERM5
Heading for terminal 5.
Definition: airport.h:69
RUNWAY_OUT2_block
static const uint64 RUNWAY_OUT2_block
Definition: airport.h:123
TERM4
Heading for terminal 4.
Definition: airport.h:68
AT_INTERCON
Intercontinental airport.
Definition: airport.h:38
AMED_LAND
Landing onto landing strip.
Definition: airport.h:53
HELIPAD1
Heading for helipad 1.
Definition: airport.h:71
HELIENDLANDING
Helicopter wants to finish landing.
Definition: airport.h:81
HELIPAD_GROUP_block
static const uint64 HELIPAD_GROUP_block
Definition: airport.h:124
AMED_HELI_RAISE
Helicopter take-off.
Definition: airport.h:56
AirportMovingData::flag
uint16 flag
special flags when moving towards the destination.
Definition: airport.h:135
NEW_AIRPORTTILE_OFFSET
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
Definition: airport.h:26
TERM3_block
static const uint64 TERM3_block
Block belonging to terminal 3.
Definition: airport.h:92
TERM2_block
static const uint64 TERM2_block
Block belonging to terminal 2.
Definition: airport.h:91
AirportFTA::heading
byte heading
heading (current orders), guiding an airplane to its target on an airport
Definition: airport.h:196
AirportMovingData::direction
DirectionByte direction
Direction to turn the aircraft after reaching the destination.
Definition: airport.h:136
AirportFTA::position
byte position
the position that an airplane is at
Definition: airport.h:194
tile_type.h
Types related to tiles.
AT_INTERNATIONAL
International airport.
Definition: airport.h:35
AirportFTAClass::terminals
const byte * terminals
Array with the number of terminal groups, followed by the number of terminals in each group...
Definition: airport.h:179
AirportTypes
AirportTypes
Airport types.
Definition: airport.h:30
ENDLANDING
Airplane wants to finish landing.
Definition: airport.h:79
AirportFTAClass::delta_z
byte delta_z
Z adjustment for helicopter pads.
Definition: airport.h:184
HELITAKEOFF
Helicopter wants to leave the airport.
Definition: airport.h:76
TERM5_block
static const uint64 TERM5_block
Block belonging to terminal 5.
Definition: airport.h:94