10 #ifndef YAPF_NODE_RAIL_HPP
11 #define YAPF_NODE_RAIL_HPP
13 #include "../../misc/dbg_helpers.h"
14 #include "../../train.h"
31 this->value = src.value;
36 this->value = (node_key.tile.base() << 4) | node_key.td;
39 inline int32_t CalcHash()
const
51 return (
Trackdir)(this->value & 0x0F);
56 return this->value == other.value;
77 EndSegmentReasonBits end_segment_reason = ESRB_NONE;
82 inline const Key &GetKey()
const
89 return this->key.GetTile();
94 return this->hash_next;
99 this->hash_next = next;
105 dmp.
WriteTile(
"last_tile", this->last_tile);
108 dmp.
WriteTile(
"last_signal_tile", this->last_signal_tile);
109 dmp.
WriteEnumT(
"last_signal_td", this->last_signal_td);
110 dmp.
WriteEnumT(
"end_segment_reason", this->end_segment_reason);
115 template <
class Tkey_>
123 uint16_t num_signals_passed;
125 uint32_t inherited_flags;
129 bool last_signal_was_red;
137 this->base::Set(parent, tile, td, is_choice);
138 this->segment =
nullptr;
139 if (parent ==
nullptr) {
140 this->num_signals_passed = 0;
141 this->flags_u.inherited_flags = 0;
155 this->num_signals_passed = parent->num_signals_passed;
156 this->flags_u.inherited_flags = parent->flags_u.inherited_flags;
157 this->last_red_signal_type = parent->last_red_signal_type;
158 this->last_signal_type = parent->last_signal_type;
160 this->flags_u.flags_s.choice_seen |= is_choice;
165 assert(this->segment !=
nullptr);
166 return this->segment->last_tile;
169 inline Trackdir GetLastTrackdir()
const
171 assert(this->segment !=
nullptr);
172 return this->segment->last_td;
177 assert(this->segment !=
nullptr);
178 this->segment->last_tile = tile;
179 this->segment->last_td = td;
182 template <
class Tbase,
class Tfunc,
class Tpf>
185 typename Tbase::TrackFollower ft(v, yapf.GetCompatibleRailTypes());
187 Trackdir cur_td = this->base::GetTrackdir();
189 while (cur != this->GetLastTile() || cur_td != this->GetLastTrackdir()) {
190 if (!((obj.*func)(cur, cur_td)))
return false;
192 if (!ft.Follow(cur, cur_td))
break;
198 return (obj.*func)(cur, cur_td);
203 this->base::Dump(dmp);
205 dmp.
WriteValue(
"num_signals_passed", this->num_signals_passed);
206 dmp.
WriteValue(
"target_seen", this->flags_u.flags_s.target_seen ?
"Yes" :
"No");
207 dmp.
WriteValue(
"choice_seen", this->flags_u.flags_s.choice_seen ?
"Yes" :
"No");
208 dmp.
WriteValue(
"last_signal_was_red", this->flags_u.flags_s.last_signal_was_red ?
"Yes" :
"No");
209 dmp.
WriteEnumT(
"last_red_signal_type", this->last_red_signal_type);
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
Hash table based node list multi-container class.
List of nodes used for the A-star pathfinder.
SignalType
Type of signal, i.e.
@ SIGTYPE_PBS
normal pbs signal
@ SIGTYPE_BLOCK
block signal
key for cached segment cost for rail YAPF
cached segment cost for rail YAPF
Class that represents the dump-into-string target.
void WriteEnumT(const std::string &name, E e)
Dump given enum value (as a number and as named value)
void WriteValue(const std::string &name, int value)
Write 'name = value' with indent and new-line.
void WriteTile(const std::string &name, TileIndex t)
Write name & TileIndex to the output.
void WriteStructT(const std::string &name, const S *s)
Dump nested object (or only its name if this instance is already known).
'Train' is either a loco or a wagon.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
@ TRACKDIR_BIT_NONE
No track build.
Node in the pathfinder's graph.