From a38d6be18b089a1c04039ca7095a80f0529c45a3 Mon Sep 17 00:00:00 2001 From: Sylae Corell Date: Sat, 19 Oct 2013 14:39:10 -0600 Subject: [PATCH] Fixing a bug with the redone PRNG Under the current system, it would have failed to be random if two calls were made during the same msec. It will now throw in the previous rand() in the new seed, which should prevent duplicates (although the next seed in the same msec will be predictable, it's not like we need to be cryptographically secure here) --- Blades of Exile/tools/mathutil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Blades of Exile/tools/mathutil.cpp b/Blades of Exile/tools/mathutil.cpp index fc732792..9e809e40 100644 --- a/Blades of Exile/tools/mathutil.cpp +++ b/Blades of Exile/tools/mathutil.cpp @@ -18,7 +18,7 @@ short get_ran (short times,short min,short max){ if(max < min) max = min; for (i = 1; i < times + 1; i++) { - srand(GetTickCount()); + srand(GetTickCount() + rand()); store = rand(); to_ret += min + (store % (max - min + 1));//min + (((store + 32767) * (max - min + 1)) / 65536); }