pathfind.c
changeset 3900 2c84ed52709d
parent 3894 b545ce79ed67
child 3933 231ae3c419f4
equal deleted inserted replaced
3899:5ba7f20a14ca 3900:2c84ed52709d
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 #include "stdafx.h"
     3 #include "stdafx.h"
     4 #include "openttd.h"
     4 #include "openttd.h"
     5 #include "bridge_map.h"
     5 #include "bridge_map.h"
       
     6 #include "station_map.h"
       
     7 #include "depot.h"
     6 #include "functions.h"
     8 #include "functions.h"
     7 #include "map.h"
     9 #include "map.h"
     8 #include "tile.h"
    10 #include "tile.h"
     9 #include "pathfind.h"
    11 #include "pathfind.h"
    10 #include "rail.h"
    12 #include "rail.h"
   252 	uint bits;
   254 	uint bits;
   253 	int i;
   255 	int i;
   254 	RememberData rd;
   256 	RememberData rd;
   255 	TileIndex tile_org = tile;
   257 	TileIndex tile_org = tile;
   256 
   258 
       
   259 	// check if the old tile can be left at that direction
       
   260 	if (tpf->tracktype == TRANSPORT_ROAD) {
       
   261 		// road stops and depots now have a track (r4419)
       
   262 		// don't enter road stop from the back
       
   263 		if (IsRoadStopTile(tile) && GetRoadStopDir(tile) != direction) return;
       
   264 		// don't enter road depot from the back
       
   265 		if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != direction) return;
       
   266 	}
       
   267 
   257 	if (IsTunnelTile(tile)) {
   268 	if (IsTunnelTile(tile)) {
   258 		if (GetTunnelDirection(tile) != direction ||
   269 		if (GetTunnelDirection(tile) != direction ||
   259 				GetTunnelTransportType(tile) != tpf->tracktype) {
   270 				GetTunnelTransportType(tile) != tpf->tracktype) {
   260 			return;
   271 			return;
   261 		}
   272 		}
   273 				/* Check if we are on a bridge (middle parts don't have an owner */
   284 				/* Check if we are on a bridge (middle parts don't have an owner */
   274 				if (!IsBridgeTile(tile) || !IsBridgeMiddle(tile))
   285 				if (!IsBridgeTile(tile) || !IsBridgeMiddle(tile))
   275 					if (!IsBridgeTile(tile_org) || !IsBridgeMiddle(tile_org))
   286 					if (!IsBridgeTile(tile_org) || !IsBridgeMiddle(tile_org))
   276 						if (GetTileOwner(tile_org) != GetTileOwner(tile))
   287 						if (GetTileOwner(tile_org) != GetTileOwner(tile))
   277 							return;
   288 							return;
       
   289 	}
       
   290 
       
   291 	// check if the new tile can be entered from that direction
       
   292 	if (tpf->tracktype == TRANSPORT_ROAD) {
       
   293 		// road stops and depots now have a track (r4419)
       
   294 		// don't enter road stop from the back
       
   295 		if (IsRoadStopTile(tile) && GetRoadStopDir(tile) == direction) return;
       
   296 		// don't enter road depot from the back
       
   297 		if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) == direction) return;
   278 	}
   298 	}
   279 
   299 
   280 	tpf->rd.cur_length++;
   300 	tpf->rd.cur_length++;
   281 
   301 
   282 	bits = GetTileTrackStatus(tile, tpf->tracktype);
   302 	bits = GetTileTrackStatus(tile, tpf->tracktype);