airport.c
changeset 5380 8ea58542b6e0
parent 4844 10fde6a49e04
equal deleted inserted replaced
5379:929378a0014f 5380:8ea58542b6e0
   217 	/* Set up the terminal and helipad count for an airport.
   217 	/* Set up the terminal and helipad count for an airport.
   218 	 * TODO: If there are more than 10 terminals or 4 helipads, internal variables
   218 	 * TODO: If there are more than 10 terminals or 4 helipads, internal variables
   219 	 * need to be changed, so don't allow that for now */
   219 	 * need to be changed, so don't allow that for now */
   220 	nofterminals = AirportGetTerminalCount(terminals, &nofterminalgroups);
   220 	nofterminals = AirportGetTerminalCount(terminals, &nofterminalgroups);
   221 	if (nofterminals > MAX_TERMINALS) {
   221 	if (nofterminals > MAX_TERMINALS) {
   222 		DEBUG(misc, 0) ("[Ap] Currently only maximum of %d terminals are supported (you wanted %d)", MAX_TERMINALS, nofterminals);
   222 		DEBUG(misc, 0, "[Ap] only a maximum of %d terminals are supported (requested %d)", MAX_TERMINALS, nofterminals);
   223 		assert(nofterminals <= MAX_TERMINALS);
   223 		assert(nofterminals <= MAX_TERMINALS);
   224 	}
   224 	}
   225 	apc->terminals = terminals;
   225 	apc->terminals = terminals;
   226 
   226 
   227 	nofhelipads = AirportGetTerminalCount(helipads, &nofhelipadgroups);
   227 	nofhelipads = AirportGetTerminalCount(helipads, &nofhelipadgroups);
   228 	if (nofhelipads > MAX_HELIPADS) {
   228 	if (nofhelipads > MAX_HELIPADS) {
   229 		DEBUG(misc, 0) ("[Ap] Currently only maximum of %d helipads are supported (you wanted %d)", MAX_HELIPADS, nofhelipads);
   229 		DEBUG(misc, 0, "[Ap] only a maximum of %d helipads are supported (requested %d)", MAX_HELIPADS, nofhelipads);
   230 		assert(nofhelipads <= MAX_HELIPADS);
   230 		assert(nofhelipads <= MAX_HELIPADS);
   231 	}
   231 	}
   232 	apc->helipads = helipads;
   232 	apc->helipads = helipads;
   233 
   233 
   234 	/* Get the number of elements from the source table. We also double check this
   234 	/* Get the number of elements from the source table. We also double check this
   235 	 * with the entry point which must be within bounds and use this information
   235 	 * with the entry point which must be within bounds and use this information
   236 	 * later on to build and validate the state machine */
   236 	 * later on to build and validate the state machine */
   237 	apc->nofelements = AirportGetNofElements(apFA);
   237 	apc->nofelements = AirportGetNofElements(apFA);
   238 	if (entry_point >= apc->nofelements) {
   238 	if (entry_point >= apc->nofelements) {
   239 		DEBUG(misc, 0) ("[Ap] Entry (%d) must be within the airport (maximum %d)", entry_point, apc->nofelements);
   239 		DEBUG(misc, 0, "[Ap] entry (%d) must be within the airport (maximum %d)", entry_point, apc->nofelements);
   240 		assert(entry_point < apc->nofelements);
   240 		assert(entry_point < apc->nofelements);
   241 	}
   241 	}
   242 
   242 
   243 	apc->acc_planes     = acc_planes;
   243 	apc->acc_planes     = acc_planes;
   244 	apc->entry_point    = entry_point;
   244 	apc->entry_point    = entry_point;
   245 	apc->airport_depots = depots;
   245 	apc->airport_depots = depots;
   246 	apc->nof_depots     = nof_depots;
   246 	apc->nof_depots     = nof_depots;
   247 
   247 
   248 	/* Build the state machine itself */
   248 	/* Build the state machine itself */
   249 	AirportBuildAutomata(apc, apFA);
   249 	AirportBuildAutomata(apc, apFA);
   250 	DEBUG(misc, 1) ("[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entry %3d",
   250 	DEBUG(misc, 2, "[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entry %3d",
   251 		apc->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, apc->entry_point);
   251 		apc->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, apc->entry_point);
   252 
   252 
   253 	/* Test if everything went allright. This is only a rude static test checking
   253 	/* Test if everything went allright. This is only a rude static test checking
   254 	 * the symantic correctness. By no means does passing the test mean that the
   254 	 * the symantic correctness. By no means does passing the test mean that the
   255 	 * airport is working correctly or will not deadlock for example */
   255 	 * airport is working correctly or will not deadlock for example */
   256 	{ byte ret = AirportTestFTA(apc);
   256 	{ byte ret = AirportTestFTA(apc);
   257 		if (ret != MAX_ELEMENTS) DEBUG(misc, 0) ("[Ap] ERROR with element: %d", ret - 1);
   257 		if (ret != MAX_ELEMENTS) DEBUG(misc, 0, "[Ap] problem with element: %d", ret - 1);
   258 		assert(ret == MAX_ELEMENTS);
   258 		assert(ret == MAX_ELEMENTS);
   259 	}
   259 	}
   260 
   260 
   261 #ifdef DEBUG_AIRPORT
   261 #ifdef DEBUG_AIRPORT
   262 	AirportPrintOut(apc, DEBUG_AIRPORT);
   262 	AirportPrintOut(apc, DEBUG_AIRPORT);