From 6570741a1c33651b102c8c95addc0a89923c6c19 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sat, 18 Apr 2020 19:43:05 +0100 Subject: [PATCH] Fix #11343, 11344. Remove all peeps cheat causes a crash/hang (#11345) * Fix #11343, 11344. Remove all peeps cheat causes a crash/hang Caused by a refactor. Co-authored-by: Tulio Leao --- src/openrct2/actions/SetCheatAction.hpp | 7 +++++-- src/openrct2/network/Network.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index a3038fa3a5..77f8c83c35 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -685,9 +685,12 @@ private: } } - Peep* peep; - FOR_ALL_GUESTS (spriteIndex, peep) + // Do not use the FOR_ALL_PEEPS macro for this as next sprite index + // will be fetched on a deleted peep. + for (spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; spriteIndex != SPRITE_INDEX_NULL;) { + auto peep = GET_PEEP(spriteIndex); + spriteIndex = peep->next; peep->Remove(); } diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index f7fb60004a..201d210acb 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -31,7 +31,7 @@ // This string 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 "3" +#define NETWORK_STREAM_VERSION "4" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr;