diff --git a/src/company_gui.cpp b/src/company_gui.cpp index ec61625d56..2112beeae3 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -1924,8 +1924,7 @@ struct CompanyInfrastructureWindow : Window size->width = std::max(size->width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width); - RoadType rt; - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) { lines++; SetDParam(0, GetRoadTypeInfo(rt)->strings.name); @@ -2067,8 +2066,7 @@ struct CompanyInfrastructureWindow : Window DrawString(r.left, r.right, y, widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT); /* Draw name of each valid roadtype. */ - RoadType rt; - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) { SetDParam(0, GetRoadTypeInfo(rt)->strings.name); DrawString(r.left + offs_left, r.right - offs_right, y += FONT_HEIGHT_NORMAL, STR_WHITE_STRING); @@ -2081,8 +2079,7 @@ struct CompanyInfrastructureWindow : Window case WID_CI_ROAD_COUNT: case WID_CI_TRAM_COUNT: { uint32 road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal(); - RoadType rt; - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_COUNT)) { this->DrawCountLine(r, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_tram_total)); } diff --git a/src/road.h b/src/road.h index 430b4fe202..bd8b4efab5 100644 --- a/src/road.h +++ b/src/road.h @@ -321,10 +321,4 @@ bool HasAnyRoadTypesAvail(CompanyID company, RoadTramType rtt); extern std::vector _sorted_roadtypes; extern RoadTypes _roadtypes_hidden_mask; -/** - * Loop header for iterating over roadtypes, sorted by sortorder. - * @param var Roadtype. - */ -#define FOR_ALL_SORTED_ROADTYPES(var) for (uint8 index = 0; index < _sorted_roadtypes.size() && (var = _sorted_roadtypes[index], true) ; index++) - #endif /* ROAD_H */ diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 8b9712213d..18b0c898a6 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1391,17 +1391,16 @@ DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, b } Dimension d = { 0, 0 }; - RoadType rt; /* Get largest icon size, to ensure text is aligned on each menu item. */ if (!for_replacement) { - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (!HasBit(used_roadtypes, rt)) continue; const RoadTypeInfo *rti = GetRoadTypeInfo(rt); d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road)); } } - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { /* If it's not used ever, don't show it to the user. */ if (!HasBit(used_roadtypes, rt)) continue; @@ -1443,13 +1442,12 @@ DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts) /* If it's not used ever, don't show it to the user. */ Dimension d = { 0, 0 }; - RoadType rt; - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (!HasBit(used_roadtypes, rt)) continue; const RoadTypeInfo *rti = GetRoadTypeInfo(rt); d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road)); } - FOR_ALL_SORTED_ROADTYPES(rt) { + for (const auto &rt : _sorted_roadtypes) { if (!HasBit(used_roadtypes, rt)) continue; const RoadTypeInfo *rti = GetRoadTypeInfo(rt);