Do not cache road vehicle path within 8 tiles of destination with multiple entrances
This commit is contained in:
@@ -267,6 +267,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Station *GetDestinationStation() const
|
||||||
|
{
|
||||||
|
return m_dest_station != INVALID_STATION ? Station::GetIfValid(m_dest_station) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** to access inherited path finder */
|
/** to access inherited path finder */
|
||||||
Tpf& Yapf()
|
Tpf& Yapf()
|
||||||
@@ -421,6 +426,22 @@ public:
|
|||||||
path_cache.tile.pop_back();
|
path_cache.tile.pop_back();
|
||||||
}
|
}
|
||||||
path_cache.layout_ctr = _road_layout_change_counter;
|
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)) {
|
||||||
|
/* Destination station has at least 2 usable road stops, or first is a drive-through stop,
|
||||||
|
* trim end of path cache within 8 tiles of road stop tile area */
|
||||||
|
TileArea non_cached_area = v->IsBus() ? st->bus_station : st->truck_station;
|
||||||
|
non_cached_area.Expand(8);
|
||||||
|
while (!path_cache.empty() && non_cached_area.Contains(path_cache.tile.back())) {
|
||||||
|
path_cache.td.pop_back();
|
||||||
|
path_cache.tile.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return next_trackdir;
|
return next_trackdir;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user