From 3d336c13ac78fcd38c4158465dc709d42df570be Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Nov 2021 00:47:05 +0100 Subject: [PATCH] - GetClosestSpriteSectors --- source/games/blood/src/actor.cpp | 5 +++-- source/games/blood/src/ai.cpp | 2 +- source/games/blood/src/aibeast.cpp | 3 ++- source/games/blood/src/gameutil.cpp | 6 +++--- source/games/blood/src/gameutil.h | 2 +- source/games/blood/src/weapon.cpp | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 03894e47c..a05d0a045 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2649,7 +2649,7 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int { auto pOwner = source->GetOwner(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && pOwner && pOwner->IsDudeActor() && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(nSector, x, y, nDist, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(§or[nSector], x, y, nDist, nullptr, newSectCheckMethod); nDist <<= 4; if (flags & 2) { @@ -5893,6 +5893,7 @@ static void actCheckExplosion() int y = pSprite->y; int z = pSprite->z; int nSector = pSprite->sectnum; + auto pSector = pSprite->sector(); int radius = pExplodeInfo->radius; #ifdef NOONE_EXTENSIONS @@ -5907,7 +5908,7 @@ static void actCheckExplosion() // so only allow this new checking method for dude spawned explosions affectedXWalls.Clear(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && Owner && Owner->IsDudeActor() && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(nSector, x, y, radius, &affectedXWalls, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, x, y, radius, &affectedXWalls, newSectCheckMethod); for (auto pWall : affectedXWalls) { diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index cc7317945..eb896006e 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -1609,7 +1609,7 @@ void aiLookForTarget(DBloodActor* actor) if (pXSprite->state) { const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic - GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, nullptr, newSectCheckMethod); + GetClosestSpriteSectors(pSprite->sector(), pSprite->x, pSprite->y, 400, nullptr, newSectCheckMethod); BloodStatIterator it(kStatDude); while (DBloodActor* actor2 = it.Next()) diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index a13511161..c21f28469 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -89,10 +89,11 @@ void StompSeqCallback(int, DBloodActor* actor1) int z = pSprite->z; int vc = 400; auto nSector = pSprite->sectnum; + auto pSector = pSprite->sector(); int v1c = 5 + 2 * gGameOptions.nDifficulty; int v10 = 25 + 30 * gGameOptions.nDifficulty; const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(nSector, x, y, vc, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, x, y, vc, nullptr, newSectCheckMethod); int hit = HitScan(actor1, pSprite->z, dx, dy, 0, CLIPMASK1, 0); DBloodActor* actor2 = nullptr; actHitcodeToData(hit, &gHitInfo, &actor2); diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 758152a06..aa02540c4 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -712,7 +712,7 @@ unsigned int ClipMove(vec3_t* pos, sectortype** pSector, int xv, int yv, int wd, return nRes; } -BitArray GetClosestSpriteSectors(int nSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod) +BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod) { // by default this function fails with sectors that linked with wide spans, or there was more than one link to the same sector. for example... // E6M1: throwing TNT on the stone footpath while standing on the brown road will fail due to the start/end points of the span being too far away. it'll only do damage at one end of the road @@ -721,10 +721,10 @@ BitArray GetClosestSpriteSectors(int nSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod = false); +BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod = false); int picWidth(int nPic, int repeat); int picHeight(int nPic, int repeat); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index c544d8538..7a6fa744c 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -2663,9 +2663,10 @@ void teslaHit(DBloodActor *missileactor, int a2) int z = pMissile->z; int nDist = 300; int nSector = pMissile->sectnum; + auto pSector = pMissile->sector(); auto owneractor = missileactor->GetOwner(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(nSector, x, y, nDist, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, x, y, nDist, nullptr, newSectCheckMethod); bool v4 = true; DBloodActor* actor = nullptr; actHitcodeToData(a2, &gHitInfo, &actor);