author | miham |
Thu, 29 Jun 2006 10:31:08 +0000 | |
changeset 4097 | 0bdec93e9f13 |
parent 4077 | d4d440dd8925 |
child 4171 | 5c6e60c392c3 |
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" |
0 | 11 |
|
2752 | 12 |
static AirportFTAClass* CountryAirport; |
13 |
static AirportFTAClass* CityAirport; |
|
14 |
static AirportFTAClass* Oilrig; |
|
15 |
static AirportFTAClass* Heliport; |
|
16 |
static AirportFTAClass* MetropolitanAirport; |
|
17 |
static AirportFTAClass* InternationalAirport; |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
18 |
static AirportFTAClass* CommuterAirport; |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
19 |
static AirportFTAClass* HeliDepot; |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
20 |
static AirportFTAClass* IntercontinentalAirport; |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
21 |
static AirportFTAClass* HeliStation; |
0 | 22 |
|
23 |
static void AirportFTAClass_Constructor(AirportFTAClass *Airport, |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
24 |
const byte *terminals, const byte *helipads, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
25 |
const byte entry_point, const byte acc_planes, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
26 |
const AirportFTAbuildup *FA, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
27 |
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
|
28 |
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
|
29 |
); |
0 | 30 |
static void AirportFTAClass_Destructor(AirportFTAClass *Airport); |
31 |
||
32 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA); |
|
33 |
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA); |
|
34 |
static byte AirportTestFTA(const AirportFTAClass *Airport); |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
35 |
#if 0 |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
36 |
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
37 |
#endif |
0 | 38 |
|
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
|
39 |
void InitializeAirports(void) |
0 | 40 |
{ |
41 |
// country airport |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
42 |
CountryAirport = malloc(sizeof(AirportFTAClass)); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
43 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
44 |
AirportFTAClass_Constructor( |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
45 |
CountryAirport, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
46 |
_airport_terminal_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
47 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
48 |
16, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
49 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
50 |
_airport_fta_country, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
51 |
_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
|
52 |
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
|
53 |
4, 3 |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
54 |
); |
0 | 55 |
|
56 |
// city airport |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
57 |
CityAirport = malloc(sizeof(AirportFTAClass)); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
58 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
59 |
AirportFTAClass_Constructor( |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
60 |
CityAirport, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
61 |
_airport_terminal_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
62 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
63 |
19, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
64 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
65 |
_airport_fta_city, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
66 |
_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
|
67 |
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
|
68 |
6, 6 |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
69 |
); |
0 | 70 |
|
71 |
// metropolitan airport |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
72 |
MetropolitanAirport = malloc(sizeof(AirportFTAClass)); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
73 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
74 |
AirportFTAClass_Constructor( |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
75 |
MetropolitanAirport, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
76 |
_airport_terminal_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
77 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
78 |
20, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
79 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
80 |
_airport_fta_metropolitan, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
81 |
_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
|
82 |
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
|
83 |
6, 6 |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
84 |
); |
0 | 85 |
|
86 |
// international airport |
|
87 |
InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
88 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
89 |
AirportFTAClass_Constructor( |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
90 |
InternationalAirport, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
91 |
_airport_terminal_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
92 |
_airport_helipad_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
93 |
37, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
94 |
ALL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
95 |
_airport_fta_international, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
96 |
_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
|
97 |
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
|
98 |
7, 7 |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
99 |
); |
0 | 100 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
101 |
// intercontintental airport |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
102 |
IntercontinentalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
103 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
104 |
AirportFTAClass_Constructor( |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
105 |
IntercontinentalAirport, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
106 |
_airport_terminal_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
107 |
_airport_helipad_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
108 |
43, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
109 |
ALL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
110 |
_airport_fta_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
111 |
_airport_depots_intercontinental, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
112 |
lengthof(_airport_depots_intercontinental), |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
113 |
9,11 |
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 |
|
0 | 116 |
// heliport, oilrig |
117 |
Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
118 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
119 |
AirportFTAClass_Constructor( |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
120 |
Heliport, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
121 |
NULL, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
122 |
_airport_helipad_heliport_oilrig, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
123 |
7, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
124 |
HELICOPTERS_ONLY, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
125 |
_airport_fta_heliport_oilrig, |
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
1, 1 |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
129 |
); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
130 |
|
0 | 131 |
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
|
132 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
133 |
// commuter airport |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
134 |
CommuterAirport = malloc(sizeof(AirportFTAClass)); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
135 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
136 |
AirportFTAClass_Constructor( |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
137 |
CommuterAirport, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
138 |
_airport_terminal_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
139 |
_airport_helipad_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
140 |
22, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
141 |
ALL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
142 |
_airport_fta_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
143 |
_airport_depots_commuter, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
144 |
lengthof(_airport_depots_commuter), |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
145 |
5,4 |
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 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
148 |
// helidepot airport |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
149 |
HeliDepot = malloc(sizeof(AirportFTAClass)); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
150 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
151 |
AirportFTAClass_Constructor( |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
152 |
HeliDepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
153 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
154 |
_airport_helipad_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
155 |
4, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
156 |
HELICOPTERS_ONLY, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
157 |
_airport_fta_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
158 |
_airport_depots_helidepot, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
159 |
lengthof(_airport_depots_helidepot), |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
160 |
2,2 |
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 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
163 |
// helistation airport |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
164 |
HeliStation = malloc(sizeof(AirportFTAClass)); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
165 |
|
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
166 |
AirportFTAClass_Constructor( |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
167 |
HeliStation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
168 |
NULL, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
169 |
_airport_helipad_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
170 |
25, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
171 |
HELICOPTERS_ONLY, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
172 |
_airport_fta_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
173 |
_airport_depots_helistation, |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
174 |
lengthof(_airport_depots_helistation), |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
175 |
4,2 |
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 |
|
0 | 178 |
} |
179 |
||
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
|
180 |
void UnInitializeAirports(void) |
0 | 181 |
{ |
182 |
AirportFTAClass_Destructor(CountryAirport); |
|
183 |
AirportFTAClass_Destructor(CityAirport); |
|
184 |
AirportFTAClass_Destructor(Heliport); |
|
185 |
AirportFTAClass_Destructor(MetropolitanAirport); |
|
186 |
AirportFTAClass_Destructor(InternationalAirport); |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
187 |
AirportFTAClass_Destructor(CommuterAirport); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
188 |
AirportFTAClass_Destructor(HeliDepot); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
189 |
AirportFTAClass_Destructor(IntercontinentalAirport); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
190 |
AirportFTAClass_Destructor(HeliStation); |
0 | 191 |
} |
192 |
||
193 |
static void AirportFTAClass_Constructor(AirportFTAClass *Airport, |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
194 |
const byte *terminals, const byte *helipads, |
0 | 195 |
const byte entry_point, const byte acc_planes, |
196 |
const AirportFTAbuildup *FA, |
|
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
|
197 |
const TileIndexDiffC *depots, const byte nof_depots, |
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
|
198 |
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
|
199 |
) |
0 | 200 |
{ |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
201 |
byte nofterminals, nofhelipads; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
202 |
byte nofterminalgroups = 0; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
203 |
byte nofhelipadgroups = 0; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
204 |
const byte * curr; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
205 |
int i; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
206 |
nofterminals = nofhelipads = 0; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
207 |
|
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
|
208 |
Airport->size_x = size_x; |
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 |
Airport->size_y = 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 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
211 |
//now we read the number of terminals we have |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
212 |
if (terminals != NULL) { |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
213 |
i = terminals[0]; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
214 |
nofterminalgroups = i; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
215 |
curr = terminals; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
216 |
while (i-- > 0) { |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
217 |
curr++; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
218 |
assert(*curr != 0); //we don't want to have an empty group |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
219 |
nofterminals += *curr; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
220 |
} |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
221 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
222 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
223 |
Airport->terminals = terminals; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
224 |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
225 |
//read helipads |
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
226 |
if (helipads != NULL) { |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
227 |
i = helipads[0]; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
228 |
nofhelipadgroups = i; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
229 |
curr = helipads; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
230 |
while (i-- > 0) { |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
231 |
curr++; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
232 |
assert(*curr != 0); //no empty groups please |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
233 |
nofhelipads += *curr; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
234 |
} |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
950
diff
changeset
|
235 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
236 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
237 |
Airport->helipads = helipads; |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
909
diff
changeset
|
238 |
|
0 | 239 |
// if there are more terminals than 6, internal variables have to be changed, so don't allow that |
240 |
// same goes for helipads |
|
241 |
if (nofterminals > MAX_TERMINALS) { printf("Currently only maximum of %2d terminals are supported (you wanted %2d)\n", MAX_TERMINALS, nofterminals);} |
|
242 |
if (nofhelipads > MAX_HELIPADS) { printf("Currently only maximum of %2d helipads are supported (you wanted %2d)\n", MAX_HELIPADS, nofhelipads);} |
|
243 |
// terminals/helipads are divided into groups. Groups are computed by dividing the number |
|
244 |
// of terminals by the number of groups. Half in half. If #terminals is uneven, first group |
|
245 |
// will get the less # of terminals |
|
246 |
||
247 |
assert(nofterminals <= MAX_TERMINALS); |
|
248 |
assert(nofhelipads <= MAX_HELIPADS); |
|
249 |
||
250 |
Airport->nofelements = AirportGetNofElements(FA); |
|
251 |
// check |
|
252 |
if (entry_point >= Airport->nofelements) {printf("Entry point (%2d) must be within the airport positions (which is max %2d)\n", entry_point, Airport->nofelements);} |
|
253 |
assert(entry_point < Airport->nofelements); |
|
254 |
||
255 |
Airport->acc_planes = acc_planes; |
|
256 |
Airport->entry_point = entry_point; |
|
699
604af534c65d
(svn r1149) Fix hack which abuses first TileIndex of airport depot array as number of depots (similar change as in map branch)
tron
parents:
679
diff
changeset
|
257 |
Airport->airport_depots = depots; |
604af534c65d
(svn r1149) Fix hack which abuses first TileIndex of airport depot array as number of depots (similar change as in map branch)
tron
parents:
679
diff
changeset
|
258 |
Airport->nof_depots = nof_depots; |
0 | 259 |
|
260 |
||
261 |
// build the state machine |
|
262 |
AirportBuildAutomata(Airport, FA); |
|
2549 | 263 |
DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s); Entry Point %d", |
264 |
Airport->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, Airport->entry_point |
|
265 |
); |
|
0 | 266 |
|
267 |
||
268 |
{ |
|
2549 | 269 |
byte ret = AirportTestFTA(Airport); |
270 |
if (ret != MAX_ELEMENTS) printf("ERROR with element: %d\n", ret - 1); |
|
271 |
assert(ret == MAX_ELEMENTS); |
|
0 | 272 |
} |
273 |
// print out full information |
|
274 |
// true -- full info including heading, block, etc |
|
275 |
// false -- short info, only position and next position |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
276 |
#if 0 |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
277 |
AirportPrintOut(Airport, false); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
278 |
#endif |
0 | 279 |
} |
280 |
||
281 |
static void AirportFTAClass_Destructor(AirportFTAClass *Airport) |
|
282 |
{ |
|
283 |
int i; |
|
284 |
AirportFTA *current, *next; |
|
285 |
||
286 |
for (i = 0; i < Airport->nofelements; i++) { |
|
287 |
current = Airport->layout[i].next_in_chain; |
|
288 |
while (current != NULL) { |
|
289 |
next = current->next_in_chain; |
|
290 |
free(current); |
|
291 |
current = next; |
|
292 |
}; |
|
293 |
} |
|
294 |
free(Airport->layout); |
|
295 |
free(Airport); |
|
296 |
} |
|
297 |
||
298 |
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA) |
|
299 |
{ |
|
300 |
int i; |
|
301 |
uint16 nofelements = 0; |
|
302 |
int temp = FA[0].position; |
|
2549 | 303 |
|
0 | 304 |
for (i = 0; i < MAX_ELEMENTS; i++) { |
305 |
if (temp != FA[i].position) { |
|
306 |
nofelements++; |
|
307 |
temp = FA[i].position; |
|
308 |
} |
|
2549 | 309 |
if (FA[i].position == MAX_ELEMENTS) break; |
0 | 310 |
} |
311 |
return nofelements; |
|
312 |
} |
|
313 |
||
314 |
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA) |
|
315 |
{ |
|
316 |
AirportFTA *FAutomata; |
|
317 |
AirportFTA *current; |
|
318 |
uint16 internalcounter, i; |
|
2549 | 319 |
FAutomata = malloc(sizeof(AirportFTA) * Airport->nofelements); |
0 | 320 |
Airport->layout = FAutomata; |
321 |
internalcounter = 0; |
|
322 |
||
323 |
for (i = 0; i < Airport->nofelements; i++) { |
|
324 |
current = &Airport->layout[i]; |
|
325 |
current->position = FA[internalcounter].position; |
|
326 |
current->heading = FA[internalcounter].heading; |
|
327 |
current->block = FA[internalcounter].block; |
|
328 |
current->next_position = FA[internalcounter].next_in_chain; |
|
329 |
||
330 |
// outgoing nodes from the same position, create linked list |
|
2549 | 331 |
while (current->position == FA[internalcounter + 1].position) { |
332 |
AirportFTA* newNode = malloc(sizeof(AirportFTA)); |
|
333 |
||
334 |
newNode->position = FA[internalcounter + 1].position; |
|
335 |
newNode->heading = FA[internalcounter + 1].heading; |
|
336 |
newNode->block = FA[internalcounter + 1].block; |
|
337 |
newNode->next_position = FA[internalcounter + 1].next_in_chain; |
|
0 | 338 |
// create link |
339 |
current->next_in_chain = newNode; |
|
340 |
current = current->next_in_chain; |
|
341 |
internalcounter++; |
|
342 |
} // while |
|
343 |
current->next_in_chain = NULL; |
|
344 |
internalcounter++; |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
static byte AirportTestFTA(const AirportFTAClass *Airport) |
|
349 |
{ |
|
350 |
byte position, i, next_element; |
|
351 |
AirportFTA *temp; |
|
352 |
next_element = 0; |
|
353 |
||
354 |
for (i = 0; i < Airport->nofelements; i++) { |
|
355 |
position = Airport->layout[i].position; |
|
2549 | 356 |
if (position != next_element) return i; |
0 | 357 |
temp = &Airport->layout[i]; |
358 |
||
359 |
do { |
|
2549 | 360 |
if (temp->heading > MAX_HEADINGS && temp->heading != 255) return i; |
361 |
if (temp->heading == 0 && temp->next_in_chain != 0) return i; |
|
362 |
if (position != temp->position) return i; |
|
363 |
if (temp->next_position >= Airport->nofelements) return i; |
|
0 | 364 |
temp = temp->next_in_chain; |
365 |
} while (temp != NULL); |
|
366 |
next_element++; |
|
367 |
} |
|
368 |
return MAX_ELEMENTS; |
|
369 |
} |
|
370 |
||
2549 | 371 |
#if 0 |
372 |
static const char* const _airport_heading_strings[] = { |
|
0 | 373 |
"TO_ALL", |
374 |
"HANGAR", |
|
375 |
"TERM1", |
|
376 |
"TERM2", |
|
377 |
"TERM3", |
|
378 |
"TERM4", |
|
379 |
"TERM5", |
|
380 |
"TERM6", |
|
381 |
"HELIPAD1", |
|
382 |
"HELIPAD2", |
|
383 |
"TAKEOFF", |
|
384 |
"STARTTAKEOFF", |
|
385 |
"ENDTAKEOFF", |
|
386 |
"HELITAKEOFF", |
|
387 |
"FLYING", |
|
388 |
"LANDING", |
|
389 |
"ENDLANDING", |
|
390 |
"HELILANDING", |
|
391 |
"HELIENDLANDING", |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
392 |
"TERM7", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
393 |
"TERM8", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
394 |
"HELIPAD3", |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
395 |
"HELIPAD4", |
0 | 396 |
"DUMMY" // extra heading for 255 |
397 |
}; |
|
398 |
||
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
399 |
|
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
400 |
static uint AirportBlockToString(uint32 block) |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
401 |
{ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
402 |
uint i = 0; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
403 |
if (block & 0xffff0000) { block >>= 16; i += 16; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
404 |
if (block & 0x0000ff00) { block >>= 8; i += 8; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
405 |
if (block & 0x000000f0) { block >>= 4; i += 4; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
406 |
if (block & 0x0000000c) { block >>= 2; i += 2; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
407 |
if (block & 0x00000002) { i += 1; } |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
408 |
return i; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
409 |
} |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
410 |
|
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
411 |
|
0 | 412 |
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report) |
413 |
{ |
|
414 |
byte heading; |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
415 |
uint i; |
0 | 416 |
|
417 |
printf("(P = Current Position; NP = Next Position)\n"); |
|
418 |
for (i = 0; i < Airport->nofelements; i++) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
419 |
const AirportFTA* temp = &Airport->layout[i]; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
420 |
|
0 | 421 |
if (full_report) { |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
422 |
heading = (temp->heading == 255) ? MAX_HEADINGS + 1 : temp->heading; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
423 |
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
424 |
temp->position, temp->next_position, |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
425 |
_airport_heading_strings[heading], AirportBlockToString(temp->block) |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
426 |
); |
2549 | 427 |
} else { |
428 |
printf("P:%2d NP:%2d", temp->position, temp->next_position); |
|
0 | 429 |
} |
430 |
while (temp->next_in_chain != NULL) { |
|
431 |
temp = temp->next_in_chain; |
|
432 |
if (full_report) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
433 |
heading = (temp->heading == 255) ? MAX_HEADINGS + 1 : temp->heading; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
434 |
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
435 |
temp->position, temp->next_position, |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
436 |
_airport_heading_strings[heading], AirportBlockToString(temp->block) |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
437 |
); |
2549 | 438 |
} else { |
439 |
printf("P:%2d NP:%2d", temp->position, temp->next_position); |
|
0 | 440 |
} |
441 |
} |
|
442 |
printf("\n"); |
|
443 |
} |
|
444 |
} |
|
2549 | 445 |
#endif |
0 | 446 |
|
447 |
const AirportFTAClass* GetAirport(const byte airport_type) |
|
448 |
{ |
|
449 |
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code |
|
450 |
// needs constant change if more airports are added |
|
451 |
switch (airport_type) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
452 |
default: NOT_REACHED(); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
453 |
case AT_SMALL: return CountryAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
454 |
case AT_LARGE: return CityAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
455 |
case AT_METROPOLITAN: return MetropolitanAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
456 |
case AT_HELIPORT: return Heliport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
457 |
case AT_OILRIG: return Oilrig; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
458 |
case AT_INTERNATIONAL: return InternationalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
459 |
case AT_COMMUTER: return CommuterAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
460 |
case AT_HELIDEPOT: return HeliDepot; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
461 |
case AT_INTERCON: return IntercontinentalAirport; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
462 |
case AT_HELISTATION: return HeliStation; |
0 | 463 |
} |
464 |
} |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
465 |
|
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
|
466 |
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
|
467 |
{ |
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
|
468 |
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
|
469 |
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
|
470 |
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
|
471 |
} |
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 |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
473 |
uint32 GetValidAirports(void) |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
474 |
{ |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
475 |
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
|
476 |
|
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
477 |
// 1980-1-1 is --> 21915 |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
478 |
// 1990-1-1 is --> 25568 |
2639 | 479 |
if (_date >= 21915) SETBIT(bytemask, 3); // metropilitan airport 1980 |
480 |
if (_date >= 25568) SETBIT(bytemask, 4); // international airport 1990 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
481 |
if (_date >= 23011) SETBIT(bytemask, 5); // commuter airport 1983 |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
482 |
if (_date >= 20455) SETBIT(bytemask, 6); // helidepot 1976 |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
483 |
if (_date >= 29951) SETBIT(bytemask, 7); // intercontinental airport 2002 |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3876
diff
changeset
|
484 |
if (_date >= 21915) SETBIT(bytemask, 8); // helistation 1980 |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
485 |
return bytemask; |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
486 |
} |