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?

This commit is contained in:
sirlemonhead 2019-11-30 14:22:43 +00:00 committed by Christoph Oelckers
parent d474478800
commit ceccc0c2ee

View file

@ -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;