summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-20 15:39:23 +0000
committerrubidium <rubidium@openttd.org>2011-11-20 15:39:23 +0000
commit56a2c4b177075c0adcb18c4053155988b8926e5c (patch)
tree0e3500d01e66592bbedc900e133e9e6d18d7f444
parent18a0dc894d49ff1b141adbac13845999ad7541a7 (diff)
downloadopenttd-56a2c4b177075c0adcb18c4053155988b8926e5c.tar.xz
(svn r23284) -Fix [FS#4845]: Pathfinders go haywire when you build a lock over a ship going perpendicular to the axis of the new lock
-rw-r--r--src/water_cmd.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 58811ac00..3e1758e9a 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -205,12 +205,17 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
{
CommandCost cost(EXPENSES_CONSTRUCTION);
+ int delta = TileOffsByDiagDir(dir);
+ CommandCost ret = EnsureNoVehicleOnGround(tile);
+ if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
+ if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
+ if (ret.Failed()) return ret;
+
/* middle tile */
- CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
cost.AddCost(ret);
- int delta = TileOffsByDiagDir(dir);
/* lower tile */
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;