diff --git a/src/road.h b/src/road.h index becbf40512..6a2af6698f 100644 --- a/src/road.h +++ b/src/road.h @@ -32,7 +32,7 @@ enum RoadTramTypes : uint8 { }; DECLARE_ENUM_AS_BIT_SET(RoadTramTypes) -#define FOR_ALL_ROADTRAMTYPES(x) for (RoadTramType x : { RTT_ROAD, RTT_TRAM }) +static const RoadTramType _roadtramtypes[] = { RTT_ROAD, RTT_TRAM }; /** Roadtype flags. Starts with RO instead of R because R is used for rails */ enum RoadTypeFlags { diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 830f9dd4fc..82e944f6e6 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1238,7 +1238,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags) /* Clear the road if only one piece is on the tile OR we are not using the DC_AUTO flag */ if ((HasExactlyOneBit(b) && GetRoadBits(tile, RTT_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) { CommandCost ret(EXPENSES_CONSTRUCTION); - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { if (!MayHaveRoad(tile) || GetRoadType(tile, rtt) == INVALID_ROADTYPE) continue; CommandCost tmp_ret = RemoveRoad(tile, flags, GetRoadBits(tile, rtt), rtt, true); @@ -2203,7 +2203,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne Company::Get(new_owner)->infrastructure.road[rt] += 2; SetTileOwner(tile, new_owner); - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { if (GetRoadOwner(tile, rtt) == old_owner) { SetRoadOwner(tile, rtt, new_owner); } @@ -2213,7 +2213,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne return; } - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { /* Update all roadtypes, no matter if they are present */ if (GetRoadOwner(tile, rtt) == old_owner) { RoadType rt = GetRoadType(tile, rtt); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 56680511cb..7fd2204943 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1855,7 +1855,7 @@ bool AfterLoadGame() } } else if (IsTileType(t, MP_ROAD)) { /* works for all RoadTileType */ - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { /* update even non-existing road types to update tile owner too */ Owner o = GetRoadOwner(t, rtt); if (o < MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rtt, OWNER_NONE); diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index fb2742a186..5770f9791e 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -128,7 +128,7 @@ void AfterLoadCompanyStats() } /* Iterate all present road types as each can have a different owner. */ - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { RoadType rt = GetRoadType(tile, rtt); if (rt == INVALID_ROADTYPE) continue; c = Company::GetIfValid(IsRoadDepot(tile) ? GetTileOwner(tile) : GetRoadOwner(tile, rtt)); @@ -151,7 +151,7 @@ void AfterLoadCompanyStats() case STATION_BUS: case STATION_TRUCK: { /* Iterate all present road types as each can have a different owner. */ - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { RoadType rt = GetRoadType(tile, rtt); if (rt == INVALID_ROADTYPE) continue; c = Company::GetIfValid(GetRoadOwner(tile, rtt)); @@ -209,7 +209,7 @@ void AfterLoadCompanyStats() case TRANSPORT_ROAD: { /* Iterate all present road types as each can have a different owner. */ - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { RoadType rt = GetRoadType(tile, rtt); if (rt == INVALID_ROADTYPE) continue; c = Company::GetIfValid(GetRoadOwner(tile, rtt)); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 451dedbad4..39efb710e6 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2029,7 +2029,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags) } /* Update company infrastructure counts. */ - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { RoadType rt = GetRoadType(tile, rtt); UpdateCompanyRoadInfrastructure(rt, GetRoadOwner(tile, rtt), -static_cast(ROAD_STOP_TRACKBIT_FACTOR)); } @@ -2110,7 +2110,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui RoadType road_type[] = { INVALID_ROADTYPE, INVALID_ROADTYPE }; Owner road_owner[] = { OWNER_NONE, OWNER_NONE }; if (IsDriveThroughStopTile(cur_tile)) { - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { road_type[rtt] = GetRoadType(cur_tile, rtt); if (road_type[rtt] == INVALID_ROADTYPE) continue; road_owner[rtt] = GetRoadOwner(cur_tile, rtt); @@ -4178,7 +4178,7 @@ void DeleteOilRig(TileIndex tile) static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_owner) { if (IsRoadStopTile(tile)) { - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { /* Update all roadtypes, no matter if they are present */ if (GetRoadOwner(tile, rtt) == old_owner) { RoadType rt = GetRoadType(tile, rtt); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 2f76dbcef9..dd8d731ee9 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1811,7 +1811,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner * don't want to update the infrastructure counts twice. */ uint num_pieces = tile < other_end ? (GetTunnelBridgeLength(tile, other_end) + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR : 0; - FOR_ALL_ROADTRAMTYPES(rtt) { + for (RoadTramType rtt : _roadtramtypes) { /* Update all roadtypes, no matter if they are present */ if (GetRoadOwner(tile, rtt) == old_owner) { RoadType rt = GetRoadType(tile, rtt);