- several more xsector references removed.

This commit is contained in:
Christoph Oelckers 2021-11-19 18:46:06 +01:00
parent adaa132515
commit 4ed1ee77c7
5 changed files with 16 additions and 32 deletions

View file

@ -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;

View file

@ -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()? &sector[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;

View file

@ -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)));
}

View file

@ -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 = &sector[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;

View file

@ -353,9 +353,9 @@ void CounterCheck(DBloodActor*, int nSector) // 12
if (!validSectorIndex(nSector)) return;
auto pSector = &sector[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;