- Exhumed: Make getSequence() return a pointer instead of a reference.

* Gets rid of the awkward `operator[]()` calls.
* Gets rid of `std::ref()` setup in gun.cpp.
* Ensures a copy isn't made if the caller accidentally leaves off an ampersand.
* Allows us to use a consistent getter for native code and VM exports.
This commit is contained in:
Mitchell Richters 2023-04-27 20:12:39 +10:00
parent ea7fe0e0b4
commit 3edc1a5a5a
27 changed files with 155 additions and 143 deletions

View file

@ -194,6 +194,12 @@ struct VMReturn
*(void **)Location = val;
}
void SetConstPointer(const void *val)
{
assert(RegType == REGT_POINTER);
*(const void **)Location = val;
}
void SetObject(DObject *val)
{
assert(RegType == REGT_POINTER);
@ -759,6 +765,7 @@ struct AFuncDesc
class AActor;
#define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state); return 1; } return 0; } while(0)
#define ACTION_RETURN_CONST_POINTER(v) do { const void *state = v; if (numret > 0) { assert(ret != NULL); ret->SetConstPointer(state); return 1; } return 0; } while(0)
#define ACTION_RETURN_POINTER(v) do { void *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state); return 1; } return 0; } while(0)
#define ACTION_RETURN_OBJECT(v) do { auto state = v; if (numret > 0) { assert(ret != NULL); ret->SetObject(state); return 1; } return 0; } while(0)
#define ACTION_RETURN_FLOAT(v) do { double u = v; if (numret > 0) { assert(ret != nullptr); ret->SetFloat(u); return 1; } return 0; } while(0)

View file

@ -134,12 +134,12 @@ void AIAnim::Tick(RunListEvent* ev)
const auto pActor = ev->pObjActor;
if (!pActor || pActor->nSeqFile == NAME_None) return;
const auto& animSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex);
const auto animSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex);
const int nFrame = pActor->nFrame;
if (!(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
{
animSeq.frames[nFrame].playSound(pActor);
animSeq->frames[nFrame].playSound(pActor);
}
if (pActor->spr.statnum == kStatIgnited)
@ -202,7 +202,7 @@ void AIAnim::Tick(RunListEvent* ev)
}
pActor->nFrame++;
if (pActor->nFrame >= animSeq.frames.Size())
if (pActor->nFrame >= animSeq->frames.Size())
{
if (pActor->nFlags & kAnimLoop)
{

View file

@ -123,8 +123,8 @@ void AIAnubis::Tick(RunListEvent* ev)
const auto ap = ev->pObjActor;
const int nAction = ap->nAction;
const auto& anubisSeq = getSequence(ap->nSeqFile, AnubisSeq[nAction].nSeqId);
const auto& seqFrame = anubisSeq.frames[ap->nFrame];
const auto anubisSeq = getSequence(ap->nSeqFile, AnubisSeq[nAction].nSeqId);
const auto& seqFrame = anubisSeq->frames[ap->nFrame];
bool bVal = false;
if (nAction < 11)
@ -135,7 +135,7 @@ void AIAnubis::Tick(RunListEvent* ev)
ap->spr.setspritetexture(seqFrame.getFirstChunkTexture());
ap->nFrame++;
if (ap->nFrame >= anubisSeq.frames.Size())
if (ap->nFrame >= anubisSeq->frames.Size())
{
ap->nFrame = 0;
bVal = true;

View file

@ -96,13 +96,13 @@ void AIBubble::Tick(RunListEvent* ev)
const auto pActor = ev->pObjActor;
if (!pActor) return;
const auto& bubbSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex);
const auto bubbSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex);
bubbSeq.frames[pActor->nFrame].playSound(pActor);
bubbSeq->frames[pActor->nFrame].playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= bubbSeq.frames.Size())
if (pActor->nFrame >= bubbSeq->frames.Size())
pActor->nFrame = 0;
pActor->spr.pos.Z = pActor->vel.Z;

View file

@ -658,13 +658,13 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, double fZOffset, DA
{
pBullet->field_12 = 0;
pBullet->seqFile = pBulletInfo->initSeq;
pBulletActor->spr.setspritetexture(getSequence(pBullet->seqFile).getFirstFrameTexture());
pBulletActor->spr.setspritetexture(getSequence(pBullet->seqFile)->getFirstFrameTexture());
}
else if (pBulletInfo->seqFile != NAME_None)
{
pBullet->field_12 = 1;
pBullet->seqFile = pBulletInfo->seqFile;
pBulletActor->spr.setspritetexture(getSequence(pBullet->seqFile).getFirstFrameTexture());
pBulletActor->spr.setspritetexture(getSequence(pBullet->seqFile)->getFirstFrameTexture());
}
else
{
@ -802,8 +802,8 @@ void AIBullet::Tick(RunListEvent* ev)
if (pBullet->seqFile == NAME_None)
return;
const auto& bulletSeq = getSequence(pBullet->seqFile);
const auto& seqFrame = bulletSeq.frames[pBullet->nFrame];
const auto bulletSeq = getSequence(pBullet->seqFile);
const auto& seqFrame = bulletSeq->frames[pBullet->nFrame];
DExhumedActor* pActor = BulletList[nBullet].pActor;
seqFrame.playSound(pActor);
@ -814,7 +814,7 @@ void AIBullet::Tick(RunListEvent* ev)
}
pBullet->nFrame++;
if (pBullet->nFrame >= bulletSeq.frames.Size())
if (pBullet->nFrame >= bulletSeq->frames.Size())
{
if (!pBullet->field_12)
{

View file

@ -51,7 +51,7 @@ void BuildFishLimb(DExhumedActor* pActor, int anim)
pChunkActor->nSeqFile = "fish";
pChunkActor->nCount = anim + 40;
pChunkActor->nFrame = RandomSize(3) % getSequence(pChunkActor->nSeqFile, pChunkActor->nCount).frames.Size();
pChunkActor->nFrame = RandomSize(3) % getSequence(pChunkActor->nSeqFile, pChunkActor->nCount)->frames.Size();
pChunkActor->spr.pos = pActor->spr.pos;
pChunkActor->spr.cstat = 0;
@ -64,7 +64,7 @@ void BuildFishLimb(DExhumedActor* pActor, int anim)
pChunkActor->spr.yoffset = 0;
pChunkActor->vel.Z = ((-(RandomByte() + 512)) * 2) / 256.;
//getSequence(pChunkActor->nSeqFile, pChunkActor->nCount).getFirstTexID();
//getSequence(pChunkActor->nSeqFile, pChunkActor->nCount)->getFirstTexID();
pChunkActor->spr.picnum = anim;
pChunkActor->spr.lotag = runlist_HeadRun() + 1;
@ -88,15 +88,15 @@ void AIFishLimb::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
const auto& fishSeq = getSequence(pActor->nSeqFile, pActor->nCount);
const auto fishSeq = getSequence(pActor->nSeqFile, pActor->nCount);
pActor->spr.setspritetexture(fishSeq.frames[pActor->nFrame].getFirstChunkTexture());
pActor->spr.setspritetexture(fishSeq->frames[pActor->nFrame].getFirstChunkTexture());
Gravity(pActor);
pActor->nFrame++;
if (pActor->nFrame >= fishSeq.frames.Size())
if (pActor->nFrame >= fishSeq->frames.Size())
{
pActor->nFrame = 0;
if (RandomBit()) {
@ -176,7 +176,7 @@ void BuildFish(DExhumedActor* pActor, const DVector3& pos, sectortype* pSector,
pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0;
pActor->nSeqFile = "fish";
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, FishSeq[0].nSeqId).getFirstFrameTexture());
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, FishSeq[0].nSeqId)->getFirstFrameTexture());
pActor->vel.X = 0;
pActor->vel.Y = 0;
pActor->vel.Z = 0;
@ -358,15 +358,15 @@ void AIFish::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& fishSeq = getSequence(pActor->nSeqFile, FishSeq[nAction].nSeqId);
const auto& seqFrame = fishSeq.frames[pActor->nFrame];
const auto fishSeq = getSequence(pActor->nSeqFile, FishSeq[nAction].nSeqId);
const auto& seqFrame = fishSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= fishSeq.frames.Size()) {
if (pActor->nFrame >= fishSeq->frames.Size()) {
pActor->nFrame = 0;
}

View file

@ -258,8 +258,8 @@ void AIGrenade::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
const auto& grenadeSeq = pActor->nFrame ? getSequence("grenboom") : getSequence("grenroll", pActor->nIndex);
const auto& seqFrame = grenadeSeq.frames[pActor->nHealth >> 8];
const auto grenadeSeq = pActor->nFrame ? getSequence("grenboom") : getSequence("grenroll", pActor->nIndex);
const auto& seqFrame = grenadeSeq->frames[pActor->nHealth >> 8];
seqFrame.playSound(pActor);
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
@ -302,11 +302,11 @@ void AIGrenade::Tick(RunListEvent* ev)
if (ebp < 0)
{
pActor->nHealth += grenadeSeq.frames.Size() << 8;
pActor->nHealth += grenadeSeq->frames.Size() << 8;
}
else
{
if (ebp >= (signed)grenadeSeq.frames.Size())
if (ebp >= (signed)grenadeSeq->frames.Size())
{
if (pActor->nFrame)
{

View file

@ -374,15 +374,15 @@ void MoveWeapons(int nPlayer)
}
const auto nSeqFile = WeaponInfo[nWeapon].nSeqFile;
auto weapSeq = std::ref(getSequence(nSeqFile, WeaponInfo[nWeapon].b[pPlayer->nState]));
auto seqFrame = std::ref(weapSeq.get().frames[pPlayer->nWeapFrame]);
auto weapSeq = getSequence(nSeqFile, WeaponInfo[nWeapon].b[pPlayer->nState]);
auto seqFrame = weapSeq->frames.Data(pPlayer->nWeapFrame);
int var_1C = (pPlayer->nDouble > 0) + 1;
int frames = var_1C - 1;
for (frames = var_1C; frames > 0; frames--)
{
seqFrame.get().playSound(pPlayerActor);
seqFrame->playSound(pPlayerActor);
pPlayer->nWeapFrame++;
@ -391,7 +391,7 @@ void MoveWeapons(int nPlayer)
dword_96E22 = 0;
}
if (pPlayer->nWeapFrame >= weapSeq.get().frames.Size())
if (pPlayer->nWeapFrame >= weapSeq->frames.Size())
{
if (pPlayer->nNextWeapon == -1)
{
@ -469,7 +469,7 @@ void MoveWeapons(int nPlayer)
}
else
{
pPlayer->nWeapFrame = weapSeq.get().frames.Size() - 1;
pPlayer->nWeapFrame = weapSeq->frames.Size() - 1;
continue;
}
}
@ -566,7 +566,7 @@ void MoveWeapons(int nPlayer)
SelectNewWeapon(nPlayer);
pPlayer->nState = 5;
pPlayer->nWeapFrame = getSequence(nSeqFile, WeaponInfo[kWeaponGrenade].b[0]).frames.Size() - 1; // CHECKME
pPlayer->nWeapFrame = getSequence(nSeqFile, WeaponInfo[kWeaponGrenade].b[0])->frames.Size() - 1; // CHECKME
goto loc_flag; // FIXME
}
}
@ -615,7 +615,7 @@ void MoveWeapons(int nPlayer)
}
}
weapSeq = std::ref(getSequence(WeaponInfo[nWeapon].nSeqFile, WeaponInfo[nWeapon].b[pPlayer->nState]));
weapSeq = getSequence(WeaponInfo[nWeapon].nSeqFile, WeaponInfo[nWeapon].b[pPlayer->nState]);
pPlayer->nWeapFrame = 0;
}
else
@ -640,9 +640,9 @@ void MoveWeapons(int nPlayer)
}
loc_flag:
seqFrame = std::ref(weapSeq.get().frames[pPlayer->nWeapFrame]);
seqFrame = weapSeq->frames.Data(pPlayer->nWeapFrame);
if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (seqFrame.get().flags & 4))
if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (seqFrame->flags & 4))
{
BuildFlash(nPlayer, 512);
AddFlash(
@ -651,7 +651,7 @@ loc_flag:
0);
}
if (seqFrame.get().flags & 0x80)
if (seqFrame->flags & 0x80)
{
int nAction = pPlayerActor->nAction;
@ -975,7 +975,7 @@ void DrawWeapons(Player* const pPlayer, double interpfrac)
int nSeqOffset = WeaponInfo[nWeapon].b[nState];
int nFrame = pPlayer->nWeapFrame;
seq_DrawGunSequence(weapSeqs->operator[](nSeqOffset).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha, nStat);
seq_DrawGunSequence(weapSeqs->Data(nSeqOffset)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha, nStat);
int nClip = pPlayer->nPlayerClip;
@ -1011,7 +1011,7 @@ void DrawWeapons(Player* const pPlayer, double interpfrac)
nSeqOffset = offsets[3];
}
seq_DrawGunSequence(weapSeqs->operator[](nSeqOffset).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
seq_DrawGunSequence(weapSeqs->Data(nSeqOffset)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
return;
}
case 1:
@ -1020,25 +1020,25 @@ void DrawWeapons(Player* const pPlayer, double interpfrac)
if (nState == 1)
nFrame = (nClip % 3) * 4;
seq_DrawGunSequence(weapSeqs->operator[](8).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
seq_DrawGunSequence(weapSeqs->Data(8)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
if (nClip <= 3) {
return;
}
seq_DrawGunSequence(weapSeqs->operator[](9).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
seq_DrawGunSequence(weapSeqs->Data(9)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
if (nClip <= 6) {
return;
}
seq_DrawGunSequence(weapSeqs->operator[](10).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
seq_DrawGunSequence(weapSeqs->Data(10)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
if (nClip <= 25) {
return;
}
seq_DrawGunSequence(weapSeqs->operator[](11).frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
seq_DrawGunSequence(weapSeqs->Data(11)->frames[nFrame], xPos, yPos, nShade, nPal, nAngle, nAlpha);
return;
}
default:

View file

@ -123,7 +123,7 @@ void BuildLava(DExhumedActor* pActor, const DVector3& pos, sectortype* pSector,
pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0;
pActor->nSeqFile = "lavag";
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, LavadudeSeq[3].nSeqId).getFirstFrameTexture());
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, LavadudeSeq[3].nSeqId)->getFirstFrameTexture());
pActor->vel.X = 0;
pActor->vel.Y = 0;
pActor->vel.Z = 0;
@ -215,8 +215,8 @@ void AILavaDude::Tick(RunListEvent* ev)
int nAction = pActor->nAction;
const auto& lavadudeSeq = getSequence(pActor->nSeqFile, LavadudeSeq[nAction].nSeqId);
const auto& seqFrame = lavadudeSeq.frames[pActor->nFrame];
const auto lavadudeSeq = getSequence(pActor->nSeqFile, LavadudeSeq[nAction].nSeqId);
const auto& seqFrame = lavadudeSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
@ -227,7 +227,7 @@ void AILavaDude::Tick(RunListEvent* ev)
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= lavadudeSeq.frames.Size())
if (pActor->nFrame >= lavadudeSeq->frames.Size())
{
var_1C = 1;
pActor->nFrame = 0;

View file

@ -200,15 +200,15 @@ void AILion::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& lionSeq = getSequence(pActor->nSeqFile, LionSeq[nAction].nSeqId);
const auto& seqFrame = lionSeq.frames[pActor->nFrame];
const auto lionSeq = getSequence(pActor->nSeqFile, LionSeq[nAction].nSeqId);
const auto& seqFrame = lionSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= lionSeq.frames.Size())
if (pActor->nFrame >= lionSeq->frames.Size())
{
pActor->nFrame = 0;
bVal = true;

View file

@ -141,8 +141,8 @@ void AIMummy::Tick(RunListEvent* ev)
Gravity(pActor);
const auto& mummySeq = getSequence(pActor->nSeqFile, MummySeq[nAction].nSeqId);
const auto& seqFrame = mummySeq.frames[pActor->nFrame];
const auto mummySeq = getSequence(pActor->nSeqFile, MummySeq[nAction].nSeqId);
const auto& seqFrame = mummySeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
@ -151,7 +151,7 @@ void AIMummy::Tick(RunListEvent* ev)
bool bVal = false;
pActor->nFrame++;
if (pActor->nFrame >= mummySeq.frames.Size())
if (pActor->nFrame >= mummySeq->frames.Size())
{
pActor->nFrame = 0;

View file

@ -1890,7 +1890,7 @@ DExhumedActor* BuildObject(DExhumedActor* pActor, int nOjectType, int nHitag)
{
if (!nOjectType) // if not Explosion Trigger (e.g. Exploding Fire Cauldron)
{
pActor->nFrame = RandomSize(4) % (getSequence(pActor->nSeqFile).frames.Size() - 1);
pActor->nFrame = RandomSize(4) % (getSequence(pActor->nSeqFile)->frames.Size() - 1);
}
auto pActor2 = insertActor(pActor->sector(), 0);
@ -1957,7 +1957,7 @@ void AIObject::Tick(RunListEvent* ev)
// do animation
if (pActor->nSeqFile != NAME_None)
{
const auto& nSeqFrames = getSequence(pActor->nSeqFile).frames;
const auto& nSeqFrames = getSequence(pActor->nSeqFile)->frames;
if (++pActor->nFrame >= nSeqFrames.Size())
pActor->nFrame = 0;
@ -2004,20 +2004,22 @@ void AIObject::Tick(RunListEvent* ev)
// int edi = nSprite | 0x4000;
const auto firepotSeqs = getFileSeqs("firepot");
if (nStat == kStatExplodeTrigger)
{
const auto firepotSeqs = getFileSeqs("firepot");
for (int i = 4; i < 8; i++) {
BuildCreatureChunk(pActor, firepotSeqs->operator[]((i >> 2) + 1).getFirstFrameTexture(), true);
BuildCreatureChunk(pActor, firepotSeqs->Data((i >> 2) + 1)->getFirstFrameTexture(), true);
}
runlist_RadialDamageEnemy(pActor, 200, 20);
}
else if (nStat == kStatExplodeTarget)
{
const auto firepotSeqs = getFileSeqs("firepot");
for (int i = 0; i < 8; i++) {
BuildCreatureChunk(pActor, firepotSeqs->operator[]((i >> 1) + 3).getFirstFrameTexture(), true);
BuildCreatureChunk(pActor, firepotSeqs->Data((i >> 1) + 3)->getFirstFrameTexture(), true);
}
}
@ -2181,8 +2183,8 @@ void DoDrips()
DExhumedActor* pActor = sDrip[i].pActor;
if (!pActor) continue;
const auto& dripSeq = getSequence("drips", !(pActor->sector()->Flag & kSectLava));
dripSeq.frames[RandomSize(2) % dripSeq.frames.Size()].playSound(pActor);
const auto dripSeq = getSequence("drips", !(pActor->sector()->Flag & kSectLava));
dripSeq->frames[RandomSize(2) % dripSeq->frames.Size()].playSound(pActor);
sDrip[i].nCount = RandomSize(8) + 90;
}

View file

@ -221,7 +221,7 @@ void RestartPlayer(int nPlayer)
pPlayerActor->nSeqFile = "joe";
pPlayerActor->nAction = 0;
pPlayerActor->nFrame = 0;
pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, 18).getFirstFrameTexture());
pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, 18)->getFirstFrameTexture());
pPlayerActor->spr.hitag = 0;
pPlayerActor->spr.extra = -1;
pPlayerActor->spr.lotag = runlist_HeadRun() + 1;
@ -641,7 +641,7 @@ void AIPlayer::Damage(RunListEvent* ev)
for (int i = 122; i <= 131; i++)
{
BuildCreatureChunk(pPlayerActor, joeSeqs->operator[](i).getFirstFrameTexture());
BuildCreatureChunk(pPlayerActor, joeSeqs->Data(i)->getFirstFrameTexture());
}
StartDeathSeq(nPlayer, 1);
@ -1924,7 +1924,7 @@ static bool doPlayerDeathRestart(Player* const pPlayer)
if (pPlayer->pActor->nAction != 20)
{
const auto pPlayerActor = pPlayer->pActor;
pPlayerActor->spr.setspritetexture(getSequence("joe", 120).getFirstFrameTexture());
pPlayerActor->spr.setspritetexture(getSequence("joe", 120)->getFirstFrameTexture());
pPlayerActor->spr.cstat = 0;
pPlayerActor->spr.pos.Z = pPlayerActor->sector()->floorz;
}
@ -1953,9 +1953,9 @@ static void doPlayerActionSequence(Player* const pPlayer)
{
const auto pPlayerActor = pPlayer->pActor;
const auto& playerSeq = getSequence(pPlayerActor->nSeqFile, PlayerSeq[pPlayerActor->nAction].nSeqId);
const auto& seqFrame = playerSeq.frames[pPlayerActor->nFrame];
const auto seqSize = playerSeq.frames.Size();
const auto playerSeq = getSequence(pPlayerActor->nSeqFile, PlayerSeq[pPlayerActor->nAction].nSeqId);
const auto& seqFrame = playerSeq->frames[pPlayerActor->nFrame];
const auto seqSize = playerSeq->frames.Size();
seqFrame.playSound(pPlayerActor);
pPlayerActor->nFrame++;
@ -2050,7 +2050,7 @@ void AIPlayer::Tick(RunListEvent* ev)
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayerActor = pPlayer->pActor;
pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, PlayerSeq[nHeightTemplate[pPlayerActor->nAction]].nSeqId).getFirstFrameTexture());
pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, PlayerSeq[nHeightTemplate[pPlayerActor->nAction]].nSeqId)->getFirstFrameTexture());
pPlayer->pDoppleSprite->spr.picnum = pPlayerActor->spr.picnum;
doPlayerCounters(pPlayer);

View file

@ -254,7 +254,7 @@ void BlowChunks(DExhumedActor* pActor)
for (int i = 0; i < 4; i++)
{
BuildCreatureChunk(pActor, spiderSeqs->operator[](i + 41).getFirstFrameTexture());
BuildCreatureChunk(pActor, spiderSeqs->Data(i + 41)->getFirstFrameTexture());
}
}
@ -279,7 +279,7 @@ void DestroyEgg(int nEgg)
for (int i = 0; i < 4; i++)
{
BuildCreatureChunk(pActor, queeneggSeqs->operator[]((i % 2) + 24).getFirstFrameTexture());
BuildCreatureChunk(pActor, queeneggSeqs->Data((i % 2) + 24)->getFirstFrameTexture());
}
}
@ -547,8 +547,8 @@ void AIQueenEgg::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& eggSeq = getSequence(pActor->nSeqFile, EggSeq[nAction].nSeqId);
const auto& seqFrame = eggSeq.frames[pEgg->nFrame];
const auto eggSeq = getSequence(pActor->nSeqFile, EggSeq[nAction].nSeqId);
const auto& seqFrame = eggSeq->frames[pEgg->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
@ -557,7 +557,7 @@ void AIQueenEgg::Tick(RunListEvent* ev)
seqFrame.playSound(pActor);
pEgg->nFrame++;
if (pEgg->nFrame >= eggSeq.frames.Size())
if (pEgg->nFrame >= eggSeq->frames.Size())
{
pEgg->nFrame = 0;
bVal = true;
@ -808,15 +808,15 @@ void AIQueenHead::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& queenSeq = getSequence(pActor->nSeqFile, HeadSeq[QueenHead.nAction].nSeqId);
const auto& seqFrame = queenSeq.frames[QueenHead.nFrame];
const auto queenSeq = getSequence(pActor->nSeqFile, HeadSeq[QueenHead.nAction].nSeqId);
const auto& seqFrame = queenSeq->frames[QueenHead.nFrame];
seqFrame.playSound(pActor);
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
QueenHead.nFrame++;
if (QueenHead.nFrame >= queenSeq.frames.Size())
if (QueenHead.nFrame >= queenSeq->frames.Size())
{
QueenHead.nFrame = 0;
var_14 = 1;
@ -1241,15 +1241,15 @@ void AIQueen::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& queenSeq = getSequence(pActor->nSeqFile, QueenSeq[nAction].nSeqId);
const auto& seqFrame = queenSeq.frames[QueenList[nQueen].nFrame];
const auto queenSeq = getSequence(pActor->nSeqFile, QueenSeq[nAction].nSeqId);
const auto& seqFrame = queenSeq->frames[QueenList[nQueen].nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
QueenList[nQueen].nFrame++;
if (QueenList[nQueen].nFrame >= queenSeq.frames.Size())
if (QueenList[nQueen].nFrame >= queenSeq->frames.Size())
{
QueenList[nQueen].nFrame = 0;
bVal = true;
@ -1444,7 +1444,7 @@ void AIQueen::Tick(RunListEvent* ev)
if (QueenList[nQueen].nIndex <= 0)
{
pActor->spr.cstat = 0;
const auto queenPicnum = getSequence("queen", 57).getFirstFrameTexture();
const auto queenPicnum = getSequence("queen", 57)->getFirstFrameTexture();
for (int i = 0; i < 20; i++)
{

View file

@ -213,8 +213,8 @@ void AIRa::Tick(RunListEvent* ev)
DExhumedActor* pActor = Ra[nPlayer].pActor;
if (!pActor) return;
const auto& raSeq = getSequence(Ra[nPlayer].pActor->nSeqFile, RaSeq[Ra[nPlayer].nAction].nSeqId);
const auto& seqFrame = raSeq.frames[Ra[nPlayer].nFrame];
const auto raSeq = getSequence(Ra[nPlayer].pActor->nSeqFile, RaSeq[Ra[nPlayer].nAction].nSeqId);
const auto& seqFrame = raSeq->frames[Ra[nPlayer].nFrame];
bool bVal = false;
@ -226,7 +226,7 @@ void AIRa::Tick(RunListEvent* ev)
seqFrame.playSound(pActor);
Ra[nPlayer].nFrame++;
if (Ra[nPlayer].nFrame >= raSeq.frames.Size())
if (Ra[nPlayer].nFrame >= raSeq->frames.Size())
{
Ra[nPlayer].nFrame = 0;
bVal = true;

View file

@ -58,7 +58,7 @@ void SerializeRat(FSerializer& arc)
void InitRats()
{
nPlayerPic = getSequence("joe", 120).getFirstFrameTexture();
nPlayerPic = getSequence("joe", 120)->getFirstFrameTexture();
}
void SetRatVel(DExhumedActor* pActor)
@ -228,15 +228,15 @@ void AIRat::Tick(RunListEvent* ev)
bool bVal = false;
const auto& ratSeq = getSequence(pActor->nSeqFile, RatSeq[nAction].nSeqId);
const auto& seqFrame = ratSeq.frames[pActor->nFrame];
const auto ratSeq = getSequence(pActor->nSeqFile, RatSeq[nAction].nSeqId);
const auto& seqFrame = ratSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= ratSeq.frames.Size())
if (pActor->nFrame >= ratSeq->frames.Size())
{
bVal = true;
pActor->nFrame = 0;
@ -275,7 +275,7 @@ void AIRat::Tick(RunListEvent* ev)
pActor->nCount = RandomSize(5) + 4;
pActor->nPhase--;
if (pActor->nFrame >= ratSeq.frames.Size())
if (pActor->nFrame >= ratSeq->frames.Size())
{
bVal = true;
pActor->nFrame = 0;

View file

@ -192,8 +192,8 @@ void AIRex::Tick(RunListEvent* ev)
Gravity(pActor);
const auto& rexSeq = getSequence(pActor->nSeqFile, RexSeq[nAction].nSeqId);
const auto& seqFrame = rexSeq.frames[pActor->nFrame];
const auto rexSeq = getSequence(pActor->nSeqFile, RexSeq[nAction].nSeqId);
const auto& seqFrame = rexSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
@ -209,7 +209,7 @@ void AIRex::Tick(RunListEvent* ev)
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= rexSeq.frames.Size())
if (pActor->nFrame >= rexSeq->frames.Size())
{
pActor->nFrame = 0;
bVal = true;

View file

@ -212,14 +212,14 @@ void AIRoach::Tick(RunListEvent* ev)
Gravity(pActor);
const auto& roachSeq = getSequence(pActor->nSeqFile, RoachSeq[nAction].nSeqId);
const auto& seqFrame = roachSeq.frames[pActor->nFrame];
const auto roachSeq = getSequence(pActor->nSeqFile, RoachSeq[nAction].nSeqId);
const auto& seqFrame = roachSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= roachSeq.frames.Size())
if (pActor->nFrame >= roachSeq->frames.Size())
{
bVal = true;
pActor->nFrame = 0;

View file

@ -207,15 +207,15 @@ void AIScorp::Tick(RunListEvent* ev)
Gravity(pActor);
}
const auto& scorpSeq = getSequence(pActor->nSeqFile, ScorpSeq[nAction].nSeqId);
const auto& seqFrame = scorpSeq.frames[pActor->nFrame];
const auto scorpSeq = getSequence(pActor->nSeqFile, ScorpSeq[nAction].nSeqId);
const auto& seqFrame = scorpSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= scorpSeq.frames.Size())
if (pActor->nFrame >= scorpSeq->frames.Size())
{
pActor->nFrame = 0;
bVal = true;

View file

@ -140,16 +140,19 @@ const TArray<Seq>* const getFileSeqs(const FName nSeqFile)
static void fixSeqs()
{
// Seq file "skulstrt" has one sprite face with 20 frames instead of 24.
if (auto skulstrt = FileSeqMap.CheckKey("skulstrt"))
if (const auto skulstrt = FileSeqMap.CheckKey("skulstrt"))
{
// Get sequence and store last frame.
auto& seq = skulstrt->operator[](4);
const auto lastframe = seq.frames.Last();
// Repeat last frame another four times.
for (unsigned i = 20; i < 24; i++)
// Get 5th sequence with missing frames.
if (const auto seq = skulstrt->Data(4))
{
seq.frames.Push(lastframe);
// Store last frame.
const auto lastframe = seq->frames.Last();
// Repeat last frame another four times.
for (unsigned i = 20; i < 24; i++)
{
seq->frames.Push(lastframe);
}
}
}
}
@ -336,18 +339,18 @@ void seq_LoadSequences()
// Perform sequence post-processing for where original assets are malformed.
fixSeqs();
nShadowPic = getSequence("shadow").getFirstFrameTexture();
nShadowPic = getSequence("shadow")->getFirstFrameTexture();
nShadowWidth = (int16_t)TexMan.GetGameTexture(nShadowPic)->GetDisplayWidth();
nFlameHeight = (int16_t)TexMan.GetGameTexture(getSequence("firepoof").getFirstFrameTexture())->GetDisplayHeight();
nFlameHeight = (int16_t)TexMan.GetGameTexture(getSequence("firepoof")->getFirstFrameTexture())->GetDisplayHeight();
nPilotLightCount = getSequence("flamer", 3).frames.Size();
nPilotLightCount = getSequence("flamer", 3)->frames.Size();
nPilotLightFrame = 0;
const auto& fontSeq = getSequence("font2");
const int nFontFirstChar = legacyTileNum(fontSeq.getFirstFrameTexture());
const auto fontSeq = getSequence("font2");
const int nFontFirstChar = legacyTileNum(fontSeq->getFirstFrameTexture());
for (unsigned i = 0; i < fontSeq.frames.Size(); i++)
for (unsigned i = 0; i < fontSeq->frames.Size(); i++)
{
auto tex = tileGetTexture(nFontFirstChar + i);
tex->SetOffsets(0, 0);
@ -362,7 +365,7 @@ void seq_LoadSequences()
void seq_DrawPilotLightSeq(double xPos, double yPos, double nAngle)
{
const auto& seqFrameChunks = getSequence("flamer", 3).frames[0].chunks;
const auto& seqFrameChunks = getSequence("flamer", 3)->frames[0].chunks;
for (unsigned i = 0; i < seqFrameChunks.Size(); i++)
{
@ -409,7 +412,7 @@ void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t
const DAngle nAngle = (nCamerapos.XY() - pTSprite->pos.XY()).Angle();
const int seqOffset = (((pTSprite->Angles.Yaw + DAngle90 + DAngle22_5 - nAngle).Buildang()) & kAngleMask) >> 8;
const auto& seqFrame = getSequence(seqFile, seqIndex + seqOffset).frames[frameIndex];
const auto& seqFrame = getSequence(seqFile, seqIndex + seqOffset)->frames[frameIndex];
const auto& frameChunk = seqFrame.chunks[0];
if (seqFrame.flags & 4)
@ -460,15 +463,15 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
}
const auto fileSeqs = getFileSeqs(seqFile);
const auto& seqFrame = fileSeqs->operator[](seqIndex + seqOffset).frames[frameIndex];
const auto& seqFrame = fileSeqs->Data(seqIndex + seqOffset)->frames[frameIndex];
const auto chunkCount = seqFrame.chunks.Size();
const auto nShade = pTSprite->shade - (100 * !!(fileSeqs->operator[](seqIndex).frames[frameIndex].flags & 4));
const auto nShade = pTSprite->shade - (100 * !!(fileSeqs->Data(seqIndex)->frames[frameIndex].flags & 4));
const auto nStatnum = (nFlags & 0x100) ? -3 : 100;
for (unsigned i = 0; i < chunkCount; i++)
{
const auto& seqFrameChunk = seqFrame.chunks[i];
const auto& frameChunk = seqFrame.chunks[i];
tspritetype* tsp = mytspriteArray->newTSprite();
tsp->pos = pTSprite->pos;
@ -482,18 +485,18 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
tsp->clipdist = pTSprite->clipdist;
tsp->statnum = chunkCount - i + nStatnum + 1;
if (seqFrameChunk.flags & 1)
if (frameChunk.flags & 1)
{
tsp->xoffset = (int8_t)seqFrameChunk.xpos;
tsp->xoffset = (int8_t)frameChunk.xpos;
tsp->cstat |= CSTAT_SPRITE_XFLIP; // x-flipped
}
else
{
tsp->xoffset = -seqFrameChunk.xpos;
tsp->xoffset = -frameChunk.xpos;
}
tsp->yoffset = -seqFrameChunk.ypos;
tsp->setspritetexture(seqFrameChunk.tex);
tsp->yoffset = -frameChunk.ypos;
tsp->setspritetexture(frameChunk.tex);
}
if (!(pTSprite->cstat & CSTAT_SPRITE_BLOCK_ALL) || (pTSprite->ownerActor->spr.statnum == 100 && nNetPlayerCount))
@ -583,7 +586,7 @@ DEFINE_ACTION_FUNCTION(_Exhumed, GetStatusSequence)
{
PARAM_PROLOGUE;
PARAM_INT(seqId);
ACTION_RETURN_POINTER(getFileSeqs("status")->Data(seqId));
ACTION_RETURN_CONST_POINTER(getSequence("status", seqId));
}
//---------------------------------------------------------------------------

View file

@ -86,9 +86,9 @@ void seq_DrawPilotLightSeq(double xPos, double yPos, double nAngle);
const TArray<Seq>* const getFileSeqs(const FName nSeqFile);
inline const Seq& getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
inline const Seq* const getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
{
return getFileSeqs(nSeqFile)->operator[](nSeqIndex);
return getFileSeqs(nSeqFile)->Data(nSeqIndex);
}
END_PS_NS

View file

@ -116,7 +116,7 @@ void BuildSoul(DExhumedActor* pSet)
pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0;
pActor->nSeqFile = "set";
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, 75).getFirstFrameTexture());
pActor->spr.setspritetexture(getSequence(pActor->nSeqFile, 75)->getFirstFrameTexture());
pActor->spr.Angles.Yaw = RandomAngle();
pActor->vel.X = 0;
pActor->vel.Y = 0;
@ -145,7 +145,7 @@ void AISoul::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
getSequence("set", 75).frames[0].playSound(pActor);
getSequence("set", 75)->frames[0].playSound(pActor);
if (pActor->spr.scale.X < 0.5)
{
@ -271,8 +271,8 @@ void AISet::Tick(RunListEvent* ev)
Gravity(pActor);
const auto& setSeq = getSequence(pActor->nSeqFile, SetSeq[nAction].nSeqId);
const auto& seqFrame = setSeq.frames[pActor->nFrame];
const auto setSeq = getSequence(pActor->nSeqFile, SetSeq[nAction].nSeqId);
const auto& seqFrame = setSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
@ -285,7 +285,7 @@ void AISet::Tick(RunListEvent* ev)
}
pActor->nFrame++;
if (pActor->nFrame >= setSeq.frames.Size())
if (pActor->nFrame >= setSeq->frames.Size())
{
pActor->nFrame = 0;
bVal = true;
@ -573,7 +573,7 @@ void AISet::Tick(RunListEvent* ev)
{
if (bVal)
{
pActor->nFrame = setSeq.frames.Size() - 1;
pActor->nFrame = setSeq->frames.Size() - 1;
}
if (nMov.exbits & kHitAux2)
@ -612,7 +612,7 @@ void AISet::Tick(RunListEvent* ev)
if (seqFrame.flags & 0x80)
{
pActor->spr.pos.Z -= GetActorHeight(pActor);
BuildCreatureChunk(pActor, getSequence("set", 76).getFirstFrameTexture());
BuildCreatureChunk(pActor, getSequence("set", 76)->getFirstFrameTexture());
pActor->spr.pos.Z += GetActorHeight(pActor);
}

View file

@ -163,7 +163,7 @@ void BuildSnake(int nPlayer, double zVal)
auto pPlayerActor = PlayerList[nPlayer].pActor;
auto pViewSect = PlayerList[nPlayer].pPlayerViewSect;
auto nPic = getSequence("snakbody", 0).getFirstFrameTexture();
auto nPic = getSequence("snakbody", 0)->getFirstFrameTexture();
auto pos = pPlayerActor->spr.pos.plusZ(zVal - 10);
@ -338,7 +338,7 @@ void AISnake::Tick(RunListEvent* ev)
DExhumedActor* pActor = SnakeList[nSnake].pSprites[0];
if (!pActor) return;
getSequence("snakehed").frames[0].playSound(pActor);
getSequence("snakehed")->frames[0].playSound(pActor);
DExhumedActor* pEnemySprite = SnakeList[nSnake].pEnemy;

View file

@ -718,8 +718,8 @@ void UpdateCreepySounds()
{
if (nCreaturesKilled < nCreaturesTotal && !(PlayerList[nLocalPlayer].pPlayerViewSect->Flag & 0x2000))
{
const auto& creepySeq = getSequence("creepy");
const auto seqFrameSound = creepySeq.frames[totalmoves % creepySeq.frames.Size()].sound;
const auto creepySeq = getSequence("creepy");
const auto seqFrameSound = creepySeq->frames[totalmoves % creepySeq->frames.Size()].sound;
if (seqFrameSound >= 0 && (seqFrameSound & 0x1ff) < kMaxSounds)
{
DVector2 adder;

View file

@ -119,15 +119,15 @@ void AISpider::Tick(RunListEvent* ev)
}
}
const auto& spiderSeq = getSequence(spp->nSeqFile, SpiderSeq[nAction].nSeqId);
const auto& seqFrame = spiderSeq.frames[spp->nFrame];
const auto spiderSeq = getSequence(spp->nSeqFile, SpiderSeq[nAction].nSeqId);
const auto& seqFrame = spiderSeq->frames[spp->nFrame];
spp->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(spp);
spp->nFrame++;
if (spp->nFrame >= spiderSeq.frames.Size()) {
if (spp->nFrame >= spiderSeq->frames.Size()) {
spp->nFrame = 0;
}
@ -423,7 +423,7 @@ void AISpider::Damage(RunListEvent* ev)
for (int i = 0; i < 7; i++)
{
BuildCreatureChunk(spp, spiderSeqs->operator[](i + 41).getFirstFrameTexture());
BuildCreatureChunk(spp, spiderSeqs->Data(i + 41)->getFirstFrameTexture());
}
}
}

View file

@ -47,7 +47,7 @@ BEGIN_PS_NS
void UpdateFrame()
{
static const auto tex = TexMan.GetGameTexture(getSequence("backgrnd").getFirstFrameTexture());
static const auto tex = TexMan.GetGameTexture(getSequence("backgrnd")->getFirstFrameTexture());
twod->AddFlatFill(0, 0, twod->GetWidth(), viewport3d.Top() - 3, tex);
twod->AddFlatFill(0, viewport3d.Bottom() + 3, twod->GetWidth(), twod->GetHeight(), tex);

View file

@ -210,15 +210,15 @@ void AIWasp::Tick(RunListEvent* ev)
bool bVal = false;
const auto& waspSeq = getSequence(pActor->nSeqFile, WaspSeq[nAction].nSeqId);
const auto& seqFrame = waspSeq.frames[pActor->nFrame];
const auto waspSeq = getSequence(pActor->nSeqFile, WaspSeq[nAction].nSeqId);
const auto& seqFrame = waspSeq->frames[pActor->nFrame];
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= waspSeq.frames.Size())
if (pActor->nFrame >= waspSeq->frames.Size())
{
pActor->nFrame = 0;
bVal = true;