X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=host.c;h=6a8c0352b55b85dfc3085ebe8cf4e504fde0f813;hb=14bec1a4c2a0623c08d1e746a023971e311fda36;hp=6994c68cf55bb98b1c4bf1f955d25ddf9e9348d0;hpb=84661191e0819cf88c208b4ad314fcd23e8e1fbd;p=xonotic%2Fdarkplaces.git diff --git a/host.c b/host.c index 6994c68c..6a8c0352 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 @@ -213,10 +216,13 @@ Host_InitLocal ====================== */ void Host_SaveConfig_f(void); +void Host_LoadConfig_f(void); 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); @@ -261,7 +267,7 @@ void Host_SaveConfig_f(void) // dedicated servers initialize the host but don't parse and set the // config.cfg cvars // LordHavoc: don't save a config if it crashed in startup - if (host_framecount >= 3 && cls.state != ca_dedicated) + if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark")) { f = FS_Open ("config.cfg", "wb", false, false); if (!f) @@ -278,6 +284,21 @@ void Host_SaveConfig_f(void) } +/* +=============== +Host_LoadConfig_f + +Resets key bindings and cvars to defaults and then reloads scripts +=============== +*/ +void Host_LoadConfig_f(void) +{ + // unlock the cvar default strings so they can be updated by the new default.cfg + Cvar_UnlockDefaults(); + // reset cvars to their defaults, and then exec startup scripts again + Cbuf_InsertText("cvar_resettodefaults_all;exec quake.rc\n"); +} + /* ================= SV_ClientPrint @@ -329,7 +350,7 @@ void SV_BroadcastPrint(const char *msg) for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++) { - if (client->spawned && client->netconnection) + if (client->active && client->netconnection) { MSG_WriteByte(&client->netconnection->message, svc_print); MSG_WriteString(&client->netconnection->message, msg); @@ -433,11 +454,18 @@ void SV_DropClient(qboolean crash) prog->globals.server->self = saveSelf; } + // if a download is active, close it + if (host_client->download_file) + { + Con_DPrintf("Download of %s aborted when %s dropped\n", host_client->download_name, host_client->name); + FS_Close(host_client->download_file); + host_client->download_file = NULL; + host_client->download_name[0] = 0; + host_client->download_expectedposition = 0; + host_client->download_started = false; + } + // remove leaving player from scoreboard - //host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name); - //if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors))) - // val->_float = 0; - //host_client->edict->fields.server->frags = 0; host_client->name[0] = 0; host_client->colors = 0; host_client->frags = 0; @@ -602,7 +630,8 @@ void Host_Main(void) } // keep the random time dependent - rand(); + if(!*sv_random_seed.string) + rand(); cl.islocalgame = NetConn_IsLocalGame(); @@ -738,10 +767,15 @@ void Host_Main(void) // decide the simulation time if (!cls.timedemo) { - if (cls.capturevideo.active)// && !cls.capturevideo.soundfile) + if (cls.capturevideo.active) { - frametime = 1.0 / cls.capturevideo.framerate; - cl.realframetime = max(cl.realframetime, frametime); + if (cls.capturevideo.realtime) + frametime = cl.realframetime = max(cl.realframetime, 1.0 / cls.capturevideo.framerate); + else + { + frametime = 1.0 / cls.capturevideo.framerate; + cl.realframetime = max(cl.realframetime, frametime); + } } else if (vid_activewindow) frametime = cl.realframetime = max(cl.realframetime, 1.0 / cl_maxfps.value); @@ -936,6 +970,7 @@ static void Host_Init (void) //PR_Cmd_Init(); PRVM_Init(); Mod_Init(); + World_Init(); SV_Init(); Host_InitCommands(); Host_InitLocal();