summaryrefslogtreecommitdiff
path: root/src/water_map.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/water_map.h')
-rw-r--r--src/water_map.h6
1 files changed, 4 insertions, 2 deletions
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 */