diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-10-31 20:20:00 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-10-31 20:20:00 +0100 |
commit | 9894f6b802c974bb36acd7fbb0d083455a1f0f1b (patch) | |
tree | 458f167a846d70d4b2391c805423d9342b36f89a /src/common/Utilities/Random.h | |
parent | a0fdac0ecc119b4ba85d41f86891b3cd35f7acde (diff) |
Core/Random: Changed random functions returning doubles to return floats
* They were all cast to float at use anyway
* Improves roll_chance_f performance (rand32() is now called internally by uniform_real_distribution once instead of twice)
Diffstat (limited to 'src/common/Utilities/Random.h')
-rw-r--r-- | src/common/Utilities/Random.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/Utilities/Random.h b/src/common/Utilities/Random.h index 82a498e42eb..c658c477ab1 100644 --- a/src/common/Utilities/Random.h +++ b/src/common/Utilities/Random.h @@ -40,11 +40,11 @@ TC_COMMON_API Milliseconds randtime(Milliseconds min, Milliseconds max); /* Return a random number in the range min..max */ TC_COMMON_API float frand(float min, float max); -/* Return a random double from 0.0 to 1.0 (exclusive). */ -TC_COMMON_API double rand_norm(); +/* Return a random float from 0.0 to 1.0 (exclusive). */ +TC_COMMON_API float rand_norm(); -/* Return a random double from 0.0 to 100.0 (exclusive). */ -TC_COMMON_API double rand_chance(); +/* Return a random float from 0.0 to 100.0 (exclusive). */ +TC_COMMON_API float rand_chance(); /* Return a random number in the range 0..count (exclusive) with each value having a different chance of happening */ TC_COMMON_API uint32 urandweighted(size_t count, double const* chances); |