Index: src/water_cmd.cpp
===================================================================
--- src/water_cmd.cpp (revision 27632)
+++ src/water_cmd.cpp (working copy)
@@ -135,6 +135,39 @@
cost.AddCost(ret);
}
+ TrackBits tb;
+ TileIndex tc = tile + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_NE) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_SE) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_NE) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_SE) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_SW) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_NW) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_SW) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_NW) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
if (flags & DC_EXEC) {
Depot *depot = new Depot(tile);
depot->build_date = _date;
@@ -372,6 +405,41 @@
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
+ Axis axis = DiagDirToAxis(dir);
+ TrackBits tb;
+ CommandCost ret;
+ TileIndex tc = tile + (axis == AXIS_X ? TileDiffXY(-1, -1) : TileDiffXY(1, -1));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_NE) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_SE) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile + (axis == AXIS_X ? TileDiffXY(1, -1) : TileDiffXY(1, 1));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_NE) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_SE) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile + (axis == AXIS_X ? TileDiffXY(-1, 1) : TileDiffXY(-1, -1));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_SW) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_NW) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
+ tc = tile + (axis == AXIS_X ? TileDiffXY(1, 1) : TileDiffXY(-1, 1));
+ if (HasTileWaterClass(tc)) {
+ tb = TrackStatusToTrackBits(GetTileTrackStatus(tc, TRANSPORT_WATER, 0));
+ if (((axis == AXIS_Y && (tb & TRACK_BIT_3WAY_SW) != 0) || (axis == AXIS_X && (tb & TRACK_BIT_3WAY_NW) != 0) && !IsShipDepotTile(tc) && IsTileType(tc, MP_WATER) && !IsLock(tc))) {
+ ret = EnsureNoVehicleOnGround(tc);
+ if (ret.Failed()) return ret;
+ }
+ }
return DoBuildLock(tile, dir, flags);
}