forked from mirror/OpenTTD
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:
@@ -32,6 +32,7 @@
|
||||
#include "saveload/saveload.h"
|
||||
#include "framerate_type.h"
|
||||
#include "landscape_cmd.h"
|
||||
#include "station_func.h"
|
||||
#include <array>
|
||||
#include <list>
|
||||
#include <set>
|
||||
@@ -574,8 +575,10 @@ void DoClearSquare(TileIndex tile)
|
||||
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
|
||||
if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != nullptr) DeleteAnimatedTile(tile);
|
||||
|
||||
bool remove = IsDockingTile(tile);
|
||||
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
|
||||
MarkTileDirtyByTile(tile);
|
||||
if (remove) RemoveDockingTile(tile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1819,9 +1819,7 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
|
||||
|
||||
/* The track was removed, and left a coast tile. Now also clear the water. */
|
||||
if (flags & DC_EXEC) {
|
||||
bool remove = IsDockingTile(tile);
|
||||
DoClearSquare(tile);
|
||||
if (remove) RemoveDockingTile(tile);
|
||||
}
|
||||
cost.AddCost(_price[PR_CLEAR_WATER]);
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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]);
|
||||
|
Reference in New Issue
Block a user