summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/follow_track.hpp2
-rw-r--r--src/pathfinder/npf/npf.cpp13
2 files changed, 9 insertions, 6 deletions
diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp
index acdff68a7..2bbad8d70 100644
--- a/src/pathfinder/follow_track.hpp
+++ b/src/pathfinder/follow_track.hpp
@@ -157,7 +157,7 @@ struct CFollowTrackT
return false;
}
- if (!Allow90degTurns()) {
+ if ((!IsRailTT() && !Allow90degTurns()) || (IsRailTT() && Rail90DegTurnDisallowed(GetTileRailType(m_old_tile), GetTileRailType(m_new_tile), !Allow90degTurns()))) {
m_new_td_bits &= (TrackdirBits)~(int)TrackdirCrossesTrackdirs(m_old_td);
if (m_new_td_bits == TRACKDIR_BIT_NONE) {
m_err = EC_90DEG;
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index d7722ae67..32c6e982d 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -803,12 +803,13 @@ static bool CanEnterTile(TileIndex tile, DiagDirection dir, AyStarUserData *user
* One-way-roads are taken into account. Signals are not tested.
*
* @param dst_tile The tile of interest.
+ * @param src_tile The originating tile.
* @param src_trackdir The direction the vehicle is currently moving.
* @param type The transporttype of the vehicle.
* @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle.
* @return The Trackdirs the vehicle can continue moving on.
*/
-static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, Trackdir src_trackdir, TransportType type, uint subtype)
+static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, TileIndex src_tile, Trackdir src_trackdir, TransportType type, uint subtype)
{
TrackdirBits trackdirbits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, type, subtype));
@@ -836,7 +837,9 @@ static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, Trackdir src_tr
trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
/* Filter out trackdirs that would make 90 deg turns for trains */
- if (_settings_game.pf.forbid_90_deg && type == TRANSPORT_RAIL) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
+ if (type == TRANSPORT_RAIL && Rail90DegTurnDisallowed(GetTileRailType(src_tile), GetTileRailType(dst_tile))) {
+ trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
+ }
DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
@@ -877,7 +880,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
if (CheckIgnoreFirstTile(&current->path)) {
/* Do not perform any checks that involve src_tile */
dst_tile = src_tile + TileOffsByDiagDir(src_exitdir);
- trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
+ trackdirbits = GetDriveableTrackdirBits(dst_tile, src_tile, src_trackdir, type, subtype);
} else if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
/* We drive through the wormhole and arrive on the other side */
dst_tile = GetOtherTunnelBridgeEnd(src_tile);
@@ -901,7 +904,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
src_trackdir = ReverseTrackdir(src_trackdir);
}
- trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
+ trackdirbits = GetDriveableTrackdirBits(dst_tile, src_tile, src_trackdir, type, subtype);
if (trackdirbits == TRACKDIR_BIT_NONE) {
/* We cannot enter the next tile. Road vehicles can reverse, others reach dead end */
@@ -910,7 +913,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
dst_tile = src_tile;
src_trackdir = ReverseTrackdir(src_trackdir);
- trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
+ trackdirbits = GetDriveableTrackdirBits(dst_tile, src_tile, src_trackdir, type, subtype);
}
}