diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index fb98332..9f3d560 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -961,7 +961,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current) * multiple targets that are spread around, we should perform a breadth first * search by specifiying CalcZero as our heuristic. */ -static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start_tile1, AyStarNode *start2, bool ignore_start_tile2, NPFFindStationOrTileData *target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, AyStarUserData *user, uint reverse_penalty) +static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start_tile1, AyStarNode *start2, bool ignore_start_tile2, NPFFindStationOrTileData *target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, AyStarUserData *user, uint reverse_penalty, bool ignore_reserved = false) { int r; NPFFoundTargetData result; @@ -982,6 +982,7 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; start1->user_data[NPF_NODE_FLAGS] = 0; NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1); + NPFSetFlag(start1, NPF_FLAG_IGNORE_RESERVED, ignore_reserved); _npf_aystar.AddStartNode(start1, 0); if (start2 != NULL) { start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; @@ -1226,14 +1227,6 @@ bool NPFTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir trackd AyStarNode start1; start1.tile = tile; start1.direction = trackdir; - /* FIXME: NPFRouteInternal is wiping out any flags on startup, also the - * NPF_FLAG_IGNORE_RESERVED flag that was intended to be set on this line. - * The flag was never set properly, since introdued in r13948. Now the line - * is commented out to silence compiler warnings (using uninitialized 'flags'). - * Currently the NPF_FLAG_IGNORE_RESERVED is nowhere used. It has to be - * decided what to do with this flag. - * - * NPFSetFlag(&start1, NPF_FLAG_IGNORE_RESERVED, true); */ RailTypes railtypes = v->compatible_railtypes; if (override_railtype) railtypes |= GetRailTypeInfo(v->railtype)->compatible_railtypes; @@ -1241,7 +1234,7 @@ bool NPFTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir trackd /* perform a breadth first search. Target is NULL, * since we are just looking for any safe tile...*/ AyStarUserData user = { v->owner, TRANSPORT_RAIL, railtypes, ROADTYPES_NONE }; - return NPFRouteInternal(&start1, true, NULL, false, &fstd, NPFFindSafeTile, NPFCalcZero, &user, 0).res_okay; + return NPFRouteInternal(&start1, true, NULL, false, &fstd, NPFFindSafeTile, NPFCalcZero, &user, 0, true).res_okay; } bool NPFTrainCheckReverse(const Train *v)