(svn r11343) -Fix[FS#1368]: Autoslope did not work correctly for single track on higher part of steep slopes. (frosch)
--- a/src/rail_cmd.cpp Thu Oct 25 23:45:03 2007 +0000
+++ b/src/rail_cmd.cpp Fri Oct 26 16:26:50 2007 +0000
@@ -2407,29 +2407,28 @@
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;
}