Skip to content

Commit

Permalink
Exhumed: fix crash on bad player animation sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 19, 2023
1 parent 541c9c0 commit 76115d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion source/games/exhumed/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
4 changes: 3 additions & 1 deletion source/games/exhumed/src/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 76115d0

Please sign in to comment.