summaryrefslogtreecommitdiff
path: root/src/pathfinder/yapf/yapf_road.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-02 17:56:02 +0000
committerrubidium <rubidium@openttd.org>2009-12-02 17:56:02 +0000
commit4ec4fdff36e96321773a2a087784e9fd4ec4105d (patch)
treec220ca47a65d32335c7b013425341a0e4f6762a5 /src/pathfinder/yapf/yapf_road.cpp
parent59f9163e37a7da7e8ef1cf52de8aa5e349ead5c1 (diff)
downloadopenttd-4ec4fdff36e96321773a2a087784e9fd4ec4105d.tar.xz
(svn r18382) -Codechange: make road vehicles behave more like trains 'around' stations and use pathfinder penalties to determine to which 'part' to go. Note that the pathfinder penalties for drive through stops are currently only looking at the occupation of the first in a row, but this is to change later on.
Diffstat (limited to 'src/pathfinder/yapf/yapf_road.cpp')
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index af4413111..5ca3b1441 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -66,11 +66,11 @@ protected:
}
break;
- case MP_STATION:
- if (IsDriveThroughStopTile(tile)) {
- cost += Yapf().PfGetSettings().road_stop_penalty;
- }
- 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)));
+ } break;
default:
break;
@@ -268,12 +268,24 @@ public:
protected:
TileIndex m_destTile;
TrackdirBits m_destTrackdirs;
+ StationID m_dest_station;
+ bool m_bus;
+ bool m_non_artic;
public:
void SetDestination(const RoadVehicle *v)
{
- m_destTile = v->dest_tile;
- m_destTrackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_ROAD, v->compatible_roadtypes));
+ if (v->current_order.IsType(OT_GOTO_STATION)) {
+ m_dest_station = v->current_order.GetDestination();
+ m_bus = v->IsBus();
+ m_destTile = CalcClosestStationTile(m_dest_station, v->tile, m_bus ? STATION_BUS : STATION_TRUCK);
+ m_non_artic = !v->HasArticulatedPart();
+ m_destTrackdirs = INVALID_TRACKDIR_BIT;
+ } else {
+ m_dest_station = INVALID_STATION;
+ m_destTile = v->dest_tile;
+ m_destTrackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_ROAD, v->compatible_roadtypes));
+ }
}
protected:
@@ -292,6 +304,13 @@ public:
FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
{
+ if (m_dest_station != INVALID_STATION) {
+ return IsTileType(tile, MP_STATION) &&
+ GetStationIndex(tile) == m_dest_station &&
+ (m_bus ? IsBusStop(tile) : IsTruckStop(tile)) &&
+ (m_non_artic || IsDriveThroughStopTile(tile));
+ }
+
return tile == m_destTile && ((m_destTrackdirs & TrackdirToTrackdirBits(trackdir)) != TRACKDIR_BIT_NONE);
}