Skip to content

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

Open
bobtista wants to merge 2 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 2 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 stops halted game time from being banked by the logic pacer.

  • Adds a zero-or-negative logic FPS guard in the Generals update path.
  • Applies the same guard in the Generals Zero Hour update path.
  • Leaves the logic accumulator unchanged while the game is paused or halted.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The new guard matches the halted-game path where effective logic FPS becomes zero.
  • The mirrored files keep the Generals and Zero Hour behavior aligned.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/Common/GameEngine.cpp Adds an early return before accumulator math when the effective logic FPS is zero or negative.
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Mirrors the halted-game logic FPS guard in the Zero Hour game-engine update path.

Reviews (1): Last reviewed commit: "bugfix(gameengine): Prevent logic time a..." | 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.

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