mirror of https://github.com/OpenTTD/OpenTTD
Fix #7060: [NPF] Do not check whether ignored first tiles are end nodes.
parent
19be1f4ace
commit
aa63517c92
|
@ -170,7 +170,7 @@ int AyStar::Loop()
|
||||||
if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
|
if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
|
||||||
|
|
||||||
/* Check for end node and if found, return that code */
|
/* 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(¤t->path)) {
|
||||||
if (this->FoundEndNode != NULL) {
|
if (this->FoundEndNode != NULL) {
|
||||||
this->FoundEndNode(this, current);
|
this->FoundEndNode(this, current);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ struct OpenListNode {
|
||||||
PathNode path;
|
PathNode path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CheckIgnoreFirstTile(const PathNode *node);
|
||||||
|
|
||||||
struct AyStar;
|
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);
|
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
|
* 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
|
* 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;
|
TileIndex src_tile = current->path.node.tile;
|
||||||
DiagDirection src_exitdir = TrackdirToExitdir(src_trackdir);
|
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(¤t->path.node, NPF_FLAG_IGNORE_START_TILE));
|
|
||||||
|
|
||||||
/* Information about the vehicle: TransportType (road/rail/water) and SubType (compatible rail/road types) */
|
/* Information about the vehicle: TransportType (road/rail/water) and SubType (compatible rail/road types) */
|
||||||
TransportType type = user->type;
|
TransportType type = user->type;
|
||||||
uint subtype = user->roadtypes;
|
uint subtype = user->roadtypes;
|
||||||
|
@ -871,7 +871,10 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
|
||||||
TrackdirBits trackdirbits;
|
TrackdirBits trackdirbits;
|
||||||
|
|
||||||
/* Find dest tile */
|
/* 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(¤t->path)) {
|
||||||
/* Do not perform any checks that involve src_tile */
|
/* Do not perform any checks that involve src_tile */
|
||||||
dst_tile = src_tile + TileOffsByDiagDir(src_exitdir);
|
dst_tile = src_tile + TileOffsByDiagDir(src_exitdir);
|
||||||
trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
|
trackdirbits = GetDriveableTrackdirBits(dst_tile, src_trackdir, type, subtype);
|
||||||
|
|
Loading…
Reference in New Issue