From c1e4edb0d3b9093ecdadb299965af253f7890900 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 25 Dec 2025 14:30:39 +0000 Subject: [PATCH] Fix #14978: Don't clear water tiles after removing buoys. (#14980) Buoys have no owner and can be cleared by anyone, but the underlying tile (e.g. canal) should not be cleared if has a different owner. --- src/landscape.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/landscape.cpp b/src/landscape.cpp index bd26488354..8c5cf4b31b 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -13,6 +13,7 @@ #include "heightmap.h" #include "clear_map.h" #include "spritecache.h" +#include "station_map.h" #include "viewport_func.h" #include "command_func.h" #include "landscape.h" @@ -682,8 +683,11 @@ CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile) /* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */ if (flags.Test(DoCommandFlag::ForceClearTile) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) { if (flags.Test(DoCommandFlag::Auto) && GetWaterClass(tile) == WaterClass::Canal) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST); - do_clear = true; - cost.AddCost(GetWaterClass(tile) == WaterClass::Canal ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]); + /* Buoy tiles are special as they can be cleared by anyone, but the underlying tile shouldn't be cleared if it has a different owner. */ + if (!IsBuoyTile(tile) || GetTileOwner(tile) == _current_company) { + do_clear = true; + cost.AddCost(GetWaterClass(tile) == WaterClass::Canal ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]); + } } Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);