]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
Improve client/listen curl transfer speed at low FPS
[xonotic/darkplaces.git] / cl_main.c
index 343aadbac0309e53066f95e8066571e9f7a12bea..dd2ea6a5911a2d1aca0935e44efe742cfba1f5df 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -360,7 +360,8 @@ Sends a disconnect message to the server
 This is also called on Host_Error, so it shouldn't cause any errors
 =====================
 */
-void CL_Disconnect(qbool kicked, const char *fmt, ... )
+
+void CL_DisconnectEx(qbool kicked, const char *fmt, ... )
 {
        va_list argptr;
        char reason[512];
@@ -386,11 +387,13 @@ void CL_Disconnect(qbool kicked, const char *fmt, ... )
 
        Con_DPrintf("CL_Disconnect\n");
 
-    Cvar_SetValueQuick(&csqc_progcrc, -1);
+       Cvar_SetValueQuick(&csqc_progcrc, -1);
        Cvar_SetValueQuick(&csqc_progsize, -1);
        CL_VM_ShutDown();
-// stop sounds (especially looping!)
-       S_StopAllSounds ();
+       // stop sounds (especially looping!)
+       S_StopAllSounds();
+       // prevent dlcache assets from this server from interfering with the next one
+       FS_UnloadPacks_dlcache();
 
        cl.parsingtextexpectingpingforscores = 0; // just in case no reply has come yet
 
@@ -460,6 +463,11 @@ void CL_Disconnect(qbool kicked, const char *fmt, ... )
                host.hook.SV_Shutdown();
 }
 
+void CL_Disconnect(void)
+{
+       CL_DisconnectEx(false, NULL);
+}
+
 /*
 ==================
 CL_Reconnect_f
@@ -538,7 +546,7 @@ static void CL_Connect_f(cmd_state_t *cmd)
 
 void CL_Disconnect_f(cmd_state_t *cmd)
 {
-       CL_Disconnect(false, Cmd_Argc(cmd) > 1 ? Cmd_Argv(cmd, 1) : NULL);
+       Cmd_Argc(cmd) < 1 ? CL_Disconnect() : CL_DisconnectEx(false, Cmd_Argv(cmd, 1));
 }
 
 
@@ -592,6 +600,7 @@ void CL_EstablishConnection(const char *address, int firstarg)
 #ifdef CONFIG_MENU
                M_Update_Return_Reason("Trying to connect...");
 #endif
+               SCR_BeginLoadingPlaque(false);
        }
        else
        {
@@ -2543,7 +2552,7 @@ static void CL_MeshEntities_Shutdown(void)
        }
 }
 
-static void CL_MeshEntities_Init(void)
+void CL_MeshEntities_Init(void)
 {
        int i;
        entity_t *ent;
@@ -2579,7 +2588,7 @@ static void CL_MeshEntities_Init(void)
                CL_UpdateRenderEntity(&ent->render);
        }
        cl_meshentities[MESH_UI].render.flags = RENDER_NOSELFSHADOW;
-       R_RegisterModule("cl_meshentities", CL_MeshEntities_Start, CL_MeshEntities_Shutdown, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
+       R_RegisterModule("CL_MeshEntities", CL_MeshEntities_Start, CL_MeshEntities_Shutdown, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
 }
 
 void CL_MeshEntities_Scene_Clear(void)
@@ -2805,6 +2814,11 @@ double CL_Frame (double time)
        SndSys_SendKeyEvents();
        Sys_SendKeyEvents();
 
+       /*
+        * If the accumulator hasn't become positive, don't
+        * run the frame. Everything that happens before this
+        * point will happen even if we're sleeping this frame.
+        */
        if((cl_timer += time) < 0)
                return cl_timer;
 
@@ -2950,7 +2964,7 @@ void CL_Shutdown (void)
        S_StopAllSounds();
        
        // disconnect client from server if active
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
        
        CL_Video_Shutdown();
 
@@ -3123,14 +3137,13 @@ void CL_Init (void)
                CL_Parse_Init();
                CL_Particles_Init();
                CL_Screen_Init();
-               CL_MeshEntities_Init();
 
                CL_Video_Init();
 
                NetConn_UpdateSockets_Client();
 
                host.hook.ConnectLocal = CL_EstablishConnection_Local;
-               host.hook.Disconnect = CL_Disconnect;
+               host.hook.Disconnect = CL_DisconnectEx;
                host.hook.CL_Intermission = CL_Intermission;
                host.hook.ToggleMenu = CL_ToggleMenu_Hook;
        }