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

Function CheckTownBuild2x2House

src/town_cmd.cpp:2749–2763  ·  view source on GitHub ↗

* Checks if a 1x2 or 2x1 building is allowed here, accounting for road layout and tile heights. * Also, tests all four building positions that occupy this tile. * @param tile The tile where the building should be built. * @param t The town. * @param maxz The maximum Z level, since all tiles must have the same height. * @param noslope Are foundations disallowed for this house? */

Source from the content-addressed store, hash-verified

2747 * @param noslope Are foundations disallowed for this house?
2748 */
2749static bool CheckTownBuild2x2House(TileIndex *tile, Town *t, int maxz, bool noslope, TownExpandModes modes)
2750{
2751 TileIndex tile2 = *tile;
2752
2753 for (DiagDirection d = DIAGDIR_SE;; d++) { // 'd' goes through DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_END
2754 if (TownLayoutAllows2x2HouseHere(t, tile2, modes) && CheckFree2x2Area(tile2, maxz, noslope)) {
2755 *tile = tile2;
2756 return true;
2757 }
2758 if (d == DIAGDIR_END) break;
2759 tile2 += TileOffsByDiagDir(ReverseDiagDir(d)); // go clockwise
2760 }
2761
2762 return false;
2763}
2764
2765/**
2766 * Build a house at this tile.

Callers 1

TryBuildTownHouseFunction · 0.85

Calls 4

CheckFree2x2AreaFunction · 0.85
TileOffsByDiagDirFunction · 0.85
ReverseDiagDirFunction · 0.85

Tested by

no test coverage detected