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

Function CheckTownBuild2House

src/town_cmd.cpp:2724–2738  ·  view source on GitHub ↗

* Checks if a 1x2 or 2x1 building is allowed here, accounting for road layout and tile heights. * Also, tests both 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? * @param second The

Source from the content-addressed store, hash-verified

2722 * @param second The diagdir from the first tile to the second tile.
2723 */
2724static bool CheckTownBuild2House(TileIndex *tile, Town *t, int maxz, bool noslope, DiagDirection second, TownExpandModes modes)
2725{
2726 /* 'tile' is already checked in BuildTownHouse() - CanBuildHouseHere() and slope test */
2727
2728 TileIndex tile2 = *tile + TileOffsByDiagDir(second);
2729 if (TownLayoutAllowsHouseHere(t, tile2, modes) && CheckBuildHouseSameZ(tile2, maxz, noslope)) return true;
2730
2731 tile2 = *tile + TileOffsByDiagDir(ReverseDiagDir(second));
2732 if (TownLayoutAllowsHouseHere(t, tile2, modes) && CheckBuildHouseSameZ(tile2, maxz, noslope)) {
2733 *tile = tile2;
2734 return true;
2735 }
2736
2737 return false;
2738}
2739
2740
2741/**

Callers 1

TryBuildTownHouseFunction · 0.85

Calls 4

TileOffsByDiagDirFunction · 0.85
CheckBuildHouseSameZFunction · 0.85
ReverseDiagDirFunction · 0.85

Tested by

no test coverage detected