(svn r12057) -Fix: slowdown train when approaching 90deg turn when 90deg turns are forbidden
authorsmatz
Mon, 04 Feb 2008 15:56:39 +0000
changeset 8482 4552a238cd58
parent 8481 b12960a2e770
child 8483 a15e052321fc
(svn r12057) -Fix: slowdown train when approaching 90deg turn when 90deg turns are forbidden
src/train_cmd.cpp
--- a/src/train_cmd.cpp	Mon Feb 04 15:26:35 2008 +0000
+++ b/src/train_cmd.cpp	Mon Feb 04 15:56:39 2008 +0000
@@ -3462,9 +3462,15 @@
 
 	/* We are sure the train is not entering a depot, it is detected above */
 
+	/* mask unreachable track bits if we are forbidden to do 90deg turns */
+	TrackBits bits = (TrackBits)((ts | (ts >> 8)) & TRACK_BIT_MASK);
+	if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg) {
+		bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
+	}
+
 	/* no suitable trackbits at all || wrong railtype || not our track ||
 	 *   tunnel/bridge from opposite side || depot from opposite side */
-	if (GB(ts, 0, 16) == 0 || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner ||
+	if (bits == TRACK_BIT_NONE || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner ||
 			(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) != dir) ||
 			(IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == dir) ) {
 		return TrainApproachingLineEnd(v, false);