Skip to content

Commit

Permalink
Only do RV leader check within uncached area
Browse files Browse the repository at this point in the history
  • Loading branch information
JGRennison committed Jul 12, 2020
1 parent c1adefc commit f998b1e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pathfinder/yapf/yapf_road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,19 @@ class CYapfFollowRoadT
Yapf().SetDestination(v);

bool multiple_targets = false;
TileArea non_cached_area;
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;
non_cached_area = v->IsBus() ? st->bus_station : st->truck_station;
non_cached_area.Expand(YAPF_ROADVEH_PATH_CACHE_DESTINATION_LIMIT);
}
}

Yapf().leader_targets[0] = INVALID_TILE;
if (multiple_targets) {
if (multiple_targets && non_cached_area.Contains(tile)) {
/* 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) {
Expand Down Expand Up @@ -502,8 +505,6 @@ class CYapfFollowRoadT
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;
non_cached_area.Expand(YAPF_ROADVEH_PATH_CACHE_DESTINATION_LIMIT);
while (!path_cache.empty() && non_cached_area.Contains(path_cache.tile.back())) {
path_cache.td.pop_back();
path_cache.tile.pop_back();
Expand Down

0 comments on commit f998b1e

Please sign in to comment.