Fix #12250: YAPF Trivial rail pathfinding crashes due to #12217 (#12258)

This commit is contained in:
Kuhnovic 2024-03-10 15:37:56 +01:00 committed by GitHub
parent cca9dcdd57
commit 005892bfdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -446,6 +446,11 @@ public:
this->FindSafePositionOnNode(pPrev);
}
/* If the best PF node has no parent, then there is no (valid) best next trackdir to return.
* This occurs when the PF is called while the train is already at its destination. */
if (pPrev == nullptr) return INVALID_TRACKDIR;
/* return trackdir from the best origin node (one of start nodes) */
Node &best_next_node = *pPrev;
next_trackdir = best_next_node.GetTrackdir();