]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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 5539c70cdc7db25b57f626cccd1fd1d00802a8ed..ce5f95d793bfb10669a4c36c97e0918258f8e6f3 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 aea36ef34baa8c75ec845f99f4faf83bf820c491..13cd059127f4ef97f4f95fbae09d9c0b6259e92a 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)