diff options
author | tron <tron@openttd.org> | 2005-01-16 09:51:56 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-01-16 09:51:56 +0000 |
commit | 1955371a714152a37d698f4c60b731f3e1edcaf5 (patch) | |
tree | 4b8b464819e210ab00a19dda8fe2b64b04a5166e | |
parent | d41a003bccf5537d7e7f6c162f874fc6bfd1fee6 (diff) | |
download | openttd-1955371a714152a37d698f4c60b731f3e1edcaf5.tar.xz |
(svn r1533) Turn an if cascade into a switch and move a const array to the only location where it is used
-rw-r--r-- | station_cmd.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/station_cmd.c b/station_cmd.c index 9ee23292b..e86189a02 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2072,22 +2072,30 @@ static void GetTileDesc_Station(uint tile, TileDesc *td) } -static const byte _tile_track_status_rail[8] = { 1,2,1,2,1,2,1,2 }; - static uint32 GetTileTrackStatus_Station(uint tile, TransportType mode) { uint i = _map5[tile]; uint j = 0; - if (mode == TRANSPORT_RAIL) { - if (i < 8) - j = _tile_track_status_rail[i]; - j += (j << 8); - } else if (mode == TRANSPORT_WATER) { - // buoy is coded as a station, it is always on open water - // (0x3F, all tracks available) - if (i == 0x52) j = 0x3F; - j += (j << 8); + switch (mode) { + case TRANSPORT_RAIL: + if (i < 8) { + const byte tile_track_status_rail[8] = { 1, 2, 1, 2, 1, 2, 1, 2 }; + j = tile_track_status_rail[i]; + } + j += (j << 8); + break; + + case TRANSPORT_WATER: + // buoy is coded as a station, it is always on open water + // (0x3F, all tracks available) + if (i == 0x52) j = 0x3F; + j += (j << 8); + break; + + default: + break; } + return j; } |