Skip to content

Comments

fix: Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds#2339

Open
Caball009 wants to merge 4 commits intoTheSuperHackers:mainfrom
Caball009:fix_consistent_seed_values
Open

fix: Replace InitGameLogicRandom with InitRandom for consistent client and audio seeds#2339
Caball009 wants to merge 4 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

Refactors random seed initialization by removing InitGameLogicRandom and consolidating to InitRandom, which sets all three seed types (logic, client, audio) for better consistency.

Critical Issue:

  • GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp still calls the removed InitGameLogicRandom function, causing a compilation error

Changes Made:

  • Removed InitGameLogicRandom function declaration and implementation
  • Updated 6 call sites across GeneralsMD to use InitRandom
  • Cleaned up commented-out code in Recorder.cpp and MapSelectMenu.cpp

Confidence Score: 0/5

  • This PR will fail to compile due to missing function updates
  • The function declaration was removed from the header but one call site in GameSpyGameInfo.cpp was not updated, resulting in undefined function compilation error. While the changes that were made are correct, the incomplete refactoring makes this PR not mergeable.
  • GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp (not in this PR) requires immediate update before merge

Important Files Changed

Filename Overview
Core/GameEngine/Include/Common/RandomValue.h Removed declaration of InitGameLogicRandom, clean header change
Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp Updated call from InitGameLogicRandom to InitRandom, correct implementation
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Updated both calls from InitGameLogicRandom to InitRandom, correct implementation

Last reviewed commit: f6aa7d2

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.


void InitGameLogicRandom( UnsignedInt seed )
{
#ifdef DETERMINISTIC

Choose a reason for hiding this comment

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

Do we use this?

Copy link
Author

@Caball009 Caball009 Feb 21, 2026

Choose a reason for hiding this comment

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

I don't think so, though I use that macro when testing sometimes to reduce the chances for run-to-run variance.

/// @todo: when Campaign & skirmish are separated, make campaign have fixed seed and skirmish random.
InitRandom(0);
/*
if (TheGlobalData->m_fixedSeed >= 0)
Copy link

Choose a reason for hiding this comment

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

Considering the todo above, do skirmish games have a random seed? Wondering if the comment can be removed?

Copy link
Author

Choose a reason for hiding this comment

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

Considering the todo above, do skirmish games have a random seed?

Skirmish multiplayer maps have a random seed, skirmish single player maps / scenarios do not.

Copy link

Choose a reason for hiding this comment

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

might be good to cleanup the todo aswell if it's not relevant

Copy link
Author

Choose a reason for hiding this comment

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

It's not entirely clear to me if this todo is completely done, but it looks that way so I'll remove the comment.

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

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.

3 participants