Add setting to control RV re-routing on road layout change

Default to road removal only
This is due to poor performance with many RVs when town growth is
continually adding to the road layout
This commit is contained in:
Jonathan G Rennison
2020-07-02 17:47:26 +01:00
parent 903b0fdd39
commit d5ada6a14b
8 changed files with 66 additions and 26 deletions

View File

@@ -467,7 +467,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
DirtyAllCompanyInfrastructureWindows();
/* Todo: Change this to be more fine-grained if necessary */
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(false);
}
} else {
assert_tile(IsDriveThroughStopTile(tile), tile);
@@ -477,7 +477,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -2);
SetRoadType(tile, rtt, INVALID_ROADTYPE);
MarkTileDirtyByTile(tile);
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(false);
}
}
return cost;
@@ -530,7 +530,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
}
}
NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, present | pieces);
if (RoadLayoutChangeNotificationEnabled(false)) NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, present | pieces);
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -(int)CountBits(pieces));
if (present == ROAD_NONE) {
@@ -575,7 +575,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -2);
Track railtrack = GetCrossingRailTrack(tile);
NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, GetCrossingRoadBits(tile));
if (RoadLayoutChangeNotificationEnabled(false)) NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, GetCrossingRoadBits(tile));
if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) {
TrackBits tracks = GetCrossingRailBits(tile);
bool reserved = HasCrossingReservation(tile);
@@ -860,7 +860,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MakeRoadCrossing(tile, company, company, GetTileOwner(tile), roaddir, GetRailType(tile), rtt == RTT_ROAD ? rt : INVALID_ROADTYPE, (rtt == RTT_TRAM) ? rt : INVALID_ROADTYPE, p2);
SetCrossingReservation(tile, reserved);
UpdateLevelCrossing(tile, false);
NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, GetCrossingRoadBits(tile));
if (RoadLayoutChangeNotificationEnabled(true)) NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, GetCrossingRoadBits(tile));
MarkTileDirtyByTile(tile);
}
return CommandCost(EXPENSES_CONSTRUCTION, 2 * RoadBuildCost(rt));
@@ -991,7 +991,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MarkBridgeDirty(tile);
AddRoadTunnelBridgeInfrastructure(tile, other_end);
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(true);
DirtyAllCompanyInfrastructureWindows();
}
@@ -1089,7 +1089,7 @@ do_clear:;
if (rtt == RTT_ROAD) SetTownIndex(tile, p2);
}
if (rttype != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rtt);
NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, existing | pieces);
if (RoadLayoutChangeNotificationEnabled(true)) NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, existing | pieces);
break;
}
@@ -1108,7 +1108,7 @@ do_clear:;
MarkTileDirtyByTile(other_end);
MarkTileDirtyByTile(tile);
}
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(true);
break;
}
@@ -1116,13 +1116,13 @@ do_clear:;
assert_tile(IsDriveThroughStopTile(tile), tile);
SetRoadType(tile, rtt, rt);
SetRoadOwner(tile, rtt, company);
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(true);
break;
}
default:
MakeRoadNormal(tile, pieces, (rtt == RTT_ROAD) ? rt : INVALID_ROADTYPE, (rtt == RTT_TRAM) ? rt : INVALID_ROADTYPE, p2, company, company);
NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, pieces);
if (RoadLayoutChangeNotificationEnabled(true)) NotifyRoadLayoutChangedIfTileNonLeaf(tile, rtt, pieces);
break;
}
@@ -1387,7 +1387,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
MarkTileDirtyByTile(tile);
MakeDefaultName(dep);
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(true);
}
cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
return cost;
@@ -1416,7 +1416,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
delete Depot::GetByTile(tile);
DoClearSquare(tile);
NotifyRoadLayoutChanged();
NotifyRoadLayoutChanged(false);
}
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_ROAD]);