From b8e611a3bf6c18b6e9fe3b29604ab27599c54bf7 Mon Sep 17 00:00:00 2001 From: Info Teddy Date: Mon, 13 Jan 2020 14:43:11 -0800 Subject: [PATCH] Destroy duplicate player entities during gotoroom The game makes sure that the player entity is never destroyed, but in doing so, it doesn't destroy any duplicate player entities that might have been created via strange means e.g. a custom level doing a createentity with t=0. Duplicate player entities are, in a sense, not the "real" player entity. For one, they can take damage and die, but when they do they'll still be stuck inside the hazard, which can result in a softlock. For another, their position isn't updated when going between rooms. It's better to just destroy them when we can. --- desktop_version/src/Map.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 9a20234d..971be047 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -900,10 +900,13 @@ void mapclass::gotoroom(int rx, int ry, Graphics& dwgfx, Game& game, entityclass } } + int theplayer = obj.getplayer(); for (int i = 0; i < obj.nentity; i++) { - //Of course the player's always gonna be object zero, this is just in case - if (obj.entities[i].rule != 0) obj.entities[i].active = false; + if (i != theplayer) + { + obj.entities[i].active = false; + } } obj.cleanup();