diff options
author | Vít Šefl <vituscze@gmail.com> | 2021-05-15 17:23:23 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-23 20:19:39 +0200 |
commit | 33d99d27f4426e7d087b7ea3ed8e84d1059e1b76 (patch) | |
tree | 6f2a2f620d586d74f9f173247b16fbbd3d7c58ae /src/pathfinder/yapf/yapf_base.hpp | |
parent | 97722931a976dc3e6603611b8ec48f10920960e4 (diff) | |
download | openttd-33d99d27f4426e7d087b7ea3ed8e84d1059e1b76.tar.xz |
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.
Diffstat (limited to 'src/pathfinder/yapf/yapf_base.hpp')
-rw-r--r-- | src/pathfinder/yapf/yapf_base.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pathfinder/yapf/yapf_base.hpp b/src/pathfinder/yapf/yapf_base.hpp index b34e40a67..41c38ab34 100644 --- a/src/pathfinder/yapf/yapf_base.hpp +++ b/src/pathfinder/yapf/yapf_base.hpp @@ -207,11 +207,14 @@ public: * remain the best intermediate node, and thus the vehicle would still * 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) { - Yapf().m_pBestIntermediateNode = Yapf().m_pBestIntermediateNode->m_parent; + bool intermediate_on_branch = false; + 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; } /** |