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

Method GetNearestTown

src/script/api/script_airport.cpp:149–160  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

147}
148
149/* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type)
150{
151 if (!::IsValidTile(tile)) return TownID::Invalid();
152 if (!IsAirportInformationAvailable(type)) return TownID::Invalid();
153
154 const AirportSpec *as = AirportSpec::Get(type);
155 if (!as->IsWithinMapBounds(0, tile)) return TownID::Invalid();
156
157 uint dist;
158 const auto &layout = as->layouts[0];
159 return AirportGetNearestTown(as, layout.rotation, tile, AirportTileTableIterator(layout.tiles, tile), dist)->index;
160}
161
162/* static */ SQInteger ScriptAirport::GetMaintenanceCostFactor(AirportType type)
163{

Callers

nothing calls this directly

Calls 5

IsValidTileFunction · 0.85
InvalidFunction · 0.85
AirportGetNearestTownFunction · 0.85
IsWithinMapBoundsMethod · 0.80

Tested by

no test coverage detected