summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-07-27 19:55:27 +0000
committerfrosch <frosch@openttd.org>2012-07-27 19:55:27 +0000
commit59a3bbcbe691bba194a5d3f17e4015e2abe90ae9 (patch)
tree756004384e3edc7ea69e1d57a95eb2f16c3238b2
parent13bfb09cbb1de18383ffa7991fa581cacc5b28b4 (diff)
downloadopenttd-59a3bbcbe691bba194a5d3f17e4015e2abe90ae9.tar.xz
(svn r24439) -Fix [FS#5254]: In some cases ships could be covered with land.
-rw-r--r--src/rail_cmd.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index ffa42de82..397173a3a 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2930,6 +2930,14 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old
return cost;
}
+/**
+ * Test-procedure for HasVehicleOnPos to check for a ship.
+ */
+static Vehicle *EnsureNoShipProc(Vehicle *v, void *data)
+{
+ return v->type == VEH_SHIP ? v : NULL;
+}
+
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
{
int z_old;
@@ -2939,6 +2947,9 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int
/* Is there flat water on the lower halftile that must be cleared expensively? */
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
+ /* Allow clearing the water only if there is no ship */
+ if (was_water && HasVehicleOnPos(tile, NULL, &EnsureNoShipProc)) return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
+
/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);