(svn r2159) - Fix: [NPF] Road vehicles never found their target station or depots (introduced in r2154)
authormatthijs
Wed, 06 Apr 2005 21:03:24 +0000
changeset 1655 f45015d2df03
parent 1654 6b415f5a42c5
child 1656 9dd38e83c003
(svn r2159) - Fix: [NPF] Road vehicles never found their target station or depots (introduced in r2154)
- Fix: [NPF] Trains still tried to go through the back of depots.
npf.c
--- a/npf.c	Wed Apr 06 20:20:31 2005 +0000
+++ b/npf.c	Wed Apr 06 21:03:24 2005 +0000
@@ -506,7 +506,7 @@
 				exitdir = GetDepotDirection(src_tile, type);
 
 			/* Let's see if were headed the right way */
-			if (src_trackdir != _dir_to_diag_trackdir[exitdir])
+			if (src_trackdir == _dir_to_diag_trackdir[_reverse_dir[exitdir]])
 				/* We are headed inwards. We can only reverse here, so we'll not
 				 * consider this direction, but jump ahead to the reverse direction.
 				 * It would be nicer to return one neighbour here (the reverse
@@ -540,18 +540,18 @@
 			return;
 
 	/* Determine available tracks */
-	if (type == TRANSPORT_ROAD && (IsRoadStationTile(dst_tile) || IsTileDepotType(dst_tile, TRANSPORT_ROAD))){
-		/* Road stations and depots return 0 on GTTS, so we have to do this by hand... */
+	if (type != TRANSPORT_WATER && (IsRoadStationTile(dst_tile) || IsTileDepotType(dst_tile, type))){
+		/* Road stations and road and train depots return 0 on GTTS, so we have to do this by hand... */
 		byte exitdir;
 		if (IsRoadStationTile(dst_tile))
 			exitdir = GetRoadStationDir(dst_tile);
-		else /* Road depot */
+		else /* Road or train depot */
 			exitdir = GetDepotDirection(dst_tile, type);
 		/* Find the trackdirs that are available for a depot or station with this
 		 * orientation. They are only "inwards", since we are reaching this tile
 		 * from some other tile. This prevents vehicles driving into depots from
 		 * the back */
-		ts = (1 << _dir_to_diag_trackdir[exitdir]);
+		ts = (1 << _dir_to_diag_trackdir[_reverse_dir[exitdir]]);
 	} else {
 		ts = GetTileTrackStatus(dst_tile, type);
 	}