* Checks whether at least one surrounding road allows to build a house here. * * @param t The tile where the house will be built. * @return true if at least one surrounding roadtype allows building houses here. */
| 1464 | * @return true if at least one surrounding roadtype allows building houses here. |
| 1465 | */ |
| 1466 | static inline bool RoadTypesAllowHouseHere(TileIndex t) |
| 1467 | { |
| 1468 | static const TileIndexDiffC tiles[] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1} }; |
| 1469 | bool allow = false; |
| 1470 | |
| 1471 | for (const auto &ptr : tiles) { |
| 1472 | TileIndex cur_tile = t + ToTileIndexDiff(ptr); |
| 1473 | if (!IsValidTile(cur_tile)) continue; |
| 1474 | |
| 1475 | if (!(IsTileType(cur_tile, MP_ROAD) || IsAnyRoadStopTile(cur_tile))) continue; |
| 1476 | allow = true; |
| 1477 | |
| 1478 | RoadType road_rt = GetRoadTypeRoad(cur_tile); |
| 1479 | if (road_rt != INVALID_ROADTYPE && !GetRoadTypeInfo(road_rt)->flags.Test(RoadTypeFlag::NoHouses)) return true; |
| 1480 | } |
| 1481 | |
| 1482 | /* If no road was found surrounding the tile we can allow building the house since there is |
| 1483 | * nothing which forbids it, if a road was found but the execution reached this point, then |
| 1484 | * all the found roads don't allow houses to be built */ |
| 1485 | return !allow; |
| 1486 | } |
| 1487 | |
| 1488 | /** Test if town can grow road onto a specific tile. |
| 1489 | * @param tile Tile to build upon. |
no test coverage detected