From 80125e11f3e1cf6a6d2e2a294ff65298b1d4a99b Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 21 Apr 2023 21:10:45 +1000 Subject: [PATCH] - Exhumed: Separate out seq variables within `DExhumedActor`. --- source/games/exhumed/src/anims.cpp | 33 ++++++++++++------------- source/games/exhumed/src/bubbles.cpp | 6 ++--- source/games/exhumed/src/exhumed.cpp | 2 ++ source/games/exhumed/src/exhumedactor.h | 2 ++ source/games/exhumed/src/object.cpp | 20 +++++++-------- source/games/exhumed/src/player.cpp | 6 ++--- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index 24a7d84f5..f49757f13 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -133,11 +133,10 @@ DExhumedActor* BuildAnim(DExhumedActor* pActor, int nSeq, int nOffset, const DVe pActor->spr.intowner = -1; pActor->spr.extra = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x100000); pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x100000); - pActor->nAction = nFlag; - pActor->nIndex = 0; - pActor->nIndex2 = getSeqFromId(nSeq, nOffset); + pActor->nFlags = nFlag; + pActor->nFrame = 0; + pActor->nSeq = getSeqFromId(nSeq, nOffset); pActor->pTarget = nullptr; - pActor->nDamage = pActor->nRun; pActor->nPhase = ITEM_MAGIC; pActor->backuppos(); @@ -155,8 +154,8 @@ void AIAnim::Tick(RunListEvent* ev) const auto pActor = ev->pObjActor; if (!pActor) return; - const int nSeq = pActor->nIndex2; - const int nFrame = pActor->nIndex; + const int nSeq = pActor->nSeq; + const int nFrame = pActor->nFrame; if (!(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)) { @@ -222,25 +221,25 @@ void AIAnim::Tick(RunListEvent* ev) } } - pActor->nIndex++; - if (pActor->nIndex >= getSeqFrameCount(nSeq)) + pActor->nFrame++; + if (pActor->nFrame >= getSeqFrameCount(nSeq)) { - if (pActor->nAction & 0x10) + if (pActor->nFlags & kAnimLoop) { - pActor->nIndex = 0; + pActor->nFrame = 0; } else if (nSeq == nPreMagicSeq) { - pActor->nIndex = 0; - pActor->nIndex2 = nMagicSeq; - pActor->nAction |= 0x10; + pActor->nFrame = 0; + pActor->nSeq = nMagicSeq; + pActor->nFlags |= kAnimLoop; pActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT; } else if (nSeq == nSavePointSeq) { - pActor->nIndex = 0; - pActor->nIndex2++; - pActor->nAction |= 0x10; + pActor->nFrame = 0; + pActor->nSeq++; + pActor->nFlags |= kAnimLoop; } else { @@ -260,7 +259,7 @@ void AIAnim::Draw(RunListEvent* ev) const auto pActor = ev->pObjActor; if (!pActor) return; - seq_PlotSequence(ev->nParam, pActor->nIndex2, pActor->nIndex, 0x101); + seq_PlotSequence(ev->nParam, pActor->nSeq, pActor->nFrame, 0x101); ev->pTSprite->ownerActor = nullptr; } diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index 4dc56724f..c1af914cc 100644 --- a/source/games/exhumed/src/bubbles.cpp +++ b/source/games/exhumed/src/bubbles.cpp @@ -77,7 +77,7 @@ static DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector, cons // GrabTimeSlot(3); pActor->nFrame = 0; - pActor->nIndex = getSeqFromId(kSeqBubble, nSize); + pActor->nSeq = getSeqFromId(kSeqBubble, nSize); pActor->spr.intowner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x140000); pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x140000); @@ -95,7 +95,7 @@ void AIBubble::Tick(RunListEvent* ev) const auto pActor = ev->pObjActor; if (!pActor) return; - const int nSeq = pActor->nIndex; + const int nSeq = pActor->nSeq; seq_MoveSequence(pActor, nSeq, pActor->nFrame); @@ -130,7 +130,7 @@ void AIBubble::Draw(RunListEvent* ev) const auto pActor = ev->pObjActor; if (!pActor) return; - seq_PlotSequence(ev->nParam, pActor->nIndex, pActor->nFrame, 1); + seq_PlotSequence(ev->nParam, pActor->nSeq, pActor->nFrame, 1); ev->pTSprite->ownerActor = nullptr; } diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index d05108d4e..e55e8de49 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -579,6 +579,8 @@ void DExhumedActor::Serialize(FSerializer& arc) ("index2", nIndex2) ("channel", nChannel) ("damage", nDamage) + ("seq", nSeq) + ("flags", nFlags) ("angle2", pitch) ("turn", nTurn) diff --git a/source/games/exhumed/src/exhumedactor.h b/source/games/exhumed/src/exhumedactor.h index 4e690ed20..de7e8b97f 100644 --- a/source/games/exhumed/src/exhumedactor.h +++ b/source/games/exhumed/src/exhumedactor.h @@ -24,7 +24,9 @@ public: int16_t nPhase; int16_t nHealth; + int16_t nSeq; int16_t nFrame; + int16_t nFlags; int16_t nAction; int16_t nCount; int16_t nRun; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index dd52293c4..64d63c39e 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1889,11 +1889,11 @@ DExhumedActor* BuildObject(DExhumedActor* pActor, int nOjectType, int nHitag) if (nSeq > -1) { - pActor->nIndex = getSeqFromId(nSeq); + pActor->nSeq = getSeqFromId(nSeq); if (!nOjectType) // if not Explosion Trigger (e.g. Exploding Fire Cauldron) { - pActor->nFrame = RandomSize(4) % (getSeqFrameCount(pActor->nIndex) - 1); + pActor->nFrame = RandomSize(4) % (getSeqFrameCount(pActor->nSeq) - 1); } auto pActor2 = insertActor(pActor->sector(), 0); @@ -1906,7 +1906,7 @@ DExhumedActor* BuildObject(DExhumedActor* pActor, int nOjectType, int nHitag) else { pActor->nFrame = 0; - pActor->nIndex = -1; + pActor->nSeq = -1; if (pActor->spr.statnum == kStatDestructibleSprite) { pActor->nIndex2 = -1; @@ -1949,7 +1949,7 @@ void AIObject::Tick(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; int nStat = pActor->spr.statnum; - int bx = pActor->nIndex; + int nSeq = pActor->nSeq; if (nStat == 97 || (!(pActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))) { return; @@ -1960,14 +1960,14 @@ void AIObject::Tick(RunListEvent* ev) } // do animation - if (bx != -1) + if (nSeq != -1) { pActor->nFrame++; - if (pActor->nFrame >= getSeqFrameCount(bx)) { + if (pActor->nFrame >= getSeqFrameCount(nSeq)) { pActor->nFrame = 0; } - pActor->spr.picnum = seq_GetSeqPicnum2(bx, pActor->nFrame); + pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); } if (pActor->nHealth >= 0) { @@ -2102,11 +2102,11 @@ void AIObject::Draw(RunListEvent* ev) { auto pActor = ev->pObjActor; if (!pActor) return; - int bx = pActor->nIndex; + int nSeq = pActor->nSeq; - if (bx > -1) + if (nSeq > -1) { - seq_PlotSequence(ev->nParam, bx, pActor->nFrame, 1); + seq_PlotSequence(ev->nParam, nSeq, pActor->nFrame, 1); } return; } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 3f24d0aa8..4bcb5b2a7 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1015,9 +1015,9 @@ void doPlayerItemPickups(Player* const pPlayer) case 59: // Scarab (Checkpoint) if (nLocalPlayer == pPlayer->nPlayer) { - pPickupActor->nIndex2++; - pPickupActor->nAction &= 0xEF; - pPickupActor->nIndex = 0; + pPickupActor->nSeq++; + pPickupActor->nFlags &= 0xEF; + pPickupActor->nFrame = 0; ChangeActorStat(pPickupActor, 899); } SetSavePoint(pPlayer->nPlayer, pPlayerActor->spr.pos, pPlayerSect, pPlayerActor->spr.Angles.Yaw);