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

@@ -968,9 +968,6 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
if (v != nullptr) FreeTrainTrackReservation(v);
}
bool removetile = false;
bool removeendtile = false;
/* Update company infrastructure counts. */
if (rail) {
if (Company::IsValidID(owner)) Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
@@ -980,16 +977,12 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
UpdateCompanyRoadInfrastructure(GetRoadTypeTram(tile), GetRoadOwner(tile, RTT_TRAM), -(int)(len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR));
} else { // Aqueduct
if (Company::IsValidID(owner)) Company::Get(owner)->infrastructure.water -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
removetile = IsDockingTile(tile);
removeendtile = IsDockingTile(endtile);
}
DirtyCompanyInfrastructureWindows(owner);
DoClearSquare(tile);
DoClearSquare(endtile);
if (removetile) RemoveDockingTile(tile);
if (removeendtile) RemoveDockingTile(endtile);
for (TileIndex c = tile + delta; c != endtile; c += delta) {
/* do not let trees appear from 'nowhere' after removing bridge */
if (IsNormalRoadTile(c) && GetRoadside(c) == ROADSIDE_TREES) {