Skip to content

Commit

Permalink
Fix OpenTTD#12250: YAPF Trivial rail pathfinding crashes due to OpenT…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuhnovic authored and TrueBrain committed Mar 16, 2024
1 parent 2d9936a commit ec25f4f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pathfinder/yapf/yapf_rail.cpp
Expand Up @@ -446,6 +446,11 @@ class CYapfFollowRailT : public CYapfReserveTrack<Types>

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();
Expand Down

0 comments on commit ec25f4f

Please sign in to comment.