author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6394 | dabe045f6f14 |
child 7804 | fc2d1522f741 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6117
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6087
diff
changeset
|
3 |
/** @file airport.cpp */ |
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6087
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1299
diff
changeset
|
6 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1093
diff
changeset
|
7 |
#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
|
8 |
#include "map.h" |
0 | 9 |
#include "airport.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
10 |
#include "macros.h" |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
11 |
#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
|
12 |
#include "airport_movement.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4171
diff
changeset
|
13 |
#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
|
14 |
#include "helpers.hpp" |
0 | 15 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
16 |
/* 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
|
17 |
* You should either use |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
18 |
* - 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
|
19 |
* OR |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
20 |
* - 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
|
21 |
//#define DEBUG_AIRPORT false |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
22 |
|
6394
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
23 |
static AirportFTAClass *DummyAirport; |
4171 | 24 |
static AirportFTAClass *CountryAirport; |
25 |
static AirportFTAClass *CityAirport; |
|
26 |
static AirportFTAClass *Oilrig; |
|
27 |
static AirportFTAClass *Heliport; |
|
28 |
static AirportFTAClass *MetropolitanAirport; |
|
29 |
static AirportFTAClass *InternationalAirport; |
|
30 |
static AirportFTAClass *CommuterAirport; |
|
31 |
static AirportFTAClass *HeliDepot; |
|
32 |
static AirportFTAClass *IntercontinentalAirport; |
|
33 |
static AirportFTAClass *HeliStation; |
|
0 | 34 |
|
35 |
||
6247 | 36 |
void InitializeAirports() |
0 | 37 |
{ |
6394
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
38 |
DummyAirport = new AirportFTAClass( |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
39 |
_airport_moving_data_dummy, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
40 |
NULL, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
41 |
NULL, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
42 |
_airport_entries_dummy, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
43 |
AirportFTAClass::ALL, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
44 |
_airport_fta_dummy, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
45 |
NULL, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
46 |
0, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
47 |
0, 0, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
48 |
0, |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
49 |
0 |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
50 |
); |
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
51 |
|
5932 | 52 |
CountryAirport = new AirportFTAClass( |
5924 | 53 |
_airport_moving_data_country, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
54 |
_airport_terminal_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
55 |
NULL, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
56 |
_airport_entries_country, |
6025 | 57 |
AirportFTAClass::ALL | AirportFTAClass::SHORT_STRIP, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
58 |
_airport_fta_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
59 |
_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
|
60 |
lengthof(_airport_depots_country), |
6020 | 61 |
4, 3, |
6041 | 62 |
0, |
63 |
4 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
64 |
); |
0 | 65 |
|
5932 | 66 |
CityAirport = new AirportFTAClass( |
5924 | 67 |
_airport_moving_data_town, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
68 |
_airport_terminal_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
69 |
NULL, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
70 |
_airport_entries_city, |
6024 | 71 |
AirportFTAClass::ALL, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
72 |
_airport_fta_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
73 |
_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
|
74 |
lengthof(_airport_depots_city), |
6020 | 75 |
6, 6, |
6041 | 76 |
0, |
77 |
5 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
78 |
); |
0 | 79 |
|
5932 | 80 |
MetropolitanAirport = new AirportFTAClass( |
5924 | 81 |
_airport_moving_data_metropolitan, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
82 |
_airport_terminal_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
83 |
NULL, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
84 |
_airport_entries_metropolitan, |
6024 | 85 |
AirportFTAClass::ALL, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
86 |
_airport_fta_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
87 |
_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
|
88 |
lengthof(_airport_depots_metropolitan), |
6020 | 89 |
6, 6, |
6041 | 90 |
0, |
91 |
6 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
92 |
); |
0 | 93 |
|
5932 | 94 |
InternationalAirport = new AirportFTAClass( |
5924 | 95 |
_airport_moving_data_international, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
96 |
_airport_terminal_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
97 |
_airport_helipad_international, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
98 |
_airport_entries_international, |
6024 | 99 |
AirportFTAClass::ALL, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
100 |
_airport_fta_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
101 |
_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
|
102 |
lengthof(_airport_depots_international), |
6020 | 103 |
7, 7, |
6041 | 104 |
0, |
105 |
8 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
106 |
); |
0 | 107 |
|
5932 | 108 |
IntercontinentalAirport = new AirportFTAClass( |
5924 | 109 |
_airport_moving_data_intercontinental, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
110 |
_airport_terminal_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
111 |
_airport_helipad_intercontinental, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
112 |
_airport_entries_intercontinental, |
6024 | 113 |
AirportFTAClass::ALL, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
114 |
_airport_fta_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
115 |
_airport_depots_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
116 |
lengthof(_airport_depots_intercontinental), |
6020 | 117 |
9, 11, |
6041 | 118 |
0, |
119 |
10 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
120 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
121 |
|
5932 | 122 |
Heliport = new AirportFTAClass( |
5924 | 123 |
_airport_moving_data_heliport, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
124 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
125 |
_airport_helipad_heliport_oilrig, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
126 |
_airport_entries_heliport_oilrig, |
6024 | 127 |
AirportFTAClass::HELICOPTERS, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
128 |
_airport_fta_heliport_oilrig, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
129 |
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
|
130 |
0, |
6020 | 131 |
1, 1, |
6041 | 132 |
60, |
133 |
4 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
134 |
); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
135 |
|
5932 | 136 |
Oilrig = new AirportFTAClass( |
5924 | 137 |
_airport_moving_data_oilrig, |
138 |
NULL, |
|
139 |
_airport_helipad_heliport_oilrig, |
|
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
140 |
_airport_entries_heliport_oilrig, |
6024 | 141 |
AirportFTAClass::HELICOPTERS, |
5924 | 142 |
_airport_fta_heliport_oilrig, |
143 |
NULL, |
|
144 |
0, |
|
6020 | 145 |
1, 1, |
6041 | 146 |
54, |
147 |
3 |
|
5924 | 148 |
); |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
149 |
|
5932 | 150 |
CommuterAirport = new AirportFTAClass( |
5924 | 151 |
_airport_moving_data_commuter, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
152 |
_airport_terminal_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
153 |
_airport_helipad_commuter, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
154 |
_airport_entries_commuter, |
6025 | 155 |
AirportFTAClass::ALL | AirportFTAClass::SHORT_STRIP, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
156 |
_airport_fta_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
157 |
_airport_depots_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
158 |
lengthof(_airport_depots_commuter), |
6020 | 159 |
5, 4, |
6041 | 160 |
0, |
161 |
4 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
162 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
163 |
|
5932 | 164 |
HeliDepot = new AirportFTAClass( |
5924 | 165 |
_airport_moving_data_helidepot, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
166 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
167 |
_airport_helipad_helidepot, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
168 |
_airport_entries_helidepot, |
6024 | 169 |
AirportFTAClass::HELICOPTERS, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
170 |
_airport_fta_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
171 |
_airport_depots_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
172 |
lengthof(_airport_depots_helidepot), |
6020 | 173 |
2, 2, |
6041 | 174 |
0, |
175 |
4 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
176 |
); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
177 |
|
5932 | 178 |
HeliStation = new AirportFTAClass( |
5924 | 179 |
_airport_moving_data_helistation, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
180 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
181 |
_airport_helipad_helistation, |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
182 |
_airport_entries_helistation, |
6024 | 183 |
AirportFTAClass::HELICOPTERS, |
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
184 |
_airport_fta_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
185 |
_airport_depots_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
186 |
lengthof(_airport_depots_helistation), |
6020 | 187 |
4, 2, |
6041 | 188 |
0, |
189 |
4 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
190 |
); |
0 | 191 |
} |
192 |
||
6247 | 193 |
void UnInitializeAirports() |
0 | 194 |
{ |
5932 | 195 |
delete CountryAirport; |
196 |
delete CityAirport; |
|
197 |
delete Heliport; |
|
198 |
delete MetropolitanAirport; |
|
199 |
delete InternationalAirport; |
|
200 |
delete CommuterAirport; |
|
201 |
delete HeliDepot; |
|
202 |
delete IntercontinentalAirport; |
|
203 |
delete HeliStation; |
|
0 | 204 |
} |
205 |
||
5932 | 206 |
|
207 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA); |
|
208 |
static AirportFTA* AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA); |
|
209 |
static byte AirportGetTerminalCount(const byte *terminals, byte *groups); |
|
210 |
static byte AirportTestFTA(uint nofelements, const AirportFTA *layout, const byte *terminals); |
|
211 |
||
212 |
#ifdef DEBUG_AIRPORT |
|
213 |
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report); |
|
214 |
#endif |
|
215 |
||
216 |
||
217 |
AirportFTAClass::AirportFTAClass( |
|
218 |
const AirportMovingData *moving_data_, |
|
219 |
const byte *terminals_, |
|
220 |
const byte *helipads_, |
|
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
221 |
const byte *entry_points_, |
6024 | 222 |
Flags flags_, |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
223 |
const AirportFTAbuildup *apFA, |
5932 | 224 |
const TileIndexDiffC *depots_, |
225 |
const byte nof_depots_, |
|
226 |
uint size_x_, |
|
6020 | 227 |
uint size_y_, |
6041 | 228 |
byte delta_z_, |
229 |
byte catchment_ |
|
5932 | 230 |
) : |
231 |
moving_data(moving_data_), |
|
232 |
terminals(terminals_), |
|
233 |
helipads(helipads_), |
|
234 |
airport_depots(depots_), |
|
6024 | 235 |
flags(flags_), |
5932 | 236 |
nof_depots(nof_depots_), |
5938 | 237 |
nofelements(AirportGetNofElements(apFA)), |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
238 |
entry_points(entry_points_), |
5932 | 239 |
size_x(size_x_), |
6020 | 240 |
size_y(size_y_), |
6041 | 241 |
delta_z(delta_z_), |
242 |
catchment(catchment_) |
|
0 | 243 |
{ |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
244 |
byte nofterminalgroups, nofhelipadgroups; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
245 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
246 |
/* 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
|
247 |
* 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
|
248 |
* need to be changed, so don't allow that for now */ |
5932 | 249 |
uint nofterminals = AirportGetTerminalCount(terminals, &nofterminalgroups); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
250 |
if (nofterminals > MAX_TERMINALS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
4844
diff
changeset
|
251 |
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
|
252 |
assert(nofterminals <= MAX_TERMINALS); |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
253 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
254 |
|
5932 | 255 |
uint nofhelipads = AirportGetTerminalCount(helipads, &nofhelipadgroups); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
256 |
if (nofhelipads > MAX_HELIPADS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
4844
diff
changeset
|
257 |
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
|
258 |
assert(nofhelipads <= MAX_HELIPADS); |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
259 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
260 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
261 |
/* 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
|
262 |
* 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
|
263 |
* later on to build and validate the state machine */ |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
264 |
for (DiagDirection i = DIAGDIR_BEGIN; i < DIAGDIR_END; i++) { |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
265 |
if (entry_points[i] >= nofelements) { |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
266 |
DEBUG(misc, 0, "[Ap] entry (%d) must be within the airport (maximum %d)", entry_points[i], nofelements); |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
267 |
assert(entry_points[i] < nofelements); |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
268 |
} |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
269 |
} |
0 | 270 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
271 |
/* Build the state machine itself */ |
5932 | 272 |
layout = AirportBuildAutomata(nofelements, apFA); |
6036
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
273 |
DEBUG(misc, 2, "[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entries %3d, %3d, %3d, %3d", |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
274 |
nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, |
333637e97400
(svn r8759) -Feature: Allow airports to have up to 4 entry points depending on approach direction. Note: they're not yet used, but will be soon
celestar
parents:
6025
diff
changeset
|
275 |
entry_points[DIAGDIR_NE], entry_points[DIAGDIR_SE], entry_points[DIAGDIR_SW], entry_points[DIAGDIR_NW]); |
0 | 276 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
277 |
/* 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
|
278 |
* 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
|
279 |
* airport is working correctly or will not deadlock for example */ |
5932 | 280 |
uint ret = AirportTestFTA(nofelements, layout, terminals); |
281 |
if (ret != MAX_ELEMENTS) DEBUG(misc, 0, "[Ap] problem with element: %d", ret - 1); |
|
282 |
assert(ret == MAX_ELEMENTS); |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
283 |
|
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
284 |
#ifdef DEBUG_AIRPORT |
5932 | 285 |
AirportPrintOut(nofelements, layout, DEBUG_AIRPORT); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
286 |
#endif |
0 | 287 |
} |
288 |
||
5932 | 289 |
|
290 |
AirportFTAClass::~AirportFTAClass() |
|
0 | 291 |
{ |
5932 | 292 |
for (uint i = 0; i < nofelements; i++) { |
293 |
AirportFTA *current = layout[i].next; |
|
0 | 294 |
while (current != NULL) { |
5932 | 295 |
AirportFTA *next = current->next; |
0 | 296 |
free(current); |
297 |
current = next; |
|
298 |
}; |
|
299 |
} |
|
5932 | 300 |
free(layout); |
0 | 301 |
} |
302 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
303 |
/** 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
|
304 |
* 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
|
305 |
* 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
|
306 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA) |
0 | 307 |
{ |
308 |
uint16 nofelements = 0; |
|
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
309 |
int temp = apFA[0].position; |
2549 | 310 |
|
6087 | 311 |
for (uint 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
|
312 |
if (temp != apFA[i].position) { |
0 | 313 |
nofelements++; |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
314 |
temp = apFA[i].position; |
0 | 315 |
} |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
316 |
if (apFA[i].position == MAX_ELEMENTS) break; |
0 | 317 |
} |
318 |
return nofelements; |
|
319 |
} |
|
320 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
321 |
/* 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
|
322 |
* 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
|
323 |
* 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
|
324 |
static byte AirportGetTerminalCount(const byte *terminals, byte *groups) |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
325 |
{ |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
326 |
byte nof_terminals = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
327 |
*groups = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
328 |
|
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
329 |
if (terminals != NULL) { |
6087 | 330 |
uint i = terminals[0]; |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
331 |
*groups = i; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
332 |
while (i-- > 0) { |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
333 |
terminals++; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
334 |
assert(*terminals != 0); // no empty groups please |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
335 |
nof_terminals += *terminals; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
336 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
337 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
338 |
return nof_terminals; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
339 |
} |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
340 |
|
5932 | 341 |
|
342 |
static AirportFTA* AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA) |
|
0 | 343 |
{ |
5932 | 344 |
AirportFTA *FAutomata = MallocT<AirportFTA>(nofelements); |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
345 |
uint16 internalcounter = 0; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
346 |
|
5932 | 347 |
for (uint i = 0; i < nofelements; i++) { |
6087 | 348 |
AirportFTA *current = &FAutomata[i]; |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
349 |
current->position = apFA[internalcounter].position; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
350 |
current->heading = apFA[internalcounter].heading; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
351 |
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
|
352 |
current->next_position = apFA[internalcounter].next; |
0 | 353 |
|
354 |
// 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
|
355 |
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
|
356 |
AirportFTA *newNode = MallocT<AirportFTA>(1); |
2549 | 357 |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
358 |
newNode->position = apFA[internalcounter + 1].position; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
359 |
newNode->heading = apFA[internalcounter + 1].heading; |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
360 |
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
|
361 |
newNode->next_position = apFA[internalcounter + 1].next; |
0 | 362 |
// create link |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
363 |
current->next = newNode; |
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
364 |
current = current->next; |
0 | 365 |
internalcounter++; |
6087 | 366 |
} |
4842
79c4c9167d93
(svn r6768) -Cleanup: For airports change *Airport to *apc (variable naming coding style
Darkvater
parents:
4434
diff
changeset
|
367 |
current->next = NULL; |
0 | 368 |
internalcounter++; |
369 |
} |
|
5932 | 370 |
return FAutomata; |
0 | 371 |
} |
372 |
||
5932 | 373 |
|
374 |
static byte AirportTestFTA(uint nofelements, const AirportFTA *layout, const byte *terminals) |
|
0 | 375 |
{ |
5932 | 376 |
uint next_position = 0; |
0 | 377 |
|
5932 | 378 |
for (uint i = 0; i < nofelements; i++) { |
379 |
uint position = layout[i].position; |
|
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
380 |
if (position != next_position) return i; |
5932 | 381 |
const AirportFTA *first = &layout[i]; |
0 | 382 |
|
6087 | 383 |
for (const AirportFTA *current = first; current != NULL; current = current->next) { |
4844
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
384 |
/* 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
|
385 |
* - 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
|
386 |
* - 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
|
387 |
if (current->heading > MAX_HEADINGS) { |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
388 |
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
|
389 |
if (current == first && current->next == NULL) return i; |
5932 | 390 |
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
|
391 |
} |
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
392 |
|
10fde6a49e04
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents:
4843
diff
changeset
|
393 |
/* 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
|
394 |
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
|
395 |
/* 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
|
396 |
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
|
397 |
/* A next position must be within bounds */ |
5932 | 398 |
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
|
399 |
} |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
400 |
next_position++; |
0 | 401 |
} |
402 |
return MAX_ELEMENTS; |
|
403 |
} |
|
404 |
||
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
405 |
#ifdef DEBUG_AIRPORT |
2549 | 406 |
static const char* const _airport_heading_strings[] = { |
0 | 407 |
"TO_ALL", |
408 |
"HANGAR", |
|
409 |
"TERM1", |
|
410 |
"TERM2", |
|
411 |
"TERM3", |
|
412 |
"TERM4", |
|
413 |
"TERM5", |
|
414 |
"TERM6", |
|
415 |
"HELIPAD1", |
|
416 |
"HELIPAD2", |
|
417 |
"TAKEOFF", |
|
418 |
"STARTTAKEOFF", |
|
419 |
"ENDTAKEOFF", |
|
420 |
"HELITAKEOFF", |
|
421 |
"FLYING", |
|
422 |
"LANDING", |
|
423 |
"ENDLANDING", |
|
424 |
"HELILANDING", |
|
425 |
"HELIENDLANDING", |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
426 |
"TERM7", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
427 |
"TERM8", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
428 |
"HELIPAD3", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
429 |
"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
|
430 |
"DUMMY" // extra heading for 255 |
0 | 431 |
}; |
432 |
||
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
433 |
static uint AirportBlockToString(uint32 block) |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
434 |
{ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
435 |
uint i = 0; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
436 |
if (block & 0xffff0000) { block >>= 16; i += 16; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
437 |
if (block & 0x0000ff00) { block >>= 8; i += 8; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
438 |
if (block & 0x000000f0) { block >>= 4; i += 4; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
439 |
if (block & 0x0000000c) { block >>= 2; i += 2; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
440 |
if (block & 0x00000002) { i += 1; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
441 |
return i; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
442 |
} |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
443 |
|
5932 | 444 |
|
445 |
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report) |
|
0 | 446 |
{ |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
447 |
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
|
448 |
|
5932 | 449 |
for (uint i = 0; i < nofelements; i++) { |
6087 | 450 |
for (const AirportFTA *current = &layout[i]; current != NULL; current = current->next) { |
0 | 451 |
if (full_report) { |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
452 |
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
|
453 |
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
|
454 |
current->next_position, _airport_heading_strings[heading], |
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
455 |
AirportBlockToString(current->block)); |
2549 | 456 |
} else { |
4843
4bef85baee3f
(svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents:
4842
diff
changeset
|
457 |
printf("P:%2d NP:%2d", current->position, current->next_position); |
0 | 458 |
} |
459 |
} |
|
460 |
printf("\n"); |
|
461 |
} |
|
462 |
} |
|
2549 | 463 |
#endif |
0 | 464 |
|
4171 | 465 |
const AirportFTAClass *GetAirport(const byte airport_type) |
0 | 466 |
{ |
467 |
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code |
|
468 |
// needs constant change if more airports are added |
|
469 |
switch (airport_type) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
470 |
default: NOT_REACHED(); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
471 |
case AT_SMALL: return CountryAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
472 |
case AT_LARGE: return CityAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
473 |
case AT_METROPOLITAN: return MetropolitanAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
474 |
case AT_HELIPORT: return Heliport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
475 |
case AT_OILRIG: return Oilrig; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
476 |
case AT_INTERNATIONAL: return InternationalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
477 |
case AT_COMMUTER: return CommuterAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
478 |
case AT_HELIDEPOT: return HeliDepot; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
479 |
case AT_INTERCON: return IntercontinentalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
480 |
case AT_HELISTATION: return HeliStation; |
6394
dabe045f6f14
(svn r9524) -Fix(FS#640,r8755): Implemented a "dummy" State Machine for stations who got their airport removed while there were still aircraft within the State Machine (and thus caused asserts)
celestar
parents:
6247
diff
changeset
|
481 |
case AT_DUMMY: return DummyAirport; |
0 | 482 |
} |
483 |
} |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
484 |
|
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
|
485 |
|
6247 | 486 |
uint32 GetValidAirports() |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
487 |
{ |
5971 | 488 |
uint32 mask = 0; |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
489 |
|
5971 | 490 |
if (_cur_year < 1960 || _patches.always_small_airport) SETBIT(mask, 0); // small airport |
491 |
if (_cur_year >= 1955) SETBIT(mask, 1); // city airport |
|
492 |
if (_cur_year >= 1963) SETBIT(mask, 2); // heliport |
|
493 |
if (_cur_year >= 1980) SETBIT(mask, 3); // metropolitan airport |
|
494 |
if (_cur_year >= 1990) SETBIT(mask, 4); // international airport |
|
495 |
if (_cur_year >= 1983) SETBIT(mask, 5); // commuter airport |
|
496 |
if (_cur_year >= 1976) SETBIT(mask, 6); // helidepot |
|
497 |
if (_cur_year >= 2002) SETBIT(mask, 7); // intercontinental airport |
|
498 |
if (_cur_year >= 1980) SETBIT(mask, 8); // helistation |
|
499 |
return mask; |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
500 |
} |