mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix loop detection in heuristic search based on pathfind_history.
In the existing version, returning to a junction in the pathfind history is considered a loop. This is not useful as it prevents the pathfinding from backtracking, which is what the pathfind_history is intended to allow. Updated to consider it a loop only when returning to a junction with no more edges left to try.
This commit is contained in:
parent
dd89a32016
commit
f0cf7c2763
|
@ -9297,7 +9297,17 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
|||
if (peep->pathfind_history[i].x == x >> 5 &&
|
||||
peep->pathfind_history[i].y == y >> 5 &&
|
||||
peep->pathfind_history[i].z == z) {
|
||||
pathLoop = true;
|
||||
if (peep->pathfind_history[i].direction == 0) {
|
||||
/* If all directions have already been tried while
|
||||
* heading to this goal, this is a loop. */
|
||||
pathLoop = true;
|
||||
}
|
||||
else {
|
||||
/* The peep remembers walking through this junction
|
||||
* before, but has not yet tried all directions.
|
||||
* Limit the edges to search to those not yet tried. */
|
||||
edges &= peep->pathfind_history[i].direction;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue