Only do RV leader check if there are multiple target candidates
This commit is contained in:
@@ -445,10 +445,22 @@ public:
|
||||
Yapf().SetOrigin(src_tile, src_trackdirs);
|
||||
Yapf().SetDestination(v);
|
||||
|
||||
for (int i = 0; i < MAX_RV_LEADER_TARGETS; ++i) {
|
||||
bool multiple_targets = false;
|
||||
const Station *st = Yapf().GetDestinationStation();
|
||||
if (st) {
|
||||
const RoadStop *stop = st->GetPrimaryRoadStop(v);
|
||||
if (stop != nullptr && (IsDriveThroughStopTile(stop->xy) || stop->GetNextRoadStop(v) != nullptr)) {
|
||||
multiple_targets = true;
|
||||
}
|
||||
}
|
||||
|
||||
Yapf().leader_targets[0] = INVALID_TILE;
|
||||
if (multiple_targets) {
|
||||
/* Destination station has at least 2 usable road stops, or first is a drive-through stop,
|
||||
* check for other vehicles headin to the same destination directly in front */
|
||||
for (int i = 1; i < MAX_RV_LEADER_TARGETS; ++i) {
|
||||
Yapf().leader_targets[i] = INVALID_TILE;
|
||||
}
|
||||
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||
FindVehiclesOnTileProcData data;
|
||||
data.origin_vehicle = v;
|
||||
data.targets = &Yapf().leader_targets;
|
||||
@@ -487,10 +499,7 @@ public:
|
||||
path_cache.layout_ctr = _road_layout_change_counter;
|
||||
|
||||
/* Check if target is a station, and cached path ends within 8 tiles of the dest tile */
|
||||
const Station *st = Yapf().GetDestinationStation();
|
||||
if (st) {
|
||||
const RoadStop *stop = st->GetPrimaryRoadStop(v);
|
||||
if (stop != nullptr && (IsDriveThroughStopTile(stop->xy) || stop->GetNextRoadStop(v) != nullptr)) {
|
||||
if (multiple_targets) {
|
||||
/* Destination station has at least 2 usable road stops, or first is a drive-through stop,
|
||||
* trim end of path cache within a number of tiles of road stop tile area */
|
||||
TileArea non_cached_area = v->IsBus() ? st->bus_station : st->truck_station;
|
||||
@@ -501,7 +510,6 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return next_trackdir;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user