X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=sv_main.c;h=d1c9e71c99085e02cbdc7112d42ef66ffc2b62c7;hb=54c8d13c76444ca7e9d3f65229b5638cc67c3db5;hp=b5186eca8072388e3952170a76e66af4a88fa1b8;hpb=aacd9507d824694ed13d9ba8c5c33c3aba87ab63;p=xonotic%2Fdarkplaces.git diff --git a/sv_main.c b/sv_main.c index b5186eca..d1c9e71c 100644 --- a/sv_main.c +++ b/sv_main.c @@ -205,6 +205,8 @@ cvar_t halflifebsp = {CF_SERVER, "halflifebsp", "0", "indicates the current map cvar_t sv_mapformat_is_quake2 = {CF_SERVER, "sv_mapformat_is_quake2", "0", "indicates the current map is q2bsp format (useful to know because of different entity behaviors, .frame on submodels and other things)"}; cvar_t sv_mapformat_is_quake3 = {CF_SERVER, "sv_mapformat_is_quake3", "0", "indicates the current map is q2bsp format (useful to know because of different entity behaviors)"}; +cvar_t sv_writepicture_quality = {CF_SERVER | CF_ARCHIVE, "sv_writepicture_quality", "10", "WritePicture quality offset (higher means better quality, but slower)"}; + server_t sv; server_static_t svs; @@ -432,30 +434,6 @@ static void SV_AreaStats_f(cmd_state_t *cmd) World_PrintAreaStats(&sv.world, "server"); } -static qbool SV_CanSave(void) -{ - prvm_prog_t *prog = SVVM_prog; - if(SV_IsLocalServer() == 1) - { - // singleplayer checks - if ((svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag))) - { - Con_Print("Can't savegame with a dead player\n"); - return false; - } - - if(host.hook.CL_Intermission && host.hook.CL_Intermission()) - { - Con_Print("Can't save in intermission.\n"); - return false; - } - } - else - Con_Print(CON_WARN "Warning: saving a multiplayer game may have strange results when restored (to properly resume, all players must join in the same player slots and then the game can be reloaded).\n"); - return true; - -} - static void SV_ServerOptions (void) { int i; @@ -548,8 +526,8 @@ void SV_Init (void) Cvar_RegisterVariable (&skill); Cvar_RegisterVariable (&host_timescale); Cvar_RegisterCallback (&host_timescale, Host_Timescale_c); - Cvar_RegisterAlias (&host_timescale, "slowmo"); - Cvar_RegisterAlias (&host_timescale, "timescale"); + Cvar_RegisterVirtual (&host_timescale, "slowmo"); + Cvar_RegisterVirtual (&host_timescale, "timescale"); Cvar_RegisterVariable (&sv_accelerate); Cvar_RegisterVariable (&sv_aim); Cvar_RegisterVariable (&sv_airaccel_qw); @@ -640,7 +618,7 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_protocolname); Cvar_RegisterVariable (&sv_random_seed); Cvar_RegisterVariable (&host_limitlocal); - Cvar_RegisterAlias(&host_limitlocal, "sv_ratelimitlocalplayer"); + Cvar_RegisterVirtual(&host_limitlocal, "sv_ratelimitlocalplayer"); Cvar_RegisterVariable (&sv_sound_land); Cvar_RegisterVariable (&sv_sound_watersplash); Cvar_RegisterVariable (&sv_stepheight); @@ -705,12 +683,15 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_mapformat_is_quake2); Cvar_RegisterVariable (&sv_mapformat_is_quake3); + Cvar_RegisterVariable (&sv_writepicture_quality); + SV_InitOperatorCommands(); - host.hook.SV_CanSave = SV_CanSave; + host.hook.SV_Shutdown = SV_Shutdown; sv_mempool = Mem_AllocPool("server", 0, NULL); SV_ServerOptions(); + Cvar_Callback(&sv_netport); } static void SV_SaveEntFile_f(cmd_state_t *cmd) @@ -2078,10 +2059,12 @@ void SV_Shutdown(void) prvm_prog_t *prog = SVVM_prog; int i; - Con_DPrintf("SV_Shutdown\n"); + SV_LockThreadMutex(); if (!sv.active) - return; + goto end; + + Con_DPrintf("SV_Shutdown\n"); NetConn_Heartbeat(2); NetConn_Heartbeat(2); @@ -2110,8 +2093,8 @@ void SV_Shutdown(void) // memset(&sv, 0, sizeof(sv)); memset(svs.clients, 0, svs.maxclients*sizeof(client_t)); - - cl.islocalgame = false; +end: + SV_UnlockThreadMutex(); } ///////////////////////////////////////////////////// @@ -2269,7 +2252,7 @@ static qbool SVVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent) static void SV_VM_Setup(void) { prvm_prog_t *prog = SVVM_prog; - PRVM_Prog_Init(prog, cmd_server); + PRVM_Prog_Init(prog, cmd_local); // allocate the mempools // TODO: move the magic numbers/constants into #defines [9/13/2006 Black] @@ -2465,12 +2448,28 @@ static void SV_CheckTimeouts(void) { if (host_client->netconnection && host.realtime > host_client->netconnection->timeout) { - Con_Printf("Client \"%s\" connection timed out\n", host_client->name); + if (host_client->begun) + SV_BroadcastPrintf("Client \"%s\" connection timed out\n", host_client->name); + else + Con_Printf("Client \"%s\" connection timed out\n", host_client->name); + SV_DropClient(false); } } } +/* +================== +SV_TimeReport + +Returns a time report string, for example for +================== +*/ +const char *SV_TimingReport(char *buf, size_t buflen) +{ + return va(buf, buflen, "%.1f%% CPU, %.2f%% lost, offset avg %.1fms, max %.1fms, sdev %.1fms", svs.perf_cpuload * 100, svs.perf_lost * 100, svs.perf_offset_avg * 1000, svs.perf_offset_max * 1000, svs.perf_offset_sdev * 1000); +} + extern cvar_t host_maxwait; extern cvar_t host_framerate; extern cvar_t cl_maxphysicsframesperserverframe; @@ -2504,7 +2503,7 @@ double SV_Frame(double time) } if(svs.perf_lost > 0 && developer_extra.integer && playing) // only complain if anyone is looking - Con_DPrintf("Server can't keep up: %s\n", Host_TimingReport(vabuf, sizeof(vabuf))); + Con_DPrintf("Server can't keep up: %s\n", SV_TimingReport(vabuf, sizeof(vabuf))); } if(svs.perf_acc_realtime > 5 || sv.time < 10) @@ -2700,7 +2699,7 @@ static int SV_ThreadFunc(void *voiddata) } if(svs.perf_lost > 0 && developer_extra.integer) if(playing) - Con_DPrintf("Server can't keep up: %s\n", Host_TimingReport(vabuf, sizeof(vabuf))); + Con_DPrintf("Server can't keep up: %s\n", SV_TimingReport(vabuf, sizeof(vabuf))); svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = 0; }