From ceccc0c2ee232c9c904e1641d1e25fb07f5aafa7 Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Sat, 30 Nov 2019 14:22:43 +0000 Subject: [PATCH] Fix an issue where the game attempts to index sprite array with -1. This occurs when runlist_DamageEnemy() is called when no source sprite for the damage is specified (an enemy burning in lava??). The game passes -1 for the 2nd parameter to this function call, and then attempts to index sprite array. Added check. Hopefully fixes crashing on the final level? --- source/exhumed/src/runlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/exhumed/src/runlist.cpp b/source/exhumed/src/runlist.cpp index 6ccb3eef7..fe0c6fbe0 100644 --- a/source/exhumed/src/runlist.cpp +++ b/source/exhumed/src/runlist.cpp @@ -1816,7 +1816,7 @@ void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage) runlist_SendMessageToRunRec(nRun, (nSprite2 & 0xFFFF) | 0x80000, nDamage * 4); // is there now one less creature? (has one died) - if (nPreCreaturesLeft > nCreaturesLeft) + if (nPreCreaturesLeft > nCreaturesLeft && nSprite2 > -1) { if (sprite[nSprite2].statnum != 100) { return;