Fix #9869: remove docking tile when doing a clear square

Terraforming through objects placed on water didn't properly remove docking tiles as expected.

By moving some logic regarding removal of docking tiles into DoClearSquare, the issue is solved, while also simplifying code, avoiding repetition elsewhere.
This commit is contained in:
SamuXarick
2022-05-24 21:11:23 +01:00
committed by Michael Lutz
parent be7db78767
commit c7505539af
4 changed files with 3 additions and 13 deletions

View File

@@ -548,10 +548,8 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
Company::Get(owner)->infrastructure.water--;
DirtyCompanyInfrastructureWindows(owner);
}
bool remove = IsDockingTile(tile);
DoClearSquare(tile);
MarkCanalsAndRiversAroundDirty(tile);
if (remove) RemoveDockingTile(tile);
}
return CommandCost(EXPENSES_CONSTRUCTION, base_cost);
@@ -565,10 +563,8 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
bool remove = IsDockingTile(tile);
DoClearSquare(tile);
MarkCanalsAndRiversAroundDirty(tile);
if (remove) RemoveDockingTile(tile);
}
if (IsSlopeWithOneCornerRaised(slope)) {
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER]);