]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
Replaced all calls to str[n]cat and strncpy by calls to strlcat and strlcpy respectively
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 6defd6dd63fca685b35b3f02d52afbb7817b255f..23f1a5ec447d03f6f5fff7b18a5d3f47a17f778e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <time.h>
 #include "quakedef.h"
+#include "libcurl.h"
 #include "cdaudio.h"
 #include "cl_video.h"
 #include "progsvm.h"
@@ -544,7 +545,11 @@ Runs all active servers
 static void Host_Init(void);
 void Host_Main(void)
 {
-       double frameoldtime, framenewtime, frametime, cl_timer, sv_timer;
+       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, frametime, cl_timer, sv_timer;
 
        Host_Init();
 
@@ -554,9 +559,8 @@ void Host_Main(void)
        framenewtime = Sys_DoubleTime();
        for (;;)
        {
-               static double time1 = 0;
-               static double time2 = 0;
-               static double time3 = 0;
+               if (setjmp(host_abortframe))
+                       continue;                       // something bad happened, or the server disconnected
 
                frameoldtime = framenewtime;
                framenewtime = Sys_DoubleTime();
@@ -573,9 +577,6 @@ void Host_Main(void)
                cl_timer += frametime;
                sv_timer += frametime;
 
-               if (setjmp(host_abortframe))
-                       continue;                       // something bad happened, or the server disconnected
-
                if (slowmo.value < 0)
                        Cvar_SetValue("slowmo", 0);
                if (host_framerate.value < 0.00001 && host_framerate.value != 0)
@@ -619,12 +620,17 @@ void Host_Main(void)
 
                NetConn_UpdateSockets();
 
+               Curl_Run();
+
        //-------------------
        //
        // server operations
        //
        //-------------------
 
+               // check for commands typed to the host
+               Host_GetConsoleCommands();
+
                if (sv_timer > 0)
                {
                        if (!sv.active)
@@ -646,15 +652,19 @@ void Host_Main(void)
                                // the middle of Host_Frame
                                NetConn_ServerFrame();
 
-                               // check for commands typed to the host
-                               Host_GetConsoleCommands();
-
                                // run the world state
                                // don't allow simulation to run too fast or too slow or logic glitches can occur
 
                                // stop running server frames if the wall time reaches this value
-                               if (sys_ticrate.value <= 0 || (cl.islocalgame && !sv_fixedframeratesingleplayer.integer))
+                               if (sys_ticrate.value <= 0)
                                        advancetime = sv_timer;
+                               else if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
+                               {
+                                       // 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;
+                               }
                                else
                                {
                                        advancetime = sys_ticrate.value;
@@ -728,7 +738,7 @@ void Host_Main(void)
                                // decide the simulation time
                                if (!cls.timedemo)
                                {
-                                       if (cls.capturevideo_active && !cls.capturevideo_soundfile)
+                                       if (cls.capturevideo_active)// && !cls.capturevideo_soundfile)
                                        {
                                                frametime = 1.0 / cls.capturevideo_framerate;
                                                cl.realframetime = max(cl.realframetime, frametime);
@@ -786,7 +796,7 @@ void Host_Main(void)
                                        csqc_usecsqclistener = false;
                                }
                                else
-                                       S_Update(&r_refdef.viewentitymatrix);
+                                       S_Update(&r_view.matrix);
 
                                CDAudio_Update();
                        }
@@ -915,6 +925,7 @@ static void Host_Init (void)
        // initialize various cvars that could not be initialized earlier
        Memory_Init_Commands();
        Con_Init_Commands();
+       Curl_Init_Commands();
        Cmd_Init_Commands();
        Sys_Init_Commands();
        COM_Init_Commands();
@@ -925,6 +936,7 @@ static void Host_Init (void)
        Mathlib_Init();
 
        NetConn_Init();
+       Curl_Init();
        //PR_Init();
        //PR_Cmd_Init();
        PRVM_Init();
@@ -1079,6 +1091,7 @@ void Host_Shutdown(void)
 
        CDAudio_Shutdown ();
        S_Terminate ();
+       Curl_Shutdown ();
        NetConn_Shutdown ();
        //PR_Shutdown ();