Changeset - r23982:5e3be2bc91ae
[Not reviewed]
master
0 1 0
frosch - 5 years ago 2019-12-17 23:48:03
frosch@openttd.org
Codechange: Use RAILTYPE_BEGIN instead of RAILTYPE_RAIL when the intention is iteration.
1 file changed with 2 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/rail_gui.cpp
Show inline comments
 
@@ -1918,25 +1918,21 @@ static void SetDefaultRailGui()
 
				if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || HasStationTileRail(t) ||
 
						(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
 
					count[GetRailType(t)]++;
 
				}
 
			}
 

	
 
			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 */
 
			FALLTHROUGH;
 
		}
 
		case 0:
 
			/* Use first available type */
 
			rt = RAILTYPE_RAIL;
 
			rt = RAILTYPE_BEGIN;
 
			while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
 
			break;
 

	
 
		case 1:
 
			/* Use last available type */
 
			rt = GetBestRailtype(_local_company);
0 comments (0 inline, 0 general)