summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2017-09-03 13:06:29 +0000
committermichi_cc <michi_cc@openttd.org>2017-09-03 13:06:29 +0000
commit016a68815d099ffb505806cbd2122bd33693e7f0 (patch)
tree7b74bdbc05bc03a5b026d46f9e791d080f90d8df /src
parent6d08d054ef40867ac9972c4def0be900f4217466 (diff)
downloadopenttd-016a68815d099ffb505806cbd2122bd33693e7f0.tar.xz
(svn r27912) -Fix (r13948): [NPF] Reserved track bits were not accounted for when trying to find any safe position.
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/npf/npf.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index fb9833237..ee60dace4 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,12 +982,14 @@ 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;
start2->user_data[NPF_NODE_FLAGS] = 0;
NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);
NPFSetFlag(start2, NPF_FLAG_REVERSE, true);
+ NPFSetFlag(start2, NPF_FLAG_IGNORE_RESERVED, ignore_reserved);
_npf_aystar.AddStartNode(start2, reverse_penalty);
}
@@ -1226,14 +1228,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 +1235,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)