From: John Hodge Date: Sun, 27 Sep 2009 06:03:02 +0000 (+0800) Subject: Added catch for when rand() sticks X-Git-Tag: rel0.06~458 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e4b700d576ea9155c3fc86b0c57869a224851954;p=tpg%2Facess2.git Added catch for when rand() sticks --- diff --git a/Kernel/lib.c b/Kernel/lib.c index b69bdd0b..88dc90c4 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -8,6 +8,7 @@ #define RANDOM_SEED 0xACE55052 #define RANDOM_A 0x00731ADE #define RANDOM_C 12345 +#define RANDOM_SPRUCE 0xf12b02b // Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; #define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years @@ -325,7 +326,11 @@ Uint rand() randomState ^= 0x9A3C5E78; return ret; #else + Uint old = giRandomState; giRandomState = (RANDOM_A*giRandomState + RANDOM_C) & 0xFFFFFFFF; + if(giRandomState == old) { + giRandomState += RANDOM_SPRUCE; + } Log("giRandomState = 0x%x", giRandomState); return giRandomState; #endif