summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-08-12 12:56:45 +0000
committertron <tron@openttd.org>2006-08-12 12:56:45 +0000
commit012e144cc10a5df24523085aab3ac78767fa92d4 (patch)
tree0bf68ac462bfafbdd65f20f1b609ed958b616c74 /rail_cmd.c
parentde4a96fd7a3a3fefb9119ffc4bf57cc27e8ae0a6 (diff)
downloadopenttd-012e144cc10a5df24523085aab3ac78767fa92d4.tar.xz
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index f94f4e2c2..4676d492b 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -160,9 +160,13 @@ uint GetRailFoundation(Slope tileh, TrackBits bits)
}
switch (bits) {
+ default: NOT_REACHED();
case TRACK_BIT_X: i = 0; break;
case TRACK_BIT_Y: i = 1; break;
- default: return 0;
+ case TRACK_BIT_LEFT: return 15 + 8 + (tileh == SLOPE_STEEP_W ? 4 : 0);
+ case TRACK_BIT_LOWER: return 15 + 8 + (tileh == SLOPE_STEEP_S ? 5 : 1);
+ case TRACK_BIT_RIGHT: return 15 + 8 + (tileh == SLOPE_STEEP_E ? 6 : 2);
+ case TRACK_BIT_UPPER: return 15 + 8 + (tileh == SLOPE_STEEP_N ? 7 : 3);
}
switch (tileh) {
case SLOPE_W:
@@ -182,9 +186,9 @@ uint GetRailFoundation(Slope tileh, TrackBits bits)
static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
{
if (IsSteepSlope(tileh)) {
- if (existing == 0 &&
- (rail_bits == TRACK_BIT_X || rail_bits == TRACK_BIT_Y)) {
- return _price.terraform;
+ if (existing == 0) {
+ TrackBits valid = TRACK_BIT_CROSS | (HASBIT(1 << SLOPE_STEEP_W | 1 << SLOPE_STEEP_E, tileh) ? TRACK_BIT_VERT : TRACK_BIT_HORZ);
+ if (valid & rail_bits) return _price.terraform;
}
} else {
rail_bits |= existing;