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

Function AlignTileToGrid

src/town_cmd.cpp:2298–2305  ·  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 adjusts a tile so that it aligns properly. * * @param tile The tile to start at. * @param layout The town layout in effect. * @return The adjusted tile. */

Source from the content-addressed store, hash-verified

2296 * @return The adjusted tile.
2297 */
2298static TileIndex AlignTileToGrid(TileIndex tile, TownLayout layout)
2299{
2300 switch (layout) {
2301 case TL_2X2_GRID: return TileXY(TileX(tile) - TileX(tile) % 3, TileY(tile) - TileY(tile) % 3);
2302 case TL_3X3_GRID: return TileXY(TileX(tile) & ~3, TileY(tile) & ~3);
2303 default: return tile;
2304 }
2305}
2306
2307/**
2308 * Towns must all be placed on the same grid or when they eventually

Callers 1

CreateRandomTownFunction · 0.85

Calls 3

TileXYFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected