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

Function DistanceFromEdge

src/map.cpp:229–238  ·  view source on GitHub ↗

* Param the minimum distance to an edge * @param tile the tile to get the distance from * @return the distance from the edge in tiles */

Source from the content-addressed store, hash-verified

227 * @return the distance from the edge in tiles
228 */
229uint DistanceFromEdge(TileIndex tile)
230{
231 const uint xl = TileX(tile);
232 const uint yl = TileY(tile);
233 const uint xh = Map::SizeX() - 1 - xl;
234 const uint yh = Map::SizeY() - 1 - yl;
235 const uint minl = std::min(xl, yl);
236 const uint minh = std::min(xh, yh);
237 return std::min(minl, minh);
238}
239
240/**
241 * Gets the distance to the edge of the map in given direction.

Callers 7

CountConnectedSeaTilesFunction · 0.85
GreyscaleToMapHeightsFunction · 0.85
GenerateStationNameFunction · 0.85
IsRoadAllowedHereFunction · 0.85
GrowTownWithExtraHouseFunction · 0.85
TownCanBePlacedHereFunction · 0.85
DistanceFromEdgeMethod · 0.85

Calls 2

TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected