Skip to content

tweak(random): Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds#2339

Merged
xezon merged 6 commits intoTheSuperHackers:mainfrom
Caball009:fix_consistent_seed_values
Feb 28, 2026
Merged

tweak(random): Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds#2339
xezon merged 6 commits intoTheSuperHackers:mainfrom
Caball009:fix_consistent_seed_values

Conversation

@Caball009
Copy link

@Caball009 Caball009 commented Feb 21, 2026

This PR removes function InitGameLogicRandom, and changes all use cases to InitRandom. The former only sets the logical seed values (important for the CRC), while the latter also sets the client and audio seed values. I think setting all 3 types of seed values improves consistency. This change is not user-facing.

I checked 2000+ of Joker's (short) replays and this change did not introduce any new mismatches, as expected.

TODO:

  • Replicate in Generals.

@Caball009 Caball009 added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Fix Is fixing something, but is not user facing labels Feb 21, 2026
@Caball009 Caball009 marked this pull request as ready for review February 21, 2026 22:36
@greptile-apps
Copy link

greptile-apps bot commented Feb 21, 2026

Greptile Summary

This PR successfully removes the InitGameLogicRandom function and replaces all use cases with InitRandom to ensure consistent initialization of all three random seed types (logic, client, and audio). The changes are well-contained and properly update all modified files:

  • Removed function declaration and implementation from RandomValue.h/cpp
  • Updated calls in network callbacks (StagingRoomGameInfo.cpp, LANAPICallbacks.cpp)
  • Updated calls in GUI callbacks across both Generals and GeneralsMD directories
  • Cleaned up obsolete commented-out code referencing the old function

The author verified no new replay mismatches were introduced across 2000+ replays, demonstrating the change maintains deterministic behavior.

Confidence Score: 5/5

  • Safe to merge once the previously flagged compilation issue is resolved
  • Clean refactoring with consistent replacements across all modified files, verified with 2000+ replay tests. The previous review already identified the remaining issue in GameSpyGameInfo.cpp files.
  • As noted in previous review, Generals/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp and GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp still reference InitGameLogicRandom

Important Files Changed

Filename Overview
Core/GameEngine/Include/Common/RandomValue.h Removed InitGameLogicRandom function declaration
Core/GameEngine/Source/Common/RandomValue.cpp Removed InitGameLogicRandom function implementation (16 lines)
Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp Replaced InitGameLogicRandom with InitRandom for seed initialization
Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp Replaced InitGameLogicRandom with InitRandom for seed initialization
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Replaced two InitGameLogicRandom calls with InitRandom for skirmish and single-player modes
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Replaced two InitGameLogicRandom calls with InitRandom for skirmish and single-player modes

Last reviewed commit: a7ba441

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.

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Feb 21, 2026

Additional Comments (1)

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp
This file still calls InitGameLogicRandom which was removed in this PR, causing a compilation error

		InitRandom( TheGameSpyGame->getSeed() );
		DEBUG_LOG(("InitRandom( %d )", TheGameSpyGame->getSeed()));
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp
Line: 566-567

Comment:
This file still calls `InitGameLogicRandom` which was removed in this PR, causing a compilation error

```suggestion
		InitRandom( TheGameSpyGame->getSeed() );
		DEBUG_LOG(("InitRandom( %d )", TheGameSpyGame->getSeed()));
```

How can I resolve this? If you propose a fix, please make it concise.

@Mauller
Copy link

Mauller commented Feb 21, 2026

Broke da build! but looks like it's due to core files being altered :P

@Caball009
Copy link
Author

Caball009 commented Feb 21, 2026

Yes, Generals isn't updated yet but the core files are, so that project won't compile.

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.

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@xezon
Copy link

xezon commented Feb 27, 2026

I think setting all 3 types of seed values improves consistency

So if I understand this correctly, then this means Client and Audio now also have random seeding on every match start, whereas before they just kept evolving from match to match? Could there be any reason why EA chose to do that intentionally?

@xezon xezon changed the title fix: Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds tweak(random): Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds Feb 27, 2026
Copy link

@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.

I do not know what this is good for but looks okay anyway. Needs Rebase and Replicate.

@Caball009
Copy link
Author

Caball009 commented Feb 27, 2026

So if I understand this correctly, then this means Client and Audio now also have random seeding on every match start, whereas before they just kept evolving from match to match?

Yes.

Could there be any reason why EA chose to do that intentionally?

Not that I can see. If you check the code for the replays, you can see that they started to use InitRandom. That makes me more confident that we should also do that for live games.

I do not know what this is good for but looks okay anyway. Needs Rebase and Replicate.

Will update later.

@xezon xezon merged commit 88d7df3 into TheSuperHackers:main Feb 28, 2026
25 checks passed
@Caball009 Caball009 deleted the fix_consistent_seed_values branch February 28, 2026 12:18
Okladnoj pushed a commit to Okladnoj/GeneralsGameCode that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants