Exhumed: fix crash on bad player animation sequence.

This commit is contained in:
Christoph Oelckers 2023-11-19 08:10:38 +01:00
parent 86584b54ec
commit 0666e3372c
2 changed files with 6 additions and 2 deletions

View file

@ -1928,8 +1928,10 @@ static void doPlayerActionSequence(DExhumedPlayer* const pPlayer)
const auto pPlayerActor = pPlayer->GetActor();
const auto playerSeq = getSequence(pPlayerActor->nSeqFile, PlayerSeq[pPlayerActor->nAction].nSeqId);
const auto& seqFrame = playerSeq->frames[pPlayerActor->nFrame];
if (playerSeq == nullptr) return;
const auto seqSize = playerSeq->frames.Size();
if (pPlayerActor->nFrame >= seqSize) pPlayerActor->nFrame = seqSize - 1;
const auto& seqFrame = playerSeq->frames[pPlayerActor->nFrame];
seqFrame.playSound(pPlayerActor);
pPlayerActor->nFrame++;

View file

@ -88,7 +88,9 @@ TArray<Seq>* getFileSeqs(const FName nSeqFile);
inline Seq* getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
{
return getFileSeqs(nSeqFile)->Data(nSeqIndex);
auto seq = getFileSeqs(nSeqFile);
if (nSeqIndex >= seq->Size()) return nullptr;
return seq->Data(nSeqIndex);
}
END_PS_NS