(svn r2249) - Fix: [ 1187703 ] [NPF] Road vehicles cannot find a depot when in a roadstop
authormatthijs
Mon, 02 May 2005 17:52:35 +0000
changeset 1745 2dcc0a66d91d
parent 1744 1677a99b0daf
child 1746 ede6a09f6777
(svn r2249) - Fix: [ 1187703 ] [NPF] Road vehicles cannot find a depot when in a roadstop
roadveh_cmd.c
--- a/roadveh_cmd.c	Mon May 02 17:14:31 2005 +0000
+++ b/roadveh_cmd.c	Mon May 02 17:52:35 2005 +0000
@@ -310,7 +310,14 @@
 	if (_patches.new_pathfinding_all) {
 		NPFFoundTargetData ftd;
 		/* See where we are now */
-		byte trackdir = _dir_to_diag_trackdir[(v->direction>>1)&3];
+		byte trackdir;
+		if (IsRoadStationTile(tile))
+			/* if we are in a station, simulate leaving the station (since
+			 * v->direction won't contain anything usefule than */
+			trackdir = _dir_to_diag_trackdir[GetRoadStationDir(tile)];
+		else
+			trackdir = _dir_to_diag_trackdir[(v->direction>>1)&3];
+
 		ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner);
 		if (ftd.best_bird_dist == 0)
 			return GetDepotByTile(ftd.node.tile); /* Target found */