summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ0an Josep <juanjo.ng.83@gmail.com>2019-02-14 19:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-02-18 22:57:19 +0100
commit6ca637b8c149efe2cb8ccffccbfd98530f633d58 (patch)
tree553ebd476a4c422636bf7f2231b847c613a0089b
parent349cbee6e90a7a7257a2872755540d5555f6ee90 (diff)
downloadopenttd-6ca637b8c149efe2cb8ccffccbfd98530f633d58.tar.xz
Fix #7226: Don't call ship pathfinders if there is no available track due to "forbid 90 deg turns".
-rw-r--r--src/ship_cmd.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 23786c17d..c4441cb15 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -510,9 +510,20 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr
return track;
}
-static inline TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir)
+/**
+ * Get the available water tracks on a tile for a ship entering a tile.
+ * @param tile The tile about to enter.
+ * @param dir The entry direction.
+ * @param trackdir The trackdir the ship has on the old tile.
+ * @return The available trackbits on the next tile.
+ */
+static inline TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir, Trackdir trackdir)
{
- return GetTileShipTrackStatus(tile) & DiagdirReachesTracks(dir);
+ TrackBits tracks = GetTileShipTrackStatus(tile) & DiagdirReachesTracks(dir);
+
+ if (_settings_game.pf.forbid_90_deg) tracks &= ~TrackCrossesTracks(TrackdirToTrack(trackdir));
+
+ return tracks;
}
static const byte _ship_subcoord[4][6][3] = {
@@ -699,7 +710,7 @@ static void ShipController(Ship *v)
DiagDirection diagdir = DiagdirBetweenTiles(gp.old_tile, gp.new_tile);
assert(diagdir != INVALID_DIAGDIR);
- tracks = GetAvailShipTracks(gp.new_tile, diagdir);
+ tracks = GetAvailShipTracks(gp.new_tile, diagdir, v->GetVehicleTrackdir());
if (tracks == TRACK_BIT_NONE) goto reverse_direction;
/* Choose a direction, and continue if we find one */