Index: src/ship_cmd.cpp
===================================================================
--- src/ship_cmd.cpp (revision 27221)
+++ src/ship_cmd.cpp (working copy)
@@ -335,19 +335,18 @@
TrackBits north_tracks = DiagdirReachesTracks(north_dir) & GetTileShipTrackStatus(north_neighbour);
TrackBits south_tracks = DiagdirReachesTracks(south_dir) & GetTileShipTrackStatus(south_neighbour);
- if (north_tracks && south_tracks) {
- /* Ask pathfinder for best direction */
- bool reverse = false;
- bool path_found;
- switch (_settings_game.pf.pathfinder_for_ships) {
- case VPF_OPF: reverse = OPFShipChooseTrack(v, north_neighbour, north_dir, north_tracks, path_found) == INVALID_TRACK; break; // OPF always allows reversing
- case VPF_NPF: reverse = NPFShipCheckReverse(v); break;
- case VPF_YAPF: reverse = YapfShipCheckReverse(v); break;
- default: NOT_REACHED();
- }
- if (reverse) north_tracks = TRACK_BIT_NONE;
+
+ /* Ask pathfinder for best direction */
+ bool reverse = false;
+ bool path_found;
+ switch (_settings_game.pf.pathfinder_for_ships) {
+ case VPF_OPF: reverse = OPFShipChooseTrack(v, north_neighbour, north_dir, north_tracks, path_found) == INVALID_TRACK; break; // OPF always allows reversing
+ case VPF_NPF: reverse = NPFShipCheckReverse(v); break;
+ case VPF_YAPF: reverse = YapfShipCheckReverse(v); break;
+ default: NOT_REACHED();
}
-
+ if (reverse) north_tracks = TRACK_BIT_NONE;
+
if (north_tracks) {
/* Leave towards north */
v->direction = DiagDirToDir(north_dir);
@@ -356,7 +355,11 @@
v->direction = DiagDirToDir(south_dir);
} else {
/* Both ways blocked */
- return false;
+ if (reverse) {
+ v->direction = DiagDirToDir(south_dir);
+ } else {
+ v->direction = DiagDirToDir(north_dir);
+ }
}
v->state = AxisToTrackBits(axis);