Fix #7060: [NPF] Do not check whether ignored first tiles are end nodes.

pull/78/head
J0an Josep 5 years ago committed by Charles Pigott
parent 19be1f4ace
commit aa63517c92

@ -170,7 +170,7 @@ int AyStar::Loop()
if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
/* Check for end node and if found, return that code */
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE) {
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && !CheckIgnoreFirstTile(&current->path)) {
if (this->FoundEndNode != NULL) {
this->FoundEndNode(this, current);
}

@ -59,6 +59,8 @@ struct OpenListNode {
PathNode path;
};
bool CheckIgnoreFirstTile(const PathNode *node);
struct AyStar;
/**

@ -101,6 +101,11 @@ static inline void NPFSetFlag(AyStarNode *node, NPFNodeFlag flag, bool value)
SB(node->user_data[NPF_NODE_FLAGS], flag, 1, value);
}
bool CheckIgnoreFirstTile(const PathNode *node)
{
return (node->parent == NULL && HasBit(node->node.user_data[NPF_NODE_FLAGS], NPF_FLAG_IGNORE_START_TILE));
}
/**
* 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
@ -853,11 +858,6 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
TileIndex src_tile = current->path.node.tile;
DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir);
/* Is src_tile valid, and can be used?
* When choosing track on a junction src_tile is the tile neighboured to the junction wrt. exitdir.
* But we must not check the validity of this move, as src_tile is totally unrelated to the move, if a roadvehicle reversed on a junction. */
bool ignore_src_tile = (current->path.parent == NULL && NPFGetFlag(&current->path.node, NPF_FLAG_IGNORE_START_TILE));
/* Information about the vehicle: TransportType (road/rail/water) and SubType (compatible rail/road types) */
TransportType type = user->type;
uint subtype = user->roadtypes;
@ -871,7 +871,10 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
TrackdirBits trackdirbits;
/* Find dest tile */
if (ignore_src_tile) {
/* Is src_tile valid, and can be used?
* When choosing track on a junction src_tile is the tile neighboured to the junction wrt. exitdir.
* But we must not check the validity of this move, as src_tile is totally unrelated to the move, if a roadvehicle reversed on a junction. */
if (CheckIgnoreFirstTile(&current->path)) {
/* Do not perform any checks that involve src_tile */
dst_tile = src_tile + TileOffsByDiagDir(src_exitdir);
trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);

Loading…
Cancel
Save