pathfind.c
changeset 3900 2c84ed52709d
parent 3894 b545ce79ed67
child 3933 231ae3c419f4
--- a/pathfind.c	Thu May 25 20:58:23 2006 +0000
+++ b/pathfind.c	Sat May 27 16:12:16 2006 +0000
@@ -3,6 +3,8 @@
 #include "stdafx.h"
 #include "openttd.h"
 #include "bridge_map.h"
+#include "station_map.h"
+#include "depot.h"
 #include "functions.h"
 #include "map.h"
 #include "tile.h"
@@ -254,6 +256,15 @@
 	RememberData rd;
 	TileIndex tile_org = tile;
 
+	// check if the old tile can be left at that direction
+	if (tpf->tracktype == TRANSPORT_ROAD) {
+		// road stops and depots now have a track (r4419)
+		// don't enter road stop from the back
+		if (IsRoadStopTile(tile) && GetRoadStopDir(tile) != direction) return;
+		// don't enter road depot from the back
+		if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != direction) return;
+	}
+
 	if (IsTunnelTile(tile)) {
 		if (GetTunnelDirection(tile) != direction ||
 				GetTunnelTransportType(tile) != tpf->tracktype) {
@@ -277,6 +288,15 @@
 							return;
 	}
 
+	// check if the new tile can be entered from that direction
+	if (tpf->tracktype == TRANSPORT_ROAD) {
+		// road stops and depots now have a track (r4419)
+		// don't enter road stop from the back
+		if (IsRoadStopTile(tile) && GetRoadStopDir(tile) == direction) return;
+		// don't enter road depot from the back
+		if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) == direction) return;
+	}
+
 	tpf->rd.cur_length++;
 
 	bits = GetTileTrackStatus(tile, tpf->tracktype);