diff options
author | tron <tron@openttd.org> | 2006-05-20 18:03:22 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-05-20 18:03:22 +0000 |
commit | 1dc8b1a00e98ea9d177b1193d8e0b9a4fc98bacd (patch) | |
tree | b71187cde11be0fb6787e8e38ea4f3df457d9598 /rail_cmd.c | |
parent | 2a3aca6139f4a108e694304687810448682f04e1 (diff) | |
download | openttd-1dc8b1a00e98ea9d177b1193d8e0b9a4fc98bacd.tar.xz |
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
Diffstat (limited to 'rail_cmd.c')
-rw-r--r-- | rail_cmd.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 55ea56cfe..203f83119 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -153,27 +153,24 @@ const TrackBits _valid_tileh_slopes[2][15] = { uint GetRailFoundation(Slope tileh, TrackBits bits) { - int i; - - if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) - return 0; + uint i; - if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) - return tileh; + if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0; + if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; - if (( - (i = 0, tileh == SLOPE_W) || - (i += 2, tileh == SLOPE_S) || - (i += 2, tileh == SLOPE_E) || - (i += 2, tileh == SLOPE_N) - ) && ( - bits == TRACK_BIT_X || - (i++, bits == TRACK_BIT_Y) - )) { - return i + 15; - } else { - return 0; + switch (bits) { + case TRACK_BIT_X: i = 0; break; + case TRACK_BIT_Y: i = 1; break; + default: return 0; + } + switch (tileh) { + case SLOPE_W: i += 0; break; + case SLOPE_S: i += 2; break; + case SLOPE_E: i += 4; break; + case SLOPE_N: i += 6; break; + default: return 0; } + return i + 15; } |