From 99175e066cf6db38853b5d7cb5b08a8e0bd8be24 Mon Sep 17 00:00:00 2001 From: Nay Date: Sun, 7 Oct 2012 12:55:51 +0100 Subject: 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 --- src/server/shared/Utilities/Util.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/server/shared/Utilities/Util.cpp') 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); } -- cgit v1.2.3