From 4ed1ee77c71a71cc3e1b3bc02d839e999a188968 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Nov 2021 18:46:06 +0100 Subject: [PATCH] - several more xsector references removed. --- source/games/blood/src/actor.cpp | 3 +-- source/games/blood/src/ai.cpp | 25 +++++++++--------------- source/games/blood/src/aiunicult.cpp | 2 +- source/games/blood/src/animatesprite.cpp | 14 +++---------- source/games/blood/src/callback.cpp | 4 ++-- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 2bac19642..cfd4bdf15 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -5276,8 +5276,7 @@ void MoveDude(DBloodActor* actor) return; } } - int nXSector = sector[pSprite->sectnum].extra; - if (nXSector > 0 && xsector[nXSector].Underwater) + if (IsUnderwaterSector(pSprite->sector())) return; if (pXSprite->height >= 0x100) return; diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 62da347ca..464f9a926 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -153,15 +153,13 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange) if (!FindSector(x, y, z, &nSector)) return false; int floorZ = getflorzofslope(nSector, x, y); - int nXSector = sector[nSector].extra; + auto pXSector = sector[nSector].hasX()? §or[nSector].xs() : nullptr; bool Underwater = 0; bool Water = 0; bool Depth = 0; bool Crusher = 0; - XSECTOR* pXSector = NULL; - if (nXSector > 0) + if (pXSector) { - pXSector = &xsector[nXSector]; if (pXSector->Underwater) Underwater = 1; if (pXSector->Depth) @@ -240,7 +238,7 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange) default: if (Crusher) return false; - if ((nXSector < 0 || (!xsector[nXSector].Underwater && !xsector[nXSector].Depth)) && floorZ - bottom > 0x2000) + if ((pXSector == nullptr || (!pXSector->Underwater && !pXSector->Depth)) && floorZ - bottom > 0x2000) return false; break; } @@ -587,9 +585,8 @@ void aiActivateDude(DBloodActor* actor) case kDudeGillBeast: { DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; - XSECTOR* pXSector = NULL; - if (sector[pSprite->sectnum].extra > 0) - pXSector = &xsector[sector[pSprite->sectnum].extra]; + XSECTOR* pXSector = pSprite->sector()->hasX()? &pSprite->sector()->xs() : nullptr; + pDudeExtraE->thinkTime = 0; pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) @@ -1432,9 +1429,8 @@ void RecoilDude(DBloodActor* actor) aiNewState(actor, &eelRecoil); break; case kDudeGillBeast: { - XSECTOR* pXSector = NULL; - if (sector[pSprite->sectnum].extra > 0) - pXSector = &xsector[sector[pSprite->sectnum].extra]; + XSECTOR* pXSector = pSprite->sector()->hasX() ? &pSprite->sector()->xs() : nullptr; + aiPlay3DSound(actor, 1702, AI_SFX_PRIORITY_2, -1); if (pXSector && pXSector->Underwater) aiNewState(actor, &gillBeastSwimRecoil); @@ -1720,11 +1716,8 @@ void aiInitSprite(DBloodActor* actor) { auto pSprite = &actor->s(); auto pXSprite = &actor->x(); - int nSector = pSprite->sectnum; - int nXSector = sector[nSector].extra; - XSECTOR* pXSector = NULL; - if (nXSector > 0) - pXSector = &xsector[nXSector]; + XSECTOR* pXSector = pSprite->sector()->hasX() ? &pSprite->sector()->xs() : nullptr; + DUDEEXTRA* pDudeExtra = &actor->dudeExtra; DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; pDudeExtra->teslaHit = 0; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index c92bcb3a8..cbaa282be 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1394,7 +1394,7 @@ bool spriteIsUnderwater(DBloodActor* actor, bool oldWay) { auto const pSprite = &actor->s(); auto const pXSprite = &actor->x(); - return ((sector[pSprite->sectnum].extra >= 0 && xsector[sector[pSprite->sectnum].extra].Underwater) + return (IsUnderwaterSector(pSprite->sector()) || (oldWay && (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo))); } diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index 628b4e137..ef649be9f 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -505,8 +505,7 @@ static tspritetype *viewAddEffect(spritetype* tsprite, int& spritesortcnt, int n static void viewApplyDefaultPal(tspritetype *pTSprite, sectortype const *pSector) { - auto& nXSector = pSector->extra; - XSECTOR const *pXSector = nXSector >= 0 ? &xsector[nXSector] : NULL; + XSECTOR const *pXSector = pSector->hasX()? &pSector->xs() : nullptr; if (pXSector && pXSector->color && (VanillaMode() || pSector->floorpal != 0)) { copyfloorpal(pTSprite, pSector); @@ -688,16 +687,9 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int } sectortype *pSector = §or[pTSprite->sectnum]; - XSECTOR *pXSector; + XSECTOR const* pXSector = pSector->hasX() ? &pSector->xs() : nullptr; int nShade = pTSprite->shade; - if (pSector->extra > 0) - { - pXSector = &xsector[pSector->extra]; - } - else - { - pXSector = NULL; - } + if ((pSector->ceilingstat&1) && (pSector->floorstat&32768) == 0) { nShade += tileShade[pSector->ceilingpicnum]+pSector->ceilingshade; diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index dae802876..9109d2f9b 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -353,9 +353,9 @@ void CounterCheck(DBloodActor*, int nSector) // 12 if (!validSectorIndex(nSector)) return; auto pSector = §or[nSector]; if (pSector->type != kSectorCounter) return; - if (pSector->extra <= 0) return; + if (!pSector->hasX()) return; - XSECTOR *pXSector = &xsector[pSector->extra]; + XSECTOR* pXSector = &pSector->xs(); int nReq = pXSector->waitTimeA; int nType = pXSector->data; int nCount = 0;