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

Function IsTileAlignedToGrid

src/town_cmd.cpp:2316–2323  ·  view source on GitHub ↗

* Towns must all be placed on the same grid or when they eventually * interpenetrate their road networks will not mesh nicely; this * function tells you if a tile is properly aligned. * * @param tile The tile to start at. * @param layout The town layout in effect. * @return true if the tile is in the correct location. */

Source from the content-addressed store, hash-verified

2314 * @return true if the tile is in the correct location.
2315 */
2316static bool IsTileAlignedToGrid(TileIndex tile, TownLayout layout)
2317{
2318 switch (layout) {
2319 case TL_2X2_GRID: return TileX(tile) % 3 == 0 && TileY(tile) % 3 == 0;
2320 case TL_3X3_GRID: return TileX(tile) % 4 == 0 && TileY(tile) % 4 == 0;
2321 default: return true;
2322 }
2323}
2324
2325/**
2326 * Given a spot on the map (presumed to be a water tile), find a good

Callers 1

Calls 2

TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected