diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-03-21 21:04:01 +0100 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-06-03 02:20:50 -0300 |
commit | ff39c27104634c9f1d37a0625eb78461e34c77a0 (patch) | |
tree | 413970e966590b0575fc7ad97f1c9a339cec4d7c /src/common/Utilities/Random.h | |
parent | d6fbe994325ea6b23d144562245e749115700996 (diff) |
Core/Utils: Changed all Trinity::Containers utilities to work on all container types (including arrays where it makes sense)
* Added MapGetValuePtr to allow writing `if (Val* v = MapGetValuePtr(map, key))`
* Added utility IteratorPair class with begin/end methods and MapEqualRange for use in range for syntax with multimaps
(cherry picked from commit a1e3b54e076bf0361d23ace53703a4e501354d7c)
Diffstat (limited to 'src/common/Utilities/Random.h')
-rw-r--r-- | src/common/Utilities/Random.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/Utilities/Random.h b/src/common/Utilities/Random.h index 94a36db42f6..ded0a6c6e5c 100644 --- a/src/common/Utilities/Random.h +++ b/src/common/Utilities/Random.h @@ -47,6 +47,9 @@ TC_COMMON_API double rand_norm(); /* Return a random double from 0.0 to 100.0 (exclusive). */ TC_COMMON_API double 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); + /* Return true if a random roll fits in the specified chance (range 0-100). */ inline bool roll_chance_f(float chance) { |