Skip to content

bugfix(gameengine): Prevent logic time accumulation while the game is halted#2865

Open
bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/fix/logic-time-accumulator-halted
Open

bugfix(gameengine): Prevent logic time accumulation while the game is halted#2865
bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/fix/logic-time-accumulator-halted

Conversation

@bobtista

@bobtista bobtista commented Jul 9, 2026

Copy link
Copy Markdown

Since #2803 the update no longer passes FramePacer::IgnoreHaltedGame, so getActualLogicTimeScaleFps returns 0 while the game is paused. That makes targetFrameTime infinite, and m_logicTimeAccumulator banks the entire pause duration, which then drains at render rate after unpausing — the game runs at 2x for about as long as it was paused.

Now returns early when the logic time scale fps is 0, leaving the accumulator untouched while the game is halted, so the game resumes at normal speed.

Todo:

  • Test pause/unpause with render fps 60 and logic time scale 30
  • Replicate to Generals

@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR prevents regular game logic from banking paused time while the game is halted.

  • Adds an early zero-or-negative logic FPS guard in Generals.
  • Applies the same guard in Generals Zero Hour.
  • Keeps halted regular-game updates from reaching accumulator timing logic.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/Common/GameEngine.cpp Adds an early return when regular-game logic timing is halted.
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Mirrors the halted regular-game logic guard for Zero Hour.

Reviews (2): Last reviewed commit: "bugfix(gameengine): Check for halted gam..." | Re-trigger Greptile

@Caball009 Caball009 self-requested a review July 10, 2026 04:40
@Caball009

Caball009 commented Jul 10, 2026

Copy link
Copy Markdown

It also broke pause on mismatch partially, because fast forward overrides pause now.

Comment on lines +708 to +714
// TheSuperHackers @bugfix bobtista 08/07/2026 Return early when the logic time scale fps is zero,
// otherwise the accumulator banks the paused duration and replays it at render rate after unpausing.
if (logicTimeScaleFps <= 0)
{
return false;
}

@Caball009 Caball009 Jul 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go after

const Int logicTimeScaleFps = TheFramePacer->getActualLogicTimeScaleFps(logicTimeQueryFlags);

otherwise this function returns true when replay mode is enabled & the game is paused & fast forward is enabled.

It doesn't need a comment as far as I'm concerned, because it's our own function and straightforward what it does and why it does it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch, pause should now win and work right in fast forward, and it fixes pause on mismatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Game logic fast-forwards at render rate after unpausing when the logic time scale is active

2 participants