Fix crash when removing rail depot or road when debug window open on tile

This commit is contained in:
Jonathan G Rennison
2021-01-05 17:44:19 +00:00
parent 204f8e173f
commit 6965a339c4
2 changed files with 4 additions and 0 deletions

View File

@@ -2403,6 +2403,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
AddSideToSignalBuffer(tile, dir, owner); AddSideToSignalBuffer(tile, dir, owner);
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
if (v != nullptr) TryPathReserve(v, true); if (v != nullptr) TryPathReserve(v, true);
DeleteNewGRFInspectWindow(GSF_RAILTYPES, tile);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_TRAIN]); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_TRAIN]);

View File

@@ -771,6 +771,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) { if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) {
/* Includes MarkTileDirtyByTile() */ /* Includes MarkTileDirtyByTile() */
DoClearSquare(tile); DoClearSquare(tile);
DeleteNewGRFInspectWindow(GSF_ROADTYPES, tile);
} else { } else {
if (rtt == RTT_ROAD && IsRoadOwner(tile, rtt, OWNER_TOWN)) { if (rtt == RTT_ROAD && IsRoadOwner(tile, rtt, OWNER_TOWN)) {
/* Update nearest-town index */ /* Update nearest-town index */
@@ -825,6 +826,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
c->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR - 1; c->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR - 1;
DirtyCompanyInfrastructureWindows(c->index); DirtyCompanyInfrastructureWindows(c->index);
} }
DeleteNewGRFInspectWindow(GSF_ROADTYPES, tile);
} else { } else {
SetRoadType(tile, rtt, INVALID_ROADTYPE); SetRoadType(tile, rtt, INVALID_ROADTYPE);
} }
@@ -1715,6 +1717,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
DoClearSquare(tile); DoClearSquare(tile);
NotifyRoadLayoutChanged(false); NotifyRoadLayoutChanged(false);
DeleteNewGRFInspectWindow(GSF_ROADTYPES, tile);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_ROAD]); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_ROAD]);