make timedemo and -benchmark use srand(0) to get more predictable results
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 30 Mar 2007 08:48:11 +0000 (08:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 30 Mar 2007 08:48:11 +0000 (08:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7030 d7cf8633-e32d-0410-b094-e92efae38249

cl_demo.c
host.c

index 5539c70..ce5f95d 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -421,6 +421,8 @@ void CL_TimeDemo_f (void)
                return;
        }
 
+       srand(0); // predictable random sequence for benchmarking
+
        CL_PlayDemo_f ();
 
 // cls.td_starttime will be grabbed at the second frame of the demo, so
diff --git a/host.c b/host.c
index aea36ef..13cd059 100644 (file)
--- a/host.c
+++ b/host.c
@@ -613,8 +613,8 @@ void Host_Main(void)
                if (cl_maxfps.value < 1)
                        Cvar_SetValue("cl_maxfps", 1);
 
-               // keep the random time dependent
-               if(!*sv_random_seed.string)
+               // keep the random time dependent, but not when playing demos/benchmarking
+               if(!*sv_random_seed.string && !cls.demoplayback)
                        rand();
 
                cl.islocalgame = NetConn_IsLocalGame();
@@ -888,7 +888,10 @@ static void Host_Init (void)
        const char* os;
 
        // LordHavoc: quake never seeded the random number generator before... heh
-       srand(time(NULL));
+       if (COM_CheckParm("-benchmark"))
+               srand(0); // predictable random sequence for -benchmark
+       else
+               srand(time(NULL));
 
        // FIXME: this is evil, but possibly temporary
 // COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers)