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

Method IsWithinMapBounds

src/newgrf_airport.cpp:100–110  ·  view source on GitHub ↗

* Check if the airport would be within the map bounds at the given tile. * @param table Selected layout table. This affects airport rotation, and therefore dimensions. * @param tile Top corner of the airport. * @return true iff the airport would be within the map bounds at the given tile. */

Source from the content-addressed store, hash-verified

98 * @return true iff the airport would be within the map bounds at the given tile.
99 */
100bool AirportSpec::IsWithinMapBounds(uint8_t table, TileIndex tile) const
101{
102 if (table >= this->layouts.size()) return false;
103
104 uint8_t w = this->size_x;
105 uint8_t h = this->size_y;
106 if (this->layouts[table].rotation == DIR_E || this->layouts[table].rotation == DIR_W) std::swap(w, h);
107
108 return TileX(tile) + w < Map::SizeX() &&
109 TileY(tile) + h < Map::SizeY();
110}
111
112/**
113 * This function initializes the airportspec array.

Callers 3

CmdBuildAirportFunction · 0.80
GetNoiseLevelIncreaseMethod · 0.80
GetNearestTownMethod · 0.80

Calls 4

swapFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected