From a1e3b54e076bf0361d23ace53703a4e501354d7c Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 21 Mar 2017 21:04:01 +0100 Subject: 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 --- src/common/Utilities/Random.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/common/Utilities/Random.h') 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) { -- cgit v1.2.3