@@ -651,7 +651,7 @@ CommandCost CmdRemoveSingleRail(DoComman
cost.AddCost(RailClearCost(GetRailType(tile)));
if (flags & DC_EXEC) {
MarkDirtyAdjacentLevelCrossingTiles(tile, GetCrossingRoadAxis(tile));
UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(tile, GetCrossingRoadAxis(tile));
if (HasReservedTracks(tile, trackbit)) {
v = GetTrainForReservation(tile, track);
@@ -504,7 +504,7 @@ static CommandCost RemoveRoad(TileIndex
}
/* A full diagonal road tile has two road bits. */
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -2);
@@ -155,6 +155,7 @@ RoadTypes AddDateIntroducedRoadTypes(Roa
void UpdateLevelCrossing(TileIndex tile, bool sound = true, bool force_bar = false);
void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis);
void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis road_axis);
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count);
struct TileInfo;
@@ -1790,7 +1790,8 @@ void UpdateLevelCrossing(TileIndex tile,
/**
* Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
* @param The tile which causes the update.
* @param tile The tile which causes the update.
* @param road_axis The road axis.
*/
void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis)
{
@@ -1805,6 +1806,44 @@ void MarkDirtyAdjacentLevelCrossingTiles
* Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing tile.
* @param tile The crossing tile which has been or is about to be removed, and which caused the update.
void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis road_axis)
const DiagDirection dir1 = AxisToDiagDir(road_axis);
const DiagDirection dir2 = ReverseDiagDir(dir1);
for (DiagDirection dir : { dir1, dir2 }) {
const TileIndexDiff diff = TileOffsByDiagDir(dir);
bool occupied = false;
for (TileIndex t = tile + diff; t < Map::Size() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == road_axis; t += diff) {
occupied |= CheckLevelCrossing(t);
if (occupied) {
/* Mark the immediately adjacent tile dirty */
const TileIndex t = tile + diff;
if (t < Map::Size() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == road_axis) {
MarkTileDirtyByTile(t);
} else {
/* Unbar the crossing tiles in this direction as necessary */
if (IsCrossingBarred(t)) {
/* The crossing tile is barred, unbar it and continue to check the next tile */
SetCrossingBarred(t, false);
/* The crossing tile is already unbarred, mark the tile dirty and stop checking */
break;
* Bars crossing and plays ding-ding sound if not barred already
* @param tile tile with crossing
* @pre tile is a rail-road crossing
Status change: