mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 20:24:12 +01:00
Codechange: Use EnumBitSet for HouseZones. (#14137)
This commit is contained in:
@@ -621,7 +621,7 @@ CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces,
|
||||
company = OWNER_TOWN;
|
||||
|
||||
/* If we are not within a town, we are not owned by the town */
|
||||
if (town == nullptr || DistanceSquare(tile, town->xy) > town->cache.squared_town_zone_radius[HZB_TOWN_EDGE]) {
|
||||
if (town == nullptr || DistanceSquare(tile, town->xy) > town->cache.squared_town_zone_radius[to_underlying(HouseZone::TownEdge)]) {
|
||||
company = OWNER_NONE;
|
||||
}
|
||||
}
|
||||
@@ -1956,7 +1956,7 @@ static const Roadside _town_road_types[][2] = {
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types) == HZB_END);
|
||||
static_assert(lengthof(_town_road_types) == NUM_HOUSE_ZONES);
|
||||
|
||||
static const Roadside _town_road_types_2[][2] = {
|
||||
{ ROADSIDE_GRASS, ROADSIDE_GRASS },
|
||||
@@ -1966,7 +1966,7 @@ static const Roadside _town_road_types_2[][2] = {
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types_2) == HZB_END);
|
||||
static_assert(lengthof(_town_road_types_2) == NUM_HOUSE_ZONES);
|
||||
|
||||
|
||||
static void TileLoop_Road(TileIndex tile)
|
||||
@@ -1997,14 +1997,14 @@ static void TileLoop_Road(TileIndex tile)
|
||||
|
||||
const Town *t = ClosestTownFromTile(tile, UINT_MAX);
|
||||
if (!HasRoadWorks(tile)) {
|
||||
HouseZonesBits grp = HZB_TOWN_EDGE;
|
||||
HouseZone grp = HouseZone::TownEdge;
|
||||
|
||||
if (t != nullptr) {
|
||||
grp = GetTownRadiusGroup(t, tile);
|
||||
|
||||
/* Show an animation to indicate road work */
|
||||
if (t->road_build_months != 0 &&
|
||||
(DistanceManhattan(t->xy, tile) < 8 || grp != HZB_TOWN_EDGE) &&
|
||||
(DistanceManhattan(t->xy, tile) < 8 || grp != HouseZone::TownEdge) &&
|
||||
IsNormalRoad(tile) && !HasAtMostOneBit(GetAllRoadBits(tile))) {
|
||||
if (std::get<0>(GetFoundationSlope(tile)) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile).Succeeded() && Chance16(1, 40)) {
|
||||
StartRoadWorks(tile);
|
||||
@@ -2023,7 +2023,7 @@ static void TileLoop_Road(TileIndex tile)
|
||||
|
||||
{
|
||||
/* Adjust road ground type depending on 'grp' (grp is the distance to the center) */
|
||||
const Roadside *new_rs = (_settings_game.game_creation.landscape == LandscapeType::Toyland) ? _town_road_types_2[grp] : _town_road_types[grp];
|
||||
const Roadside *new_rs = (_settings_game.game_creation.landscape == LandscapeType::Toyland) ? _town_road_types_2[to_underlying(grp)] : _town_road_types[to_underlying(grp)];
|
||||
Roadside cur_rs = GetRoadside(tile);
|
||||
|
||||
/* We have our desired type, do nothing */
|
||||
|
||||
Reference in New Issue
Block a user