Skip to content

Commit

Permalink
Fix #12236: Ship pathfinder causes crash when ship is already at dest…
Browse files Browse the repository at this point in the history
…ination (#12238)
  • Loading branch information
Kuhnovic committed Mar 8, 2024
1 parent ab353f8 commit 08ff1ab
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 @@ -263,7 +263,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 08ff1ab

Please sign in to comment.