summaryrefslogtreecommitdiff
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
commita3c6034eb789be84a4c9df7f17f7ba470cce9838 (patch)
tree3d5aaba148bd05bc7efb326e8efefc262e77dffb
parent134227aa8ccd822e2a836042ba734213c5b15023 (diff)
downloadopenttd-a3c6034eb789be84a4c9df7f17f7ba470cce9838.tar.xz
(svn r11343) -Fix[FS#1368]: Autoslope did not work correctly for single track on higher part of steep slopes. (frosch)
-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;
}