Skip to content

bugfix(saveload): Save the next evaluation frame of delayed scripts - #3130

Draft
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/script-frame-to-evaluate
Draft

bugfix(saveload): Save the next evaluation frame of delayed scripts#3130
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/script-frame-to-evaluate

Conversation

@bobtista

@bobtista bobtista commented Aug 13, 2026

Copy link
Copy Markdown

Script::xfer only transfers the active flag, so m_frameToEvaluateAt is never restored when a save is loaded. ScriptList::xfer walks the scripts that were rebuilt from the map rather than creating them from the save, so nothing else restores it either, and the field keeps whatever checkConditionsForTeamNames assigned during setup - a random stagger of 0 to 60 frames. Any real load frame is past that, so ScriptEngine::executeScript's frame check always passes: every script with a delay evaluates on its first pass after loading and then re-times itself from the load frame, losing both the remainder of its interval and its original stagger. 893 scripts across 35 stock maps use a non-zero delay, including every Generals Challenge map and most campaign missions.

Now the field is transferred in a version 2 xfer, so a delayed script resumes on the frame it was already waiting for. Version 1 saves still load and keep the old behaviour. The field also moves above the "Runtime fields - not saved or read" comment in the header, since it is now saved.

Measured on MD_CHI01 by saving at logic frame 3000 and loading the save back, logging the field on both sides of the xfer. The numbers are m_frameToEvaluateAt itself, an absolute logic frame at 30 frames per second:

script evaluation delay next eval frame, saved after load, before after load, after
Attack Wave 3 Condition 20s 14 49 14
Attack Wave 2 Condition 30s 48 23 48
Attack Wave 1 Condition 40s 24 8 24
Attack Wave 1 Condition - EASY 40s 4 52 4

Before the fix the load replaces the saved value with a freshly generated stagger, after the fix it round-trips exactly.

Todo:

  • Verify on MD_CHI01: save at frame 3000, load, confirm each delayed script's next evaluation frame is restored
  • Replicate to Generals

Comment thread Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp
@Caball009 Caball009 added Bug Something is not working right, typically is user facing Gen Relates to Generals ZH Relates to Zero Hour Saveload Is Saveload/Xfer related Minor Severity: Minor < Major < Critical < Blocker labels Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Saveload Is Saveload/Xfer related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scripts with a delayed evaluation run immediately after loading a save

2 participants