From fa82dd6096e6797ebd83024f05cdbd8cf2869255 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 5 Jun 2024 17:31:55 +0100 Subject: [PATCH] Fix #12030: Water infrastructure totals when using DC_FORCE_CLEAR_TILE To remove objects on water --- src/landscape.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/landscape.cpp b/src/landscape.cpp index d9bc4bc659..121c603569 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -30,6 +30,7 @@ #include "core/random_func.hpp" #include "object_base.h" #include "company_func.h" +#include "company_gui.h" #include "pathfinder/aystar.h" #include "saveload/saveload.h" #include "framerate_type.h" @@ -680,7 +681,16 @@ CommandCost CmdLandscapeClear(DoCommandFlag flags, TileIndex tile) if (flags & DC_EXEC) { if (c != nullptr) c->clear_limit -= 1 << 16; - if (do_clear) DoClearSquare(tile); + if (do_clear) { + if (IsWaterTile(tile) && IsCanal(tile)) { + Owner owner = GetTileOwner(tile); + if (Company::IsValidID(owner)) { + Company::Get(owner)->infrastructure.water--; + DirtyCompanyInfrastructureWindows(owner); + } + } + DoClearSquare(tile); + } } return cost; }