From 21a208e59e4342f33956b0a3bdafe89c96fd5546 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Sep 2021 09:59:10 +0200 Subject: [PATCH] - eliminated most references to spritetype::extra This was all places that could have been done earlier but had been overlooked. --- source/games/blood/src/_polymost.cpp | 1 - source/games/blood/src/actor.cpp | 5 ++--- source/games/blood/src/aibeast.cpp | 2 +- source/games/blood/src/aiunicult.cpp | 4 ++-- source/games/blood/src/callback.cpp | 10 ++++------ source/games/blood/src/db.cpp | 10 +++++----- source/games/blood/src/nnexts.cpp | 2 +- source/games/blood/src/player.cpp | 7 +++---- source/games/blood/src/prediction.cpp | 2 -- source/games/blood/src/triggers.cpp | 6 +++--- 10 files changed, 21 insertions(+), 28 deletions(-) diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 4fe144f0e..7ad4a9283 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -51,7 +51,6 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation) pTSprite->cstat = pSprite->cstat; pTSprite->statnum = kStatDecoration; pTSprite->owner = pSprite->index; - pTSprite->extra = pSprite->extra; pTSprite->flags = pSprite->hitag | 0x200; pTSprite->x = dx + interpolatedvalue(pSprite->ox, pSprite->x, interpolation); pTSprite->y = dy + interpolatedvalue(pSprite->oy, pSprite->y, interpolation); diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 786eed31d..fe641fb95 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2407,7 +2407,7 @@ static void actInitThings() break; case kThingBloodChunks: { - SEQINST* pInst = GetInstance(3, pSprite->extra); + SEQINST* pInst = GetInstance(act); if (pInst) { auto seq = getSequence(pInst->nSeqID); @@ -3929,7 +3929,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) } } - if (pMissile->extra > 0) + if (missileActor->hasX()) { actPostSprite(missileActor, kStatDecoration); if (pMissile->ang == 1024) sfxPlay3DSound(pMissile, 307, -1, 0); @@ -7341,7 +7341,6 @@ void MakeSplash(DBloodActor* actor) auto pXSprite = &actor->x(); auto pSprite = &actor->s(); pSprite->flags &= ~2; - int nXSprite = pSprite->extra; pSprite->z -= 4 << 8; int nSurface = tileGetSurfType(actor->hit.florhit); switch (pSprite->type) diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index eecabd03d..af727ff16 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -113,7 +113,7 @@ void StompSeqCallback(int, DBloodActor* actor1) if (actor1 != actor2 || v4) { spritetype* pSprite2 = &actor2->s(); - if (pSprite2->extra > 0 && pSprite2->extra < kMaxXSprites) + if (actor2->hasX()) { if (pSprite2->type == kDudeBeast) continue; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 9fe90fc1b..5e157428b 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1848,7 +1848,7 @@ void dudeLeechOperate(DBloodActor* actor, const EVENT& event) if (actTarget != nullptr && actTarget != actor->GetOwner()) { spritetype* pTarget = &actTarget->s(); - if (pTarget->statnum == kStatDude && !(pTarget->flags & 32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites && !pXSprite->stateTimer) + if (pTarget->statnum == kStatDude && !(pTarget->flags & 32) && actTarget->hasX() && !pXSprite->stateTimer) { if (IsPlayerSprite(pTarget)) { @@ -1908,7 +1908,7 @@ bool doExplosion(DBloodActor* actor, int nType) auto actExplosion = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, kStatExplosion, true); auto const pExplosion = &actExplosion->s(); auto const pXExplosion = &actExplosion->x(); - if (pExplosion->extra < 0 || pExplosion->extra >= kMaxXSprites) + if (!actExplosion->hasX()) return false; int nSeq = 4; int nSnd = 304; const EXPLOSION* pExpl = &explodeInfo[nType]; diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 0806692ae..f60a302f4 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -134,8 +134,7 @@ void fxZombieBloodSpurt(DBloodActor* actor, int) // 5 { if (!actor) return; spritetype *pSprite = &actor->s(); - int nXSprite = pSprite->extra; - assert(nXSprite > 0 && nXSprite < kMaxXSprites); + assert(actor->hasX()); XSPRITE *pXSprite = &actor->x(); int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -215,7 +214,7 @@ void Respawn(DBloodActor* actor, int) // 9 { if (!actor) return; spritetype *pSprite = &actor->s(); - assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); + assert(actor->hasX()); XSPRITE *pXSprite = &actor->x(); if (pSprite->statnum != kStatRespawn && pSprite->statnum != kStatThing) { @@ -475,7 +474,7 @@ void sleeveStopBouncing(DBloodActor* actor) { auto pSprite = &actor->s(); actor->xvel = actor->yvel = actor->zvel = 0; - if (pSprite->extra > 0) seqKill(actor); + if (actor->hasX()) seqKill(actor); sfxKill3DSound(pSprite, -1, -1); switch (pSprite->type) { @@ -639,8 +638,7 @@ void DropVoodooCb(DBloodActor* actor, int) // unused return; } pSprite->ang = getangle(pOwner->x-pSprite->x, pOwner->y-pSprite->y); - int nXSprite = pSprite->extra; - if (nXSprite > 0) + if (actor->hasX()) { XSPRITE *pXSprite = &actor->x(); if (pXSprite->data1 == 0) diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index 0520dcdef..0e7dd2dc6 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -186,6 +186,7 @@ int InsertSprite(int nSector, int nStat) } RemoveSpriteStat(nSprite); DBloodActor* actor = &bloodActors[nSprite]; + actor->Clear(); spritetype *pSprite = &actor->s(); memset(pSprite, 0, sizeof(spritetype)); InsertSpriteStat(nSprite, nStat); @@ -196,7 +197,6 @@ int InsertSprite(int nSector, int nStat) actor->SetOwner(nullptr); pSprite->extra = -1; pSprite->index = nSprite; - actor->xvel = actor->yvel = actor->zvel = 0; Numsprites++; @@ -897,11 +897,11 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor pSprite->time = i; ValidateSprite(*pSprite); - InsertSpriteSect(i, sprite[i].sectnum); - InsertSpriteStat(i, sprite[i].statnum); + InsertSpriteSect(i, pSprite->sectnum); + InsertSpriteStat(i, pSprite->statnum); Numsprites++; - sprite[i].index = i; - if (sprite[i].extra > 0) + pSprite->index = i; + if (pSprite->extra > 0) { char pBuffer[nXSpriteSize]; int nXSprite = dbInsertXSprite(i); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index d3c0efd06..a6e29ac0b 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -6760,7 +6760,7 @@ void useSlopeChanger(DBloodActor* sourceactor, int objType, int objIndex, DBlood { auto spr = &iactor->s(); auto xspr = &iactor->x(); - if (spr->extra > 0 && xspr->physAttr > 0) + if (iactor->hasX() && xspr->physAttr > 0) { xspr->physAttr |= kPhysFalling; iactor->zvel++; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 7f7c0ac1a..c5583c381 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -661,7 +661,7 @@ void playerStart(int nPlayer, int bNewLevel) auto actor = actSpawnSprite(pStartZone->sectnum, pStartZone->x, pStartZone->y, pStartZone->z, 6, 1); spritetype* pSprite = &actor->s(); - assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); + assert(actor->hasX()); XSPRITE *pXSprite = &actor->x(); pPlayer->pSprite = pSprite; pPlayer->pXSprite = pXSprite; @@ -901,7 +901,7 @@ char PickupItem(PLAYER *pPlayer, DBloodActor* itemactor) #endif case kItemFlagABase: case kItemFlagBBase: { - if (gGameOptions.nGameType != 3 || pItem->extra <= 0) return 0; + if (gGameOptions.nGameType != 3 || !itemactor->hasX()) return 0; XSPRITE * pXItem = &itemactor->x(); if (pItem->type == kItemFlagABase) { if (pPlayer->teamId == 1) { @@ -1105,7 +1105,7 @@ char PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor) if (pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; #ifdef NOONE_EXTENSIONS - else if (gModernMap && pAmmo->extra >= 0 && ammoactor->x().data1 > 0) // allow custom amount for item + else if (gModernMap && ammoactor->hasX() && ammoactor->x().data1 > 0) // allow custom amount for item pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + ammoactor->x().data1, gAmmoInfo[nAmmoType].max); #endif else @@ -1941,7 +1941,6 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage spritetype *pSprite = pPlayer->pSprite; XSPRITE *pXSprite = pPlayer->pXSprite; auto pActor = pPlayer->actor; - int nXSprite = pSprite->extra; int nXSector = sector[pSprite->sectnum].extra; DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nDeathSeqID = -1; diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index aa944e64a..af758ea7e 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -601,8 +601,6 @@ void fakeActProcessSprites(void) spritetype *pSprite = gMe->pSprite; if (pSprite->statnum == kStatDude) { - int nXSprite = pSprite->extra; - assert(nXSprite > 0 && nXSprite < kMaxXSprites); int nSector = predict.sectnum; int nXSector = sector[nSector].extra; XSECTOR *pXSector = NULL; diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 6f2cd7c57..e50b3896e 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -226,7 +226,7 @@ void LifeLeechOperate(DBloodActor* actor, EVENT event) if (!pXSprite->stateTimer) { spritetype *pTarget = &target->s(); - if (pTarget->statnum == kStatDude && !(pTarget->flags&32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites) + if (pTarget->statnum == kStatDude && !(pTarget->flags&32) && target->hasX()) { int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -1140,7 +1140,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2) if (actor && a2 > pXSector->busy) { spritetype *pSprite = &actor->s(); - assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); + assert(actor->hasX()); XSPRITE *pXSprite = &actor->x(); if (pXSector->onCeilZ > pXSector->offCeilZ || pXSector->onFloorZ < pXSector->offFloorZ) { @@ -1174,7 +1174,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2) else if (actor && a2 < pXSector->busy) { spritetype* pSprite = &actor->s(); - assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); + assert(actor->hasX()); XSPRITE* pXSprite = &actor->x(); if (pXSector->offCeilZ > pXSector->onCeilZ || pXSector->offFloorZ < pXSector->onFloorZ) {