From e42c3afbea3b442f53a818d4102445ab1a98b616 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 21 Dec 2021 14:33:25 +0100 Subject: [PATCH] - Exhumed: fixed trap setup. Must clear the structure before the first return and iterate over the walls by reference, otherwise bad pointers will get copied. --- source/games/exhumed/src/object.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 20662e744..032003f7a 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1210,6 +1210,7 @@ int BuildTrap(DExhumedActor* pActor, int edx, int ebx, int ecx) int var_10 = ecx; int nTrap = sTrap.Reserve(1); + sTrap[nTrap] = {}; ChangeActorStat(pActor, 0); @@ -1241,12 +1242,9 @@ int BuildTrap(DExhumedActor* pActor, int edx, int ebx, int ecx) return nTrap; } - sTrap[nTrap].pWall1 = nullptr; - sTrap[nTrap].pWall2 = nullptr; - auto pSector = pSprite->sector(); - for(auto wal : wallsofsector(pSector)) + for(auto& wal : wallsofsector(pSector)) { if (var_18 == wal.hitag) {