mirror of https://github.com/OpenTTD/OpenTTD
Fix: Encountering two-way red signals could prune unrelated branches.
The intermediate node branch is now only pruned if the node is on the path leading to the two-way red signal.pull/9011/merge
parent
97722931a9
commit
33d99d27f4
|
@ -207,11 +207,14 @@ public:
|
||||||
* remain the best intermediate node, and thus the vehicle would still
|
* remain the best intermediate node, and thus the vehicle would still
|
||||||
* go towards the red EOL signal.
|
* go towards the red EOL signal.
|
||||||
*/
|
*/
|
||||||
void PruneIntermediateNodeBranch()
|
void PruneIntermediateNodeBranch(Node *n)
|
||||||
{
|
{
|
||||||
while (Yapf().m_pBestIntermediateNode != nullptr && (Yapf().m_pBestIntermediateNode->m_segment->m_end_segment_reason & ESRB_CHOICE_FOLLOWS) == 0) {
|
bool intermediate_on_branch = false;
|
||||||
Yapf().m_pBestIntermediateNode = Yapf().m_pBestIntermediateNode->m_parent;
|
while (n != nullptr && (n->m_segment->m_end_segment_reason & ESRB_CHOICE_FOLLOWS) == 0) {
|
||||||
|
if (n == Yapf().m_pBestIntermediateNode) intermediate_on_branch = true;
|
||||||
|
n = n->m_parent;
|
||||||
}
|
}
|
||||||
|
if (intermediate_on_branch) Yapf().m_pBestIntermediateNode = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -199,7 +199,7 @@ public:
|
||||||
* was it first signal which is two-way? */
|
* was it first signal which is two-way? */
|
||||||
if (!IsPbsSignal(sig_type) && Yapf().TreatFirstRedTwoWaySignalAsEOL() && n.flags_u.flags_s.m_choice_seen && has_signal_against && n.m_num_signals_passed == 0) {
|
if (!IsPbsSignal(sig_type) && Yapf().TreatFirstRedTwoWaySignalAsEOL() && n.flags_u.flags_s.m_choice_seen && has_signal_against && n.m_num_signals_passed == 0) {
|
||||||
/* yes, the first signal is two-way red signal => DEAD END. Prune this branch... */
|
/* yes, the first signal is two-way red signal => DEAD END. Prune this branch... */
|
||||||
Yapf().PruneIntermediateNodeBranch();
|
Yapf().PruneIntermediateNodeBranch(&n);
|
||||||
n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
|
n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
|
||||||
Yapf().m_stopped_on_first_two_way_signal = true;
|
Yapf().m_stopped_on_first_two_way_signal = true;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue