From f98b8e9de937877628a213678992bb40cb566c32 Mon Sep 17 00:00:00 2001 From: zaxcav Date: Thu, 5 Jan 2017 17:45:18 +0100 Subject: [PATCH 1/4] Restrict peep backtracking further via pathfind_history[i].direction Dependent on the path layout it is possible for peeps to get stuck in backtracking cycles between two or more path tiles - each such tile is a turn around point because from that tile, the reachable tile on the search boundary that is closest to the peep destination is in the direction the peep came from. When storing/updating the pathfind_histroy, remove the direction the peep came from (in addition to the chosen direction) from the directions left to try to prevent such backtracking. --- src/openrct2/peep/peep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index 5cb844580a..4b2ae7d17e 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -9795,6 +9795,9 @@ 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 the peep came from 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); @@ -9813,6 +9816,9 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep) peep->pathfind_history[i].z = z; peep->pathfind_history[i].direction = permitted_edges; peep->pathfind_history[i].direction &= ~(1 << chosen_edge); + /* Also remove the edge the peep came from 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); From 78715fa1c0047b281263ac3b4e6afd183db7d6fe Mon Sep 17 00:00:00 2001 From: zaxcav Date: Thu, 5 Jan 2017 20:46:14 +0100 Subject: [PATCH 2/4] Increment network version --- src/openrct2/network/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index 0002a124c9..ffe1fdfa80 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -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 From 64a2d105e5158b42bfce749493886e6bcd2109b0 Mon Sep 17 00:00:00 2001 From: zaxcav Date: Thu, 5 Jan 2017 21:43:57 +0100 Subject: [PATCH 3/4] Reword comments with "from from". --- src/openrct2/peep/peep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index 4b2ae7d17e..ca9f9e3b4e 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -9795,8 +9795,8 @@ 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 the peep came from from - * those left to try. */ + /* 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) { @@ -9816,8 +9816,8 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep) peep->pathfind_history[i].z = z; peep->pathfind_history[i].direction = permitted_edges; peep->pathfind_history[i].direction &= ~(1 << chosen_edge); - /* Also remove the edge the peep came from from - * those left to try. */ + /* 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) { From 9772c34ceee9806e25230403213746e09e78e3b1 Mon Sep 17 00:00:00 2001 From: zaxcav Date: Fri, 6 Jan 2017 12:26:23 +0100 Subject: [PATCH 4/4] Update debugging messages to reflect changes in how pathfind_history[].direction is updated. --- src/openrct2/peep/peep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index ca9f9e3b4e..80ce5e992f 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -9800,7 +9800,7 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep) 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; @@ -9815,13 +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 }