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