Refactored some code into functions for enabling/disabling pathfinding debugging for a specific peep.
Some new log messages for improved clarity when debugging pathfinding.
Added a #define to independently enable/disable pathfinding debugging to be friendly to others using debugging builds.
Currently pathfinding falls back to aimless movement in this case.
Resetting the pathfind_goal (which in turn will cause the pathfind_history to be reset) makes the pathfinding try again afresh the next time around.
Potentially useful for adjusting to path changes by the player and recovering from a stuck position due to earlier bad pathfinding.
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.
When choosing a direction at a junction in pathfind_history (with no untried directions) the existing path finding falls back to aimless movement.
This change makes the pathfinding try again.
Useful for adjusting to path changes by the player and recovering from a stuck position in a savegame due to earlier bad pathfinding.
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 is applicable for overlaid paths placed with zero clearance.
Previously the pathfinding only used the first path element.
Notes:
1. Logic related to path slope still only uses the the first path element. Overlaying path elements with the same base height but different slopes may cause pathfinding glitches.
2. The heuristic search already uses a similar approach - the inconsistency could have caused pathfinding glitches.