Fixes to the new SDL_rand capability #10063
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I ran hundreds of core-hours of statistical testing to make sure the LCG constants are not terrible. These 32-bit parameters perform as well as a full 64-bit implementation.
I'm unsure about changing SDL_rand_n to Uint32. Sint32 is probably what users want, but there's gotchas when n is negative. But are people going to miss the 'U' and pass negative numbers anyway? Should switch to Sint32 and add some special logic?
Feel free to revert the one commit that removes SDL_rand_r if you think we really need it. I feel it's too advanced for what we're offering and it would force users to bring their own rand_n and rand_float. (or require us to make SDL_rand_r_n()...)
I also updated the caution statements to explicitly mention things this is not suitable for. I know we say no guarantees about quality, but this implantation is better than many std::rand() implementations. Way better than @slouken's 'demo code only' requirement. This is a good enough solution for 99% of single-player games. Should we soften the warning a bit?
Existing Issue(s)