From d4439b879c089ccec2ee132fa4c002bfccc08316 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 31 Aug 2021 19:38:25 +0200 Subject: [PATCH] - Blood: added checks to the SEQ code to handle situation where their attached object has been removed from the game. --- source/games/blood/src/seq.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 670991d79..13f2d8709 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -260,7 +260,8 @@ void UpdateSprite(int nXSprite, SEQFRAME* pFrame) { assert(nXSprite > 0 && nXSprite < kMaxXSprites); int nSprite = xsprite[nXSprite].reference; - assert(nSprite >= 0 && nSprite < kMaxSprites); + if (!(nSprite >= 0 && nSprite < kMaxSprites)) return; // sprite may have been deleted already. + spritetype* pSprite = &sprite[nSprite]; assert(pSprite->extra == nXSprite); if (pSprite->flags & 2) @@ -657,12 +658,14 @@ void seqProcess(int nTicks) { if (pInst->type == SS_SPRITE) { - short nSprite = (short)xsprite[index].reference; - assert(nSprite >= 0 && nSprite < kMaxSprites); - evKill(nSprite, SS_SPRITE); - if ((sprite[nSprite].hitag & kAttrRespawn) != 0 && (sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)) - evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); - else deletesprite(nSprite); // safe to not use actPostSprite here + int nSprite = xsprite[index].reference; + if (nSprite >= 0 && nSprite < kMaxSprites) + { + evKill(nSprite, SS_SPRITE); + if ((sprite[nSprite].hitag & kAttrRespawn) != 0 && (sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)) + evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); + else deletesprite(nSprite); // safe to not use actPostSprite here + } } if (pInst->type == SS_MASKED)