]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
fix multithreaded OpenGL support; actually load CGL functions from OpenGL.framework
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 13cd059127f4ef97f4f95fbae09d9c0b6259e92a..d1a9032f65d50d1bea254db2f8107edf6cf0aecb 100644 (file)
--- a/host.c
+++ b/host.c
@@ -435,9 +435,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);
-                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol);
-                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000);
                }
                // break the net connection
                NetConn_Close(host_client->netconnection);
@@ -577,12 +577,11 @@ Runs all active servers
 static void Host_Init(void);
 void Host_Main(void)
 {
-       static double time1 = 0;
-       static double time2 = 0;
-       static double time3 = 0;
-       // these are static because of setjmp/longjmp warnings in mingw32 gcc 2.95.3
-       static double frameoldtime, framenewtime, framedeltatime, cl_timer, sv_timer;
-       double clframetime;
+       double time1 = 0;
+       double time2 = 0;
+       double time3 = 0;
+       double cl_timer, sv_timer;
+       double clframetime, deltarealtime, oldrealtime;
        double wait;
        int pass1, pass2, pass3;
 
@@ -591,20 +590,18 @@ void Host_Main(void)
        cl_timer = 0;
        sv_timer = 0;
 
-       framenewtime = Sys_DoubleTime();
+       realtime = Sys_DoubleTime();
        for (;;)
        {
                if (setjmp(host_abortframe))
                        continue;                       // something bad happened, or the server disconnected
 
-               frameoldtime = framenewtime;
-               framenewtime = Sys_DoubleTime();
-               framedeltatime = framenewtime - frameoldtime;
-               realtime += framedeltatime;
+               oldrealtime = realtime;
+               realtime = Sys_DoubleTime();
 
-               // accumulate the new frametime into the timers
-               cl_timer += framedeltatime;
-               sv_timer += framedeltatime;
+               deltarealtime = realtime - oldrealtime;
+               cl_timer += deltarealtime;
+               sv_timer += deltarealtime;
 
                if (slowmo.value < 0)
                        Cvar_SetValue("slowmo", 0);
@@ -701,7 +698,7 @@ void Host_Main(void)
                                // synchronize to the client frametime, but no less than 10ms and no more than sys_ticrate
                                advancetime = bound(0.01, cl_timer, sys_ticrate.value);
                                framelimit = 10;
-                               aborttime = Sys_DoubleTime() + 0.1;
+                               aborttime = realtime + 0.1;
                        }
                        else
                        {
@@ -710,7 +707,7 @@ void Host_Main(void)
                                if (cls.state == ca_connected)
                                {
                                        framelimit = 10;
-                                       aborttime = Sys_DoubleTime() + 0.1;
+                                       aborttime = realtime + 0.1;
                                }
                        }
                        advancetime = min(advancetime, 0.1);
@@ -734,17 +731,14 @@ void Host_Main(void)
                                if (sv.frametime)
                                        SV_Physics();
 
-                               // send all messages to the clients
-                               SV_SendClientMessages();
-
-                               // clear the general datagram
-                               SV_ClearDatagram();
-
                                // if this server frame took too long, break out of the loop
                                if (framelimit > 1 && Sys_DoubleTime() >= aborttime)
                                        break;
                        }
 
+                       // send all messages to the clients
+                       SV_SendClientMessages();
+
                        // end the server VM frame
                        SV_VM_End();
 
@@ -795,16 +789,17 @@ void Host_Main(void)
                        // Collect input into cmd
                        CL_Input();
 
+                       // check for new packets
                        NetConn_ClientFrame();
 
-                       if (cls.state == ca_connected)
-                       {
-                               CL_ReadFromServer();
-                               // if running the server remotely, send intentions now after
-                               // the incoming messages have been read
-                               //if (!cl.islocalgame)
-                               //      CL_SendCmd();
-                       }
+                       // read a new frame from a demo if needed
+                       CL_ReadDemoMessage();
+
+                       // now that packets have been read, send input to server
+                       CL_SendMove();
+
+                       // update client world (interpolate entities, create trails, etc)
+                       CL_UpdateWorld();
 
                        // update video
                        if (host_speeds.integer)