diff options
author | tron <tron@openttd.org> | 2006-08-10 14:44:32 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-08-10 14:44:32 +0000 |
commit | 0403405d5dd575ccbaf8d2a1d34ba5f6df6cf305 (patch) | |
tree | f0019d1ff7a97f3f447d9e52ade98bd94a777737 /rail_cmd.c | |
parent | 1f006f20620d02633b37ce3cc3808ecd3b6bcc0c (diff) | |
download | openttd-0403405d5dd575ccbaf8d2a1d34ba5f6df6cf305.tar.xz |
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
Diffstat (limited to 'rail_cmd.c')
-rw-r--r-- | rail_cmd.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 338742b25..f94f4e2c2 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -154,8 +154,10 @@ uint GetRailFoundation(Slope tileh, TrackBits bits) { uint i; - if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0; - if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; + if (!IsSteepSlope(tileh)) { + if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0; + if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; + } switch (bits) { case TRACK_BIT_X: i = 0; break; @@ -163,11 +165,15 @@ uint GetRailFoundation(Slope tileh, TrackBits bits) 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; + case SLOPE_W: + case SLOPE_STEEP_W: i += 0; break; + case SLOPE_S: + case SLOPE_STEEP_S: i += 2; break; + case SLOPE_E: + case SLOPE_STEEP_E: i += 4; break; + case SLOPE_N: + case SLOPE_STEEP_N: i += 6; break; + default: return 0; } return i + 15; } @@ -175,8 +181,12 @@ uint GetRailFoundation(Slope tileh, TrackBits bits) static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) { - // never allow building on top of steep tiles - if (!IsSteepSlope(tileh)) { + if (IsSteepSlope(tileh)) { + if (existing == 0 && + (rail_bits == TRACK_BIT_X || rail_bits == TRACK_BIT_Y)) { + return _price.terraform; + } + } else { rail_bits |= existing; // don't allow building on the lower side of a coast @@ -1702,7 +1712,11 @@ static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y) uint f = GetRailFoundation(tileh, GetTrackBits(tile)); if (f != 0) { - if (f < 15) return z + TILE_HEIGHT; // leveled foundation + if (IsSteepSlope(tileh)) { + z += TILE_HEIGHT; + } else if (f < 15) { + return z + TILE_HEIGHT; // leveled foundation + } tileh = _inclined_tileh[f - 15]; // inclined foundation } return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |