From 1d371b8cbf1f4f7725519e2ce1622566e9a87b40 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 7 Dec 2021 19:05:40 +0100 Subject: [PATCH] - clear some data on init. --- source/games/exhumed/src/freelistarray.h | 3 +++ source/games/exhumed/src/lighting.cpp | 1 + source/games/exhumed/src/move.cpp | 1 + 3 files changed, 5 insertions(+) diff --git a/source/games/exhumed/src/freelistarray.h b/source/games/exhumed/src/freelistarray.h index f56fedd38..6e0cb4262 100644 --- a/source/games/exhumed/src/freelistarray.h +++ b/source/games/exhumed/src/freelistarray.h @@ -46,6 +46,7 @@ public: enum { count = size }; void Clear() { + memset(DataList, 0, sizeof(DataList)); freecount = size; for (int i = 0; i < size; i++) { @@ -61,6 +62,8 @@ public: void Release(int i) { + // Important: This must not clear the released objects because several + // linked list loops are written to access the 'next' field after the Release call! FreeList[freecount++] = i; } diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index b1c6f3027..a3d8953e5 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -539,6 +539,7 @@ loc_1868A: { nLastFlash = edi; } + pFlash->pActor = nullptr; sFlash.Release(nFlash); } } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index b26c88bee..ec0d534dc 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -801,6 +801,7 @@ int GetUpAngle(DExhumedActor* pActor1, int nVal, DExhumedActor* pActor2, int ecx void InitPushBlocks() { nPushBlocks = 0; + memset(sBlockInfo, 0, sizeof(sBlockInfo)); } int GrabPushBlock()