3232#include " Common/RandomValue.h"
3333#include " Common/crc.h"
3434#include " Common/Debug.h"
35+ #include " Common/CRCDebug.h"
3536#include " GameLogic/GameLogic.h"
3637
3738#undef DEBUG_RANDOM_AUDIO
@@ -115,6 +116,9 @@ void InitRandom()
115116
116117void InitRandom ( UnsignedInt seed )
117118{
119+ #ifdef DEBUG_CRC
120+ CRCGEN_LOG ((" InitRandom called with seed: %u" , seed));
121+ #endif
118122#ifdef DETERMINISTIC
119123 seed = 0 ;
120124#endif
@@ -124,6 +128,10 @@ void InitRandom( UnsignedInt seed )
124128 seedRandom (seed, theGameLogicSeed);
125129 theGameLogicBaseSeed = seed;
126130
131+ if (g_logRandom)
132+ {
133+ addCRCRandomLine (" InitRandom %08lx" , seed);
134+ }
127135#ifdef DEBUG_RANDOM_LOGIC
128136 DEBUG_LOG ((" InitRandom %08lx" , seed));
129137#endif
@@ -280,6 +288,10 @@ Int GetGameLogicRandomValue( int lo, int hi, const char *file, int line )
280288
281289 const Int rval = ((Int)(randomValue (theGameLogicSeed) % delta)) + lo;
282290
291+ if (g_logRandom)
292+ {
293+ addCRCRandomLine (" %d: GetGameLogicRandomValue = %d (%d - %d), %s line %d" , TheGameLogic ? TheGameLogic->getFrame () : -1 , rval, lo, hi, file, line);
294+ }
283295#ifdef DEBUG_RANDOM_LOGIC
284296 DEBUG_LOG (( " %d: GetGameLogicRandomValue = %d (%d - %d), %s line %d" ,
285297 TheGameLogic->getFrame (), rval, lo, hi, file, line ));
@@ -307,6 +319,10 @@ Real GetGameLogicRandomValueReal( Real lo, Real hi, const char *file, int line )
307319
308320 const Real rval = ((Real)(randomValue (theGameLogicSeed)) * theMultFactor) * delta + lo;
309321
322+ if (g_logRandom)
323+ {
324+ addCRCRandomLine (" %d: GetGameLogicRandomValueReal = %f, %s line %d" , TheGameLogic ? TheGameLogic->getFrame () : -1 , rval, file, line);
325+ }
310326#ifdef DEBUG_RANDOM_LOGIC
311327 DEBUG_LOG (( " %d: GetGameLogicRandomValueReal = %f, %s line %d" ,
312328 TheGameLogic->getFrame (), rval, file, line ));
@@ -337,6 +353,10 @@ Int GetGameLogicRandomValueUnchanged( int lo, int hi, const char *file, int line
337353 const UnsignedInt delta = hi - lo + 1 ;
338354 const Int rval = ((Int)(randomValue (seed) % delta)) + lo;
339355
356+ if (g_logRandom)
357+ {
358+ addCRCRandomLine (" %d: GetGameLogicRandomValueUnchanged = %d (%d - %d), %s line %d" , TheGameLogic ? TheGameLogic->getFrame () : -1 , rval, lo, hi, file, line);
359+ }
340360#ifdef DEBUG_RANDOM_LOGIC
341361 DEBUG_LOG (( " %d: GetGameLogicRandomValueUnchanged = %d (%d - %d), %s line %d" ,
342362 TheGameLogic->getFrame (), rval, lo, hi, file, line ));
@@ -367,6 +387,10 @@ Real GetGameLogicRandomValueRealUnchanged( Real lo, Real hi, const char *file, i
367387 const Real delta = hi - lo;
368388 const Real rval = ((Real)(randomValue (seed)) * theMultFactor) * delta + lo;
369389
390+ if (g_logRandom)
391+ {
392+ addCRCRandomLine (" %d: GetGameLogicRandomValueRealUnchanged = %f, %s line %d" , TheGameLogic ? TheGameLogic->getFrame () : -1 , rval, file, line);
393+ }
370394#ifdef DEBUG_RANDOM_LOGIC
371395 DEBUG_LOG (( " %d: GetGameLogicRandomValueRealUnchanged = %f, %s line %d" ,
372396 TheGameLogic->getFrame (), rval, file, line ));
0 commit comments