src/roadveh_cmd.cpp
changeset 8551 f0bcd6753287
parent 8510 1c0456a2feaf
child 8554 81520f852e48
equal deleted inserted replaced
8550:9f90ede990ac 8551:f0bcd6753287
   414 
   414 
   415 static const Depot* FindClosestRoadDepot(const Vehicle* v)
   415 static const Depot* FindClosestRoadDepot(const Vehicle* v)
   416 {
   416 {
   417 	TileIndex tile = v->tile;
   417 	TileIndex tile = v->tile;
   418 
   418 
   419 	if (_patches.yapf.road_use_yapf) {
   419 	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF is being used */
   420 		Depot* ret = YapfFindNearestRoadDepot(v);
   420 		Depot* ret = YapfFindNearestRoadDepot(v);
   421 		return ret;
   421 		return ret;
   422 	} else if (_patches.new_pathfinding_all) {
   422 	} else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF is being used */
   423 		NPFFoundTargetData ftd;
   423 		NPFFoundTargetData ftd;
   424 		/* See where we are now */
   424 		/* See where we are now */
   425 		Trackdir trackdir = GetVehicleTrackdir(v);
   425 		Trackdir trackdir = GetVehicleTrackdir(v);
   426 
   426 
   427 		ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
   427 		ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
   429 			return GetDepotByTile(ftd.node.tile); /* Target found */
   429 			return GetDepotByTile(ftd.node.tile); /* Target found */
   430 		} else {
   430 		} else {
   431 			return NULL; /* Target not found */
   431 			return NULL; /* Target not found */
   432 		}
   432 		}
   433 		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
   433 		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
   434 	} else {
   434 	} else { /* OPF is being used */
   435 		RoadFindDepotData rfdd;
   435 		RoadFindDepotData rfdd;
   436 
   436 
   437 		rfdd.owner = v->owner;
   437 		rfdd.owner = v->owner;
   438 		rfdd.best_length = (uint)-1;
   438 		rfdd.best_length = (uint)-1;
   439 
   439 
  1215 	/* Only one track to choose between? */
  1215 	/* Only one track to choose between? */
  1216 	if (KillFirstBit(trackdirs) == TRACKDIR_BIT_NONE) {
  1216 	if (KillFirstBit(trackdirs) == TRACKDIR_BIT_NONE) {
  1217 		return_track(FindFirstBit2x64(trackdirs));
  1217 		return_track(FindFirstBit2x64(trackdirs));
  1218 	}
  1218 	}
  1219 
  1219 
  1220 	if (_patches.yapf.road_use_yapf) {
  1220 	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF */
  1221 		Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
  1221 		Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
  1222 		if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
  1222 		if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
  1223 		return_track(PickRandomBit(trackdirs));
  1223 		return_track(PickRandomBit(trackdirs));
  1224 	} else if (_patches.new_pathfinding_all) {
  1224 	} else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF */
  1225 		NPFFindStationOrTileData fstd;
  1225 		NPFFindStationOrTileData fstd;
  1226 		NPFFoundTargetData ftd;
  1226 		NPFFoundTargetData ftd;
  1227 		Trackdir trackdir;
  1227 		Trackdir trackdir;
  1228 
  1228 
  1229 		NPFFillWithOrderData(&fstd, v);
  1229 		NPFFillWithOrderData(&fstd, v);
  1241 			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
  1241 			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
  1242 			we did not find our target, but ftd.best_trackdir contains the direction leading
  1242 			we did not find our target, but ftd.best_trackdir contains the direction leading
  1243 			to the tile closest to our target. */
  1243 			to the tile closest to our target. */
  1244 			return_track(ftd.best_trackdir);
  1244 			return_track(ftd.best_trackdir);
  1245 		}
  1245 		}
  1246 	} else {
  1246 	} else { /* OPF */
  1247 		DiagDirection dir;
  1247 		DiagDirection dir;
  1248 
  1248 
  1249 		if (IsTileType(desttile, MP_ROAD)) {
  1249 		if (IsTileType(desttile, MP_ROAD)) {
  1250 			if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) {
  1250 			if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) {
  1251 				dir = GetRoadDepotDirection(desttile);
  1251 				dir = GetRoadDepotDirection(desttile);
  1298 }
  1298 }
  1299 
  1299 
  1300 static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
  1300 static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
  1301 {
  1301 {
  1302 	uint dist;
  1302 	uint dist;
  1303 	if (_patches.yapf.road_use_yapf) {
  1303 	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) {
  1304 		/* use YAPF */
  1304 		/* use YAPF */
  1305 		dist = YapfRoadVehDistanceToTile(v, tile);
  1305 		dist = YapfRoadVehDistanceToTile(v, tile);
  1306 	} else {
  1306 	} else {
  1307 		/* use NPF */
  1307 		/* use NPF */
  1308 		NPFFindStationOrTileData fstd;
  1308 		NPFFindStationOrTileData fstd;