From d95a87257901d79c95cca6d8447122344c5789d1 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 7 Feb 2007 17:52:21 +0000 Subject: [PATCH] (svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile. --- src/station_cmd.cpp | 10 +++++++++- src/station_map.h | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6e3e1b4d19..528352256e 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1806,7 +1806,15 @@ static int32 RemoveBuoy(Station *st, uint32 flags) st->facilities &= ~FACIL_DOCK; st->had_vehicle_of_type &= ~HVOT_BUOY; - MakeWater(tile); + /* We have to set the water tile's state to the same state as before the + * buoy was placed. Otherwise one could plant a buoy on a canal edge, + * remove it and flood the land (if the canal edge is at level 0) */ + Owner o = GetTileOwner(tile); + if (o == OWNER_WATER) { + MakeWater(tile); + } else { + MakeCanal(tile, o); + } MarkTileDirtyByTile(tile); UpdateStationVirtCoordDirty(st); diff --git a/src/station_map.h b/src/station_map.h index fed2107665..1128a39f99 100644 --- a/src/station_map.h +++ b/src/station_map.h @@ -287,7 +287,10 @@ static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section static inline void MakeBuoy(TileIndex t, StationID sid) { - MakeStation(t, OWNER_NONE, sid, GFX_BUOY_BASE); + /* Make the owner of the buoy tile the same as the current owner of the + * water tile. In this way, we can reset the owner of the water to its + * original state when the buoy gets removed. */ + MakeStation(t, GetTileOwner(t), sid, GFX_BUOY_BASE); } static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)