-
Notifications
You must be signed in to change notification settings - Fork 618
Fix RNG used by cosmetics editor to use same RNG method as rando #5979
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
base: develop
Are you sure you want to change the base?
Fix RNG used by cosmetics editor to use same RNG method as rando #5979
Conversation
| state = seed; | ||
| } | ||
|
|
||
| uint32_t ShipUtils_next32() { |
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.
ideally random.cpp core functions would change to taking state as parameter, then these endpoints with globals could pass those into the core function
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.
Yeah if we want to shift Rando over to these funcs as well that's what I would do, trying to decide if that's in-scope for right now or not. I guess if I'm doing this on develop instead of dev-copper I might as well go all the way.
| #if !defined(__SWITCH__) && !defined(__WIIU__) | ||
| uint64_t seed = static_cast<uint64_t>(std::random_device{}()); | ||
| #else | ||
| uint64_t seed = static_cast<uint64_t>(std::hash<std::string>{}(std::to_string(rand()))); |
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.
| uint64_t seed = static_cast<uint64_t>(std::hash<std::string>{}(std::to_string(rand()))); | |
| uint64_t seed = static_cast<uint64_t>(rand()); |
Beyond this PR's scope, but we should go ahead & rely on rand without the string-then-hash song & dance
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.
If this was on dev-copper instead of dev I'd say it's probably out of scope but since its on dev I might as well go ahead and make the bigger changes, so I'm thinking this is maybe not quite out of scope after all.
Apparently,
std::random_deviceis not properly non-deterministic on certain situations where rng hardware is not accessible or something like that. I recently bumped into this with a Linux distro on my gaming desktop. So I essentially copied the randomizer rng to ShipUtils so I could use it for the Cosmetics Editor (withstd::random_deviceit was always generating every color to the same dark blue color). It is a copy of the same functionality, it does not use the same seeds/state variables so randomizing cosmetics won't effect randomizer seed generation and vice/versa.Build Artifacts