Changeset - r26441:fbfcf787e54d
[Not reviewed]
master
0 4 0
SamuXarick - 2 years ago 2022-05-24 20:11:23
43006711+SamuXarick@users.noreply.github.com
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.
4 files changed with 3 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/landscape.cpp
Show inline comments
 
@@ -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);
 
}
 

	
 
/**
src/rail_cmd.cpp
Show inline comments
 
@@ -1819,9 +1819,7 @@ static CommandCost ClearTile_Track(TileI
 

	
 
				/* 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]);
 
			}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -968,9 +968,6 @@ static CommandCost DoClearBridge(TileInd
 
			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(TileInd
 
			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) {
src/water_cmd.cpp
Show inline comments
 
@@ -548,10 +548,8 @@ static CommandCost ClearTile_Water(TileI
 
					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(TileI
 
			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]);
0 comments (0 inline, 0 general)