mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #4997 from zaxcav/restrictBacktrack
Restrict backtracking during peep pathfinding
This commit is contained in:
@@ -55,7 +55,7 @@ extern "C" {
|
||||
// This define specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "26"
|
||||
#define NETWORK_STREAM_VERSION "27"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -9795,9 +9795,12 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
|
||||
/* Peep remembers this junction, so remove the
|
||||
* chosen_edge from those left to try. */
|
||||
peep->pathfind_history[i].direction &= ~(1 << chosen_edge);
|
||||
/* Also remove the edge through which the peep
|
||||
* entered the junction from those left to try. */
|
||||
peep->pathfind_history[i].direction &= ~(1 << (peep->direction ^ 2));
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
if (gPathFindDebug) {
|
||||
log_verbose("Removing edge %d from existing pf_history for %d,%d,%d.", chosen_edge, x >> 5, y >> 5, z);
|
||||
log_verbose("Updating existing pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", i, x >> 5, y >> 5, z, peep->direction ^ 2, chosen_edge);
|
||||
}
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
return chosen_edge;
|
||||
@@ -9812,10 +9815,14 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
|
||||
peep->pathfind_history[i].y = y >> 5;
|
||||
peep->pathfind_history[i].z = z;
|
||||
peep->pathfind_history[i].direction = permitted_edges;
|
||||
/* Remove the chosen_edge from those left to try. */
|
||||
peep->pathfind_history[i].direction &= ~(1 << chosen_edge);
|
||||
/* Also remove the edge through which the peep
|
||||
* entered the junction from those left to try. */
|
||||
peep->pathfind_history[i].direction &= ~(1 << (peep->direction ^ 2));
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
if (gPathFindDebug) {
|
||||
log_verbose("Storing new pf_history (in index: %d) for %d,%d,%d without edge %d.", i, x >> 5, y >> 5, z, chosen_edge);
|
||||
log_verbose("Storing new pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", i, x >> 5, y >> 5, z, peep->direction ^ 2, chosen_edge);
|
||||
}
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user