summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-10-26 16:26:50 +0000
committerbelugas <belugas@openttd.org>2007-10-26 16:26:50 +0000
commitc9858e35db267848d4a885edf60ed6daa9cac10d (patch)
tree3d5aaba148bd05bc7efb326e8efefc262e77dffb /src
parenta1c3d51f7fdfb7de8ba6b1f144c150490f24582a (diff)
downloadopenttd-c9858e35db267848d4a885edf60ed6daa9cac10d.tar.xz
(svn r11343) -Fix[FS#1368]: Autoslope did not work correctly for single track on higher part of steep slopes. (frosch)
Diffstat (limited to 'src')
-rw-r--r--src/rail_cmd.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 630671af3..ebb15f9c9 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2407,29 +2407,28 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_ol
z_old += ApplyFoundationToSlope(GetRailFoundation(tileh_old, rail_bits), &tileh_old);
z_new += ApplyFoundationToSlope(GetRailFoundation(tileh_new, rail_bits), &tileh_new);
- Slope track_corner;
+ Corner track_corner;
switch (rail_bits) {
- case TRACK_BIT_LEFT: track_corner = SLOPE_W; break;
- case TRACK_BIT_LOWER: track_corner = SLOPE_S; break;
- case TRACK_BIT_RIGHT: track_corner = SLOPE_E; break;
- case TRACK_BIT_UPPER: track_corner = SLOPE_N; break;
+ case TRACK_BIT_LEFT: track_corner = CORNER_W; break;
+ case TRACK_BIT_LOWER: track_corner = CORNER_S; break;
+ case TRACK_BIT_RIGHT: track_corner = CORNER_E; break;
+ case TRACK_BIT_UPPER: track_corner = CORNER_N; break;
/* Surface slope must not be changed */
default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : _price.terraform);
}
/* The height of the track_corner must not be changed. The rest ensures GetRailFoundation() already. */
- if ((tileh_old & track_corner) != 0) z_old += TILE_HEIGHT;
- if ((tileh_new & track_corner) != 0) z_new += TILE_HEIGHT;
+ z_old += GetSlopeZInCorner((Slope)(tileh_old & ~SLOPE_HALFTILE_MASK), track_corner);
+ z_new += GetSlopeZInCorner((Slope)(tileh_new & ~SLOPE_HALFTILE_MASK), track_corner);
if (z_old != z_new) return CMD_ERROR;
- bool was_water = GetRailGroundType(tile) == RAIL_GROUND_WATER;
-
- /* Make the ground dirty, if surface slope has changed */
- if ((tileh_old != tileh_new) && ((flags & DC_EXEC) != 0)) SetRailGroundType(tile, RAIL_GROUND_BARREN);
-
CommandCost cost = CommandCost(_price.terraform);
- if (was_water) cost.AddCost(_price.clear_water);
+ /* Make the ground dirty, if surface slope has changed */
+ if (tileh_old != tileh_new) {
+ if (GetRailGroundType(tile) == RAIL_GROUND_WATER) cost.AddCost(_price.clear_water);
+ if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
+ }
return cost;
}