diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index e9f1d582af..b77f2ba228 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -192,9 +192,9 @@ private: { const Node *node = static_cast(node_ptr); for (;;) { - TileIndex last_signal_tile = node->m_segment->m_last_signal_tile; + TileIndex last_signal_tile = node->m_last_non_reserve_through_signal_tile; if (last_signal_tile != INVALID_TILE) { - Trackdir last_signal_trackdir = node->m_segment->m_last_signal_td; + Trackdir last_signal_trackdir = node->m_last_non_reserve_through_signal_td; if (HasPbsSignalOnTrackdir(last_signal_tile, last_signal_trackdir)) { return last_signal_tile; } else { @@ -347,14 +347,18 @@ public: } } + bool is_reserve_through = false; if (ShouldCheckTraceRestrict(n, tile)) { TraceRestrictProgramResult out; - bool is_reserve_through = false; if (ExecuteTraceRestrict(n, tile, trackdir, cost, out, &is_reserve_through)) { return -1; } if (is_reserve_through) n.m_num_signals_res_through_passed++; } + if (!is_reserve_through) { + n.m_last_non_reserve_through_signal_tile = tile; + n.m_last_non_reserve_through_signal_td = trackdir; + } n.m_num_signals_passed++; n.m_segment->m_last_signal_tile = tile; diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp index 3584366961..94c8d6c2f4 100644 --- a/src/pathfinder/yapf/yapf_node_rail.hpp +++ b/src/pathfinder/yapf/yapf_node_rail.hpp @@ -129,6 +129,8 @@ struct CYapfRailNodeT CYapfRailSegment *m_segment; uint16 m_num_signals_passed; uint16 m_num_signals_res_through_passed; + TileIndex m_last_non_reserve_through_signal_tile; + Trackdir m_last_non_reserve_through_signal_td; union { uint32 m_inherited_flags; struct { @@ -147,6 +149,8 @@ struct CYapfRailNodeT if (parent == NULL) { m_num_signals_passed = 0; m_num_signals_res_through_passed = 0; + m_last_non_reserve_through_signal_tile = INVALID_TILE; + m_last_non_reserve_through_signal_td = INVALID_TRACKDIR; flags_u.m_inherited_flags = 0; m_last_red_signal_type = SIGTYPE_NORMAL; /* We use PBS as initial signal type because if we are in @@ -163,6 +167,8 @@ struct CYapfRailNodeT } else { m_num_signals_passed = parent->m_num_signals_passed; m_num_signals_res_through_passed = parent->m_num_signals_res_through_passed; + m_last_non_reserve_through_signal_tile = parent->m_last_non_reserve_through_signal_tile; + m_last_non_reserve_through_signal_td = parent->m_last_non_reserve_through_signal_td; flags_u.m_inherited_flags = parent->flags_u.m_inherited_flags; m_last_red_signal_type = parent->m_last_red_signal_type; m_last_signal_type = parent->m_last_signal_type;