@ -11,35 +11,32 @@
namespace devilution {
int AnimationInfo : : GetFrameToUseForRendering ( )
int AnimationInfo : : GetFrameToUseForRendering ( ) const
{
// Normal logic is used,
// - if no frame-skipping is required and so we have exactly one Animationframe per GameTick
// or
// - if we load from a savegame where the new variables are not stored (we don't want to break savegame compatiblity because of smoother rendering of one animation)
int relevantAnimationFramesForDistributing = RelevantFramesForDistributing ;
if ( relevantAnimationFramesForDistributing < = 0 )
if ( RelevantFramesForDistributing < = 0 )
return CurrentFrame ;
if ( CurrentFrame > relevantAnimation FramesForDistributing)
if ( CurrentFrame > Relevant FramesForDistributing)
return CurrentFrame ;
assert ( GameTicksSinceSequenceStarted > = 0 ) ;
float progressToNextGameTick = gfProgressToNextGameTick ;
// we don't use the processed game ticks alone but also the fragtion of the next game tick (if a rendering happens between game ticks). This helps to smooth the animations.
float totalGameTicksForCurrentAnimationSequence = p rogressToNextGameTick + ( float ) GameTicksSinceSequenceStarted ;
float totalGameTicksForCurrentAnimationSequence = gfProgressToNextGameTick + ( float ) GameTicksSinceSequenceStarted ;
// 1 added for rounding reasons. float to int cast always truncate.
int absoluteAnimationFrame = 1 + ( int ) ( totalGameTicksForCurrentAnimationSequence * GameTickModifier ) ;
if ( absoluteAnimationFrame > relevantAnimation FramesForDistributing) {
if ( absoluteAnimationFrame > Relevant FramesForDistributing) {
// this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f)
if ( absoluteAnimationFrame > ( relevantAnimation FramesForDistributing + 1 ) ) {
if ( absoluteAnimationFrame > ( Relevant FramesForDistributing + 1 ) ) {
// we should never have +2 frames even if next game tick is due
Log ( " GetFrameToUseForRendering: Calculated an invalid Animation Frame (Calculated {} MaxFrame {}) " , absoluteAnimationFrame , relevantAnimation FramesForDistributing) ;
Log ( " GetFrameToUseForRendering: Calculated an invalid Animation Frame (Calculated {} MaxFrame {}) " , absoluteAnimationFrame , Relevant FramesForDistributing) ;
}
return relevantAnimation FramesForDistributing;
return Relevant FramesForDistributing;
}
if ( absoluteAnimationFrame < = 0 ) {
Log ( " GetFrameToUseForRendering: Calculated an invalid Animation Frame (Calculated {}) " , absoluteAnimationFrame ) ;