]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
use DP_LINK_ZLIB=dlopen on mingw build to reduce compile-time
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 43ed906b01f2b72b27f142c522a84213e127f469..b236b0f12c051cff5946c31d268d5a82316f6166 100644 (file)
--- a/host.c
+++ b/host.c
@@ -23,7 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <time.h>
 #include "libcurl.h"
+#ifdef CONFIG_CD
 #include "cdaudio.h"
+#endif
 #include "cl_video.h"
 #include "progsvm.h"
 #include "csprogs.h"
@@ -97,6 +99,7 @@ Host_AbortCurrentFrame
 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
@@ -476,9 +479,9 @@ void SV_DropClient(qboolean crash)
                        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);
                }
        }
 
@@ -672,7 +675,6 @@ void Host_Main(void)
        Host_Init();
 
        realtime = 0;
-       dirtytime = Sys_DirtyTime();
        for (;;)
        {
                if (setjmp(host_abortframe))
@@ -709,10 +711,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++)
-                               if(host_client->spawned)
+                               if(host_client->begun)
                                        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;
@@ -893,7 +901,7 @@ void Host_Main(void)
                        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");
                        }
@@ -919,7 +927,7 @@ void Host_Main(void)
                {
                        R_TimeReport("---");
                        Collision_Cache_NewFrame();
-                       R_TimeReport("collisioncache");
+                       R_TimeReport("photoncache");
                        // decide the simulation time
                        if (cls.capturevideo.active)
                        {
@@ -955,13 +963,15 @@ void Host_Main(void)
                                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;
@@ -1016,8 +1026,10 @@ void Host_Main(void)
                        else
                                S_Update(&r_refdef.view.matrix);
 
+#ifdef CONFIG_CD
                        CDAudio_Update();
                        R_TimeReport("audio");
+#endif
 
                        // reset gathering of mouse input
                        in_mouse_x = in_mouse_y = 0;
@@ -1065,7 +1077,9 @@ void Host_StartVideo(void)
                // make sure we open sockets before opening video because the Windows Firewall "unblock?" dialog can screw up the graphics context on some graphics drivers
                NetConn_UpdateSockets();
                VID_Start();
+#ifdef CONFIG_CD
                CDAudio_Startup();
+#endif
        }
 }
 
@@ -1098,7 +1112,7 @@ void Host_LockSession(void)
        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);
@@ -1266,7 +1280,9 @@ static void Host_Init (void)
                VID_Init();
                Render_Init();
                S_Init();
+#ifdef CONFIG_CD
                CDAudio_Init();
+#endif
                Key_Init();
                CL_Init();
        }
@@ -1294,7 +1310,7 @@ static void Host_Init (void)
        }
 
        // 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)
        {
@@ -1402,7 +1418,9 @@ void Host_Shutdown(void)
 
        Host_SaveConfig();
 
+#ifdef CONFIG_CD
        CDAudio_Shutdown ();
+#endif
        S_Terminate ();
        Curl_Shutdown ();
        NetConn_Shutdown ();