diff options
author | Michael Lutz <michi@icosahedron.de> | 2019-03-10 09:12:47 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-10 08:12:47 +0000 |
commit | cc5f17561571b45b52e7406fb66051446f8cceb4 (patch) | |
tree | 2d5f5d0ffd8fd9495b0f82ae3b46196c9f38e192 /src/pathfinder | |
parent | 26b0615c476039c43b4a845c6b01d590d1fb20dd (diff) | |
download | openttd-cc5f17561571b45b52e7406fb66051446f8cceb4.tar.xz |
Feature: Railtype flags to allow/disallow 90 degree curves. (#7352)
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/follow_track.hpp | 2 | ||||
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 13 |
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(¤t->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); } } |