From 9a8dc4b6ffd828a41aee0c8b130b06c4ca9563a8 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 15 Jun 2020 16:19:25 -0700 Subject: [PATCH] Only remove duplicate player entities in scriptclass::hardreset() Looks like duplicate player entities persisting across rooms is a semi-useful feature used by some levels. Still, though, it's a bit of a nuisance to have duplicate player entities persisting across game sessions. And levels can't rely on this persistence anyway, anyone could just close the game and re-open it to get rid of the duplicate entities regardless. --- desktop_version/src/Map.cpp | 6 ++---- desktop_version/src/Script.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 5e98c386..07474d47 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -855,13 +855,11 @@ void mapclass::gotoroom(int rx, int ry) } } - int theplayer = obj.getplayer(); - for (int i = 0; i < (int) obj.entities.size(); i++) + for (size_t i = 0; i < obj.entities.size(); i++) { - if (i != theplayer) + if (obj.entities[i].rule != 0) { removeentity_iter(i); - theplayer--; //just in case indice of player is not 0 } } diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 0a6bd660..92b63539 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3628,8 +3628,19 @@ void scriptclass::hardreset() obj.customcollect.resize(100); i = 100; //previously a for-loop iterating over collect/customcollect set this to 100 - if (obj.getplayer() > -1){ - obj.entities[obj.getplayer()].tile = 0; + int theplayer = obj.getplayer(); + if (theplayer > -1){ + obj.entities[theplayer].tile = 0; + } + + // Remove duplicate player entities + for (int i = 0; i < (int) obj.entities.size(); i++) + { + if (i != theplayer) + { + removeentity_iter(i); + theplayer--; // just in case indice of player is not 0 + } } //Script Stuff