- several s() in nnexts.cpp.

This commit is contained in:
Christoph Oelckers 2021-12-23 12:17:13 +01:00
parent c4c6c1def1
commit e460d90f37

View file

@ -257,35 +257,33 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceactor, DBloodActor* origin
{ {
DBloodActor* pDudeActor = nullptr; DBloodActor* pDudeActor = nullptr;
auto pXSource = &sourceactor->x(); auto pXSource = &sourceactor->x();
auto pOrigin = &origin->s();
if (nType < kDudeBase || nType >= kDudeMax || (pDudeActor = actSpawnSprite(origin, kStatDude)) == NULL) if (nType < kDudeBase || nType >= kDudeMax || (pDudeActor = actSpawnSprite(origin, kStatDude)) == NULL)
return NULL; return NULL;
spritetype* pDude = &pDudeActor->s();
XSPRITE* pXDude = &pDudeActor->x(); XSPRITE* pXDude = &pDudeActor->x();
int angle = pOrigin->ang; int angle = origin->spr.ang;
int x, y, z = a4 + pOrigin->pos.Z; int x, y, z = a4 + origin->spr.pos.Z;
if (a3 < 0) if (a3 < 0)
{ {
x = pOrigin->pos.X; x = origin->spr.pos.X;
y = pOrigin->pos.Y; y = origin->spr.pos.Y;
} }
else else
{ {
x = pOrigin->pos.X + mulscale30r(Cos(angle), a3); x = origin->spr.pos.X + mulscale30r(Cos(angle), a3);
y = pOrigin->pos.Y + mulscale30r(Sin(angle), a3); y = origin->spr.pos.Y + mulscale30r(Sin(angle), a3);
} }
vec3_t pos = { x, y, z }; vec3_t pos = { x, y, z };
SetActor(pDudeActor, &pos); SetActor(pDudeActor, &pos);
pDude->type = nType; pDudeActor->spr.type = nType;
pDude->ang = angle; pDudeActor->spr.ang = angle;
pDude->cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL; pDudeActor->spr.cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL;
pDude->clipdist = getDudeInfo(nType)->clipdist; pDudeActor->spr.clipdist = getDudeInfo(nType)->clipdist;
pXDude->respawn = 1; pXDude->respawn = 1;
pXDude->health = getDudeInfo(nType)->startHealth << 4; pXDude->health = getDudeInfo(nType)->startHealth << 4;
@ -297,8 +295,8 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceactor, DBloodActor* origin
if (sourceactor->spr.flags & kModernTypeFlag1) { if (sourceactor->spr.flags & kModernTypeFlag1) {
//inherit pal? //inherit pal?
if (pDude->pal <= 0) if (pDudeActor->spr.pal <= 0)
pDude->pal = sourceactor->spr.pal; pDudeActor->spr.pal = sourceactor->spr.pal;
// inherit spawn sprite trigger settings, so designer can count monsters. // inherit spawn sprite trigger settings, so designer can count monsters.
pXDude->txID = pXSource->txID; pXDude->txID = pXSource->txID;
@ -803,15 +801,14 @@ void nnExtInitModernStuff(TArray<DBloodActor*>& actors)
continue; continue;
XSPRITE* pXSpr = &iactor2->x(); XSPRITE* pXSpr = &iactor2->x();
spritetype* pSpr = &iactor2->s(); switch (iactor2->spr.type)
switch (pSpr->type)
{ {
case kSwitchToggle: // exceptions case kSwitchToggle: // exceptions
case kSwitchOneWay: // exceptions case kSwitchOneWay: // exceptions
continue; continue;
} }
if (pSpr->type == kModernCondition || pSpr->type == kModernConditionFalse) if (iactor2->spr.type == kModernCondition || iactor2->spr.type == kModernConditionFalse)
condError(iactor, "Tracking condition always must be first in condition sequence!"); condError(iactor, "Tracking condition always must be first in condition sequence!");
if (count >= kMaxTracedObjects) if (count >= kMaxTracedObjects)
@ -960,12 +957,10 @@ static DBloodActor* randomDropPickupObject(DBloodActor* sourceactor, int prevIte
spawned = actDropObject(sourceactor, selected); spawned = actDropObject(sourceactor, selected);
if (spawned) if (spawned)
{ {
auto pSprite2 = &spawned->s(); pXSource->dropMsg = uint8_t(spawned->spr.type); // store dropped item type in dropMsg
spawned->spr.pos.X = sourceactor->spr.pos.X;
pXSource->dropMsg = uint8_t(pSprite2->type); // store dropped item type in dropMsg spawned->spr.pos.Y = sourceactor->spr.pos.Y;
pSprite2->pos.X = sourceactor->spr.pos.X; spawned->spr.pos.Z = sourceactor->spr.pos.Z;
pSprite2->pos.Y = sourceactor->spr.pos.Y;
pSprite2->pos.Z = sourceactor->spr.pos.Z;
if ((sourceactor->spr.flags & kModernTypeFlag1) && (pXSource->txID > 0 || (pXSource->txID != 3 && pXSource->lockMsg > 0))) if ((sourceactor->spr.flags & kModernTypeFlag1) && (pXSource->txID > 0 || (pXSource->txID != 3 && pXSource->lockMsg > 0)))
{ {
@ -1017,10 +1012,9 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector)
BloodSectIterator it(pSector); BloodSectIterator it(pSector);
while (auto actor = it.Next()) while (auto actor = it.Next())
{ {
auto sp = &actor->s(); if (actor->spr.type == kMarkerOn && actor->spr.statnum != kStatMarker)
if (sp->type == kMarkerOn && sp->statnum != kStatMarker)
{ {
maxZ = sp->pos.Z; maxZ = actor->spr.pos.Z;
maxZfound = true; maxZfound = true;
break; break;
} }
@ -1029,8 +1023,7 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector)
it.Reset(pSector); it.Reset(pSector);
while (auto actor = it.Next()) while (auto actor = it.Next())
{ {
auto pSpr = &actor->s(); switch (actor->spr.statnum)
switch (pSpr->statnum)
{ {
case kStatFree: case kStatFree:
continue; continue;
@ -1039,16 +1032,16 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector)
continue; continue;
case kStatThing: case kStatThing:
case kStatDude: case kStatDude:
if (pSpr->flags & kPhysGravity) break; if (actor->spr.flags & kPhysGravity) break;
continue; continue;
default: default:
if (actor->hasX() && actor->xspr.physAttr & kPhysGravity) break; if (actor->hasX() && actor->xspr.physAttr & kPhysGravity) break;
continue; continue;
} }
if (maxZfound && pSpr->pos.Z <= maxZ) if (maxZfound && actor->spr.pos.Z <= maxZ)
{ {
zdiff = pSpr->pos.Z - maxZ; zdiff = actor->spr.pos.Z - maxZ;
if (actor->zvel < 0) actor->zvel += MulScale(actor->zvel >> 4, zdiff, 16); if (actor->zvel < 0) actor->zvel += MulScale(actor->zvel >> 4, zdiff, 16);
continue; continue;
@ -1058,7 +1051,7 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector)
if (actor->zvel >= 0) actor->zvel += val; if (actor->zvel >= 0) actor->zvel += val;
else actor->zvel = val; else actor->zvel = val;
pSpr->pos.Z += actor->zvel >> 12; actor->spr.pos.Z += actor->zvel >> 12;
} }
@ -1111,8 +1104,7 @@ void nnExtProcessSuperSprites()
while (auto windactor = it.Next()) while (auto windactor = it.Next())
{ {
spritetype* pWind = &windactor->s(); if (!(windactor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) || windactor->spr.statnum >= kMaxStatus || !windactor->hasX())
if (!(pWind->cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) || pWind->statnum >= kMaxStatus || !windactor->hasX())
continue; continue;
XSPRITE* pXWind = &windactor->x(); XSPRITE* pXWind = &windactor->x();
@ -1120,7 +1112,7 @@ void nnExtProcessSuperSprites()
continue; continue;
int j, rx; int j, rx;
bool fWindAlways = (pWind->flags & kModernTypeFlag1); bool fWindAlways = (windactor->spr.flags & kModernTypeFlag1);
if (pXWind->txID) { if (pXWind->txID) {
@ -1150,12 +1142,12 @@ void nnExtProcessSuperSprites()
} }
} }
else if (pWind->insector()) else if (windactor->spr.insector())
{ {
sectortype* pSect = pWind->sector(); sectortype* pSect = windactor->spr.sector();
XSECTOR* pXSector = (pSect->hasX()) ? &pSect->xs() : nullptr; XSECTOR* pXSector = (pSect->hasX()) ? &pSect->xs() : nullptr;
if ((fWindAlways) || (pXSector && !pXSector->locked && (pXSector->windAlways || pXSector->busy))) if ((fWindAlways) || (pXSector && !pXSector->locked && (pXSector->windAlways || pXSector->busy)))
windGenDoVerticalWind(pXWind->sysData2, pWind->sector()); windGenDoVerticalWind(pXWind->sysData2, windactor->spr.sector());
} }
} }
@ -1167,16 +1159,15 @@ void nnExtProcessSuperSprites()
DBloodActor* pProx = gProxySpritesList[i]; DBloodActor* pProx = gProxySpritesList[i];
if (!pProx || !pProx->hasX()) continue; if (!pProx || !pProx->hasX()) continue;
auto const pProxSpr = &pProx->s();
XSPRITE* pXProxSpr = &pProx->x(); XSPRITE* pXProxSpr = &pProx->x();
if (!pXProxSpr->Proximity || (!pXProxSpr->Interrutable && pXProxSpr->state != pXProxSpr->restState) || pXProxSpr->locked == 1 if (!pXProxSpr->Proximity || (!pXProxSpr->Interrutable && pXProxSpr->state != pXProxSpr->restState) || pXProxSpr->locked == 1
|| pXProxSpr->isTriggered) continue; // don't process locked or triggered sprites || pXProxSpr->isTriggered) continue; // don't process locked or triggered sprites
int okDist = (pProx->IsDudeActor()) ? 96 : ClipLow(pProxSpr->clipdist * 3, 32); int okDist = (pProx->IsDudeActor()) ? 96 : ClipLow(pProx->spr.clipdist * 3, 32);
int x = pProxSpr->pos.X; int x = pProx->spr.pos.X;
int y = pProxSpr->pos.Y; int y = pProx->spr.pos.Y;
int z = pProxSpr->pos.Z; int z = pProx->spr.pos.Z;
auto pSect = pProxSpr->sector(); auto pSect = pProx->spr.sector();
if (!pXProxSpr->DudeLockout) if (!pXProxSpr->DudeLockout)
{ {
@ -1217,7 +1208,6 @@ void nnExtProcessSuperSprites()
DBloodActor* pSight = gSightSpritesList[i]; DBloodActor* pSight = gSightSpritesList[i];
if (!pSight || !pSight->hasX()) continue; if (!pSight || !pSight->hasX()) continue;
auto const pSightSpr = &pSight->s();
XSPRITE* pXSightSpr = &pSight->x(); XSPRITE* pXSightSpr = &pSight->x();
if ((!pXSightSpr->Interrutable && pXSightSpr->state != pXSightSpr->restState) || pXSightSpr->locked == 1 || if ((!pXSightSpr->Interrutable && pXSightSpr->state != pXSightSpr->restState) || pXSightSpr->locked == 1 ||
@ -1231,10 +1221,10 @@ void nnExtProcessSuperSprites()
continue; continue;
} }
int x = pSightSpr->pos.X; int x = pSight->spr.pos.X;
int y = pSightSpr->pos.Y; int y = pSight->spr.pos.Y;
int z = pSightSpr->pos.Z; int z = pSight->spr.pos.Z;
auto pSightSect = pSightSpr->sector(); auto pSightSect = pSight->spr.sector();
int ztop2, zbot2; int ztop2, zbot2;
for (int a = connecthead; a >= 0; a = connectpoint2[a]) for (int a = connecthead; a >= 0; a = connectpoint2[a])
@ -1255,14 +1245,14 @@ void nnExtProcessSuperSprites()
if (pXSightSpr->unused3 & kTriggerSpriteAim) if (pXSightSpr->unused3 & kTriggerSpriteAim)
{ {
bool vector = (pSightSpr->cstat & CSTAT_SPRITE_BLOCK_HITSCAN); bool vector = (pSight->spr.cstat & CSTAT_SPRITE_BLOCK_HITSCAN);
if (!vector) if (!vector)
pSightSpr->cstat |= CSTAT_SPRITE_BLOCK_HITSCAN; pSight->spr.cstat |= CSTAT_SPRITE_BLOCK_HITSCAN;
HitScan(pPlayer->actor, pPlayer->zWeapon, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, CLIPMASK0 | CLIPMASK1, 0); HitScan(pPlayer->actor, pPlayer->zWeapon, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, CLIPMASK0 | CLIPMASK1, 0);
if (!vector) if (!vector)
pSightSpr->cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; pSight->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN;
if (gHitInfo.actor() == pSight) if (gHitInfo.actor() == pSight)
{ {
@ -1284,7 +1274,7 @@ void nnExtProcessSuperSprites()
if (debrisactor == nullptr || !debrisactor->hasX()) continue; if (debrisactor == nullptr || !debrisactor->hasX()) continue;
auto const pDebris = &debrisactor->s(); auto const pDebris = &debrisactor->s();
if (pDebris->statnum == kStatFree || (pDebris->flags & kHitagFree) != 0) if (debrisactor->spr.statnum == kStatFree || (debrisactor->spr.flags & kHitagFree) != 0)
{ {
gPhysSpritesList[i] = nullptr; gPhysSpritesList[i] = nullptr;
continue; continue;
@ -1297,7 +1287,7 @@ void nnExtProcessSuperSprites()
continue; continue;
} }
XSECTOR* pXSector = (pDebris->sector()->hasX()) ? &pDebris->sector()->xs() : nullptr; XSECTOR* pXSector = (debrisactor->spr.sector()->hasX()) ? &debrisactor->spr.sector()->xs() : nullptr;
viewBackupSpriteLoc(debrisactor); viewBackupSpriteLoc(debrisactor);
bool uwater = false; bool uwater = false;
@ -1310,7 +1300,7 @@ void nnExtProcessSuperSprites()
if (pXSector != nullptr) if (pXSector != nullptr)
{ {
if ((uwater = pXSector->Underwater) != 0) airVel <<= 6; if ((uwater = pXSector->Underwater) != 0) airVel <<= 6;
if (pXSector->panVel != 0 && getflorzofslopeptr(pDebris->sector(), pDebris->pos.X, pDebris->pos.Y) <= bottom) if (pXSector->panVel != 0 && getflorzofslopeptr(debrisactor->spr.sector(), debrisactor->spr.pos.X, debrisactor->spr.pos.Y) <= bottom)
{ {
int angle = pXSector->panAngle; int speed = 0; int angle = pXSector->panAngle; int speed = 0;
if (pXSector->panAlways || pXSector->state || pXSector->busy) if (pXSector->panAlways || pXSector->state || pXSector->busy)
@ -1319,8 +1309,8 @@ void nnExtProcessSuperSprites()
if (!pXSector->panAlways && pXSector->busy) if (!pXSector->panAlways && pXSector->busy)
speed = MulScale(speed, pXSector->busy, 16); speed = MulScale(speed, pXSector->busy, 16);
} }
if (pDebris->sector()->floorstat & CSTAT_SECTOR_ALIGN) if (debrisactor->spr.sector()->floorstat & CSTAT_SECTOR_ALIGN)
angle = (angle + GetWallAngle(pDebris->sector()->firstWall()) + 512) & 2047; angle = (angle + GetWallAngle(debrisactor->spr.sector()->firstWall()) + 512) & 2047;
int dx = MulScale(speed, Cos(angle), 30); int dx = MulScale(speed, Cos(angle), 30);
int dy = MulScale(speed, Sin(angle), 30); int dy = MulScale(speed, Sin(angle), 30);
debrisactor->xvel += dx; debrisactor->xvel += dx;
@ -1352,35 +1342,35 @@ void nnExtProcessSuperSprites()
} }
if (pXDebris->physAttr & kPhysGravity) pXDebris->physAttr |= kPhysFalling; if (pXDebris->physAttr & kPhysGravity) pXDebris->physAttr |= kPhysFalling;
if ((pXDebris->physAttr & kPhysFalling) || debrisactor->xvel || debrisactor->yvel || debrisactor->zvel || pDebris->sector()->velFloor || pDebris->sector()->velCeil) if ((pXDebris->physAttr & kPhysFalling) || debrisactor->xvel || debrisactor->yvel || debrisactor->zvel || debrisactor->spr.sector()->velFloor || debrisactor->spr.sector()->velCeil)
debrisMove(i); debrisMove(i);
if (debrisactor->xvel || debrisactor->yvel) if (debrisactor->xvel || debrisactor->yvel)
pXDebris->goalAng = getangle(debrisactor->xvel, debrisactor->yvel) & 2047; pXDebris->goalAng = getangle(debrisactor->xvel, debrisactor->yvel) & 2047;
int ang = pDebris->ang & 2047; int ang = debrisactor->spr.ang & 2047;
if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble); if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble);
else if (Chance(0x1000 - mass)) else if (Chance(0x1000 - mass))
{ {
if (debrisactor->zvel > 0x100) debrisBubble(debrisactor); if (debrisactor->zvel > 0x100) debrisBubble(debrisactor);
if (ang == pXDebris->goalAng) if (ang == pXDebris->goalAng)
{ {
pXDebris->goalAng = (pDebris->ang + Random3(kAng60)) & 2047; pXDebris->goalAng = (debrisactor->spr.ang + Random3(kAng60)) & 2047;
debrisBubble(debrisactor); debrisBubble(debrisactor);
} }
} }
int angStep = ClipLow(mulscale8(1, ((abs(debrisactor->xvel) + abs(debrisactor->yvel)) >> 5)), (uwater) ? 1 : 0); int angStep = ClipLow(mulscale8(1, ((abs(debrisactor->xvel) + abs(debrisactor->yvel)) >> 5)), (uwater) ? 1 : 0);
if (ang < pXDebris->goalAng) pDebris->ang = ClipHigh(ang + angStep, pXDebris->goalAng); if (ang < pXDebris->goalAng) debrisactor->spr.ang = ClipHigh(ang + angStep, pXDebris->goalAng);
else if (ang > pXDebris->goalAng) pDebris->ang = ClipLow(ang - angStep, pXDebris->goalAng); else if (ang > pXDebris->goalAng) debrisactor->spr.ang = ClipLow(ang - angStep, pXDebris->goalAng);
auto pSector = pDebris->sector(); auto pSector = debrisactor->spr.sector();
int cz = getceilzofslopeptr(pSector, pDebris->pos.X, pDebris->pos.Y); int cz = getceilzofslopeptr(pSector, debrisactor->spr.pos.X, debrisactor->spr.pos.Y);
int fz = getflorzofslopeptr(pSector, pDebris->pos.X, pDebris->pos.Y); int fz = getflorzofslopeptr(pSector, debrisactor->spr.pos.X, debrisactor->spr.pos.Y);
GetActorExtents(debrisactor, &top, &bottom); GetActorExtents(debrisactor, &top, &bottom);
if (fz >= bottom && pSector->lowerLink == nullptr && !(pSector->ceilingstat & CSTAT_SECTOR_SKY)) pDebris->pos.Z += ClipLow(cz - top, 0); if (fz >= bottom && pSector->lowerLink == nullptr && !(pSector->ceilingstat & CSTAT_SECTOR_SKY)) debrisactor->spr.pos.Z += ClipLow(cz - top, 0);
if (cz <= top && pSector->upperLink == nullptr && !(pSector->floorstat & CSTAT_SECTOR_SKY)) pDebris->pos.Z += ClipHigh(fz - bottom, 0); if (cz <= top && pSector->upperLink == nullptr && !(pSector->floorstat & CSTAT_SECTOR_SKY)) debrisactor->spr.pos.Z += ClipHigh(fz - bottom, 0);
} }
} }
} }
@ -1559,10 +1549,10 @@ int debrisGetFreeIndex(void)
for (int i = 0; i < kMaxSuperXSprites; i++) for (int i = 0; i < kMaxSuperXSprites; i++)
{ {
if (gPhysSpritesList[i] == nullptr) return i; if (gPhysSpritesList[i] == nullptr) return i;
auto spr = &gPhysSpritesList[i]->s(); auto actor = gPhysSpritesList[i];
if (spr->statnum == kStatFree) return i; if (actor->spr.statnum == kStatFree) return i;
else if ((spr->flags & kHitagFree) || !gPhysSpritesList[i]->hasX()) return i; else if ((actor->spr.flags & kHitagFree) || !gPhysSpritesList[i]->hasX()) return i;
else if (gPhysSpritesList[i]->xspr.physAttr == 0) return i; else if (gPhysSpritesList[i]->xspr.physAttr == 0) return i;
} }
@ -2900,11 +2890,10 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
BloodSectIterator it(pSector); BloodSectIterator it(pSector);
while (auto iactor = it.Next()) while (auto iactor = it.Next())
{ {
spritetype* pSpr = &iactor->s(); if (iactor->spr.statnum != kStatDude || !iactor->IsDudeActor() || ! iactor->hasX())
if (pSpr->statnum != kStatDude || !iactor->IsDudeActor() || ! iactor->hasX())
continue; continue;
PLAYER* pPlayer = getPlayerById(pSpr->type); PLAYER* pPlayer = getPlayerById(iactor->spr.type);
if (pXSector->Underwater) if (pXSector->Underwater)
{ {
if (pLower) if (pLower)