summaryrefslogtreecommitdiff
path: root/src/pathfinder/yapf
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-04 20:52:19 +0000
committerrubidium <rubidium@openttd.org>2009-12-04 20:52:19 +0000
commitfac2f8ce1ad9b527bbfdd1b80b727282a1e84e73 (patch)
tree534ac167cbfaa6800571d6acd6c58f5782439507 /src/pathfinder/yapf
parent65b3e38beab6454ec67eae26f30db548a84d437d (diff)
downloadopenttd-fac2f8ce1ad9b527bbfdd1b80b727282a1e84e73.tar.xz
(svn r18404) -Codechange: link drive through stops better together
-Feature: make penalty for road stop occupancy user configurable -Fix [FS#1944]: road vehicles would not pick an empty drive through stop. Now they will *if* the penalty for driving around is less than the occupancy penalty -Fix [FS#1495]: long (articulated) road vehicles could block loading of others when the following road vehicle already got 'permission' to go to the next bay even when it could not reach it -Change: improve the throughput of the drive through road stops by letting them stop closer together
Diffstat (limited to 'src/pathfinder/yapf')
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index 09df7ccf1..91a721da0 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -66,9 +66,21 @@ protected:
break;
case MP_STATION: {
- if (IsDriveThroughStopTile(tile)) cost += Yapf().PfGetSettings().road_stop_penalty;
- RoadStop *rs = RoadStop::GetByTile(tile, GetRoadStopType(tile));
- cost += 8 * YAPF_TILE_LENGTH * ((!rs->IsFreeBay(0)) + (!rs->IsFreeBay(1)));
+ const RoadStop *rs = RoadStop::GetByTile(tile, GetRoadStopType(tile));
+ if (IsDriveThroughStopTile(tile)) {
+ /* Increase the cost for drive-through road stops */
+ cost += Yapf().PfGetSettings().road_stop_penalty;
+ DiagDirection dir = TrackdirToExitdir(trackdir);
+ if (!RoadStop::IsDriveThroughRoadStopContinuation(tile, tile - TileOffsByDiagDir(dir))) {
+ /* 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();
+ }
+ } else {
+ /* Increase cost for filled road stops */
+ cost += Yapf().PfGetSettings().road_stop_bay_occupied_penalty * (!rs->IsFreeBay(0) + !rs->IsFreeBay(1)) / 2;
+ }
} break;
default: