diff options
author | rubidium <rubidium@openttd.org> | 2009-12-02 14:44:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-02 14:44:32 +0000 |
commit | 1c65150d6d30e460d1615c907e9c403d45a518ed (patch) | |
tree | 6fe6c859300525188d08b384c129442561fddf81 /src/pathfinder | |
parent | a1e28925e3c974a3c34a609737677ca072c559e1 (diff) | |
download | openttd-1c65150d6d30e460d1615c907e9c403d45a518ed.tar.xz |
(svn r18376) -Codechange: simplify setting the destination
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/yapf/yapf_road.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 9c9c9fe32..21a125f8b 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -271,10 +271,10 @@ protected: TrackdirBits m_destTrackdirs; public: - void SetDestination(TileIndex tile, TrackdirBits trackdirs) + void SetDestination(const RoadVehicle *v) { - m_destTile = tile; - m_destTrackdirs = trackdirs; + m_destTile = v->dest_tile; + m_destTrackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_ROAD, v->compatible_roadtypes)); } protected: @@ -288,8 +288,7 @@ public: /** Called by YAPF to detect if node ends in the desired destination */ FORCEINLINE bool PfDetectDestination(Node& n) { - bool bDest = (n.m_segment_last_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.m_segment_last_td)) != TRACKDIR_BIT_NONE); - return bDest; + return PfDetectDestinationTile(n.m_segment_last_tile, n.m_segment_last_td); } FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir) @@ -382,13 +381,9 @@ public: /* select reachable trackdirs only */ src_trackdirs &= DiagdirReachesTrackdirs(enterdir); - /* get available trackdirs on the destination tile */ - TileIndex dest_tile = v->dest_tile; - TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->compatible_roadtypes)); - /* set origin and destination nodes */ Yapf().SetOrigin(src_tile, src_trackdirs); - Yapf().SetDestination(dest_tile, dest_trackdirs); + Yapf().SetDestination(v); /* find the best path */ Yapf().FindPath(v); @@ -426,10 +421,8 @@ public: if (!SetOriginFromVehiclePos(v)) return UINT_MAX; - /* set destination tile, trackdir - * get available trackdirs on the destination tile */ - TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->compatible_roadtypes)); - Yapf().SetDestination(dst_tile, dst_td_bits); + /* get available trackdirs on the destination tile */ + Yapf().SetDestination(v); /* if path not found - return distance = UINT_MAX */ uint dist = UINT_MAX; |