Exhumed: sanitize stupid implementation of UpdateEnemy and fixed bad use of it for the queen's eggs.

This commit is contained in:
Christoph Oelckers 2023-11-05 13:37:34 +01:00
parent 91dfeb42bd
commit 5a176fdf3d
4 changed files with 11 additions and 14 deletions

View file

@ -210,7 +210,7 @@ void MoveThings();
void InitChunks();
void InitPushBlocks();
void Gravity(DExhumedActor* actor);
DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy);
DExhumedActor* UpdateEnemy(DExhumedActor* ppEnemy);
Collision MoveCreature(DExhumedActor* nSprite);
Collision MoveCreatureWithCaution(DExhumedActor* actor);
DVector3 WheresMyMouth(DExhumedPlayer* const pPlayer, sectortype** sectnum);

View file

@ -1286,15 +1286,15 @@ void AICreatureChunk::Tick(RunListEvent* ev)
//
//---------------------------------------------------------------------------
DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy)
DExhumedActor* UpdateEnemy(DExhumedActor* ppEnemy)
{
if (*ppEnemy)
if (ppEnemy)
{
if (!((*ppEnemy)->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) {
*ppEnemy = nullptr;
if (!(ppEnemy->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
{
return nullptr;
}
}
return *ppEnemy;
return ppEnemy;
}
END_PS_NS

View file

@ -133,9 +133,8 @@ void AIMummy::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
DExhumedActor* targ = pActor->pTarget;
auto pTarget = UpdateEnemy(&targ);
pActor->pTarget = targ;
auto pTarget = UpdateEnemy(pActor->pTarget);
pActor->pTarget = pTarget;
int nAction = pActor->nAction;

View file

@ -563,10 +563,7 @@ void AIQueenEgg::Tick(RunListEvent* ev)
bVal = true;
}
DExhumedActor* enemy = pEgg->pActor;
pTarget = UpdateEnemy(&enemy);
pEgg->pActor = enemy;
pEgg->pTarget = pTarget;
pTarget = UpdateEnemy(pEgg->pTarget);
if (pTarget && (pTarget->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) == 0)
{
@ -734,6 +731,7 @@ void AIQueenEgg::Draw(RunListEvent* ev)
const auto nEgg = RunData[ev->nRun].nObjIndex;
const auto pEgg = &QueenEgg[nEgg];
const auto eggSeq = &EggSeq[pEgg->nAction];
if (pEgg->pActor == nullptr) return;
seq_PlotSequence(ev->nParam, pEgg->pActor->nSeqFile, eggSeq->nSeqId, pEgg->nFrame, eggSeq->nFlags);
}