From fac2f8ce1ad9b527bbfdd1b80b727282a1e84e73 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 4 Dec 2009 20:52:19 +0000 Subject: (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 --- src/pathfinder/npf/npf.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/pathfinder/npf') diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index ad7626f30..f6841796a 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -351,10 +351,21 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare case MP_STATION: { cost = NPF_TILE_LENGTH; - /* Increase the cost for drive-through road stops */ - if (IsDriveThroughStopTile(tile)) cost += _settings_game.pf.npf.npf_road_drive_through_penalty; - RoadStop *rs = RoadStop::GetByTile(tile, GetRoadStopType(tile)); - cost += 8 * NPF_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 += _settings_game.pf.npf.npf_road_drive_through_penalty; + DiagDirection dir = TrackdirToExitdir(current->direction); + 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() * _settings_game.pf.npf.npf_road_dt_occupied_penalty / entry->GetLength(); + } + } else { + /* Increase cost for filled road stops */ + cost += _settings_game.pf.npf.npf_road_bay_occupied_penalty * (!rs->IsFreeBay(0) + !rs->IsFreeBay(1)) / 2; + } } break; default: -- cgit v1.2.3-54-g00ecf