1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-30 01:49:10 +00:00

Fix #9870: Don't update infrastructure totals when overbuilding object on canal

This commit is contained in:
Tyler Trahan
2022-05-11 17:59:57 -06:00
committed by Michael Lutz
parent 24d7697acc
commit 37d318c410

View File

@@ -495,11 +495,14 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
FALLTHROUGH; FALLTHROUGH;
default: default:
MakeCanal(current_tile, _current_company, Random()); /* If we overbuild a water object with a canal, don't update the infrastructure total. */
if (Company::IsValidID(_current_company)) { 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++; Company::Get(_current_company)->infrastructure.water++;
DirtyCompanyInfrastructureWindows(_current_company); DirtyCompanyInfrastructureWindows(_current_company);
} }
MakeCanal(current_tile, _current_company, Random());
break; break;
} }
MarkTileDirtyByTile(current_tile); MarkTileDirtyByTile(current_tile);