summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2019-12-18 00:48:03 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-12-23 17:23:20 +0000
commit6fa217dfc8afbd06bbc46462a2b6affc35268b5b (patch)
treed0bac9a9adbbaec210cbfbeea138abadbc8a0bcf
parent3d29c9483b180791f3d5b5f9a6664fc1322d4f52 (diff)
downloadopenttd-6fa217dfc8afbd06bbc46462a2b6affc35268b5b.tar.xz
Codechange: Use RAILTYPE_BEGIN instead of RAILTYPE_RAIL when the intention is iteration.
-rw-r--r--src/rail_gui.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index cd0d93c8f..7917268a1 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1921,11 +1921,7 @@ static void SetDefaultRailGui()
}
}
- rt = RAILTYPE_RAIL;
- for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) {
- if (count[r] >= count[rt]) rt = r;
- }
-
+ rt = static_cast<RailType>(std::max_element(count + RAILTYPE_BEGIN, count + RAILTYPE_END) - count);
if (count[rt] > 0) break;
/* No rail, just get the first available one */
@@ -1933,7 +1929,7 @@ static void SetDefaultRailGui()
}
case 0:
/* Use first available type */
- rt = RAILTYPE_RAIL;
+ rt = RAILTYPE_BEGIN;
while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
break;