]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
patch from div0 that adds sv_random_seed for benchmarking servers with bots the same...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 10:09:16 +0000 (10:09 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 10:09:16 +0000 (10:09 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6693 d7cf8633-e32d-0410-b094-e92efae38249

host.c
sv_main.c

diff --git a/host.c b/host.c
index 2a26253cb8fb24efc973f93c491f9d48741b48b3..f72a7e097fb302e51a0b7a4ef4b74dab1edb0d4e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -52,6 +52,9 @@ client_t *host_client;
 
 jmp_buf host_abortframe;
 
+// random seed
+cvar_t sv_random_seed = {0, "sv_random_seed", "", "random seed; when set, on every map start this random seed is used to initialize the random number generator. Don't touch it unless for benchmarking or debugging"};
+
 // pretend frames take this amount of time (in seconds), 0 = realtime
 cvar_t host_framerate = {0, "host_framerate","0", "locks frame timing to this value in seconds, 0.05 is 20fps for example, note that this can easily run too fast, use host_maxfps if you want to limit your framerate instead, or sys_ticrate to limit server speed"};
 // shows time used by certain subsystems
@@ -219,6 +222,7 @@ static void Host_InitLocal (void)
        Cmd_AddCommand("saveconfig", Host_SaveConfig_f, "save settings to config.cfg immediately (also automatic when quitting)");
        Cmd_AddCommand("loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
 
+       Cvar_RegisterVariable (&sv_random_seed);
        Cvar_RegisterVariable (&host_framerate);
        Cvar_RegisterVariable (&host_speeds);
        Cvar_RegisterVariable (&slowmo);
@@ -619,7 +623,8 @@ void Host_Main(void)
                }
 
                // keep the random time dependent
-               rand();
+               if(!*sv_random_seed.string)
+                       rand();
 
                cl.islocalgame = NetConn_IsLocalGame();
 
index 77092df80904d6a539197a95b5a88611e33df6c2..2b90a6e3933afbc054afc2e2cac324bcde53cea2 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -37,6 +37,8 @@ cvar_t sv_protocolname = {0, "sv_protocolname", "DP7", "selects network protocol
 cvar_t sv_ratelimitlocalplayer = {0, "sv_ratelimitlocalplayer", "0", "whether to apply rate limiting to the local player in a listen server (only useful for testing)"};
 cvar_t sv_maxrate = {CVAR_SAVE | CVAR_NOTIFY, "sv_maxrate", "10000", "upper limit on client rate cvar, should reflect your network connection quality"};
 
+extern cvar_t sv_random_seed;
+
 static cvar_t sv_cullentities_pvs = {0, "sv_cullentities_pvs", "1", "fast but loose culling of hidden entities"}; // fast but loose
 static cvar_t sv_cullentities_trace = {0, "sv_cullentities_trace", "0", "somewhat slow but very tight culling of hidden entities, minimizes network traffic and makes wallhack cheats useless"}; // tends to get false negatives, uses a timeout to keep entities visible a short time after becoming hidden
 static cvar_t sv_cullentities_stats = {0, "sv_cullentities_stats", "0", "displays stats on network entities culled by various methods for each client"};
@@ -1743,6 +1745,12 @@ void SV_SpawnServer (const char *server)
        // level's data which is no longer valiud
        cls.signon = 0;
 
+       if(*sv_random_seed.string)
+       {
+               srand(sv_random_seed.integer);
+               Con_Printf("NOTE: random seed is %d; use for debugging/benchmarking only!\nUnset sv_random_seed to get real random numbers again.\n", sv_random_seed.integer);
+       }
+
        SV_VM_Setup();
 
        sv.active = true;