summaryrefslogtreecommitdiff
path: root/src/yapf/yapf_destrail.hpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:51:53 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:51:53 +0000
commit53cc7e8a5c6f1b72c1c0187c1ea9374a924ef832 (patch)
tree355223636c21b47b2c3e4c0eeff3fcffe1cacba8 /src/yapf/yapf_destrail.hpp
parent2b153abd9337e8c2f9b5d896a4839701a3d07e53 (diff)
downloadopenttd-53cc7e8a5c6f1b72c1c0187c1ea9374a924ef832.tar.xz
(svn r13944) -Add [YAPP]: Add YAPF provider to find a safe tile and reserve a path. (michi_cc)
Diffstat (limited to 'src/yapf/yapf_destrail.hpp')
-rw-r--r--src/yapf/yapf_destrail.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index 7ea73889e..9790758e4 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -63,6 +63,41 @@ public:
};
template <class Types>
+class CYapfDestinationAnySafeTileRailT
+ : public CYapfDestinationRailBase
+{
+public:
+ typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
+ typedef typename Types::NodeList::Titem Node; ///< this will be our node type
+ typedef typename Node::Key Key; ///< key to hash tables
+
+ /// to access inherited path finder
+ Tpf& Yapf() {return *static_cast<Tpf*>(this);}
+
+ /// Called by YAPF to detect if node ends in the desired destination
+ FORCEINLINE bool PfDetectDestination(Node& n)
+ {
+ return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
+ }
+
+ /// Called by YAPF to detect if node ends in the desired destination
+ FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
+ {
+ return
+ IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, Types::TrackFollower::Allow90degTurns()) &&
+ IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, Types::TrackFollower::Allow90degTurns());
+ }
+
+ /** 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)
+ {
+ n.m_estimate = n.m_cost;
+ return true;
+ }
+};
+
+template <class Types>
class CYapfDestinationTileOrStationRailT
: public CYapfDestinationRailBase
{