-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add fixedSeed param to GameSetup and use it to initialize RNG #875
Changes from 2 commits
3822bb9
26c3300
a4ee96f
14ae421
d6af1e9
e324f78
ac6248a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ CR_REG_METADATA(CGameSetup, ( | |
CR_IGNORED(dsMapHash), | ||
CR_IGNORED(dsModHash), | ||
CR_IGNORED(mapSeed), | ||
CR_IGNORED(fixedSeed), | ||
|
||
CR_IGNORED(gameStartDelay), | ||
|
||
|
@@ -180,6 +181,7 @@ void CGameSetup::ResetState() | |
std::memset(dsMapHash, 0, sizeof(dsMapHash)); | ||
std::memset(dsModHash, 0, sizeof(dsModHash)); | ||
mapSeed = 0; | ||
fixedSeed = 0; | ||
|
||
gameStartDelay = 0; | ||
numDemoPlayers = 0; | ||
|
@@ -582,6 +584,7 @@ bool CGameSetup::Init(const std::string& buf) | |
|
||
file.GetTDef(mapSeed, unsigned(0), "GAME\\MapSeed"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like "map seed" exists which makes "fixed seed" not obviously RNG related. Perhaps call it "FixedRNGSeed" or something? Otherwise looks good though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FixedRNGSeed is much more clear. Changing that 🙌 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done 👍 |
||
|
||
file.GetTDef(fixedSeed, unsigned(0), "GAME\\FixedSeed"); // 0 means use random seed | ||
gameID = file.SGetValueDef("", "GAME\\GameID"); | ||
modName = file.SGetValueDef("", "GAME\\Gametype"); | ||
mapName = file.SGetValueDef("", "GAME\\MapName"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,9 +268,13 @@ void CGameServer::Initialize() | |
streflop::streflop_init<streflop::Simple>(); | ||
|
||
if (!demoReader) { | ||
GenerateAndSendGameID(); | ||
rng.Seed(gameID.intArray[0] ^ gameID.intArray[1] ^ gameID.intArray[2] ^ gameID.intArray[3]); | ||
Broadcast(CBaseNetProtocol::Get().SendRandSeed(rng())); | ||
if (myGameSetup->fixedSeed == 0) { | ||
GenerateAndSendGameID(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't gameID be sent regardless? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good find, you're absolutely right this should live outside the condition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed! |
||
rng.Seed(gameID.intArray[0] ^ gameID.intArray[1] ^ gameID.intArray[2] ^ gameID.intArray[3]); | ||
Broadcast(CBaseNetProtocol::Get().SendRandSeed(rng())); | ||
} else { | ||
Broadcast(CBaseNetProtocol::Get().SendRandSeed(myGameSetup->fixedSeed)); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 'benchmarking runs only'? Surely it's useful for things like say reproducible cutscenes in missions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didnt think of that, thats a good use case!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed - check out the new description