Skip to content

Commit

Permalink
Fix OpenTTD#12236: Ship pathfinder causes crash when ship is already …
Browse files Browse the repository at this point in the history
…at destination (OpenTTD#12238)
  • Loading branch information
Kuhnovic authored and michicc committed Mar 9, 2024
1 parent 3cc00d0 commit f66e6cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pathfinder/yapf/yapf_ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ class CYapfFollowShipT
}
node = node->m_parent;
}
assert(!path_cache.empty());

/* A empty path means we are already at the destination. The pathfinder shouldn't have been called at all.
* Return a random reachable trackdir to hopefully nudge the ship out of this strange situation. */
if (path_cache.empty()) return GetRandomFollowUpTrackdir(v, src_tile, trackdir, true);

/* Take out the last trackdir as the result. */
const Trackdir result = path_cache.front();
Expand Down

0 comments on commit f66e6cb

Please sign in to comment.