Allow drive-through road stops to be one-way

This commit is contained in:
Jonathan G Rennison
2020-10-24 20:39:15 +01:00
parent 3fa92f5d8e
commit 3a75f13874
16 changed files with 333 additions and 50 deletions

View File

@@ -68,7 +68,7 @@ protected:
}
/** return one tile cost */
inline int OneTileCost(TileIndex tile, Trackdir trackdir)
inline int OneTileCost(TileIndex tile, Trackdir trackdir, const TrackFollower *tf)
{
int cost = 0;
@@ -101,7 +101,11 @@ protected:
/* When we're the first road stop in a 'queue' of them we increase
* cost based on the fill percentage of the whole queue. */
const RoadStop::Entry *entry = rs->GetEntry(dir);
cost += entry->GetOccupied() * Yapf().PfGetSettings().road_stop_occupied_penalty / entry->GetLength();
if (GetDriveThroughStopDisallowedRoadDirections(tile) != DRD_NONE && !tf->IsTram()) {
cost += (entry->GetOccupied() + rs->GetEntry(ReverseDiagDir(dir))->GetOccupied()) * Yapf().PfGetSettings().road_stop_occupied_penalty / (2 * entry->GetLength());
} else {
cost += entry->GetOccupied() * Yapf().PfGetSettings().road_stop_occupied_penalty / entry->GetLength();
}
}
if (predicted_occupied) {
@@ -153,7 +157,7 @@ public:
for (;;) {
/* base tile cost depending on distance between edges */
segment_cost += Yapf().OneTileCost(tile, trackdir);
segment_cost += Yapf().OneTileCost(tile, trackdir, tf);
const RoadVehicle *v = Yapf().GetVehicle();
/* we have reached the vehicle's destination - segment should end here to avoid target skipping */