summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-02 18:18:56 +0000
committerrubidium <rubidium@openttd.org>2009-12-02 18:18:56 +0000
commit0ef0e1379534c6372ea93790c1e4b0855c8077d1 (patch)
treed044e4280831f6afdf44626ee303896ef8570c6b /src/pathfinder
parent429f3993f8dc380780a23a6f46420797a9a8a11c (diff)
downloadopenttd-0ef0e1379534c6372ea93790c1e4b0855c8077d1.tar.xz
(svn r18385) -Cleanup: remove the now unneeded multistop slot management code
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/yapf/yapf.h15
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp146
2 files changed, 0 insertions, 161 deletions
diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h
index c7ddb3d6e..1f7b4a6a5 100644
--- a/src/pathfinder/yapf/yapf.h
+++ b/src/pathfinder/yapf/yapf.h
@@ -49,21 +49,6 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi
*/
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, struct PBSTileInfo *target);
-/** Used by RV multistop feature to find the nearest road stop that has a free slot.
- * @param v RV (its current tile will be the origin)
- * @param tile destination tile
- * @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
- */
-uint YapfRoadVehDistanceToTile(const RoadVehicle *v, TileIndex tile);
-
-/** Used to determinine the closest reachable compatible road stop for a given vehicle.
- * @param v vehicle that needs to go to the road stop
- * @param station the station the road stop must belong to
- * @param stop_tile receives the stop tile if a stop was found
- * @return true if stop was found.
- */
-bool YapfFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, StationID station, TileIndex *stop_tile);
-
/**
* Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
* @param v vehicle that needs to go to some depot
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index 5ca3b1441..a565def27 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -185,78 +185,6 @@ public:
template <class Types>
-class CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT
-{
-public:
- typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
- typedef typename Types::TrackFollower TrackFollower;
- typedef typename Types::NodeList::Titem Node; ///< this will be our node type
- typedef typename Node::Key Key; ///< key to hash tables
-
- TileIndex m_destTile;
- StationID m_dest_station;
- bool m_bus;
- bool m_non_artic;
-
- /** to access inherited path finder */
- Tpf& Yapf()
- {
- return *static_cast<Tpf*>(this);
- }
-
- void SetDestination(const RoadVehicle *v, StationID sid, TileIndex destTile)
- {
- m_dest_station = sid;
- m_destTile = destTile;
- m_bus = v->IsBus();
- m_non_artic = !v->HasArticulatedPart();
- }
-
- /** Called by YAPF to detect if node ends in the desired destination */
- FORCEINLINE bool PfDetectDestination(Node& n)
- {
- return PfDetectDestinationTile(n.m_segment_last_tile, INVALID_TRACKDIR);
- }
-
- FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
- {
- return
- IsTileType(tile, MP_STATION) &&
- GetStationIndex(tile) == m_dest_station &&
- (m_bus ? IsBusStop(tile) : IsTruckStop(tile)) &&
- (m_non_artic || IsDriveThroughStopTile(tile));
- }
-
- /** Called by YAPF to calculate cost estimate. Calculates distance to the destination
- * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
- FORCEINLINE bool PfCalcEstimate(Node& n)
- {
- static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
- static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
- if (PfDetectDestination(n)) {
- n.m_estimate = n.m_cost;
- return true;
- }
-
- TileIndex tile = n.m_segment_last_tile;
- DiagDirection exitdir = TrackdirToExitdir(n.m_segment_last_td);
- int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
- int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
- int x2 = 2 * TileX(m_destTile);
- int y2 = 2 * TileY(m_destTile);
- int dx = abs(x1 - x2);
- int dy = abs(y1 - y2);
- int dmin = min(dx, dy);
- int dxy = abs(dx - dy);
- int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
- n.m_estimate = n.m_cost + d;
- assert(n.m_estimate >= n.m_parent->m_estimate);
- return true;
- }
-};
-
-
-template <class Types>
class CYapfDestinationTileRoadT
{
public:
@@ -497,30 +425,6 @@ public:
*depot_tile = n->m_segment_last_tile;
return true;
}
-
- static bool stFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, TileIndex tile, TileIndex destTile, Trackdir td, StationID sid, TileIndex *stop_tile)
- {
- Tpf pf;
- return pf.FindNearestRoadVehicleCompatibleStop(v, tile, destTile, td, sid, stop_tile);
- }
-
- FORCEINLINE bool FindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, TileIndex tile, TileIndex destTile, Trackdir td, StationID sid, TileIndex *stop_tile)
- {
- /* set origin and destination nodes */
- Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
- Yapf().SetDestination(v, sid, destTile);
-
- /* find the best path */
- bool bFound = Yapf().FindPath(v);
- if (!bFound) return false;
-
- /* some path found
- * get found depot tile */
- const Node *n = Yapf().GetBestNode();
-
- *stop_tile = n->m_segment_last_tile;
- return true;
- }
};
template <class Tpf_, class Tnode_list, template <class Types> class Tdestination>
@@ -546,9 +450,6 @@ struct CYapfRoad2 : CYapfT<CYapfRoad_TypesT<CYapfRoad2 , CRoadNod
struct CYapfRoadAnyDepot1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot1, CRoadNodeListTrackDir, CYapfDestinationAnyDepotRoadT> > {};
struct CYapfRoadAnyDepot2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot2, CRoadNodeListExitDir , CYapfDestinationAnyDepotRoadT> > {};
-struct CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1, CRoadNodeListTrackDir, CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT> > {};
-struct CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2, CRoadNodeListExitDir , CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT> > {};
-
Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs)
{
@@ -565,27 +466,6 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi
return (td_ret != INVALID_TRACKDIR) ? td_ret : (Trackdir)FindFirstBit2x64(trackdirs);
}
-uint YapfRoadVehDistanceToTile(const RoadVehicle *v, TileIndex tile)
-{
- /* default is YAPF type 2 */
- typedef uint (*PfnDistanceToTile)(const RoadVehicle*, TileIndex);
- PfnDistanceToTile pfnDistanceToTile = &CYapfRoad2::stDistanceToTile; // default: ExitDir, allow 90-deg
-
- /* check if non-default YAPF type should be used */
- if (_settings_game.pf.yapf.disable_node_optimization) {
- pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
- }
-
- /* measure distance in YAPF units */
- uint dist = pfnDistanceToTile(v, tile);
- /* convert distance to tiles */
- if (dist != UINT_MAX) {
- dist = (dist + YAPF_TILE_LENGTH - 1) / YAPF_TILE_LENGTH;
- }
-
- return dist;
-}
-
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_distance)
{
TileIndex tile = v->tile;
@@ -608,29 +488,3 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dist
fdd.best_length = ret ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
return ret;
}
-
-bool YapfFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, StationID station, TileIndex *stop_tile)
-{
- *stop_tile = INVALID_TILE;
-
- const RoadStop *rs = Station::Get(station)->GetPrimaryRoadStop(v);
- if (rs == NULL) return false;
-
- TileIndex tile = v->tile;
- Trackdir trackdir = v->GetVehicleTrackdir();
- if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
- return false;
- }
-
- /* default is YAPF type 2 */
- typedef bool (*PfnFindNearestRoadVehicleCompatibleStop)(const RoadVehicle*, TileIndex, TileIndex, Trackdir, StationID, TileIndex*);
- PfnFindNearestRoadVehicleCompatibleStop pfnFindNearestRoadVehicleCompatibleStop = &CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2::stFindNearestRoadVehicleCompatibleStop;
-
- /* check if non-default YAPF type should be used */
- if (_settings_game.pf.yapf.disable_node_optimization) {
- pfnFindNearestRoadVehicleCompatibleStop = &CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1::stFindNearestRoadVehicleCompatibleStop; // Trackdir, allow 90-deg
- }
-
- bool ret = pfnFindNearestRoadVehicleCompatibleStop(v, tile, rs->xy, trackdir, station, stop_tile);
- return ret;
-}