From 37d318c41098f128924e1fa3369492594a9ce6c3 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Wed, 11 May 2022 17:59:57 -0600 Subject: [PATCH] Fix #9870: Don't update infrastructure totals when overbuilding object on canal --- src/water_cmd.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 6d26888d14..211e89b4a0 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -495,11 +495,14 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t FALLTHROUGH; default: - MakeCanal(current_tile, _current_company, Random()); - if (Company::IsValidID(_current_company)) { + /* If we overbuild a water object with a canal, don't update the infrastructure total. */ + bool is_existing_canal = IsTileType(current_tile, MP_WATER) && IsCanal(current_tile); + if (Company::IsValidID(_current_company) && !is_existing_canal) { Company::Get(_current_company)->infrastructure.water++; DirtyCompanyInfrastructureWindows(_current_company); } + + MakeCanal(current_tile, _current_company, Random()); break; } MarkTileDirtyByTile(current_tile);