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