12 #ifndef YAPF_DESTRAIL_HPP
13 #define YAPF_DESTRAIL_HPP
20 void SetDestination(
const Train *v,
bool override_rail_type =
false)
22 m_compatible_railtypes = v->compatible_railtypes;
26 bool IsCompatibleRailType(
RailType rt)
28 return HasBit(m_compatible_railtypes, rt);
33 return m_compatible_railtypes;
37 template <
class Types>
40 typedef typename Types::Tpf
Tpf;
41 typedef typename Types::NodeList::Titem
Node;
42 typedef typename Node::Key
Key;
47 return *
static_cast<Tpf *
>(
this);
69 n.m_estimate = n.m_cost;
74 template <
class Types>
77 typedef typename Types::Tpf
Tpf;
78 typedef typename Types::NodeList::Titem
Node;
79 typedef typename Node::Key
Key;
85 return *
static_cast<Tpf *
>(
this);
107 n.m_estimate = n.m_cost;
112 template <
class Types>
115 typedef typename Types::Tpf
Tpf;
116 typedef typename Types::NodeList::Titem
Node;
117 typedef typename Node::Key
Key;
122 StationID m_dest_station_id;
127 return *
static_cast<Tpf *
>(
this);
131 void SetDestination(
const Train *v)
134 case OT_GOTO_WAYPOINT:
141 Yapf().DisableCache(
true);
144 case OT_GOTO_STATION:
152 m_dest_station_id = INVALID_STATION;
156 CYapfDestinationRailBase::SetDestination(v);
169 if (m_dest_station_id != INVALID_STATION) {
174 bDest = (tile == m_destTile)
186 static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
187 static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
189 n.m_estimate = n.m_cost;
195 int x1 = 2 *
TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
196 int y1 = 2 *
TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
197 int x2 = 2 *
TileX(m_destTile);
198 int y2 = 2 *
TileY(m_destTile);
199 int dx =
abs(x1 - x2);
200 int dy =
abs(y1 - y2);
201 int dmin =
min(dx, dy);
202 int dxy =
abs(dx - dy);
204 n.m_estimate = n.m_cost + d;
205 assert(n.m_estimate >= n.m_parent->m_estimate);