- wrap the bit tests for GetClosestSpriteSectors's return.

They need to check spritenum which is supposed to go away, so this function avoids keeping obsolete references.
This commit is contained in:
Christoph Oelckers 2021-11-24 00:04:56 +01:00
parent 368a21f75e
commit 669aa033e9
4 changed files with 16 additions and 11 deletions

View file

@ -2663,7 +2663,7 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int
if (act2->hasX())
{
if (pSprite2->flags & 0x20) continue;
if (!sectorMap[pSprite2->sectnum]) continue;
if (!CheckSector(sectorMap, pSprite2)) continue;
if (!CheckProximity(act2, x, y, z, nSector, nDist)) continue;
int dx = abs(x - pSprite2->x);
@ -2690,7 +2690,7 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int
auto pSprite2 = &act2->s();
if (pSprite2->flags & 0x20) continue;
if (!sectorMap[pSprite2->sectnum]) continue;
if (!CheckSector(sectorMap, pSprite2)) continue;
if (!CheckProximity(act2, x, y, z, nSector, nDist)) continue;
XSPRITE* pXSprite2 = &act2->x();
@ -5923,7 +5923,7 @@ static void actCheckExplosion()
if (pDude->flags & 32) continue;
if (sectorMap[pDude->sectnum])
if (CheckSector(sectorMap, pDude))
{
if (pXSprite->data1 && CheckProximity(dudeactor, x, y, z, nSector, radius))
{
@ -5952,7 +5952,7 @@ static void actCheckExplosion()
if (pThing->flags & 32) continue;
if (sectorMap[pThing->sectnum])
if (CheckSector(sectorMap, pThing))
{
if (pXSprite->data1 && CheckProximity(thingactor, x, y, z, nSector, radius) && thingactor->hasX())
{
@ -5996,7 +5996,7 @@ static void actCheckExplosion()
spritetype* pDebris = &physactor->s();
if (pDebris->sectnum < 0 || (pDebris->flags & kHitagFree) != 0) continue;
if (!sectorMap[pDebris->sectnum] || !CheckProximity(physactor, x, y, z, nSector, radius)) continue;
if (!CheckSector(sectorMap, pDebris) || !CheckProximity(physactor, x, y, z, nSector, radius)) continue;
else debrisConcuss(Owner, i, x, y, z, pExplodeInfo->dmgType);
}
}
@ -6008,9 +6008,9 @@ static void actCheckExplosion()
if (gImpactSpritesList[i] == nullptr) continue;
auto impactactor = gImpactSpritesList[i];
if (!impactactor->hasX() || impactactor->s().sectnum < 0 || (impactactor->s().flags & kHitagFree) != 0) continue;
if (!impactactor->hasX() || !impactactor->s().insector() || (impactactor->s().flags & kHitagFree) != 0) continue;
if (/*pXImpact->state == pXImpact->restState ||*/ !sectorMap[impactactor->s().sectnum] || !CheckProximity(impactactor, x, y, z, nSector, radius))
if (!CheckSector(sectorMap, &impactactor->s()) || !CheckProximity(impactactor, x, y, z, nSector, radius))
continue;
trTriggerSprite(impactactor, kCmdSpriteImpact);

View file

@ -110,7 +110,7 @@ void StompSeqCallback(int, DBloodActor* actor1)
continue;
if (pSprite2->flags & 32)
continue;
if (sectorMap[pSprite2->sectnum] && CheckProximity(actor2, x, y, z, nSector, vc))
if (CheckSector(sectorMap, pSprite2) && CheckProximity(actor2, x, y, z, nSector, vc))
{
int top, bottom;
GetActorExtents(actor1, &top, &bottom);
@ -141,7 +141,7 @@ void StompSeqCallback(int, DBloodActor* actor1)
spritetype* pSprite2 = &actor2->s();
if (pSprite2->flags & 32)
continue;
if (sectorMap[pSprite2->sectnum] && CheckProximity(actor2, x, y, z, nSector, vc))
if (CheckSector(sectorMap, pSprite2) && CheckProximity(actor2, x, y, z, nSector, vc))
{
XSPRITE* pXSprite = &actor2->x();
if (pXSprite->locked)

View file

@ -70,5 +70,10 @@ BitArray GetClosestSpriteSectors(int nSector, int x, int y, int nDist, TArray<wa
int picWidth(int nPic, int repeat);
int picHeight(int nPic, int repeat);
inline bool CheckSector(const BitArray& bits, spritetype* spr)
{
return bits[spr->sectnum];
}
END_BLD_NS

View file

@ -2679,7 +2679,7 @@ void teslaHit(DBloodActor *missileactor, int a2)
spritetype *pHitSprite = &hitactor->s();
if (pHitSprite->flags&32)
continue;
if (sectorMap[pHitSprite->sectnum] && CheckProximity(hitactor, x, y, z, nSector, nDist))
if (CheckSector(sectorMap, pHitSprite) && CheckProximity(hitactor, x, y, z, nSector, nDist))
{
int dx = pMissile->x-pHitSprite->x;
int dy = pMissile->y-pHitSprite->y;
@ -2696,7 +2696,7 @@ void teslaHit(DBloodActor *missileactor, int a2)
spritetype *pHitSprite = &hitactor->s();
if (pHitSprite->flags&32)
continue;
if (sectorMap[pHitSprite->sectnum] && CheckProximity(hitactor, x, y, z, nSector, nDist))
if (CheckSector(sectorMap, pHitSprite) && CheckProximity(hitactor, x, y, z, nSector, nDist))
{
XSPRITE *pXSprite = &hitactor->x();
if (!pXSprite->locked)