]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
Revert "Make cdda optional, server does not need to play music" because it
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 3d98c0f38cacb118d32edcbd14d6e6939f59b762..0b97a4547183e3c6675ca0bf4ed550aa38ead26c 100644 (file)
--- a/host.c
+++ b/host.c
@@ -97,6 +97,7 @@ Host_AbortCurrentFrame
 aborts the current host frame and goes on with the next one
 ================
 */
 aborts the current host frame and goes on with the next one
 ================
 */
+void Host_AbortCurrentFrame(void) DP_FUNC_NORETURN;
 void Host_AbortCurrentFrame(void)
 {
        // in case we were previously nice, make us mean again
 void Host_AbortCurrentFrame(void)
 {
        // in case we were previously nice, make us mean again
@@ -476,9 +477,9 @@ void SV_DropClient(qboolean crash)
                        buf.data = bufdata;
                        buf.maxsize = sizeof(bufdata);
                        MSG_WriteByte(&buf, svc_disconnect);
                        buf.data = bufdata;
                        buf.maxsize = sizeof(bufdata);
                        MSG_WriteByte(&buf, svc_disconnect);
-                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false);
-                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false);
-                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, false);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                }
        }
 
                }
        }
 
@@ -667,11 +668,11 @@ void Host_Main(void)
        double wait;
        int pass1, pass2, pass3, i;
        char vabuf[1024];
        double wait;
        int pass1, pass2, pass3, i;
        char vabuf[1024];
+       qboolean playing;
 
        Host_Init();
 
        realtime = 0;
 
        Host_Init();
 
        realtime = 0;
-       dirtytime = Sys_DirtyTime();
        for (;;)
        {
                if (setjmp(host_abortframe))
        for (;;)
        {
                if (setjmp(host_abortframe))
@@ -708,10 +709,16 @@ void Host_Main(void)
                        // Look for clients who have spawned
                        playing = false;
                        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
                        // Look for clients who have spawned
                        playing = false;
                        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
-                               if(host_client->spawned)
+                               if(host_client->begun)
                                        if(host_client->netconnection)
                                                playing = true;
                                        if(host_client->netconnection)
                                                playing = true;
-                       if(svs.perf_acc_realtime > 5)
+                       if(sv.time < 10)
+                       {
+                               // don't accumulate time for the first 10 seconds of a match
+                               // so things can settle
+                               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;
+                       }
+                       else if(svs.perf_acc_realtime > 5)
                        {
                                svs.perf_cpuload = 1 - svs.perf_acc_sleeptime / svs.perf_acc_realtime;
                                svs.perf_lost = svs.perf_acc_lost / svs.perf_acc_realtime;
                        {
                                svs.perf_cpuload = 1 - svs.perf_acc_sleeptime / svs.perf_acc_realtime;
                                svs.perf_lost = svs.perf_acc_lost / svs.perf_acc_realtime;
@@ -892,7 +899,7 @@ void Host_Main(void)
                        SV_SendClientMessages();
 
                        if (sv.paused == 1 && realtime > sv.pausedstart && sv.pausedstart > 0) {
                        SV_SendClientMessages();
 
                        if (sv.paused == 1 && realtime > sv.pausedstart && sv.pausedstart > 0) {
-                               prog->globals.generic[OFS_PARM0] = realtime - sv.pausedstart;
+                               prog->globals.fp[OFS_PARM0] = realtime - sv.pausedstart;
                                PRVM_serverglobalfloat(time) = sv.time;
                                prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
                        }
                                PRVM_serverglobalfloat(time) = sv.time;
                                prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
                        }
@@ -918,7 +925,7 @@ void Host_Main(void)
                {
                        R_TimeReport("---");
                        Collision_Cache_NewFrame();
                {
                        R_TimeReport("---");
                        Collision_Cache_NewFrame();
-                       R_TimeReport("collisioncache");
+                       R_TimeReport("photoncache");
                        // decide the simulation time
                        if (cls.capturevideo.active)
                        {
                        // decide the simulation time
                        if (cls.capturevideo.active)
                        {
@@ -954,13 +961,15 @@ void Host_Main(void)
                                if (cls.demopaused)
                                        clframetime = 0;
                        }
                                if (cls.demopaused)
                                        clframetime = 0;
                        }
+                       else
+                       {
+                               // host_framerate overrides all else
+                               if (host_framerate.value)
+                                       clframetime = host_framerate.value;
 
 
-                       // host_framerate overrides all else
-                       if (host_framerate.value)
-                               clframetime = host_framerate.value;
-
-                       if (cl.paused || (cl.islocalgame && (key_dest != key_game || key_consoleactive || cl.csqc_paused)))
-                               clframetime = 0;
+                               if (cl.paused || (cl.islocalgame && (key_dest != key_game || key_consoleactive || cl.csqc_paused)))
+                                       clframetime = 0;
+                       }
 
                        if (cls.timedemo)
                                clframetime = cl.realframetime = cl_timer;
 
                        if (cls.timedemo)
                                clframetime = cl.realframetime = cl_timer;
@@ -1097,7 +1106,7 @@ void Host_LockSession(void)
        if(locksession_run)
                return;
        locksession_run = true;
        if(locksession_run)
                return;
        locksession_run = true;
-       if(locksession.integer != 0)
+       if(locksession.integer != 0 && !COM_CheckParm("-readonly"))
        {
                char vabuf[1024];
                char *p = va(vabuf, sizeof(vabuf), "%slock%s", *fs_userdir ? fs_userdir : fs_basedir, sessionid.string);
        {
                char vabuf[1024];
                char *p = va(vabuf, sizeof(vabuf), "%slock%s", *fs_userdir ? fs_userdir : fs_basedir, sessionid.string);
@@ -1293,7 +1302,7 @@ static void Host_Init (void)
        }
 
        // put up the loading image so the user doesn't stare at a black screen...
        }
 
        // put up the loading image so the user doesn't stare at a black screen...
-       SCR_BeginLoadingPlaque();
+       SCR_BeginLoadingPlaque(true);
 
        if (cls.state != ca_dedicated)
        {
 
        if (cls.state != ca_dedicated)
        {