From 35472fe6e28e04ff8d618ef699a90d59b2499f86 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 12 Dec 2016 08:33:55 +0000 Subject: [PATCH] Fix #4819. Prevent peep queue loops when next_in_queue broken. --- src/network/network.h | 2 +- src/peep/peep.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/network/network.h b/src/network/network.h index eec83f4f08..73377e6dbf 100644 --- a/src/network/network.h +++ b/src/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 "20" +#define NETWORK_STREAM_VERSION "21" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION #ifdef __cplusplus diff --git a/src/peep/peep.c b/src/peep/peep.c index 93a7f12887..d831593a13 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -4889,7 +4889,20 @@ static void peep_update_queuing(rct_peep* peep){ } if (peep->sub_state != 10){ - if (peep->next_in_queue == 0xFFFF){ + bool is_front = true; + if (peep->next_in_queue != 0xFFFF) { + // Fix #4819: Occasionally the peep->next_in_queue is incorrectly set + // to prevent this from causing the peeps to enter a loop + // first check if the next in queue is actually nearby + // if they are not then its safe to assume that this is + // the front of the queue. + rct_peep* next_peep = GET_PEEP(peep->next_in_queue); + if (abs(next_peep->x - peep->x) < 32 && + abs(next_peep->y - peep->y) < 32) { + is_front = false; + } + } + if (is_front){ //Happens every time peep goes onto ride. peep->destination_tolerence = 0; peep_decrement_num_riders(peep);