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

@@ -648,10 +648,12 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
make_bridge_ramp(tile_start, dir);
make_bridge_ramp(tile_end, ReverseDiagDir(dir));
AddRoadTunnelBridgeInfrastructure(tile_start, tile_end);
if (IsRoadCustomBridgeHead(tile_start) || IsRoadCustomBridgeHead(tile_end)) {
NotifyRoadLayoutChanged();
} else {
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile_start, tile_end, dir, GetRoadTramType(roadtype));
if (RoadLayoutChangeNotificationEnabled(true)) {
if (IsRoadCustomBridgeHead(tile_start) || IsRoadCustomBridgeHead(tile_end)) {
NotifyRoadLayoutChanged();
} else {
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile_start, tile_end, dir, GetRoadTramType(roadtype));
}
}
break;
}
@@ -1011,7 +1013,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction));
} else {
if (c != nullptr) c->infrastructure.road[roadtype] += num_pieces * 2; // A full diagonal road has two road bits.
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(start_tile, end_tile, direction, GetRoadTramType(roadtype));
if (RoadLayoutChangeNotificationEnabled(true)) NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(start_tile, end_tile, direction, GetRoadTramType(roadtype));
RoadType road_rt = RoadTypeIsRoad(roadtype) ? roadtype : INVALID_ROADTYPE;
RoadType tram_rt = RoadTypeIsTram(roadtype) ? roadtype : INVALID_ROADTYPE;
MakeRoadTunnel(start_tile, company, t->index, direction, road_rt, tram_rt);
@@ -1148,8 +1150,10 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
/* A full diagonal road tile has two road bits. */
UpdateCompanyRoadInfrastructure(GetRoadTypeRoad(tile), GetRoadOwner(tile, RTT_ROAD), -(int)(len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR));
UpdateCompanyRoadInfrastructure(GetRoadTypeTram(tile), GetRoadOwner(tile, RTT_TRAM), -(int)(len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR));
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, GetTunnelBridgeDirection(tile), RTT_ROAD);
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, GetTunnelBridgeDirection(tile), RTT_TRAM);
if (RoadLayoutChangeNotificationEnabled(false)) {
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, GetTunnelBridgeDirection(tile), RTT_ROAD);
NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, GetTunnelBridgeDirection(tile), RTT_TRAM);
}
delete Tunnel::GetByTile(tile);
@@ -1246,11 +1250,13 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
SubtractRailTunnelBridgeInfrastructure(tile, endtile);
} else if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
SubtractRoadTunnelBridgeInfrastructure(tile, endtile);
if (IsRoadCustomBridgeHead(tile) || IsRoadCustomBridgeHead(endtile)) {
NotifyRoadLayoutChanged();
} else {
if (HasRoadTypeRoad(tile)) NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, direction, RTT_ROAD);
if (HasRoadTypeTram(tile)) NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, direction, RTT_TRAM);
if (RoadLayoutChangeNotificationEnabled(false)) {
if (IsRoadCustomBridgeHead(tile) || IsRoadCustomBridgeHead(endtile)) {
NotifyRoadLayoutChanged();
} else {
if (HasRoadTypeRoad(tile)) NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, direction, RTT_ROAD);
if (HasRoadTypeTram(tile)) NotifyRoadLayoutChangedIfSimpleTunnelBridgeNonLeaf(tile, endtile, direction, RTT_TRAM);
}
}
} else { // Aqueduct
if (Company::IsValidID(owner)) Company::Get(owner)->infrastructure.water -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;