Codechange: make RoadBits an EnumBitSet (#15476)

This commit is contained in:
Peter Nelson
2026-04-13 21:23:17 +01:00
committed by GitHub
parent a5a60c8615
commit b33b0d92a0
18 changed files with 268 additions and 262 deletions
+4 -4
View File
@@ -58,7 +58,7 @@ static bool IsPossibleCrossing(const TileIndex tile, Axis ax)
*/
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
{
if (!IsValidTile(tile)) return ROAD_NONE;
if (!IsValidTile(tile)) return {};
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
const TileIndex neighbour_tile = TileAddByDiagDir(tile, dir);
@@ -66,7 +66,7 @@ RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
const RoadBits target_rb = DiagDirToRoadBits(dir);
/* If the roadbit is in the current plan */
if (org_rb & target_rb) {
if (org_rb.Any(target_rb)) {
bool connective = false;
const RoadBits mirrored_rb = MirrorRoadBits(target_rb);
@@ -88,7 +88,7 @@ RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
const RoadBits neighbour_rb = GetAnyRoadBits(neighbour_tile, RoadTramType::Road) | GetAnyRoadBits(neighbour_tile, RoadTramType::Tram);
/* Accept only connective tiles */
connective = (neighbour_rb & mirrored_rb) != ROAD_NONE;
connective = neighbour_rb.Any(mirrored_rb);
}
break;
@@ -107,7 +107,7 @@ RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
}
/* If the neighbour tile is inconnective, remove the planned road connection to it */
if (!connective) org_rb ^= target_rb;
if (!connective) org_rb.Flip(target_rb);
}
}