From 53b7235adf1e84706900057fdf75dbaced356770 Mon Sep 17 00:00:00 2001 From: Mitchell Richters <mjr4077au@gmail.com> Date: Thu, 6 Apr 2023 19:19:23 +1000 Subject: [PATCH] - Exhumed: Wrap all access to `SeqOffsets[]` array and make static. --- source/games/exhumed/src/anims.cpp | 8 ++++---- source/games/exhumed/src/anubis.cpp | 4 ++-- source/games/exhumed/src/bubbles.cpp | 2 +- source/games/exhumed/src/bullet.cpp | 4 ++-- source/games/exhumed/src/fish.cpp | 10 +++++----- source/games/exhumed/src/grenade.cpp | 4 ++-- source/games/exhumed/src/gun.cpp | 8 ++++---- source/games/exhumed/src/lavadude.cpp | 6 +++--- source/games/exhumed/src/lion.cpp | 4 ++-- source/games/exhumed/src/mummy.cpp | 4 ++-- source/games/exhumed/src/object.cpp | 4 ++-- source/games/exhumed/src/player.cpp | 4 ++-- source/games/exhumed/src/queen.cpp | 12 ++++++------ source/games/exhumed/src/ra.cpp | 4 ++-- source/games/exhumed/src/rat.cpp | 4 ++-- source/games/exhumed/src/rex.cpp | 4 ++-- source/games/exhumed/src/roach.cpp | 4 ++-- source/games/exhumed/src/scorp.cpp | 4 ++-- source/games/exhumed/src/sequence.cpp | 24 +++++++++++++++++------- source/games/exhumed/src/sequence.h | 3 ++- source/games/exhumed/src/set.cpp | 6 +++--- source/games/exhumed/src/snake.cpp | 6 +++--- source/games/exhumed/src/sound.cpp | 2 +- source/games/exhumed/src/spider.cpp | 4 ++-- source/games/exhumed/src/status.cpp | 2 +- source/games/exhumed/src/wasp.cpp | 4 ++-- 26 files changed, 78 insertions(+), 67 deletions(-) diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index 5a349382e..c1bf50888 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -49,9 +49,9 @@ void SerializeAnim(FSerializer& arc) void InitAnims() { - nMagicSeq = SeqOffsets[kSeqItems] + 21; - nPreMagicSeq = SeqOffsets[kSeqMagic2]; - nSavePointSeq = SeqOffsets[kSeqItems] + 12; + nMagicSeq = getSeqFromId(kSeqItems, 21); + nPreMagicSeq = getSeqFromId(kSeqMagic2); + nSavePointSeq = getSeqFromId(kSeqItems, 12); } /* @@ -135,7 +135,7 @@ DExhumedActor* BuildAnim(DExhumedActor* pActor, int nSeq, int nOffset, const DVe pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x100000); pActor->nAction = nFlag; pActor->nIndex = 0; - pActor->nIndex2 = SeqOffsets[nSeq] + nOffset; + pActor->nIndex2 = getSeqFromId(nSeq, nOffset); pActor->pTarget = nullptr; pActor->nDamage = pActor->nRun; pActor->nPhase = ITEM_MAGIC; diff --git a/source/games/exhumed/src/anubis.cpp b/source/games/exhumed/src/anubis.cpp index de83cb691..8d16e4dbd 100644 --- a/source/games/exhumed/src/anubis.cpp +++ b/source/games/exhumed/src/anubis.cpp @@ -120,7 +120,7 @@ void AIAnubis::Tick(RunListEvent* ev) { const auto ap = ev->pObjActor; const int nAction = ap->nAction; - const int nSeq = SeqOffsets[kSeqAnubis] + AnubisSeq[nAction].a; + const int nSeq = getSeqFromId(kSeqAnubis, AnubisSeq[nAction].a); const int nFrame = SeqBase[nSeq] + ap->nFrame; const int nFlag = FrameFlag[nFrame]; bool bVal = false; @@ -340,7 +340,7 @@ void AIAnubis::Draw(RunListEvent* ev) const auto ap = ev->pObjActor; if (!ap) return; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqAnubis, AnubisSeq[ap->nAction].a), ap->nFrame, AnubisSeq[ap->nAction].b); } void AIAnubis::RadialDamage(RunListEvent* ev) diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index 46539a2cf..24a405150 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 = SeqOffsets[kSeqBubble] + nSize; + pActor->nIndex = getSeqFromId(kSeqBubble, nSize); pActor->spr.intowner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x140000); pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x140000); diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index ad905efc5..60476e25c 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -799,7 +799,7 @@ void AIBullet::Tick(RunListEvent* ev) int nBullet = RunData[ev->nRun].nObjIndex; assert(nBullet >= 0 && nBullet < kMaxBullets); - int nSeq = SeqOffsets[BulletList[nBullet].nSeq]; + int nSeq = getSeqFromId(BulletList[nBullet].nSeq); DExhumedActor* pActor = BulletList[nBullet].pActor; int nFlag = FrameFlag[SeqBase[nSeq] + BulletList[nBullet].nFrame]; @@ -844,7 +844,7 @@ void AIBullet::Draw(RunListEvent* ev) int nBullet = RunData[ev->nRun].nObjIndex; assert(nBullet >= 0 && nBullet < kMaxBullets); - int nSeq = SeqOffsets[BulletList[nBullet].nSeq]; + int nSeq = getSeqFromId(BulletList[nBullet].nSeq); ev->pTSprite->statnum = 1000; diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index 160448761..c102e9e8e 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -50,7 +50,7 @@ void BuildFishLimb(DExhumedActor* pActor, int anim) auto pChunkActor = insertActor(pActor->sector(), 99); pChunkActor->nCount = anim + 40; - pChunkActor->nFrame = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + anim + 40]; + pChunkActor->nFrame = RandomSize(3) % SeqSize[getSeqFromId(kSeqFish, pChunkActor->nCount)]; pChunkActor->spr.pos = pActor->spr.pos; pChunkActor->spr.cstat = 0; @@ -92,7 +92,7 @@ void AIFishLimb::Tick(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; - int nSeq = SeqOffsets[kSeqFish] + pActor->nCount; + int nSeq = getSeqFromId(kSeqFish, pActor->nCount); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); @@ -149,7 +149,7 @@ void AIFishLimb::Draw(RunListEvent* ev) { auto pActor = ev->pObjActor; if (pActor == nullptr) return; - int nSeq = SeqOffsets[kSeqFish] + pActor->nCount; + int nSeq = getSeqFromId(kSeqFish, pActor->nCount); seq_PlotSequence(ev->nParam, nSeq, pActor->nFrame, 1); } @@ -258,7 +258,7 @@ void AIFish::Draw(RunListEvent* ev) if (pActor == nullptr) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, pActor->nFrame, FishSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqFish, FishSeq[nAction].a), pActor->nFrame, FishSeq[nAction].b); ev->pTSprite->ownerActor = nullptr; return; } @@ -362,7 +362,7 @@ void AIFish::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a; + int nSeq = getSeqFromId(kSeqFish, FishSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index 07ec9a856..5a385a1d2 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -237,7 +237,7 @@ void AIGrenade::Draw(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; - int nSeq = pActor->nFrame ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + pActor->nIndex; + int nSeq = pActor->nFrame ? getSeqFromId(kSeqGrenBoom) : getSeqFromId(kSeqGrenRoll, pActor->nIndex); seq_PlotSequence(ev->nParam, nSeq, pActor->nHealth >> 8, 1); } @@ -253,7 +253,7 @@ void AIGrenade::Tick(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; - int nSeq = pActor->nFrame ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + pActor->nIndex; + int nSeq = pActor->nFrame ? getSeqFromId(kSeqGrenBoom) : getSeqFromId(kSeqGrenRoll, pActor->nIndex); seq_MoveSequence(pActor, nSeq, pActor->nHealth >> 8); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nHealth >> 8); diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index c13f0dcaf..62598bdfd 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -376,7 +376,7 @@ void MoveWeapons(int nPlayer) int eax = pPlayer->nState; int nSeq = WeaponInfo[nWeapon].nSeq; - int var_3C = WeaponInfo[nWeapon].b[eax] + SeqOffsets[nSeq]; + int var_3C = getSeqFromId(nSeq, WeaponInfo[nWeapon].b[eax]); int var_1C = (pPlayer->nDouble > 0) + 1; @@ -568,7 +568,7 @@ void MoveWeapons(int nPlayer) SelectNewWeapon(nPlayer); pPlayer->nState = 5; - pPlayer->nSeqSize2 = SeqSize[WeaponInfo[kWeaponGrenade].b[0] + SeqOffsets[nSeq]] - 1; // CHECKME + pPlayer->nSeqSize2 = SeqSize[getSeqFromId(nSeq, WeaponInfo[kWeaponGrenade].b[0])] - 1; // CHECKME goto loc_flag; // FIXME } } @@ -618,7 +618,7 @@ void MoveWeapons(int nPlayer) } // loc_26FC5 - var_3C = SeqOffsets[WeaponInfo[nWeapon].nSeq] + WeaponInfo[nWeapon].b[pPlayer->nState]; + var_3C = getSeqFromId(WeaponInfo[nWeapon].nSeq, WeaponInfo[nWeapon].b[pPlayer->nState]); pPlayer->nSeqSize2 = 0; } else @@ -919,7 +919,7 @@ void DrawWeapons(double interpfrac) } int var_34 = PlayerList[nLocalPlayer].nState; - int var_30 = SeqOffsets[WeaponInfo[nWeapon].nSeq]; + int var_30 = getSeqFromId(WeaponInfo[nWeapon].nSeq); int var_28 = var_30 + WeaponInfo[nWeapon].b[var_34]; diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index cb17bfdad..8a8a2ba14 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -92,7 +92,7 @@ void AILavaDudeLimb::Draw(RunListEvent* ev) { auto pActor = ev->pObjActor; if (!pActor) return; - seq_PlotSequence(ev->nParam, (SeqOffsets[kSeqLavag] + 30) + pActor->spr.picnum, 0, 1); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqLavag, 30) + pActor->spr.picnum, 0, 1); } @@ -150,7 +150,7 @@ void AILavaDude::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - int nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; + int nSeq = getSeqFromId(kSeqLavag, LavadudeSeq[nAction].a); seq_PlotSequence(ev->nParam, nSeq, pActor->nFrame, LavadudeSeq[nAction].b); ev->pTSprite->ownerActor = nullptr; @@ -213,7 +213,7 @@ void AILavaDude::Tick(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - int nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; + int nSeq = getSeqFromId(kSeqLavag, LavadudeSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); int var_38 = pActor->nFrame; diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index 9053e2cdc..ca9cf1ac8 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -93,7 +93,7 @@ void AILion::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqLion] + LionSeq[nAction].a, pActor->nFrame, LionSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqLion, LionSeq[nAction].a), pActor->nFrame, LionSeq[nAction].b); } void AILion::RadialDamage(RunListEvent* ev) @@ -198,7 +198,7 @@ void AILion::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a; + int nSeq = getSeqFromId(kSeqLion, LionSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/mummy.cpp b/source/games/exhumed/src/mummy.cpp index bdfbcecb8..4df71638d 100644 --- a/source/games/exhumed/src/mummy.cpp +++ b/source/games/exhumed/src/mummy.cpp @@ -139,7 +139,7 @@ void AIMummy::Tick(RunListEvent* ev) Gravity(pActor); - int nSeq = SeqOffsets[kSeqMummy] + MummySeq[nAction].a; + int nSeq = getSeqFromId(kSeqMummy, MummySeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); @@ -419,7 +419,7 @@ void AIMummy::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqMummy] + MummySeq[nAction].a, pActor->nFrame, MummySeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqMummy, MummySeq[nAction].a), pActor->nFrame, MummySeq[nAction].b); return; } diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 17369727e..a711686cc 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1889,7 +1889,7 @@ DExhumedActor* BuildObject(DExhumedActor* pActor, int nOjectType, int nHitag) if (nSeq > -1) { - pActor->nIndex = SeqOffsets[nSeq]; + pActor->nIndex = getSeqFromId(nSeq); if (!nOjectType) // if not Explosion Trigger (e.g. Exploding Fire Cauldron) { @@ -2199,7 +2199,7 @@ void DoDrips() { DExhumedActor* pActor = sDrip[i].pActor; if (!pActor) continue; - int nSeqOffset = SeqOffsets[kSeqDrips]; + int nSeqOffset = getSeqFromId(kSeqDrips); if (!(pActor->sector()->Flag & kSectLava)) { nSeqOffset++; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 59ebb9480..ca171d1f6 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -529,7 +529,7 @@ void AIPlayer::Draw(RunListEvent* ev) const auto pPlayer = &PlayerList[nPlayer]; const auto nAction = pPlayer->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[pPlayer->nSeq] + PlayerSeq[nAction].a, pPlayer->nSeqSize, PlayerSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(pPlayer->nSeq, PlayerSeq[nAction].a), pPlayer->nSeqSize, PlayerSeq[nAction].b); } //--------------------------------------------------------------------------- @@ -1912,7 +1912,7 @@ static bool doPlayerDeathRestart(Player* const pPlayer) static void doPlayerActionSequence(Player* const pPlayer) { const auto pPlayerActor = pPlayer->pActor; - const auto nSeq = SeqOffsets[pPlayer->nSeq] + PlayerSeq[pPlayer->nAction].a; + const auto nSeq = getSeqFromId(pPlayer->nSeq, PlayerSeq[pPlayer->nAction].a); seq_MoveSequence(pPlayerActor, nSeq, pPlayer->nSeqSize); pPlayer->nSeqSize++; diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 9257d550e..8b37897e6 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -542,7 +542,7 @@ void AIQueenEgg::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a; + int nSeq = getSeqFromId(kSeqQueenEgg, EggSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pEgg->nFrame); @@ -725,7 +725,7 @@ void AIQueenEgg::Draw(RunListEvent* ev) { int nEgg = RunData[ev->nRun].nObjIndex; Egg* pEgg = &QueenEgg[nEgg]; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueenEgg] + EggSeq[pEgg->nAction].a, pEgg->nFrame, EggSeq[pEgg->nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqQueenEgg, EggSeq[pEgg->nAction].a), pEgg->nFrame, EggSeq[pEgg->nAction].b); } //--------------------------------------------------------------------------- @@ -798,7 +798,7 @@ void AIQueenHead::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqQueen] + HeadSeq[QueenHead.nAction].a; + int nSeq = getSeqFromId(kSeqQueen, HeadSeq[QueenHead.nAction].a); seq_MoveSequence(pActor, nSeq, QueenHead.nFrame); @@ -1129,7 +1129,7 @@ void AIQueenHead::Draw(RunListEvent* ev) int nHead = RunData[ev->nRun].nObjIndex; int nAction = QueenHead.nAction; - int nSeq = SeqOffsets[kSeqQueen]; + int nSeq = getSeqFromId(kSeqQueen); int edx; @@ -1239,7 +1239,7 @@ void AIQueen::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqQueen] + QueenSeq[nAction].a; + int nSeq = getSeqFromId(kSeqQueen, QueenSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].nFrame); @@ -1572,7 +1572,7 @@ void AIQueen::Draw(RunListEvent* ev) int nQueen = RunData[ev->nRun].nObjIndex; assert(nQueen >= 0 && nQueen < kMaxQueens); int nAction = QueenList[nQueen].nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueen] + QueenSeq[nAction].a, QueenList[nQueen].nFrame, QueenSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqQueen, QueenSeq[nAction].a), QueenList[nQueen].nFrame, QueenSeq[nAction].b); } END_PS_NS diff --git a/source/games/exhumed/src/ra.cpp b/source/games/exhumed/src/ra.cpp index 363598d45..470cc8bdb 100644 --- a/source/games/exhumed/src/ra.cpp +++ b/source/games/exhumed/src/ra.cpp @@ -209,7 +209,7 @@ void AIRa::Tick(RunListEvent* ev) int nPlayer = RunData[ev->nRun].nObjIndex; int nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon; - int nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a; + int nSeq = getSeqFromId(kSeqEyeHit, RaSeq[Ra[nPlayer].nAction].a); DExhumedActor* pActor = Ra[nPlayer].pActor; if (!pActor) return; @@ -336,7 +336,7 @@ void AIRa::Tick(RunListEvent* ev) void AIRa::Draw(RunListEvent* ev) { int nPlayer = RunData[ev->nRun].nObjIndex; - int nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a; + int nSeq = getSeqFromId(kSeqEyeHit, RaSeq[Ra[nPlayer].nAction].a); seq_PlotSequence(ev->nParam, nSeq, Ra[nPlayer].nFrame, 1); ev->pTSprite->ownerActor = nullptr; diff --git a/source/games/exhumed/src/rat.cpp b/source/games/exhumed/src/rat.cpp index 27400b937..fcd5534d5 100644 --- a/source/games/exhumed/src/rat.cpp +++ b/source/games/exhumed/src/rat.cpp @@ -224,7 +224,7 @@ void AIRat::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqRat] + RatSeq[nAction].a, pActor->nFrame, RatSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqRat, RatSeq[nAction].a), pActor->nFrame, RatSeq[nAction].b); } @@ -244,7 +244,7 @@ void AIRat::Tick(RunListEvent* ev) bool bVal = false; - int nSeq = SeqOffsets[kSeqRat] + RatSeq[nAction].a; + int nSeq = getSeqFromId(kSeqRat, RatSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); seq_MoveSequence(pActor, nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/rex.cpp b/source/games/exhumed/src/rex.cpp index 762375c6f..9fbbc5040 100644 --- a/source/games/exhumed/src/rex.cpp +++ b/source/games/exhumed/src/rex.cpp @@ -171,7 +171,7 @@ void AIRex::Draw(RunListEvent* ev) int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqRex] + RexSeq[nAction].a, pActor->nFrame, RexSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqRex, RexSeq[nAction].a), pActor->nFrame, RexSeq[nAction].b); return; } @@ -192,7 +192,7 @@ void AIRex::Tick(RunListEvent* ev) Gravity(pActor); - int nSeq = SeqOffsets[kSeqRex] + RexSeq[nAction].a; + int nSeq = getSeqFromId(kSeqRex, RexSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/roach.cpp b/source/games/exhumed/src/roach.cpp index 705a6ef1d..daf74879e 100644 --- a/source/games/exhumed/src/roach.cpp +++ b/source/games/exhumed/src/roach.cpp @@ -110,7 +110,7 @@ void AIRoach::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, RoachSeq[nAction].a + SeqOffsets[kSeqRoach], pActor->nFrame, RoachSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqRoach, RoachSeq[nAction].a), pActor->nFrame, RoachSeq[nAction].b); return; } @@ -211,7 +211,7 @@ void AIRoach::Tick(RunListEvent* ev) Gravity(pActor); - int nSeq = SeqOffsets[kSeqRoach] + RoachSeq[pActor->nAction].a; + int nSeq = getSeqFromId(kSeqRoach, RoachSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); seq_MoveSequence(pActor, nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/scorp.cpp b/source/games/exhumed/src/scorp.cpp index 2b8d4f0a3..83352cde7 100644 --- a/source/games/exhumed/src/scorp.cpp +++ b/source/games/exhumed/src/scorp.cpp @@ -105,7 +105,7 @@ void AIScorp::Draw(RunListEvent* ev) int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, pActor->nFrame, ScorpSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqScorp, ScorpSeq[nAction].a), pActor->nFrame, ScorpSeq[nAction].b); } //--------------------------------------------------------------------------- @@ -206,7 +206,7 @@ void AIScorp::Tick(RunListEvent* ev) Gravity(pActor); } - int nSeq = SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a; + int nSeq = getSeqFromId(kSeqScorp, ScorpSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); seq_MoveSequence(pActor, nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index b93af8352..c42ab8ff6 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -148,9 +148,20 @@ const char *SeqNames[kMaxSEQFiles] = "rat" }; -int16_t SeqOffsets[kMaxSEQFiles]; +static int16_t SeqOffsets[kMaxSEQFiles]; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int getSeqFromId(const int nSeqFileId, const int nSeq) +{ + return SeqOffsets[nSeqFileId] + nSeq; +} + //--------------------------------------------------------------------------- // // @@ -307,7 +318,7 @@ int seq_ReadSequence(const char *seqName) int seq_GetFirstSeqPicnum(int nSeq) { - int i = SeqOffsets[nSeq]; + int i = getSeqFromId(nSeq); i = SeqBase[i]; i = FrameBase[i]; i = ChunkPict[i]; @@ -360,13 +371,13 @@ void seq_LoadSequences() nBackgroundPic = seq_GetFirstSeqPicnum(kSeqBackgrnd); - nPilotLightBase = SeqBase[SeqOffsets[kSeqFlamer] + 3]; - nPilotLightCount = SeqSize[SeqOffsets[kSeqFlamer] + 3]; + nPilotLightBase = SeqBase[getSeqFromId(kSeqFlamer, 3)]; + nPilotLightCount = SeqSize[getSeqFromId(kSeqFlamer, 3)]; nPilotLightFrame = 0; nFontFirstChar = seq_GetFirstSeqPicnum(kSeqFont2); - int16_t nSize = SeqSize[SeqOffsets[kSeqFont2]]; + int16_t nSize = SeqSize[getSeqFromId(kSeqFont2)]; for (i = 0; i < nSize; i++) { @@ -514,8 +525,7 @@ int seq_GetSeqPicnum2(int16_t nSeq, int16_t nFrame) int seq_GetSeqPicnum(int16_t nSeq, int16_t edx, int16_t ebx) { - edx += SeqOffsets[nSeq]; - ebx += SeqBase[edx]; + ebx += SeqBase[getSeqFromId(nSeq, edx)]; int16_t c = FrameBase[ebx]; return ChunkPict[c]; diff --git a/source/games/exhumed/src/sequence.h b/source/games/exhumed/src/sequence.h index 5ac308761..7adc5d4dd 100644 --- a/source/games/exhumed/src/sequence.h +++ b/source/games/exhumed/src/sequence.h @@ -112,7 +112,6 @@ extern int16_t frames; extern int16_t SeqBase[]; extern int16_t SeqSize[]; -extern int16_t SeqOffsets[]; extern int16_t FrameFlag[]; extern int16_t nShadowWidth; @@ -143,5 +142,7 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx); int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal); void seq_DrawPilotLightSeq(double xOffset, double yOffset); +int getSeqFromId(const int nSeqFileId, const int nSeq = 0); + END_PS_NS diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 82aedf2e4..b00832152 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -142,7 +142,7 @@ void AISoul::Tick(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; - seq_MoveSequence(pActor, SeqOffsets[kSeqSet] + 75, 0); + seq_MoveSequence(pActor, getSeqFromId(kSeqSet, 75), 0); if (pActor->spr.scale.X < 0.5) { @@ -248,7 +248,7 @@ void AISet::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSet] + SetSeq[nAction].a, pActor->nFrame, SetSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqSet, SetSeq[nAction].a), pActor->nFrame, SetSeq[nAction].b); return; } @@ -269,7 +269,7 @@ void AISet::Tick(RunListEvent* ev) Gravity(pActor); - int nSeq = SeqOffsets[kSeqSet] + SetSeq[pActor->nAction].a; + int nSeq = getSeqFromId(kSeqSet, SetSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame); seq_MoveSequence(pActor, nSeq, pActor->nFrame); diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index baa84c7f1..2692c7b5f 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -339,7 +339,7 @@ void AISnake::Tick(RunListEvent* ev) DExhumedActor* pActor = SnakeList[nSnake].pSprites[0]; if (!pActor) return; - seq_MoveSequence(pActor, SeqOffsets[kSeqSnakehed], 0); + seq_MoveSequence(pActor, getSeqFromId(kSeqSnakehed), 0); DExhumedActor* pEnemySprite = SnakeList[nSnake].pEnemy; @@ -428,10 +428,10 @@ void AISnake::Draw(RunListEvent* ev) int nSprite = ev->nParam; if ((nSnake & 0xFF) == 0) { - seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakehed], 0, 0); + seq_PlotSequence(nSprite, getSeqFromId(kSeqSnakehed), 0, 0); } else { - seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakBody], 0, 0); + seq_PlotSequence(nSprite, getSeqFromId(kSeqSnakBody), 0, 0); } ev->pTSprite->ownerActor = nullptr; diff --git a/source/games/exhumed/src/sound.cpp b/source/games/exhumed/src/sound.cpp index 98e9ec495..5f0d5dfe9 100644 --- a/source/games/exhumed/src/sound.cpp +++ b/source/games/exhumed/src/sound.cpp @@ -718,7 +718,7 @@ void UpdateCreepySounds() { if (nCreaturesKilled < nCreaturesTotal && !(PlayerList[nLocalPlayer].pPlayerViewSect->Flag & 0x2000)) { - int vsi = seq_GetFrameSound(SeqOffsets[kSeqCreepy], totalmoves % SeqSize[SeqOffsets[kSeqCreepy]]); + int vsi = seq_GetFrameSound(getSeqFromId(kSeqCreepy), totalmoves % SeqSize[getSeqFromId(kSeqCreepy)]); if (vsi >= 0 && (vsi & 0x1ff) < kMaxSounds) { DVector2 adder; diff --git a/source/games/exhumed/src/spider.cpp b/source/games/exhumed/src/spider.cpp index 12cbea0ea..7f9d830ba 100644 --- a/source/games/exhumed/src/spider.cpp +++ b/source/games/exhumed/src/spider.cpp @@ -117,7 +117,7 @@ void AISpider::Tick(RunListEvent* ev) } } - int nSeq = SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a; + int nSeq = getSeqFromId(kSeqSpider, SpiderSeq[nAction].a); spp->spr.picnum = seq_GetSeqPicnum2(nSeq, spp->nFrame); @@ -354,7 +354,7 @@ void AISpider::Draw(RunListEvent* ev) int nAction = spp->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a, spp->nFrame, SpiderSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqSpider, SpiderSeq[nAction].a), spp->nFrame, SpiderSeq[nAction].b); } //--------------------------------------------------------------------------- diff --git a/source/games/exhumed/src/status.cpp b/source/games/exhumed/src/status.cpp index f27d1df7d..f3f4aee7a 100644 --- a/source/games/exhumed/src/status.cpp +++ b/source/games/exhumed/src/status.cpp @@ -47,7 +47,7 @@ int nStatusSeqOffset; void InitStatus() { - nStatusSeqOffset = SeqOffsets[kSeqStatus]; + nStatusSeqOffset = getSeqFromId(kSeqStatus); } diff --git a/source/games/exhumed/src/wasp.cpp b/source/games/exhumed/src/wasp.cpp index 1b0c929c2..37c267b3c 100644 --- a/source/games/exhumed/src/wasp.cpp +++ b/source/games/exhumed/src/wasp.cpp @@ -122,7 +122,7 @@ void AIWasp::Draw(RunListEvent* ev) if (!pActor) return; int nAction = pActor->nAction; - seq_PlotSequence(ev->nParam, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, pActor->nFrame, WaspSeq[nAction].b); + seq_PlotSequence(ev->nParam, getSeqFromId(kSeqWasp, WaspSeq[nAction].a), pActor->nFrame, WaspSeq[nAction].b); return; } @@ -214,7 +214,7 @@ void AIWasp::Tick(RunListEvent* ev) bool bVal = false; - int nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a; + int nSeq = getSeqFromId(kSeqWasp, WaspSeq[nAction].a); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);