diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1442,8 +1442,8 @@ static CommandCost RemoveTrainDepot(Tile if (v != NULL) FreeTrainTrackReservation(v); } + delete Depot::GetByTile(tile); DoClearSquare(tile); - delete Depot::GetByTile(tile); AddSideToSignalBuffer(tile, dir, owner); YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); if (v != NULL) TryPathReserve(v, true); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -895,8 +895,8 @@ static CommandCost RemoveRoadDepot(TileI if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { + delete Depot::GetByTile(tile); DoClearSquare(tile); - delete Depot::GetByTile(tile); } return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);