12 #ifndef YAPF_DESTRAIL_HPP
13 #define YAPF_DESTRAIL_HPP
21 void SetDestination(
const Train *v,
bool override_rail_type =
false)
23 m_compatible_railtypes = v->compatible_railtypes;
27 bool IsCompatibleRailType(
RailType rt)
29 return HasBit(m_compatible_railtypes, rt);
34 return m_compatible_railtypes;
38 template <
class Types>
43 typedef typename Types::Tpf
Tpf;
44 typedef typename Types::NodeList::Titem
Node;
45 typedef typename Node::Key
Key;
50 return *
static_cast<Tpf*
>(
this);
72 n.m_estimate = n.m_cost;
77 template <
class Types>
82 typedef typename Types::Tpf
Tpf;
83 typedef typename Types::NodeList::Titem
Node;
84 typedef typename Node::Key
Key;
90 return *
static_cast<Tpf*
>(
this);
112 n.m_estimate = n.m_cost;
117 template <
class Types>
122 typedef typename Types::Tpf
Tpf;
123 typedef typename Types::NodeList::Titem
Node;
124 typedef typename Node::Key
Key;
129 StationID m_dest_station_id;
134 return *
static_cast<Tpf*
>(
this);
138 void SetDestination(
const Train *v)
141 case OT_GOTO_WAYPOINT:
148 Yapf().DisableCache(
true);
151 case OT_GOTO_STATION:
159 m_dest_station_id = INVALID_STATION;
163 CYapfDestinationRailBase::SetDestination(v);
176 if (m_dest_station_id != INVALID_STATION) {
181 bDest = (tile == m_destTile)
193 static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
194 static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
196 n.m_estimate = n.m_cost;
202 int x1 = 2 *
TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
203 int y1 = 2 *
TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
204 int x2 = 2 *
TileX(m_destTile);
205 int y2 = 2 *
TileY(m_destTile);
206 int dx =
abs(x1 - x2);
207 int dy =
abs(y1 - y2);
208 int dmin =
min(dx, dy);
209 int dxy =
abs(dx - dy);
211 n.m_estimate = n.m_cost + d;
212 assert(n.m_estimate >= n.m_parent->m_estimate);