8000 bugfix(skirmish): Prevent mismatch in Replay playback by restoring correct game seed after restarting a Skirmish game by Caball009 · Pull Request #2270 · TheSuperHackers/GeneralsGameCode · GitHub
[go: up one dir, main page]

Skip to content

bugfix(skirmish): Prevent mismatch in Replay playback by restoring correct game seed after restarting a Skirmish game#2270

Merged
xezon merged 4 commits intoTheSuperHackers:mainfrom
Caball009:fix_bug_skirmish_restart_seed_values
Feb 21, 2026
Merged

bugfix(skirmish): Prevent mismatch in Replay playback by restoring correct game seed after restarting a Skirmish game#2270
xezon merged 4 commits intoTheSuperHackers:mainfrom
Caball009:fix_bug_skirmish_restart_seed_values

Conversation

@Caball009
Copy link
@Caball009 Caball009 commented Feb 8, 2026

This PR makes the seed value consistent for started vs. restarted skirmish games, and fixes a bug that causes replays of restarted skirmish game to always mismatch.

TODO:

  • Replicate in Generals.

@Caball009 Caball009 added Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime labels Feb 8, 2026
@greptile-apps
Copy link
greptile-apps bot commented Feb 8, 2026

Greptile Summary

This PR fixes a replay mismatch bug in skirmish game restarts by ensuring the original seed value is preserved and reused when restarting a skirmish game.

Key changes:

  • In QuitMenu.cpp: Captures the skirmish seed before clearGameData() is called, then uses it in InitRandom() instead of hardcoded 0
  • In SkirmishGameOptionsMenu.cpp: Moves InitGameLogicRandom() calls into conditional branches to properly differentiate seed initialization for skirmish (TheSkirmishGameInfo->getSeed()) vs single-player scenarios (0)
  • Changes are identically replicated in both Generals and GeneralsMD variants

Previously discussed issues:
Most concerns from previous review threads have been addressed by the author, including caching the seed before clearGameData and using TheSkirmishGameInfo for the condition check. The InitRandom vs InitGameLogicRandom asymmetry is noted for a follow-up PR.

Confidence Score: 4/5

  • This PR is safe to merge with only minor style concerns
  • The logic is sound and addresses the replay mismatch bug correctly. The seed is properly captured before clearGameData, and the conditional branches ensure proper seed initialization for different game modes. Previous concerns about seed staleness and type conversions have been addressed through discussion. The only remaining issue is a minor code style violation (inline author comment)
  • No files require special attention - the changes are straightforward and well-tested

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp Captures skirmish seed before clearGameData to preserve it for restart, fixing replay mismatch bug
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp Identical change to Generals variant - captures skirmish seed before clearGameData to preserve it for restart

Last reviewed commit: c7bd0e9

Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@Caball009
Copy link
Author
Caball009 commented Feb 8, 2026

I did find a single case where the game would start a new GAME_SINGLE_PLAYER game bit without using a non-zero seed value. I've added that to this PR for more consistent seed values.

@Caball009 Caball009 force-pushed the fix_bug_skirmish_restart_seed_values branch from 6dacb8a to 45fa3ea Compare February 9, 2026 01:49
@Caball009 Caball009 changed the title bugfix(skirmish): Avoid mismatches for restarted skirmish games bugfix(skirmish): Set consistent seed value for skirmish games to prevent mismatches for restarted skirmish games Feb 9, 2026
@Caball009
Copy link
Author
Caball009 commented Feb 9, 2026

EDIT: Maybe I didn't properly explain what I documented here. The findings below explain how the seed value is set for different game modes. I noted the execution flow with the current changes of this PR. TheGameInfo ... && TheSkirmishGameInfo ... indicate what the values of these globals are inside the restartMissionMenu function.

Here are the results of my testing with this PR:

1. Campaign (GAME_SINGLE_PLAYER):
Start: doGameStart -> InitRandom( 0 )
Restart: restartMissionMenu -> InitRandom( (gameMode == GAME_SKIRMISH) ? TheSkirmishGameInfo->getSeed() : 0 )
TheGameInfo == nullptr && TheSkirmishGameInfo == nullptr

2. Challenges (GAME_SINGLE_PLAYER):
Start: ChallengeMenuSystem -> InitRandom( 0 )
Restart: restartMissionMenu -> InitRandom( (gameMode == GAME_SKIRMISH) ? TheSkirmishGameInfo->getSeed() : 0 )
TheGameInfo != nullptr && TheSkirmishGameInfo == nullptr

3. Skirmish, single player map / scenario (GAME_SINGLE_PLAYER):
Start: reallyDoStart -> InitGameLogicRandom( 0 )
Restart: restartMissionMenu -> InitRandom( (gameMode == GAME_SKIRMISH) ? TheSkirmishGameInfo->getSeed() : 0 )
TheGameInfo == nullptr && TheSkirmishGameInfo == nullptr

4. Skirmish, multiplayer map (GAME_SKIRMISH):
Start: reallyDoStart -> InitGameLogicRandom( TheSkirmishGameInfo->getSeed() )
Restart: restartMissionMenu -> InitRandom( (gameMode == GAME_SKIRMISH) ? TheSkirmishGameInfo->getSeed() : 0 )
TheGameInfo != nullptr && TheSkirmishGameInfo != nullptr

@Caball009
Copy link
Author
Caball009 commented Feb 9, 2026

If we're ever to enable replays for campaign / challenge / single player scenarios, we may need to verify that this issue doesn't happen there as well. I don't see anything that could still present an issue in that regard, though.

@Caball009 Caball009 changed the title bugfix(skirmish): Set consistent seed value for skirmish games to prevent mismatches for restarted skirmish games bugfix(skirmish): Set consistent seed values for skirmish games to prevent mismatches for restarted skirmish games Feb 9, 2026
Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Caball009 Caball009 force-pushed the fix_bug_skirmish_restart_seed_values branch from 3208aa9 to 4b6d3dc Compare February 9, 2026 19:34
Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
4D24 @xezon xezon left a comment

Choose a reason for hiding this comment

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

Looks like this is correct then.

@Caball009
Copy link
Author
Caball009 commented Feb 15, 2026

I expect to update this PR in a couple of days.

Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Caball009 Caball009 force-pushed the fix_bug_skirmish_restart_seed_values branch from 5a53659 to 096d621 Compare February 17, 2026 20:59
@Caball009
Copy link
Author

Replicated in Generals, and ready to be merged, I 4D1C think.

Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour labels Feb 18, 2026
@xezon xezon added this to the Major bug fixes milestone Feb 18, 2026
@xezon xezon changed the title bugfix(skirmish): Set consistent seed values for skirmish games to prevent mismatches for restarted skirmish games bugfix(skirmish): Prevent mismatch in Replay playback by restoring correct game seed after restarting a Skirmish game Feb 18, 2026
Copy link
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@xezon xezon merged commit 862422d into TheSuperHackers:main Feb 21, 2026
24 checks passed
4D1C
@Caball009 Caball009 deleted the fix_bug_skirmish_restart_seed_values branch February 21, 2026 22:03
CookieLandProjects pushed a commit to CookieLandProjects/CLP_AI that referenced this pull request Feb 28, 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 Major Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replay will mismatch 100% when Skirmish Game is recorded after RESTART GAME

2 participants

0