From 08973ba8ebc7630304810fdcae5a5b55e08e4990 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 2 Mar 2007 00:17:35 +0000 Subject: (svn r8966) -Codechange: replace some if-cascades by switches. --- src/rail_cmd.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/rail_cmd.cpp') diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index b18fd8805..8e6a0f057 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1845,16 +1845,21 @@ set_ground: static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode) { - byte a; - uint16 b; - if (mode != TRANSPORT_RAIL) return 0; - if (IsPlainRailTile(tile)) { - TrackBits rails = GetTrackBits(tile); - uint32 ret = rails * 0x101; + switch (GetRailTileType(tile)) { + default: NOT_REACHED(); + case RAIL_TILE_NORMAL: { + TrackBits rails = GetTrackBits(tile); + uint32 ret = rails * 0x101; + return (rails == TRACK_BIT_CROSS) ? ret | 0x40 : ret; + } + + case RAIL_TILE_SIGNALS: { + uint32 ret = GetTrackBits(tile) * 0x101; + byte a; + uint16 b; - if (HasSignals(tile)) { a = _m[tile].m3; b = _m[tile].m2; @@ -1871,25 +1876,21 @@ static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode) if ((b & 0x40) == 0) ret |= 0x07100000; if ((b & 0x20) == 0) ret |= 0x20080000; if ((b & 0x10) == 0) ret |= 0x08200000; - } else { - if (rails == TRACK_BIT_CROSS) ret |= 0x40; - } - return ret; - } else { - if (IsRailDepot(tile)) { - return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101; - } else { - return GetRailWaypointBits(tile) * 0x101; + + return ret; } + + case RAIL_TILE_DEPOT: return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101; + case RAIL_TILE_WAYPOINT: return GetRailWaypointBits(tile) * 0x101; } } static void ClickTile_Track(TileIndex tile) { - if (IsTileDepotType(tile, TRANSPORT_RAIL)) { - ShowDepotWindow(tile, VEH_Train); - } else if (IsRailWaypoint(tile)) { - ShowRenameWaypointWindow(GetWaypointByTile(tile)); + switch (GetRailTileType(tile)) { + case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_Train); break; + case RAIL_TILE_WAYPOINT: ShowRenameWaypointWindow(GetWaypointByTile(tile)); break; + default: break; } } -- cgit v1.2.3-54-g00ecf