From 792ab1b7bc1bf5bb59282d791eca95d2b16a2d7f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 21 Sep 2013 19:18:06 +0000 Subject: [PATCH] attempt to fix oos related to random number generation --- source/shared_lib/sources/util/randomgen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/shared_lib/sources/util/randomgen.cpp b/source/shared_lib/sources/util/randomgen.cpp index 4604be6c8..ad44c9c80 100644 --- a/source/shared_lib/sources/util/randomgen.cpp +++ b/source/shared_lib/sources/util/randomgen.cpp @@ -15,9 +15,12 @@ #include "util.h" #include #include "platform_util.h" +#include "math_util.h" #include "leak_dumper.h" using namespace std; +using namespace Shared::Graphics; + namespace Shared { namespace Util { // ===================================================== @@ -71,7 +74,7 @@ int RandomGen::randRange(int min, int max){ // int res = streflop::Random(min, max); // streflop //#else int diff= max-min; - int res= min + static_cast(static_cast(diff+1)*RandomGen::rand() / m); + int res= min + static_cast(truncateDecimal(static_cast(diff+1))*RandomGen::rand() / m); //#endif assert(res>=min && res<=max); if(res < min || res > max) { @@ -98,6 +101,7 @@ float RandomGen::randRange(float min, float max){ //#else float rand01= static_cast(RandomGen::rand())/(m-1); float res= min+(max-min)*rand01; + res = truncateDecimal(res); //#endif assert(res>=min && res<=max);