diff options
author | Nay <dnpd.dd@gmail.com> | 2012-10-07 12:55:51 +0100 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2012-10-07 12:55:51 +0100 |
commit | 99175e066cf6db38853b5d7cb5b08a8e0bd8be24 (patch) | |
tree | 3cf88d1d82aa7230bca7e333a505778f0632a6d4 /src/server/shared/Utilities/Util.cpp | |
parent | 26b998d94c9b10d147712920dbf84cb75556979b (diff) |
Core/Utils: Add asserts to irand, urand and frand
max should always be higher or equal than min
notice that SFMT was already covering these cases and it would return 0, -1 or min
Diffstat (limited to 'src/server/shared/Utilities/Util.cpp')
-rwxr-xr-x | src/server/shared/Utilities/Util.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 9778e86d444..0897c8814ab 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -28,16 +28,19 @@ static SFMTRandTSS sfmtRand; int32 irand(int32 min, int32 max) { + assert(max >= min); return int32(sfmtRand->IRandom(min, max)); } uint32 urand(uint32 min, uint32 max) { + assert(max >= min); return sfmtRand->URandom(min, max); } float frand(float min, float max) { + assert(max >= min); return float(sfmtRand->Random() * (max - min) + min); } |