From 2b07dfc503a1c489d27a01e7b70a965bbae03cab Mon Sep 17 00:00:00 2001 From: Tom Anderson Date: Wed, 3 Jul 2024 14:45:37 -0600 Subject: [PATCH] make FramesFromNow() accept a float arg Well, this is embarrassing. Most of the time FrameFromNow() is passed an integer. But there's an important call that passes a float on this check: while (FramesFromNow(latencyTolerance) > topSentFrame) { itsNet->FrameAction(); } Passing latencyTolerance as an integer was truncating the LT. For example, an LT=1.5 would be treated as LT=1 and result in less than the full LT of frames being sent on time. --- src/game/CAvaraGame.cpp | 2 +- src/game/CAvaraGame.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/CAvaraGame.cpp b/src/game/CAvaraGame.cpp index 04a0f3f7..f1a0436f 100755 --- a/src/game/CAvaraGame.cpp +++ b/src/game/CAvaraGame.cpp @@ -1135,7 +1135,7 @@ void CAvaraGame::IncrementFrame(bool firstFrame) { isClassicFrame = (frameNumber % (CLASSICFRAMETIME / frameTime) == 0); } -FrameNumber CAvaraGame::FramesFromNow(FrameNumber classicFrameCount) { +FrameNumber CAvaraGame::FramesFromNow(double classicFrameCount) { return frameNumber + classicFrameCount / fpsScale; } diff --git a/src/game/CAvaraGame.h b/src/game/CAvaraGame.h index 91eb6058..feeab9cc 100644 --- a/src/game/CAvaraGame.h +++ b/src/game/CAvaraGame.h @@ -269,7 +269,7 @@ class CAvaraGame { virtual FrameNumber NextFrameForPeriod(long period, long referenceFrame = 0); virtual void SetFrameTime(int32_t ft); virtual void IncrementFrame(bool firstFrame = false); - virtual FrameNumber FramesFromNow(FrameNumber classicFrames); + virtual FrameNumber FramesFromNow(double classicFrames); virtual void SetSpawnOrder(SpawnOrder order); void SetKeysFromStdin() { keysFromStdin = true; };