Skip to content

Commit dce2fca

Browse files
committed
Fix OpenTTD#14978: Don't clear water tiles after removing buoys.
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.
1 parent fb79508 commit dce2fca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/landscape.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "heightmap.h"
1414
#include "clear_map.h"
1515
#include "spritecache.h"
16+
#include "station_map.h"
1617
#include "viewport_func.h"
1718
#include "command_func.h"
1819
#include "landscape.h"
@@ -682,8 +683,11 @@ CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile)
682683
/* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */
683684
if (flags.Test(DoCommandFlag::ForceClearTile) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
684685
if (flags.Test(DoCommandFlag::Auto) && GetWaterClass(tile) == WaterClass::Canal) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
685-
do_clear = true;
686-
cost.AddCost(GetWaterClass(tile) == WaterClass::Canal ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
686+
/* 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. */
687+
if (!IsBuoyTile(tile) || GetTileOwner(tile) == _current_company) {
688+
do_clear = true;
689+
cost.AddCost(GetWaterClass(tile) == WaterClass::Canal ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
690+
}
687691
}
688692

689693
Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);

0 commit comments

Comments
 (0)