Cleanup: Replace FOR_ALL_SORTED_RAILTYPES macro with range iterator.
(cherry picked from commit 3b3d80c8ef
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
a4821e2732
commit
571f807b20
@@ -1902,8 +1902,7 @@ struct CompanyInfrastructureWindow : Window
|
|||||||
|
|
||||||
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width);
|
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width);
|
||||||
|
|
||||||
RailType rt;
|
for (const auto &rt : _sorted_railtypes) {
|
||||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
|
||||||
if (HasBit(this->railtypes, rt)) {
|
if (HasBit(this->railtypes, rt)) {
|
||||||
lines++;
|
lines++;
|
||||||
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
||||||
@@ -2035,8 +2034,7 @@ struct CompanyInfrastructureWindow : Window
|
|||||||
|
|
||||||
if (this->railtypes != RAILTYPES_NONE) {
|
if (this->railtypes != RAILTYPES_NONE) {
|
||||||
/* Draw name of each valid railtype. */
|
/* Draw name of each valid railtype. */
|
||||||
RailType rt;
|
for (const auto &rt : _sorted_railtypes) {
|
||||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
|
||||||
if (HasBit(this->railtypes, rt)) {
|
if (HasBit(this->railtypes, rt)) {
|
||||||
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
||||||
DrawString(r.left + offs_left, r.right - offs_right, y += FONT_HEIGHT_NORMAL, STR_WHITE_STRING);
|
DrawString(r.left + offs_left, r.right - offs_right, y += FONT_HEIGHT_NORMAL, STR_WHITE_STRING);
|
||||||
@@ -2053,8 +2051,7 @@ struct CompanyInfrastructureWindow : Window
|
|||||||
case WID_CI_RAIL_COUNT: {
|
case WID_CI_RAIL_COUNT: {
|
||||||
/* Draw infrastructure count for each valid railtype. */
|
/* Draw infrastructure count for each valid railtype. */
|
||||||
uint32 rail_total = c->infrastructure.GetRailTotal();
|
uint32 rail_total = c->infrastructure.GetRailTotal();
|
||||||
RailType rt;
|
for (const auto &rt : _sorted_railtypes) {
|
||||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
|
||||||
if (HasBit(this->railtypes, rt)) {
|
if (HasBit(this->railtypes, rt)) {
|
||||||
this->DrawCountLine(r, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
|
this->DrawCountLine(r, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
|
||||||
}
|
}
|
||||||
|
@@ -497,12 +497,6 @@ RailType AllocateRailType(RailTypeLabel label);
|
|||||||
extern std::vector<RailType> _sorted_railtypes;
|
extern std::vector<RailType> _sorted_railtypes;
|
||||||
extern RailTypes _railtypes_hidden_mask;
|
extern RailTypes _railtypes_hidden_mask;
|
||||||
|
|
||||||
/**
|
|
||||||
* Loop header for iterating over railtypes, sorted by sortorder.
|
|
||||||
* @param var Railtype.
|
|
||||||
*/
|
|
||||||
#define FOR_ALL_SORTED_RAILTYPES(var) for (uint8 index = 0; index < _sorted_railtypes.size() && (var = _sorted_railtypes[index], true) ; index++)
|
|
||||||
|
|
||||||
/** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
|
/** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
|
||||||
enum SignalOffsets {
|
enum SignalOffsets {
|
||||||
SIGNAL_TO_SOUTHWEST,
|
SIGNAL_TO_SOUTHWEST,
|
||||||
|
@@ -2400,17 +2400,16 @@ DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dimension d = { 0, 0 };
|
Dimension d = { 0, 0 };
|
||||||
RailType rt;
|
|
||||||
/* Get largest icon size, to ensure text is aligned on each menu item. */
|
/* Get largest icon size, to ensure text is aligned on each menu item. */
|
||||||
if (!for_replacement) {
|
if (!for_replacement) {
|
||||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
for (const auto &rt : _sorted_railtypes) {
|
||||||
if (!HasBit(used_railtypes, rt)) continue;
|
if (!HasBit(used_railtypes, rt)) continue;
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||||
d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_rail));
|
d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_rail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
for (const auto &rt : _sorted_railtypes) {
|
||||||
/* If it's not used ever, don't show it to the user. */
|
/* If it's not used ever, don't show it to the user. */
|
||||||
if (!HasBit(used_railtypes, rt)) continue;
|
if (!HasBit(used_railtypes, rt)) continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user