|
@@ -156,78 +156,78 @@ static uint16 AirportGetNofElements(cons
|
|
|
if (temp != apFA[i].position) {
|
|
|
nofelements++;
|
|
|
temp = apFA[i].position;
|
|
|
}
|
|
|
if (apFA[i].position == MAX_ELEMENTS) break;
|
|
|
}
|
|
|
return nofelements;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Construct the FTA given a description.
|
|
|
* @param nofelements The number of elements in the FTA.
|
|
|
* @param apFA The description of the FTA.
|
|
|
* @return The FTA describing the airport.
|
|
|
*/
|
|
|
static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA)
|
|
|
{
|
|
|
AirportFTA *FAutomata = MallocT<AirportFTA>(nofelements);
|
|
|
uint16 internalcounter = 0;
|
|
|
|
|
|
for (uint i = 0; i < nofelements; i++) {
|
|
|
AirportFTA *current = &FAutomata[i];
|
|
|
current->position = apFA[internalcounter].position;
|
|
|
current->heading = apFA[internalcounter].heading;
|
|
|
current->block = apFA[internalcounter].block;
|
|
|
current->next_position = apFA[internalcounter].next;
|
|
|
|
|
|
/* outgoing nodes from the same position, create linked list */
|
|
|
while (current->position == apFA[internalcounter + 1].position) {
|
|
|
AirportFTA *newNode = MallocT<AirportFTA>(1);
|
|
|
|
|
|
newNode->position = apFA[internalcounter + 1].position;
|
|
|
newNode->heading = apFA[internalcounter + 1].heading;
|
|
|
newNode->block = apFA[internalcounter + 1].block;
|
|
|
newNode->next_position = apFA[internalcounter + 1].next;
|
|
|
/* create link */
|
|
|
current->next = newNode;
|
|
|
current = current->next;
|
|
|
internalcounter++;
|
|
|
}
|
|
|
current->next = NULL;
|
|
|
internalcounter++;
|
|
|
}
|
|
|
return FAutomata;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the finite state machine of an airport type.
|
|
|
* @param airport_type Airport type to query FTA from. @see AirportTypes
|
|
|
* @param airport_type %Airport type to query FTA from. @see AirportTypes
|
|
|
* @return Finite state machine of the airport.
|
|
|
*/
|
|
|
const AirportFTAClass *GetAirport(const byte airport_type)
|
|
|
{
|
|
|
if (airport_type == AT_DUMMY) return &_airportfta_dummy;
|
|
|
return AirportSpec::Get(airport_type)->fsm;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the vehicle position when an aircraft is build at the given tile
|
|
|
* @param hangar_tile The tile on which the vehicle is build
|
|
|
* @return The position (index in airport node array) where the aircraft ends up
|
|
|
*/
|
|
|
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
|
|
|
{
|
|
|
const Station *st = Station::GetByTile(hangar_tile);
|
|
|
const AirportFTAClass *apc = st->airport.GetFTA();
|
|
|
/* When we click on hangar we know the tile it is on. By that we know
|
|
|
* its position in the array of depots the airport has.....we can search
|
|
|
* layout for #th position of depot. Since layout must start with a listing
|
|
|
* of all depots, it is simple */
|
|
|
for (uint i = 0;; i++) {
|
|
|
if (st->airport.GetHangarTile(i) == hangar_tile) {
|
|
|
assert(apc->layout[i].heading == HANGAR);
|
|
|
return apc->layout[i].position;
|
|
|
}
|
|
|
}
|
|
|
NOT_REACHED();
|
|
|
}
|