Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix divide-by-zero crash in getAnimationProgress() #7532

Merged
merged 5 commits into from
Nov 16, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Source/engine/animationinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ uint8_t AnimationInfo::getAnimationProgress() const
int32_t tickModifier = tickModifier_;

if (relevantFramesForDistributing_ <= 0) {
if (ticksPerFrame <= 0) {
Log("getAnimationProgress: Invalid ticksPerFrame {}", ticksPerFrame);
}
kphoenix137 marked this conversation as resolved.
Show resolved Hide resolved
// This logic is used if animation distribution is not active (see getFrameToUseForRendering).
// In this case the variables calculated with animation distribution are not initialized and we have to calculate them on the fly with the given information.
ticksSinceSequenceStarted = ((currentFrame * ticksPerFrame) + tickCounterOfCurrentFrame) * baseValueFraction;
tickModifier = baseValueFraction / ticksPerFrame;
ticksSinceSequenceStarted = ((currentFrame * std::max<int8_t>(1, ticksPerFrame)) + tickCounterOfCurrentFrame) * baseValueFraction;
tickModifier = baseValueFraction / std::max<int8_t>(1, ticksPerFrame);
}

int32_t totalTicksForCurrentAnimationSequence = getProgressToNextGameTick() + ticksSinceSequenceStarted;
Expand Down
Loading