Codechange: Use EnumBitSet for RoadTypes.

This commit is contained in:
Peter Nelson
2025-03-24 20:02:19 +00:00
committed by Peter Nelson
parent 819e097d6e
commit 732109e444
16 changed files with 75 additions and 83 deletions

View File

@@ -47,7 +47,7 @@
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT &&
HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
::GetPresentRoadTypes(tile).Test(::RoadType(GetCurrentRoadType()));
}
/* static */ bool ScriptRoad::IsRoadStationTile(TileIndex tile)
@@ -55,7 +55,7 @@
if (!::IsValidTile(tile)) return false;
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
return ::IsStationRoadStopTile(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
return ::IsStationRoadStopTile(tile) && ::GetPresentRoadTypes(tile).Test(::RoadType(GetCurrentRoadType()));
}
/* static */ bool ScriptRoad::IsDriveThroughRoadStationTile(TileIndex tile)
@@ -63,7 +63,7 @@
if (!::IsValidTile(tile)) return false;
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
return ::IsDriveThroughStopTile(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
return ::IsDriveThroughStopTile(tile) && ::GetPresentRoadTypes(tile).Test(::RoadType(GetCurrentRoadType()));
}
/* static */ bool ScriptRoad::IsRoadTypeAvailable(RoadType road_type)
@@ -101,7 +101,7 @@
{
if (!ScriptMap::IsValidTile(tile)) return false;
if (!IsRoadTypeAvailable(road_type)) return false;
return ::MayHaveRoad(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)road_type);
return ::MayHaveRoad(tile) && ::GetPresentRoadTypes(tile).Test(::RoadType(road_type));
}
/* static */ bool ScriptRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2)
@@ -461,7 +461,7 @@ static std::optional<RoadPartOrientation> ToRoadPartOrientation(const TileIndex
static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagDirection neighbour)
{
TileIndex neighbour_tile = ::TileAddByDiagDir(start_tile, neighbour);
if (!HasBit(::GetPresentRoadTypes(neighbour_tile), rt)) return false;
if (!::GetPresentRoadTypes(neighbour_tile).Test(rt)) return false;
switch (::GetTileType(neighbour_tile)) {
case MP_ROAD: