summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-07-07 14:16:16 +0000
committermichi_cc <michi_cc@openttd.org>2011-07-07 14:16:16 +0000
commit662a0a9cd31111f9507e6d0706c3d5e9b7a425cc (patch)
tree844aa17136cf00df449de2dccfd9b6978df163fe /src
parentd1be388bc91fcffe5dc5687b2ae57789c5d576a7 (diff)
downloadopenttd-662a0a9cd31111f9507e6d0706c3d5e9b7a425cc.tar.xz
(svn r22638) -Fix: Keep the previous owner of the upper and lower lock parts if they are built on existing water.
Diffstat (limited to 'src')
-rw-r--r--src/water_cmd.cpp4
-rw-r--r--src/water_map.h6
2 files changed, 6 insertions, 4 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 3ce93333b..b37636ccb 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -279,8 +279,8 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) {
DoClearSquare(tile);
- MakeWaterKeepingClass(tile + delta, GetTileOwner(tile));
- MakeWaterKeepingClass(tile - delta, GetTileOwner(tile));
+ MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
+ MakeWaterKeepingClass(tile - delta, GetTileOwner(tile - delta));
MarkCanalsAndRiversAroundDirty(tile - delta);
MarkCanalsAndRiversAroundDirty(tile + delta);
}
diff --git a/src/water_map.h b/src/water_map.h
index d26b93210..02838a684 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -421,8 +421,10 @@ static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc
TileIndexDiff delta = TileOffsByDiagDir(d);
MakeLockTile(t, o, LOCK_MIDDLE + d, WATER_CLASS_CANAL);
- MakeLockTile(t - delta, o, LOCK_LOWER + d, wc_lower);
- MakeLockTile(t + delta, o, LOCK_UPPER + d, wc_upper);
+ /* Keep the current owner for the upper and lower part if it is a
+ * water tile so we can restore the owner after deleting the lock. */
+ MakeLockTile(t - delta, IsWaterTile(t - delta) ? GetTileOwner(t - delta) : o, LOCK_LOWER + d, wc_lower);
+ MakeLockTile(t + delta, IsWaterTile(t + delta) ? GetTileOwner(t + delta) : o, LOCK_UPPER + d, wc_upper);
}
#endif /* WATER_MAP_H */