equal
deleted
inserted
replaced
24 * and adds it to the open list by calling Yapf().AddNewNode(n) */ |
24 * and adds it to the open list by calling Yapf().AddNewNode(n) */ |
25 inline void PfFollowNode(Node& old_node) |
25 inline void PfFollowNode(Node& old_node) |
26 { |
26 { |
27 TrackFollower F; |
27 TrackFollower F; |
28 if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) |
28 if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) |
29 Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits); |
29 Yapf().AddMultipleNodes(&old_node, F); |
30 } |
30 } |
31 |
31 |
32 /// return debug report character to identify the transportation type |
32 /// return debug report character to identify the transportation type |
33 FORCEINLINE char TransportTypeChar() const {return 'w';} |
33 FORCEINLINE char TransportTypeChar() const {return 'w';} |
34 |
34 |
84 template <class Types> |
84 template <class Types> |
85 class CYapfCostShipT |
85 class CYapfCostShipT |
86 { |
86 { |
87 public: |
87 public: |
88 typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) |
88 typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) |
|
89 typedef typename Types::TrackFollower TrackFollower; |
89 typedef typename Types::NodeList::Titem Node; ///< this will be our node type |
90 typedef typename Types::NodeList::Titem Node; ///< this will be our node type |
90 typedef typename Node::Key Key; ///< key to hash tables |
91 typedef typename Node::Key Key; ///< key to hash tables |
91 |
92 |
92 protected: |
93 protected: |
93 /// to access inherited path finder |
94 /// to access inherited path finder |
95 |
96 |
96 public: |
97 public: |
97 /** Called by YAPF to calculate the cost from the origin to the given node. |
98 /** Called by YAPF to calculate the cost from the origin to the given node. |
98 * Calculates only the cost of given node, adds it to the parent node cost |
99 * Calculates only the cost of given node, adds it to the parent node cost |
99 * and stores the result into Node::m_cost member */ |
100 * and stores the result into Node::m_cost member */ |
100 FORCEINLINE bool PfCalcCost(Node& n) |
101 FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower &tf) |
101 { |
102 { |
102 // base tile cost depending on distance |
103 // base tile cost depending on distance |
103 int c = IsDiagonalTrackdir(n.GetTrackdir()) ? 10 : 7; |
104 int c = IsDiagonalTrackdir(n.GetTrackdir()) ? 10 : 7; |
104 // additional penalty for curves |
105 // additional penalty for curves |
105 if (n.m_parent != NULL && n.GetTrackdir() != n.m_parent->GetTrackdir()) c += 3; |
106 if (n.m_parent != NULL && n.GetTrackdir() != n.m_parent->GetTrackdir()) c += 3; |