File diff r24596:eddf98238034 → r24597:afde5721a3b6
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -108,25 +108,25 @@ bool CheckIgnoreFirstTile(const PathNode
 

	
 
/**
 
 * Calculates the minimum distance travelled to get from t0 to t1 when only
 
 * using tracks (ie, only making 45 degree turns). Returns the distance in the
 
 * NPF scale, ie the number of full tiles multiplied by NPF_TILE_LENGTH to
 
 * prevent rounding.
 
 */
 
static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
 
{
 
	const uint dx = Delta(TileX(t0), TileX(t1));
 
	const uint dy = Delta(TileY(t0), TileY(t1));
 

	
 
	const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
 
	const uint straightTracks = 2 * std::min(dx, dy); // The number of straight (not full length) tracks
 
	/* OPTIMISATION:
 
	 * Original: diagTracks = max(dx, dy) - min(dx,dy);
 
	 * Proof:
 
	 * (dx+dy) - straightTracks  == (min + max) - straightTracks = min + max - 2 * min = max - min */
 
	const uint diagTracks = dx + dy - straightTracks; // The number of diagonal (full tile length) tracks.
 

	
 
	/* Don't factor out NPF_TILE_LENGTH below, this will round values and lose
 
	 * precision */
 
	return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH;
 
}
 

	
 
/**