File diff r12009:28cf5f05f012 → r12010:5513d8f8e97d
src/npf.cpp
Show inline comments
 
@@ -416,25 +416,25 @@ static int32 NPFRailPathCost(AyStar *as,
 
/* Will find any depot */
 
static int32 NPFFindDepot(AyStar *as, OpenListNode *current)
 
{
 
	/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
 
	 * since checking the cache not that much faster than the actual check */
 
	return IsDepotTypeTile(current->path.node.tile, (TransportType)as->user_data[NPF_TYPE]) ?
 
		AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 
}
 

	
 
/** Find any safe and free tile. */
 
static int32 NPFFindSafeTile(AyStar *as, OpenListNode *current)
 
{
 
	const Train *v = (Train *)((NPFFindStationOrTileData*)as->user_target)->v;
 
	const Train *v = (const Train *)((NPFFindStationOrTileData*)as->user_target)->v;
 

	
 
	return
 
		IsSafeWaitingPosition(v, current->path.node.tile, current->path.node.direction, true, _settings_game.pf.forbid_90_deg) &&
 
		IsWaitingPositionFree(v, current->path.node.tile, current->path.node.direction, _settings_game.pf.forbid_90_deg) ?
 
			AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 
}
 

	
 
/* Will find a station identified using the NPFFindStationOrTileData */
 
static int32 NPFFindStationOrTile(AyStar *as, OpenListNode *current)
 
{
 
	NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target;
 
	AyStarNode *node = &current->path.node;
 
@@ -497,25 +497,25 @@ static void ClearPathReservation(const P
 
 */
 
static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
 
{
 
	NPFFoundTargetData *ftd = (NPFFoundTargetData*)as->user_path;
 
	ftd->best_trackdir = (Trackdir)current->path.node.user_data[NPF_TRACKDIR_CHOICE];
 
	ftd->best_path_dist = current->g;
 
	ftd->best_bird_dist = 0;
 
	ftd->node = current->path.node;
 
	ftd->res_okay = false;
 

	
 
	if (as->user_target != NULL && ((NPFFindStationOrTileData*)as->user_target)->reserve_path && as->user_data[NPF_TYPE] == TRANSPORT_RAIL) {
 
		/* Path reservation is requested. */
 
		const Train *v = (Train *)((NPFFindStationOrTileData*)as->user_target)->v;
 
		const Train *v = (const Train *)((NPFFindStationOrTileData*)as->user_target)->v;
 

	
 
		const PathNode *target = FindSafePosition(&current->path, v);
 
		ftd->node = target->node;
 

	
 
		/* If the target is a station skip to platform end. */
 
		if (IsRailwayStationTile(target->node.tile)) {
 
			DiagDirection dir = TrackdirToExitdir(target->node.direction);
 
			uint len = GetStationByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir);
 
			TileIndex end_tile = TILE_ADD(target->node.tile, (len - 1) * TileOffsByDiagDir(dir));
 

	
 
			/* Update only end tile, trackdir of a station stays the same. */
 
			ftd->node.tile = end_tile;