10 #ifndef YAPF_COMMON_HPP
11 #define YAPF_COMMON_HPP
13 #include "../../core/bitmath_func.hpp"
14 #include "../../tile_type.h"
15 #include "../../track_type.h"
18 template <
class Types>
22 typedef typename Types::Tpf
Tpf;
23 typedef typename Types::NodeList::Item
Node;
24 typedef typename Node::Key
Key;
33 return *
static_cast<Tpf *
>(
this);
40 this->origin_tile = tile;
41 this->origin_trackdirs = trackdirs;
51 n1.Set(
nullptr, this->origin_tile, td, is_choice);
52 Yapf().AddStartupNode(n1);
58 template <
class Types>
62 typedef typename Types::Tpf
Tpf;
63 typedef typename Types::NodeList::Item
Node;
64 typedef typename Node::Key
Key;
77 return *
static_cast<Tpf *
>(
this);
84 this->origin_tile = tile;
86 this->reverse_tile = tiler;
87 this->reverse_td = tdr;
97 n1.Set(
nullptr, this->origin_tile, this->origin_td,
false);
98 Yapf().AddStartupNode(n1);
102 n2.Set(
nullptr, this->reverse_tile, this->reverse_td,
false);
104 Yapf().AddStartupNode(n2);
121 template <
class Ttypes>
123 :
public Ttypes::PfBase
124 ,
public Ttypes::PfCost
125 ,
public Ttypes::PfCache
126 ,
public Ttypes::PfOrigin
127 ,
public Ttypes::PfDestination
128 ,
public Ttypes::PfFollow
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
YAPF origin provider base class - used when origin is one tile / multiple trackdirs.
Node::Key Key
key to hash tables
Tpf & Yapf()
to access inherited path finder
Types::Tpf Tpf
the pathfinder class (derived from THIS class)
TrackdirBits origin_trackdirs
origin trackdir mask
void SetOrigin(TileIndex tile, TrackdirBits trackdirs)
Set origin tile / trackdir mask.
void PfSetStartupNodes()
Called when YAPF needs to place origin nodes into open list.
TileIndex origin_tile
origin tile
Types::NodeList::Item Node
this will be our node type
YAPF origin provider base class - used when there are two tile/trackdir origins.
Trackdir reverse_td
second (reverse) origin trackdir
Tpf & Yapf()
to access inherited path finder
void PfSetStartupNodes()
Called when YAPF needs to place origin nodes into open list.
void SetOrigin(TileIndex tile, Trackdir td, TileIndex tiler=INVALID_TILE, Trackdir tdr=INVALID_TRACKDIR, int reverse_penalty=0, bool treat_first_red_two_way_signal_as_eol=true)
set origin (tiles, trackdirs, etc.)
bool TreatFirstRedTwoWaySignalAsEOL()
return true if first two-way signal should be treated as dead end
int reverse_penalty
penalty to be added for using the reverse origin
Node::Key Key
key to hash tables
TileIndex reverse_tile
second (reverse) origin tile
Trackdir origin_td
first origin trackdir
Types::Tpf Tpf
the pathfinder class (derived from THIS class)
bool treat_first_red_two_way_signal_as_eol
in some cases (leaving station) we need to handle first two-way signal differently
Types::NodeList::Item Node
this will be our node type
TileIndex origin_tile
first origin tile
YAPF template that uses Ttypes template argument to determine all YAPF components (base classes) from...
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACKDIR_BIT_NONE
No track build.