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

Function TownLayoutAllowsHouseHere

src/town_cmd.cpp:2652–2675  ·  view source on GitHub ↗

* Checks if the current town layout allows building here. * @param t The town. * @param tile The tile to check. * @return true iff town layout allows building here. * @note see layouts */

Source from the content-addressed store, hash-verified

2650 * @note see layouts
2651 */
2652static inline bool TownLayoutAllowsHouseHere(Town *t, TileIndex tile, TownExpandModes modes)
2653{
2654 if (!modes.Test(TownExpandMode::Buildings)) return false;
2655
2656 /* Allow towns everywhere when we don't build roads */
2657 if (!TownAllowedToBuildRoads(modes)) return true;
2658
2659 TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile);
2660
2661 switch (t->layout) {
2662 case TL_2X2_GRID:
2663 if ((grid_pos.x % 3) == 0 || (grid_pos.y % 3) == 0) return false;
2664 break;
2665
2666 case TL_3X3_GRID:
2667 if ((grid_pos.x % 4) == 0 || (grid_pos.y % 4) == 0) return false;
2668 break;
2669
2670 default:
2671 break;
2672 }
2673
2674 return true;
2675}
2676
2677
2678/**

Callers 2

CheckTownBuild2HouseFunction · 0.85
TryBuildTownHouseFunction · 0.85

Calls 3

TownAllowedToBuildRoadsFunction · 0.85
TestMethod · 0.80

Tested by

no test coverage detected