summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/company_gui.cpp9
-rw-r--r--src/road.h6
-rw-r--r--src/road_gui.cpp10
3 files changed, 7 insertions, 18 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 3706db2f5..f9eceba17 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -1862,8 +1862,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);
@@ -2005,8 +2004,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);
@@ -2019,8 +2017,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 1082ab272..becbf4051 100644
--- a/src/road.h
+++ b/src/road.h
@@ -305,10 +305,4 @@ bool HasAnyRoadTypesAvail(CompanyID company, RoadTramType rtt);
extern std::vector<RoadType> _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 9aa195247..9cc68028d 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -1313,17 +1313,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;
@@ -1365,13 +1364,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);