Skip to content

Commit 25a653d

Browse files
committed
bugfix(gui): Reset the frame pacer before the whole-screen fade to prevent a load-gap jump
1 parent 355e006 commit 25a653d

5 files changed

Lines changed: 18 additions & 0 deletions

File tree

Core/GameEngine/Include/Common/FramePacer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class FramePacer
3939
~FramePacer();
4040

4141
void update(); ///< Signal that the app/render update is done and wait for the fps limit if applicable.
42+
void reset(); ///< Discard elapsed time since the last update (e.g. across a blocking load) so the next update measures a real frame.
4243

4344
void setFramesPerSecondLimit( Int fps ); ///< Set the update fps limit.
4445
Int getFramesPerSecondLimit() const; ///< Get the update fps limit.

Core/GameEngine/Include/Common/FrameRateLimit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class FrameRateLimit
2727
FrameRateLimit();
2828

2929
Real wait(UnsignedInt maxFps);
30+
void reset(); ///< Move the timing anchor to now, discarding any time elapsed since the last wait().
3031

3132
private:
3233
Int64 m_freq;

Core/GameEngine/Source/Common/FramePacer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ void FramePacer::update()
5858
m_updateTime = m_frameRateLimit.wait(maxFps);
5959
}
6060

61+
void FramePacer::reset()
62+
{
63+
m_frameRateLimit.reset();
64+
m_updateTime = 1.0f / (Real)getActualFramesPerSecondLimit();
65+
}
66+
6167
void FramePacer::setFramesPerSecondLimit( Int fps )
6268
{
6369
DEBUG_LOG(("FramePacer::setFramesPerSecondLimit() - setting max fps to %d (TheGlobalData->m_useFpsLimit == %d)", fps, TheGlobalData->m_useFpsLimit));

Core/GameEngine/Source/Common/FrameRateLimit.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ Real FrameRateLimit::wait(UnsignedInt maxFps)
5858
return (Real)elapsedSeconds;
5959
}
6060

61+
void FrameRateLimit::reset()
62+
{
63+
LARGE_INTEGER tick;
64+
QueryPerformanceCounter(&tick);
65+
m_start = tick.QuadPart;
66+
}
67+
6168

6269
const UnsignedInt RenderFpsPreset::s_fpsValues[] = {
6370
30, 50, 56, 60, 65, 70, 72, 75, 80, 85, 90, 100, 110, 120, 144, 240, 480, UncappedFpsValue };

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,9 @@ void GameLogic::tryStartNewGame( Bool loadingSaveGame )
22392239
// if we're in a load game, don't fade yet
22402240
if(loadingSaveGame == FALSE && TheTransitionHandler != nullptr && m_loadScreen)
22412241
{
2242+
// TheSuperHackers @bugfix bobtista 18/07/2026 Prime the pacer so the fade's first frame
2243+
// time is not the whole blocking load, which would jump the transition several frames.
2244+
TheFramePacer->reset();
22422245
TheTransitionHandler->setGroup("FadeWholeScreen");
22432246
while(!TheTransitionHandler->isFinished())
22442247
{

0 commit comments

Comments
 (0)