From dae7587ec0117cc32fbe4cfc46d974e9a1f29cf7 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 14 Jan 2007 10:09:16 +0000 Subject: [PATCH] patch from div0 that adds sv_random_seed for benchmarking servers with bots the same way repeatedly git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6693 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 7 ++++++- sv_main.c | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/host.c b/host.c index 2a26253c..f72a7e09 100644 --- 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(); diff --git a/sv_main.c b/sv_main.c index 77092df8..2b90a6e3 100644 --- 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; -- 2.39.2