mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Cleanup: Replace FOR_ALL_SORTED_ROADTYPES macro with range iterator.
(cherry picked from commit de81afdf4b
)
This commit is contained in:
parent
571f807b20
commit
5e1b4e1844
@ -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));
|
||||
}
|
||||
|
@ -321,10 +321,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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user