* 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? */
| 2747 | * @param noslope Are foundations disallowed for this house? |
| 2748 | */ |
| 2749 | static 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. |
no test coverage detected