mirror of https://github.com/OpenRCT2/OpenRCT2.git
Reset pathfind_history before the heuristic search function is called.
Now that the heuristic search uses the pathfind_history for loop detection it is important that when the pathfind_goal is reset the pathfind_history gets reset before calling the heuristic search.
This commit is contained in:
parent
afcf48080c
commit
b83ab8d6e7
|
@ -9550,6 +9550,26 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
|
|||
}
|
||||
}
|
||||
|
||||
/* If this is a new goal for the peep. Store it and reset the peep's
|
||||
* pathfind_history. */
|
||||
if (peep->pathfind_goal.direction > 3 ||
|
||||
peep->pathfind_goal.x != goal.x ||
|
||||
peep->pathfind_goal.y != goal.y ||
|
||||
peep->pathfind_goal.z != goal.z
|
||||
) {
|
||||
peep->pathfind_goal.x = goal.x;
|
||||
peep->pathfind_goal.y = goal.y;
|
||||
peep->pathfind_goal.z = goal.z;
|
||||
peep->pathfind_goal.direction = 0;
|
||||
|
||||
// Clear pathfinding history
|
||||
memset(peep->pathfind_history, 0xFF, sizeof(peep->pathfind_history));
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
if (gPathFindDebug) {
|
||||
log_verbose("New goal; clearing pf_history.");
|
||||
}
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
}
|
||||
|
||||
// Peep has tried all edges.
|
||||
if (edges == 0) return -1;
|
||||
|
@ -9677,27 +9697,6 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
|
|||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
}
|
||||
|
||||
/* If this is a new goal for the peep. Store it and reset the peep's
|
||||
* pathfind_history. */
|
||||
if (peep->pathfind_goal.direction > 3 ||
|
||||
peep->pathfind_goal.x != goal.x ||
|
||||
peep->pathfind_goal.y != goal.y ||
|
||||
peep->pathfind_goal.z != goal.z
|
||||
) {
|
||||
peep->pathfind_goal.x = goal.x;
|
||||
peep->pathfind_goal.y = goal.y;
|
||||
peep->pathfind_goal.z = goal.z;
|
||||
peep->pathfind_goal.direction = 0;
|
||||
|
||||
// Clear pathfinding history
|
||||
memset(peep->pathfind_history, 0xFF, sizeof(peep->pathfind_history));
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
if (gPathFindDebug) {
|
||||
log_verbose("New goal; clearing pf_history.");
|
||||
}
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
}
|
||||
|
||||
if (isThin) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (peep->pathfind_history[i].x == x >> 5 &&
|
||||
|
|
Loading…
Reference in New Issue