airport.c
changeset 1019 6bae6c11e865
parent 950 165341d74973
child 1093 4fdc46eaf423
equal deleted inserted replaced
1018:3212d4365653 1019:6bae6c11e865
    24 
    24 
    25 void InitializeAirports()
    25 void InitializeAirports()
    26 {
    26 {
    27 	// country airport
    27 	// country airport
    28 	CountryAirport = malloc(sizeof(AirportFTAClass));
    28 	CountryAirport = malloc(sizeof(AirportFTAClass));
    29 	
    29 
    30 	AirportFTAClass_Constructor(
    30 	AirportFTAClass_Constructor(
    31 		CountryAirport, 
    31 		CountryAirport,
    32 		_airport_terminal_country, 
    32 		_airport_terminal_country,
    33 		NULL, 
    33 		NULL,
    34 		16, 
    34 		16,
    35 		ALL, 
    35 		ALL,
    36 		_airport_fta_country, 
    36 		_airport_fta_country,
    37 		_airport_depots_country, 
    37 		_airport_depots_country,
    38 		lengthof(_airport_depots_country)
    38 		lengthof(_airport_depots_country)
    39 	);
    39 	);
    40 
    40 
    41 	// city airport
    41 	// city airport
    42 	CityAirport = malloc(sizeof(AirportFTAClass));
    42 	CityAirport = malloc(sizeof(AirportFTAClass));
    43 	
    43 
    44 	AirportFTAClass_Constructor(
    44 	AirportFTAClass_Constructor(
    45 		CityAirport, 
    45 		CityAirport,
    46 		_airport_terminal_city, 
    46 		_airport_terminal_city,
    47 		NULL, 
    47 		NULL,
    48 		19, 
    48 		19,
    49 		ALL, 
    49 		ALL,
    50 		_airport_fta_city, 
    50 		_airport_fta_city,
    51 		_airport_depots_city, 
    51 		_airport_depots_city,
    52 		lengthof(_airport_depots_city)
    52 		lengthof(_airport_depots_city)
    53 	);
    53 	);
    54 
    54 
    55 	// metropolitan airport
    55 	// metropolitan airport
    56 	MetropolitanAirport = malloc(sizeof(AirportFTAClass));
    56 	MetropolitanAirport = malloc(sizeof(AirportFTAClass));
    57 	
    57 
    58 	AirportFTAClass_Constructor(
    58 	AirportFTAClass_Constructor(
    59 		MetropolitanAirport, 
    59 		MetropolitanAirport,
    60 		_airport_terminal_metropolitan, 
    60 		_airport_terminal_metropolitan,
    61 		NULL, 
    61 		NULL,
    62 		20, 
    62 		20,
    63 		ALL, 
    63 		ALL,
    64 		_airport_fta_metropolitan, 
    64 		_airport_fta_metropolitan,
    65 		_airport_depots_metropolitan, 
    65 		_airport_depots_metropolitan,
    66 		lengthof(_airport_depots_metropolitan)
    66 		lengthof(_airport_depots_metropolitan)
    67 	);
    67 	);
    68 
    68 
    69 	// international airport
    69 	// international airport
    70 	InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
    70 	InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
    71 	
    71 
    72 	AirportFTAClass_Constructor(
    72 	AirportFTAClass_Constructor(
    73 		InternationalAirport, 
    73 		InternationalAirport,
    74 		_airport_terminal_international, 
    74 		_airport_terminal_international,
    75 		_airport_helipad_international, 
    75 		_airport_helipad_international,
    76 		37, 
    76 		37,
    77 		ALL, 
    77 		ALL,
    78 		_airport_fta_international, 
    78 		_airport_fta_international,
    79 		_airport_depots_international, 
    79 		_airport_depots_international,
    80 		lengthof(_airport_depots_international)
    80 		lengthof(_airport_depots_international)
    81 	);
    81 	);
    82 
    82 
    83 	// heliport, oilrig
    83 	// heliport, oilrig
    84 	Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
    84 	Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
    85 	
    85 
    86 	AirportFTAClass_Constructor(
    86 	AirportFTAClass_Constructor(
    87 		Heliport, 
    87 		Heliport,
    88 		NULL, 
    88 		NULL,
    89 		_airport_helipad_heliport_oilrig, 
    89 		_airport_helipad_heliport_oilrig,
    90 		7, 
    90 		7,
    91 		HELICOPTERS_ONLY, 
    91 		HELICOPTERS_ONLY,
    92 		_airport_fta_heliport_oilrig, 
    92 		_airport_fta_heliport_oilrig,
    93 		NULL, 
    93 		NULL,
    94 		0
    94 		0
    95 	);
    95 	);
    96 	
    96 
    97 	Oilrig = Heliport;  // exactly the same structure for heliport/oilrig, so share state machine
    97 	Oilrig = Heliport;  // exactly the same structure for heliport/oilrig, so share state machine
    98 }
    98 }
    99 
    99 
   100 void UnInitializeAirports()
   100 void UnInitializeAirports()
   101 {
   101 {
   116 	byte nofterminalgroups = 0;
   116 	byte nofterminalgroups = 0;
   117 	byte nofhelipadgroups = 0;
   117 	byte nofhelipadgroups = 0;
   118 	const byte * curr;
   118 	const byte * curr;
   119 	int i;
   119 	int i;
   120 	nofterminals = nofhelipads = 0;
   120 	nofterminals = nofhelipads = 0;
   121 	
   121 
   122 	//now we read the number of terminals we have
   122 	//now we read the number of terminals we have
   123 	if (terminals != NULL) {
   123 	if (terminals != NULL) {
   124 		i = terminals[0];
   124 		i = terminals[0];
   125 		nofterminalgroups = i;
   125 		nofterminalgroups = i;
   126 		curr = terminals;
   126 		curr = terminals;
   127 		while (i-- > 0) {
   127 		while (i-- > 0) {
   128 			curr++;
   128 			curr++;
   129 			assert(*curr != 0);	//we don't want to have an empty group
   129 			assert(*curr != 0);	//we don't want to have an empty group
   130 			nofterminals += *curr;
   130 			nofterminals += *curr;
   131 		}
   131 		}
   132 	
   132 
   133 	}
   133 	}
   134 	Airport->terminals = terminals;
   134 	Airport->terminals = terminals;
   135 
   135 
   136 	//read helipads	
   136 	//read helipads
   137 	if (helipads != NULL) {
   137 	if (helipads != NULL) {
   138 		i = helipads[0];
   138 		i = helipads[0];
   139 		nofhelipadgroups = i;
   139 		nofhelipadgroups = i;
   140 		curr = helipads;
   140 		curr = helipads;
   141 		while (i-- > 0) {
   141 		while (i-- > 0) {
   142 			curr++;
   142 			curr++;
   143 			assert(*curr != 0); //no empty groups please
   143 			assert(*curr != 0); //no empty groups please
   144 			nofhelipads += *curr;
   144 			nofhelipads += *curr;
   145 		}
   145 		}
   146 	
   146 
   147 	}
   147 	}
   148 	Airport->helipads = helipads;
   148 	Airport->helipads = helipads;
   149 
   149 
   150 	// if there are more terminals than 6, internal variables have to be changed, so don't allow that
   150 	// if there are more terminals than 6, internal variables have to be changed, so don't allow that
   151 	// same goes for helipads
   151 	// same goes for helipads