From c6f2aaf1b7f49592a5dc550faad67fa6ef6aa86d Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Wed, 10 Nov 2021 08:45:25 +1100 Subject: [PATCH] - Miscellaneous fixes to commit to change sector checks over to `validSectorIndex()`. * Fix missed changeover in Blood's `actSpawnSprite()`. * Fix non-negated check on a `validSectorIndex()` call in Blood's `debrisMove()`. * Removed a superfluous terminator in Duke's `actor.cpp`. * Fixed bad call to `validSectorIndex()` in Exhumed's `AIAnim::Tick()`. --- source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/nnexts.cpp | 8 +------- source/games/duke/src/actors.cpp | 2 +- source/games/exhumed/src/anims.cpp | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 6d8df5f49..84a2a7c34 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6402,7 +6402,7 @@ DBloodActor* actSpawnSprite(DBloodActor* source, int nStat) BloodStatIterator it(kStatPurge); actor = it.Next(); assert(actor); - assert(pSource->sectnum >= 0 && pSource->sectnum < kMaxSectors); + assert(validSectorIndex(pSource->sectnum)); ChangeActorSect(actor, pSource->sectnum); actPostSprite(actor, nStat); } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index baaabd50c..5bd3cf258 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1692,17 +1692,11 @@ void debrisMove(int listIndex) spritetype* pSprite = &actor->s(); int nSector = pSprite->sectnum; - if (!actor->hasX()) + if (!actor->hasX() || !validSectorIndex(pSprite->sectnum)) { gPhysSpritesList[listIndex] = nullptr; return; } - else if (validSectorIndex(pSprite->sectnum)) - { - gPhysSpritesList[listIndex] = nullptr; - return; - } - int top, bottom, i; GetActorExtents(actor, &top, &bottom); diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 06350d566..5a6e0a263 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -2255,7 +2255,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f if (callsetsprite) setsprite(actor, s->pos); // this was after the slope calls, but we should avoid calling that for invalid sectors. - if (!validSectorIndex(s->sectnum)); + if (!validSectorIndex(s->sectnum)) { deletesprite(actor); return false; diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index 3e08a8080..80fb9f065 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -149,7 +149,7 @@ void AIAnim::Tick(RunListEvent* ev) if (pSpriteB->sectnum != pSprite->sectnum) { - if (!validSectorIndex(pSpriteB)) + if (!validSectorIndex(pSpriteB->sectnum)) { DestroyAnim(pActor); return;