author | tron |
Thu, 15 Feb 2007 07:43:06 +0000 | |
changeset 6020 | a7463b7eb894 |
parent 5971 | b21fda7c7f1e |
child 6024 | 37e72f8f6a99 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1299
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1093
diff
changeset
|
5 |
#include "debug.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
222
diff
changeset
|
6 |
#include "map.h" |
0 | 7 |
#include "airport.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
8 |
#include "macros.h" |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
9 |
#include "variables.h" |
3701
fdbb6bcab8a2
(svn r4642) - Codechange: reorganise airport.h and airport_movement.h to avoid having 8 copies of the airport FTAs, and make the enums used available elsewhere.
peter1138
parents:
2752
diff
changeset
|
10 |
#include "airport_movement.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4171
diff
changeset
|
11 |
#include "date.h" |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
12 |
#include "helpers.hpp" |
0 | 13 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
14 |
/* Uncomment this to print out a full report of the airport-structure |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
15 |
* You should either use |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
16 |
* - true: full-report, print out every state and choice with string-names |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
17 |
* OR |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
18 |
* - false: give a summarized report which only shows current and next position */ |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
19 |
//#define DEBUG_AIRPORT false |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
20 |
|
4171 | 21 |
static AirportFTAClass *CountryAirport; |
22 |
static AirportFTAClass *CityAirport; |
|
23 |
static AirportFTAClass *Oilrig; |
|
24 |
static AirportFTAClass *Heliport; |
|
25 |
static AirportFTAClass *MetropolitanAirport; |
|
26 |
static AirportFTAClass *InternationalAirport; |
|
27 |
static AirportFTAClass *CommuterAirport; |
|
28 |
static AirportFTAClass *HeliDepot; |
|
29 |
static AirportFTAClass *IntercontinentalAirport; |
|
30 |
static AirportFTAClass *HeliStation; |
|
0 | 31 |
|
32 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
33 |
void InitializeAirports(void) |
0 | 34 |
{ |
5932 | 35 |
CountryAirport = new AirportFTAClass( |
5924 | 36 |
_airport_moving_data_country, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
37 |
_airport_terminal_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
38 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
39 |
16, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
40 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
41 |
_airport_fta_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
42 |
_airport_depots_country, |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
43 |
lengthof(_airport_depots_country), |
6020 | 44 |
4, 3, |
45 |
0 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
46 |
); |
0 | 47 |
|
5932 | 48 |
CityAirport = new AirportFTAClass( |
5924 | 49 |
_airport_moving_data_town, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
50 |
_airport_terminal_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
51 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
52 |
19, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
53 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
54 |
_airport_fta_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
55 |
_airport_depots_city, |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
56 |
lengthof(_airport_depots_city), |
6020 | 57 |
6, 6, |
58 |
0 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
59 |
); |
0 | 60 |
|
5932 | 61 |
MetropolitanAirport = new AirportFTAClass( |
5924 | 62 |
_airport_moving_data_metropolitan, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
63 |
_airport_terminal_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
64 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
65 |
20, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
66 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
67 |
_airport_fta_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
68 |
_airport_depots_metropolitan, |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
69 |
lengthof(_airport_depots_metropolitan), |
6020 | 70 |
6, 6, |
71 |
0 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
72 |
); |
0 | 73 |
|
5932 | 74 |
InternationalAirport = new AirportFTAClass( |
5924 | 75 |
_airport_moving_data_international, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
76 |
_airport_terminal_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
77 |
_airport_helipad_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
78 |
37, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
79 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
80 |
_airport_fta_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
81 |
_airport_depots_international, |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
82 |
lengthof(_airport_depots_international), |
6020 | 83 |
7, 7, |
84 |
0 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
85 |
); |
0 | 86 |
|
5932 | 87 |
IntercontinentalAirport = new AirportFTAClass( |
5924 | 88 |
_airport_moving_data_intercontinental, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
89 |
_airport_terminal_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
90 |
_airport_helipad_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
91 |
43, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
92 |
ALL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
93 |
_airport_fta_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
94 |
_airport_depots_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
95 |
lengthof(_airport_depots_intercontinental), |
6020 | 96 |
9, 11, |
97 |
0 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
98 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
99 |
|
5932 | 100 |
Heliport = new AirportFTAClass( |
5924 | 101 |
_airport_moving_data_heliport, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
102 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
103 |
_airport_helipad_heliport_oilrig, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
104 |
7, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
105 |
HELICOPTERS_ONLY, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
106 |
_airport_fta_heliport_oilrig, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
107 |
NULL, |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
108 |
0, |
6020 | 109 |
1, 1, |
110 |
60 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
111 |
); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
112 |
|
5932 | 113 |
Oilrig = new AirportFTAClass( |
5924 | 114 |
_airport_moving_data_oilrig, |
115 |
NULL, |
|
116 |
_airport_helipad_heliport_oilrig, |
|
117 |
7, |
|
118 |
HELICOPTERS_ONLY, |
|
119 |
_airport_fta_heliport_oilrig, |
|
120 |
NULL, |
|
121 |
0, |
|
6020 | 122 |
1, 1, |
123 |
54 |
|
5924 | 124 |
); |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
125 |
|
5932 | 126 |
CommuterAirport = new AirportFTAClass( |
5924 | 127 |
_airport_moving_data_commuter, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
128 |
_airport_terminal_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
129 |
_airport_helipad_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
130 |
22, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
131 |
ALL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
132 |
_airport_fta_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
133 |
_airport_depots_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
134 |
lengthof(_airport_depots_commuter), |
6020 | 135 |
5, 4, |
136 |
0 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
137 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
138 |
|
5932 | 139 |
HeliDepot = new AirportFTAClass( |
5924 | 140 |
_airport_moving_data_helidepot, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
141 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
142 |
_airport_helipad_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
143 |
4, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
144 |
HELICOPTERS_ONLY, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
145 |
_airport_fta_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
146 |
_airport_depots_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
147 |
lengthof(_airport_depots_helidepot), |
6020 | 148 |
2, 2, |
149 |
0 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
150 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
151 |
|
5932 | 152 |
HeliStation = new AirportFTAClass( |
5924 | 153 |
_airport_moving_data_helistation, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
154 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
155 |
_airport_helipad_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
156 |
25, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
157 |
HELICOPTERS_ONLY, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
158 |
_airport_fta_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
159 |
_airport_depots_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
160 |
lengthof(_airport_depots_helistation), |
6020 | 161 |
4, 2, |
162 |
0 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
163 |
); |
0 | 164 |
} |
165 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1019
diff
changeset
|
166 |
void UnInitializeAirports(void) |
0 | 167 |
{ |
5932 | 168 |
delete CountryAirport; |
169 |
delete CityAirport; |
|
170 |
delete Heliport; |
|
171 |
delete MetropolitanAirport; |
|
172 |
delete InternationalAirport; |
|
173 |
delete CommuterAirport; |
|
174 |
delete HeliDepot; |
|
175 |
delete IntercontinentalAirport; |
|
176 |
delete HeliStation; |
|
0 | 177 |
} |
178 |
||
5932 | 179 |
|
180 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA); |
|
181 |
static AirportFTA* AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA); |
|
182 |
static byte AirportGetTerminalCount(const byte *terminals, byte *groups); |
|
183 |
static byte AirportTestFTA(uint nofelements, const AirportFTA *layout, const byte *terminals); |
|
184 |
||
185 |
#ifdef DEBUG_AIRPORT |
|
186 |
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report); |
|
187 |
#endif |
|
188 |
||
189 |
||
190 |
AirportFTAClass::AirportFTAClass( |
|
191 |
const AirportMovingData *moving_data_, |
|
192 |
const byte *terminals_, |
|
193 |
const byte *helipads_, |
|
194 |
const byte entry_point_, |
|
195 |
const AcceptPlanes acc_planes_, |
|
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
196 |
const AirportFTAbuildup *apFA, |
5932 | 197 |
const TileIndexDiffC *depots_, |
198 |
const byte nof_depots_, |
|
199 |
uint size_x_, |
|
6020 | 200 |
uint size_y_, |
201 |
byte delta_z_ |
|
5932 | 202 |
) : |
203 |
moving_data(moving_data_), |
|
204 |
terminals(terminals_), |
|
205 |
helipads(helipads_), |
|
206 |
airport_depots(depots_), |
|
207 |
nof_depots(nof_depots_), |
|
5938 | 208 |
nofelements(AirportGetNofElements(apFA)), |
209 |
entry_point(entry_point_), |
|
5932 | 210 |
size_x(size_x_), |
6020 | 211 |
size_y(size_y_), |
212 |
delta_z(delta_z_) |
|
0 | 213 |
{ |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
214 |
byte nofterminalgroups, nofhelipadgroups; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
215 |
|
5932 | 216 |
acc_planes = acc_planes_; // XXX TinyEnumT has no initialisation, only assignment |
3876
468642825a10
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
3701
diff
changeset
|
217 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
218 |
/* Set up the terminal and helipad count for an airport. |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
219 |
* TODO: If there are more than 10 terminals or 4 helipads, internal variables |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
220 |
* need to be changed, so don't allow that for now */ |
5932 | 221 |
uint nofterminals = AirportGetTerminalCount(terminals, &nofterminalgroups); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
222 |
if (nofterminals > MAX_TERMINALS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
4844
diff
changeset
|
223 |
DEBUG(misc, 0, "[Ap] only a maximum of %d terminals are supported (requested %d)", MAX_TERMINALS, nofterminals); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
224 |
assert(nofterminals <= MAX_TERMINALS); |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
225 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
226 |
|
5932 | 227 |
uint nofhelipads = AirportGetTerminalCount(helipads, &nofhelipadgroups); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
228 |
if (nofhelipads > MAX_HELIPADS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
4844
diff
changeset
|
229 |
DEBUG(misc, 0, "[Ap] only a maximum of %d helipads are supported (requested %d)", MAX_HELIPADS, nofhelipads); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
230 |
assert(nofhelipads <= MAX_HELIPADS); |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
231 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
232 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
233 |
/* Get the number of elements from the source table. We also double check this |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
234 |
* with the entry point which must be within bounds and use this information |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
235 |
* later on to build and validate the state machine */ |
5932 | 236 |
if (entry_point >= nofelements) { |
237 |
DEBUG(misc, 0, "[Ap] entry (%d) must be within the airport (maximum %d)", entry_point, nofelements); |
|
238 |
assert(entry_point < nofelements); |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
239 |
} |
0 | 240 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
241 |
/* Build the state machine itself */ |
5932 | 242 |
layout = AirportBuildAutomata(nofelements, apFA); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
4844
diff
changeset
|
243 |
DEBUG(misc, 2, "[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entry %3d", |
5932 | 244 |
nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, entry_point); |
0 | 245 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
246 |
/* Test if everything went allright. This is only a rude static test checking |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
247 |
* the symantic correctness. By no means does passing the test mean that the |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
248 |
* airport is working correctly or will not deadlock for example */ |
5932 | 249 |
uint ret = AirportTestFTA(nofelements, layout, terminals); |
250 |
if (ret != MAX_ELEMENTS) DEBUG(misc, 0, "[Ap] problem with element: %d", ret - 1); |
|
251 |
assert(ret == MAX_ELEMENTS); |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
252 |
|
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
253 |
#ifdef DEBUG_AIRPORT |
5932 | 254 |
AirportPrintOut(nofelements, layout, DEBUG_AIRPORT); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
255 |
#endif |
0 | 256 |
} |
257 |
||
5932 | 258 |
|
259 |
AirportFTAClass::~AirportFTAClass() |
|
0 | 260 |
{ |
5932 | 261 |
for (uint i = 0; i < nofelements; i++) { |
262 |
AirportFTA *current = layout[i].next; |
|
0 | 263 |
while (current != NULL) { |
5932 | 264 |
AirportFTA *next = current->next; |
0 | 265 |
free(current); |
266 |
current = next; |
|
267 |
}; |
|
268 |
} |
|
5932 | 269 |
free(layout); |
0 | 270 |
} |
271 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
272 |
/** Get the number of elements of a source Airport state automata |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
273 |
* Since it is actually just a big array of AirportFTA types, we only |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
274 |
* know one element from the other by differing 'position' identifiers */ |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
275 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA) |
0 | 276 |
{ |
277 |
int i; |
|
278 |
uint16 nofelements = 0; |
|
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
279 |
int temp = apFA[0].position; |
2549 | 280 |
|
0 | 281 |
for (i = 0; i < MAX_ELEMENTS; i++) { |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
282 |
if (temp != apFA[i].position) { |
0 | 283 |
nofelements++; |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
284 |
temp = apFA[i].position; |
0 | 285 |
} |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
286 |
if (apFA[i].position == MAX_ELEMENTS) break; |
0 | 287 |
} |
288 |
return nofelements; |
|
289 |
} |
|
290 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
291 |
/* We calculate the terminal/helipod count based on the data passed to us |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
292 |
* This data (terminals) contains an index as a first element as to how many |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
293 |
* groups there are, and then the number of terminals for each group */ |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
294 |
static byte AirportGetTerminalCount(const byte *terminals, byte *groups) |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
295 |
{ |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
296 |
byte i; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
297 |
byte nof_terminals = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
298 |
*groups = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
299 |
|
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
300 |
if (terminals != NULL) { |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
301 |
i = terminals[0]; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
302 |
*groups = i; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
303 |
while (i-- > 0) { |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
304 |
terminals++; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
305 |
assert(*terminals != 0); // no empty groups please |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
306 |
nof_terminals += *terminals; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
307 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
308 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
309 |
return nof_terminals; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
310 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
311 |
|
5932 | 312 |
|
313 |
static AirportFTA* AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA) |
|
0 | 314 |
{ |
315 |
AirportFTA *current; |
|
5932 | 316 |
AirportFTA *FAutomata = MallocT<AirportFTA>(nofelements); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
317 |
uint16 internalcounter = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
318 |
|
5932 | 319 |
for (uint i = 0; i < nofelements; i++) { |
320 |
current = &FAutomata[i]; |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
321 |
current->position = apFA[internalcounter].position; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
322 |
current->heading = apFA[internalcounter].heading; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
323 |
current->block = apFA[internalcounter].block; |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
324 |
current->next_position = apFA[internalcounter].next; |
0 | 325 |
|
326 |
// outgoing nodes from the same position, create linked list |
|
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
327 |
while (current->position == apFA[internalcounter + 1].position) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5587
diff
changeset
|
328 |
AirportFTA *newNode = MallocT<AirportFTA>(1); |
2549 | 329 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
330 |
newNode->position = apFA[internalcounter + 1].position; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
331 |
newNode->heading = apFA[internalcounter + 1].heading; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
332 |
newNode->block = apFA[internalcounter + 1].block; |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
333 |
newNode->next_position = apFA[internalcounter + 1].next; |
0 | 334 |
// create link |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
335 |
current->next = newNode; |
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
336 |
current = current->next; |
0 | 337 |
internalcounter++; |
338 |
} // while |
|
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
339 |
current->next = NULL; |
0 | 340 |
internalcounter++; |
341 |
} |
|
5932 | 342 |
return FAutomata; |
0 | 343 |
} |
344 |
||
5932 | 345 |
|
346 |
static byte AirportTestFTA(uint nofelements, const AirportFTA *layout, const byte *terminals) |
|
0 | 347 |
{ |
5932 | 348 |
uint next_position = 0; |
0 | 349 |
|
5932 | 350 |
for (uint i = 0; i < nofelements; i++) { |
351 |
uint position = layout[i].position; |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
352 |
if (position != next_position) return i; |
5932 | 353 |
const AirportFTA *first = &layout[i]; |
354 |
const AirportFTA *current = first; |
|
0 | 355 |
|
4844
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
356 |
for (; current != NULL; current = current->next) { |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
357 |
/* A heading must always be valid. The only exceptions are |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
358 |
* - multiple choices as start, identified by a special value of 255 |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
359 |
* - terminal group which is identified by a special value of 255 */ |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
360 |
if (current->heading > MAX_HEADINGS) { |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
361 |
if (current->heading != 255) return i; |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
362 |
if (current == first && current->next == NULL) return i; |
5932 | 363 |
if (current != first && current->next_position > terminals[0]) return i; |
4844
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
364 |
} |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
365 |
|
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
366 |
/* If there is only one choice, it must be at the end */ |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
367 |
if (current->heading == 0 && current->next != NULL) return i; |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
368 |
/* Obviously the elements of the linked list must have the same identifier */ |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
369 |
if (position != current->position) return i; |
4844
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
370 |
/* A next position must be within bounds */ |
5932 | 371 |
if (current->next_position >= nofelements) return i; |
4844
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
372 |
} |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
373 |
next_position++; |
0 | 374 |
} |
375 |
return MAX_ELEMENTS; |
|
376 |
} |
|
377 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
378 |
#ifdef DEBUG_AIRPORT |
2549 | 379 |
static const char* const _airport_heading_strings[] = { |
0 | 380 |
"TO_ALL", |
381 |
"HANGAR", |
|
382 |
"TERM1", |
|
383 |
"TERM2", |
|
384 |
"TERM3", |
|
385 |
"TERM4", |
|
386 |
"TERM5", |
|
387 |
"TERM6", |
|
388 |
"HELIPAD1", |
|
389 |
"HELIPAD2", |
|
390 |
"TAKEOFF", |
|
391 |
"STARTTAKEOFF", |
|
392 |
"ENDTAKEOFF", |
|
393 |
"HELITAKEOFF", |
|
394 |
"FLYING", |
|
395 |
"LANDING", |
|
396 |
"ENDLANDING", |
|
397 |
"HELILANDING", |
|
398 |
"HELIENDLANDING", |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
399 |
"TERM7", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
400 |
"TERM8", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
401 |
"HELIPAD3", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
402 |
"HELIPAD4", |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4294
diff
changeset
|
403 |
"DUMMY" // extra heading for 255 |
0 | 404 |
}; |
405 |
||
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
406 |
static uint AirportBlockToString(uint32 block) |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
407 |
{ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
408 |
uint i = 0; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
409 |
if (block & 0xffff0000) { block >>= 16; i += 16; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
410 |
if (block & 0x0000ff00) { block >>= 8; i += 8; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
411 |
if (block & 0x000000f0) { block >>= 4; i += 4; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
412 |
if (block & 0x0000000c) { block >>= 2; i += 2; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
413 |
if (block & 0x00000002) { i += 1; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
414 |
return i; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
415 |
} |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
416 |
|
5932 | 417 |
|
418 |
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report) |
|
0 | 419 |
{ |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
420 |
if (!full_report) printf("(P = Current Position; NP = Next Position)\n"); |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
421 |
|
5932 | 422 |
for (uint i = 0; i < nofelements; i++) { |
423 |
const AirportFTA *current = &layout[i]; |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
424 |
|
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
425 |
for (; current != NULL; current = current->next) { |
0 | 426 |
if (full_report) { |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
427 |
byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
428 |
printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position, |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
429 |
current->next_position, _airport_heading_strings[heading], |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
430 |
AirportBlockToString(current->block)); |
2549 | 431 |
} else { |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
432 |
printf("P:%2d NP:%2d", current->position, current->next_position); |
0 | 433 |
} |
434 |
} |
|
435 |
printf("\n"); |
|
436 |
} |
|
437 |
} |
|
2549 | 438 |
#endif |
0 | 439 |
|
4171 | 440 |
const AirportFTAClass *GetAirport(const byte airport_type) |
0 | 441 |
{ |
442 |
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code |
|
443 |
// needs constant change if more airports are added |
|
444 |
switch (airport_type) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
445 |
default: NOT_REACHED(); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
446 |
case AT_SMALL: return CountryAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
447 |
case AT_LARGE: return CityAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
448 |
case AT_METROPOLITAN: return MetropolitanAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
449 |
case AT_HELIPORT: return Heliport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
450 |
case AT_OILRIG: return Oilrig; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
451 |
case AT_INTERNATIONAL: return InternationalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
452 |
case AT_COMMUTER: return CommuterAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
453 |
case AT_HELIDEPOT: return HeliDepot; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
454 |
case AT_INTERCON: return IntercontinentalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
455 |
case AT_HELISTATION: return HeliStation; |
0 | 456 |
} |
457 |
} |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
458 |
|
3701
fdbb6bcab8a2
(svn r4642) - Codechange: reorganise airport.h and airport_movement.h to avoid having 8 copies of the airport FTAs, and make the enums used available elsewhere.
peter1138
parents:
2752
diff
changeset
|
459 |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
460 |
uint32 GetValidAirports(void) |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
461 |
{ |
5971 | 462 |
uint32 mask = 0; |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
463 |
|
5971 | 464 |
if (_cur_year < 1960 || _patches.always_small_airport) SETBIT(mask, 0); // small airport |
465 |
if (_cur_year >= 1955) SETBIT(mask, 1); // city airport |
|
466 |
if (_cur_year >= 1963) SETBIT(mask, 2); // heliport |
|
467 |
if (_cur_year >= 1980) SETBIT(mask, 3); // metropolitan airport |
|
468 |
if (_cur_year >= 1990) SETBIT(mask, 4); // international airport |
|
469 |
if (_cur_year >= 1983) SETBIT(mask, 5); // commuter airport |
|
470 |
if (_cur_year >= 1976) SETBIT(mask, 6); // helidepot |
|
471 |
if (_cur_year >= 2002) SETBIT(mask, 7); // intercontinental airport |
|
472 |
if (_cur_year >= 1980) SETBIT(mask, 8); // helistation |
|
473 |
return mask; |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
474 |
} |