airport.c
author pasky
Mon, 07 Mar 2005 13:20:22 +0000
changeset 1451 eb24b5a58340
parent 1299 39c06aba09aa
child 1891 862800791170
permissions -rw-r--r--
(svn r1955) Fix: Make the town growth frequency scale properly both up and down. The scaling is now also based on the number of towns instead of the map size. (In cooperation with HackyKid.)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
69
f8c29cdb388e (svn r70) -Fix: typo in english.txt
darkvater
parents: 65
diff changeset
     2
#include "ttd.h"
1299
39c06aba09aa (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1093
diff changeset
     3
#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
     4
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "airport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
AirportFTAClass *CountryAirport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
AirportFTAClass *CityAirport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
AirportFTAClass *Heliport, *Oilrig;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
AirportFTAClass *MetropolitanAirport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
AirportFTAClass *InternationalAirport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
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
    14
																				const byte *terminals, const byte *helipads,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
																				const byte entry_point,  const byte acc_planes,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
																				const AirportFTAbuildup *FA,
909
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 699
diff changeset
    17
																				const TileIndexDiffC *depots, const byte nof_depots);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
static byte AirportTestFTA(const AirportFTAClass *Airport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
static byte AirportBlockToString(uint32 block);*/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
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
    26
void InitializeAirports(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	// country airport
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    29
	CountryAirport = malloc(sizeof(AirportFTAClass));
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    30
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    31
	AirportFTAClass_Constructor(
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    32
		CountryAirport,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    33
		_airport_terminal_country,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    34
		NULL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    35
		16,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    36
		ALL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    37
		_airport_fta_country,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    38
		_airport_depots_country,
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    39
		lengthof(_airport_depots_country)
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    40
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	// city airport
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    43
	CityAirport = malloc(sizeof(AirportFTAClass));
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    44
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    45
	AirportFTAClass_Constructor(
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    46
		CityAirport,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    47
		_airport_terminal_city,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    48
		NULL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    49
		19,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    50
		ALL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    51
		_airport_fta_city,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    52
		_airport_depots_city,
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    53
		lengthof(_airport_depots_city)
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    54
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	// metropolitan airport
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    57
	MetropolitanAirport = 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
		MetropolitanAirport,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    61
		_airport_terminal_metropolitan,
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
		20,
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_metropolitan,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    66
		_airport_depots_metropolitan,
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    67
		lengthof(_airport_depots_metropolitan)
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    68
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	// international airport
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    72
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    73
	AirportFTAClass_Constructor(
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    74
		InternationalAirport,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    75
		_airport_terminal_international,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    76
		_airport_helipad_international,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    77
		37,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    78
		ALL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    79
		_airport_fta_international,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    80
		_airport_depots_international,
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    81
		lengthof(_airport_depots_international)
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    82
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	// heliport, oilrig
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    86
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    87
	AirportFTAClass_Constructor(
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    88
		Heliport,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    89
		NULL,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    90
		_airport_helipad_heliport_oilrig,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    91
		7,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    92
		HELICOPTERS_ONLY,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    93
		_airport_fta_heliport_oilrig,
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    94
		NULL,
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    95
		0
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
    96
	);
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
    97
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	Oilrig = Heliport;  // exactly the same structure for heliport/oilrig, so share state machine
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
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
   101
void UnInitializeAirports(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	AirportFTAClass_Destructor(CountryAirport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	AirportFTAClass_Destructor(CityAirport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	AirportFTAClass_Destructor(Heliport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	AirportFTAClass_Destructor(MetropolitanAirport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	AirportFTAClass_Destructor(InternationalAirport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
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
   111
																				const byte *terminals, const byte *helipads,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
																				const byte entry_point, const byte acc_planes,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
																				const AirportFTAbuildup *FA,
909
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 699
diff changeset
   114
																				const TileIndexDiffC *depots, const byte nof_depots)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
{
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   116
	byte nofterminals, nofhelipads;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   117
	byte nofterminalgroups = 0;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   118
	byte nofhelipadgroups = 0;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   119
	const byte * curr;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   120
	int i;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   121
	nofterminals = nofhelipads = 0;
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
   122
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   123
	//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
   124
	if (terminals != NULL) {
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   125
		i = terminals[0];
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   126
		nofterminalgroups = i;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   127
		curr = terminals;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   128
		while (i-- > 0) {
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   129
			curr++;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   130
			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
   131
			nofterminals += *curr;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   132
		}
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
   133
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   134
	}
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   135
	Airport->terminals = terminals;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   136
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
   137
	//read helipads
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   138
	if (helipads != NULL) {
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   139
		i = helipads[0];
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   140
		nofhelipadgroups = i;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   141
		curr = helipads;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   142
		while (i-- > 0) {
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   143
			curr++;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   144
			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
   145
			nofhelipads += *curr;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   146
		}
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 950
diff changeset
   147
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   148
	}
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   149
	Airport->helipads = helipads;
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   150
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	// if there are more terminals than 6, internal variables have to be changed, so don't allow that
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
	// same goes for helipads
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
	if (nofterminals > MAX_TERMINALS) { printf("Currently only maximum of %2d terminals are supported (you wanted %2d)\n", MAX_TERMINALS, nofterminals);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	if (nofhelipads > MAX_HELIPADS) { printf("Currently only maximum of %2d helipads are supported (you wanted %2d)\n", MAX_HELIPADS, nofhelipads);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	// terminals/helipads are divided into groups. Groups are computed by dividing the number
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	// of terminals by the number of groups. Half in half. If #terminals is uneven, first group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	// will get the less # of terminals
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	assert(nofterminals <= MAX_TERMINALS);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	assert(nofhelipads <= MAX_HELIPADS);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	Airport->nofelements = AirportGetNofElements(FA);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	// check
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	if (entry_point >= Airport->nofelements) {printf("Entry point (%2d) must be within the airport positions (which is max %2d)\n", entry_point, Airport->nofelements);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	assert(entry_point < Airport->nofelements);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	Airport->acc_planes = acc_planes;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	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
   169
	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
   170
	Airport->nof_depots = nof_depots;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
	// build the state machine
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	AirportBuildAutomata(Airport, FA);
950
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   175
		DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s); Entry Point %d", Airport->nofelements,
165341d74973 (svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents: 909
diff changeset
   176
				  nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, Airport->entry_point);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
		byte _retval = AirportTestFTA(Airport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
		if (_retval != MAX_ELEMENTS) {printf("ERROR with element: %d\n", _retval-1);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
		assert(_retval == MAX_ELEMENTS);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	// print out full information
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	// true  -- full info including heading, block, etc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	// false -- short info, only position and next position
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	//AirportPrintOut(Airport, false);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
static void AirportFTAClass_Destructor(AirportFTAClass *Airport)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	AirportFTA *current, *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	for (i = 0; i < Airport->nofelements; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
		current = Airport->layout[i].next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
		while (current != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
			next = current->next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
			free(current);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
			current = next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
		};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	free(Airport->layout);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	free(Airport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	uint16 nofelements = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
	int temp = FA[0].position;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
	for (i = 0; i < MAX_ELEMENTS; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
		if (temp != FA[i].position) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
			nofelements++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
			temp = FA[i].position;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
		if (FA[i].position == MAX_ELEMENTS) {break;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	return nofelements;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
	AirportFTA *FAutomata;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	AirportFTA *current;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
	uint16 internalcounter, i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
	FAutomata = (AirportFTA *)malloc(sizeof(AirportFTA) * Airport->nofelements);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
	Airport->layout = FAutomata;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	internalcounter = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
	for (i = 0; i < Airport->nofelements; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
		current = &Airport->layout[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
		current->position = FA[internalcounter].position;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
		current->heading  = FA[internalcounter].heading;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
		current->block    = FA[internalcounter].block;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
		current->next_position = FA[internalcounter].next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
		// outgoing nodes from the same position, create linked list
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
		while (current->position == FA[internalcounter+1].position) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
			AirportFTA *newNode = (AirportFTA *)malloc(sizeof(AirportFTA));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
			newNode->position = FA[internalcounter+1].position;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
			newNode->heading  = FA[internalcounter+1].heading;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
			newNode->block    = FA[internalcounter+1].block;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
			newNode->next_position = FA[internalcounter+1].next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			// create link
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
			current->next_in_chain = newNode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
			current = current->next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			internalcounter++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
		} // while
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
		current->next_in_chain = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		internalcounter++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
static byte AirportTestFTA(const AirportFTAClass *Airport)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
	byte position, i, next_element;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
	AirportFTA *temp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
	next_element = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
	for (i = 0; i < Airport->nofelements; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		position = Airport->layout[i].position;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		if (position != next_element) {return i;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
		temp = &Airport->layout[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
			if (temp->heading > MAX_HEADINGS && temp->heading != 255) {return i;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			if (temp->heading == 0 && temp->next_in_chain != 0) {return i;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
			if (position != temp->position) {return i;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
			if (temp->next_position >= Airport->nofelements) {return i;}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
			temp = temp->next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
		} while (temp != NULL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
		next_element++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	return MAX_ELEMENTS;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
static const char* const _airport_heading_strings[MAX_HEADINGS+2] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	"TO_ALL",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	"HANGAR",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	"TERM1",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	"TERM2",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
	"TERM3",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	"TERM4",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	"TERM5",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	"TERM6",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
	"HELIPAD1",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	"HELIPAD2",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	"TAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	"STARTTAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	"ENDTAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	"HELITAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	"FLYING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	"LANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	"ENDLANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	"HELILANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
	"HELIENDLANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
	"DUMMY"	// extra heading for 255
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
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
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
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
	AirportFTA *temp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	uint16 i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	byte heading;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	printf("(P = Current Position; NP = Next Position)\n");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
	for (i = 0; i < Airport->nofelements; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
		temp = &Airport->layout[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		if (full_report) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
			heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
			printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
						 _airport_heading_strings[heading], AirportBlockToString(temp->block));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
		else { printf("P:%2d NP:%2d", temp->position, temp->next_position);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
		while (temp->next_in_chain != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
			temp = temp->next_in_chain;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
			if (full_report) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
				heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
				printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
							_airport_heading_strings[heading], AirportBlockToString(temp->block));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
			else { printf("P:%2d NP:%2d", temp->position, temp->next_position);}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
		printf("\n");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
	}
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
static byte AirportBlockToString(uint32 block)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	byte i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	if (block & 0xffff0000) { block >>= 16; i += 16; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	if (block & 0x0000ff00) { block >>= 8;  i += 8; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
	if (block & 0x000000f0) { block >>= 4;  i += 4; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
	if (block & 0x0000000c) { block >>= 2;  i += 2; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
	if (block & 0x00000002) { i += 1; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
	return i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
}*/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
const AirportFTAClass* GetAirport(const byte airport_type)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	AirportFTAClass *Airport = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	//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
   346
	// needs constant change if more airports are added
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
	switch (airport_type) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
		case AT_SMALL: Airport = CountryAirport; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
		case AT_LARGE: Airport = CityAirport; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
		case AT_METROPOLITAN: Airport = MetropolitanAirport; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
		case AT_HELIPORT: Airport = Heliport; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
		case AT_OILRIG: Airport = Oilrig; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		case AT_INTERNATIONAL: Airport = InternationalAirport; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
			#ifdef DEBUG__
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
				printf("Airport AircraftNextAirportPos_and_Order not yet implemented\n");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
			#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
			assert(airport_type <= AT_INTERNATIONAL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	return Airport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
}