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