MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FreeTerminal

Function FreeTerminal

src/aircraft_cmd.cpp:1972–1985  ·  view source on GitHub ↗

* Find a free terminal or helipad, and if available, assign it. * @param v Aircraft looking for a free terminal or helipad. * @param i First terminal to examine. * @param last_terminal Terminal number to stop examining. * @return A terminal or helipad has been found, and has been assigned to the aircraft. */

Source from the content-addressed store, hash-verified

1970 * @return A terminal or helipad has been found, and has been assigned to the aircraft.
1971 */
1972static bool FreeTerminal(Aircraft *v, uint8_t i, uint8_t last_terminal)
1973{
1974 assert(last_terminal <= lengthof(_airport_terminal_mapping));
1975 Station *st = Station::Get(v->targetairport);
1976 for (; i < last_terminal; i++) {
1977 if (!st->airport.blocks.Any(_airport_terminal_mapping[i].blocks)) {
1978 /* TERMINAL# HELIPAD# */
1979 v->state = _airport_terminal_mapping[i].state; // start moving to that terminal/helipad
1980 st->airport.blocks.Set(_airport_terminal_mapping[i].blocks); // occupy terminal/helipad
1981 return true;
1982 }
1983 }
1984 return false;
1985}
1986
1987/**
1988 * Get the number of terminals at the airport.

Callers 2

AirportFindFreeTerminalFunction · 0.85
AirportFindFreeHelipadFunction · 0.85

Calls 2

AnyMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected