* 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 */
| 2650 | * @note see layouts |
| 2651 | */ |
| 2652 | static 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 | /** |
no test coverage detected