(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.

This commit is contained in:
rubidium
2009-12-02 17:56:02 +00:00
parent 59f9163e37
commit 4ec4fdff36
3 changed files with 52 additions and 27 deletions

View File

@@ -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);
}