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

Function IsCloseToTown

src/town_cmd.cpp:390–395  ·  view source on GitHub ↗

* Determines if a town is close to a tile. * @param tile TileIndex of the tile to query. * @param dist The maximum distance to be accepted. * @returns true if the tile is within the specified distance. */

Source from the content-addressed store, hash-verified

388 * @returns true if the tile is within the specified distance.
389 */
390static bool IsCloseToTown(TileIndex tile, uint dist)
391{
392 if (_town_kdtree.Count() == 0) return false;
393 Town *t = Town::Get(_town_kdtree.FindNearest(TileX(tile), TileY(tile)));
394 return DistanceManhattan(tile, t->xy) < dist;
395}
396
397/** Resize the sign (label) of the town after it changes population. */
398void Town::UpdateVirtCoord()

Callers 1

TownCanBePlacedHereFunction · 0.85

Calls 5

TileXFunction · 0.85
TileYFunction · 0.85
DistanceManhattanFunction · 0.85
FindNearestMethod · 0.80
CountMethod · 0.45

Tested by

no test coverage detected