src/ship_cmd.cpp
changeset 8510 1c0456a2feaf
parent 8467 605661f3a91c
child 8551 f0bcd6753287
equal deleted inserted replaced
8509:84c0cc012ad3 8510:1c0456a2feaf
   121 	TileIndex tile2 = v->tile;
   121 	TileIndex tile2 = v->tile;
   122 
   122 
   123 	if (_patches.new_pathfinding_all) {
   123 	if (_patches.new_pathfinding_all) {
   124 		NPFFoundTargetData ftd;
   124 		NPFFoundTargetData ftd;
   125 		Trackdir trackdir = GetVehicleTrackdir(v);
   125 		Trackdir trackdir = GetVehicleTrackdir(v);
   126 		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
   126 		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
   127 		if (ftd.best_bird_dist == 0) {
   127 		if (ftd.best_bird_dist == 0) {
   128 			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
   128 			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
   129 		} else {
   129 		} else {
   130 			best_depot = NULL; /* Did not find target */
   130 			best_depot = NULL; /* Did not find target */
   131 		}
   131 		}
   508 
   508 
   509 	*track = best_track;
   509 	*track = best_track;
   510 	return best_bird_dist;
   510 	return best_bird_dist;
   511 }
   511 }
   512 
   512 
   513 static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypes railtypes)
   513 static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypes railtypes)
   514 {
   514 {
   515 
   515 
   516 	void* perf = NpfBeginInterval();
   516 	void* perf = NpfBeginInterval();
   517 	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, 0, owner, railtypes);
   517 	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, ignore_start_tile, target, type, 0, owner, railtypes);
   518 	int t = NpfEndInterval(perf);
   518 	int t = NpfEndInterval(perf);
   519 	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
   519 	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
   520 	return ret;
   520 	return ret;
   521 }
   521 }
   522 
   522 
   531 		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
   531 		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
   532 		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
   532 		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
   533 	} else if (_patches.new_pathfinding_all) {
   533 	} else if (_patches.new_pathfinding_all) {
   534 		NPFFindStationOrTileData fstd;
   534 		NPFFindStationOrTileData fstd;
   535 		NPFFoundTargetData ftd;
   535 		NPFFoundTargetData ftd;
   536 		TileIndex src_tile = TILE_ADD(tile, TileOffsByDiagDir(ReverseDiagDir(enterdir)));
       
   537 		Trackdir trackdir = GetVehicleTrackdir(v);
   536 		Trackdir trackdir = GetVehicleTrackdir(v);
   538 		assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
   537 		assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
   539 
   538 
   540 		NPFFillWithOrderData(&fstd, v);
   539 		NPFFillWithOrderData(&fstd, v);
   541 
   540 
   542 		ftd = PerfNPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
   541 		ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
   543 
   542 
   544 		if (ftd.best_trackdir != 0xff) {
   543 		if (ftd.best_trackdir != 0xff) {
   545 			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
   544 			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
   546 			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
   545 			the direction we need to take to get there, if ftd.best_bird_dist is not 0,
   547 			we did not find our target, but ftd.best_trackdir contains the direction leading
   546 			we did not find our target, but ftd.best_trackdir contains the direction leading