]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cl_main: Keep old CL_Disconnect for simplicity. Move guts to CL_DisconnectEx
authorCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 23:04:06 +0000 (19:04 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 23:04:06 +0000 (19:04 -0400)
cl_demo.c
cl_input.c
cl_main.c
cl_parse.c
client.h
csprogs.c
fs.c
host.c
libcurl.c
netconn.c
sv_save.c

index 4c826c0db6fffa0494df5d3c73126ba9ea90f47c..beab8f84ed84354dc28d5f813e3a77ae4b13895b 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -256,7 +256,7 @@ void CL_ReadDemoMessage(void)
                }
                if (cl_message.cursize > cl_message.maxsize)
                {
                }
                if (cl_message.cursize > cl_message.maxsize)
                {
-                       CL_Disconnect(false, "Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize);
+                       CL_DisconnectEx(false, "Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize);
                        cl_message.cursize = 0;
                        return;
                }
                        cl_message.cursize = 0;
                        return;
                }
@@ -284,7 +284,7 @@ void CL_ReadDemoMessage(void)
                }
                else
                {
                }
                else
                {
-                       CL_Disconnect(false, NULL);
+                       CL_Disconnect();
                        return;
                }
        }
                        return;
                }
        }
@@ -363,7 +363,7 @@ void CL_Record_f(cmd_state_t *cmd)
        }
 
        if (cls.state == ca_connected)
        }
 
        if (cls.state == ca_connected)
-               CL_Disconnect(false, NULL);
+               CL_Disconnect();
 
        // write the forced cd track number, or -1
        if (c == 4)
 
        // write the forced cd track number, or -1
        if (c == 4)
@@ -421,7 +421,7 @@ void CL_PlayDemo(const char *demo)
        cls.demostarting = true;
 
        // disconnect from server
        cls.demostarting = true;
 
        // disconnect from server
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
 
        // update networking ports (this is mainly just needed at startup)
        NetConn_UpdateSockets();
 
        // update networking ports (this is mainly just needed at startup)
        NetConn_UpdateSockets();
@@ -679,7 +679,7 @@ static void CL_Demos_f(cmd_state_t *cmd)
                return;
        if (cls.demonum == -1)
                cls.demonum = 1;
                return;
        if (cls.demonum == -1)
                cls.demonum = 1;
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
        CL_NextDemo();
 }
 
        CL_NextDemo();
 }
 
@@ -694,7 +694,7 @@ static void CL_Stopdemo_f(cmd_state_t *cmd)
 {
        if (!cls.demoplayback)
                return;
 {
        if (!cls.demoplayback)
                return;
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
 }
 
 // LadyHavoc: pausedemo command
 }
 
 // LadyHavoc: pausedemo command
index 7c5598ca54960ff1666673a5efaeb4ca52060193..da3104fdac12ea2f9455a8802c6fde0833cf3561 100644 (file)
@@ -2167,7 +2167,7 @@ void CL_SendMove(void)
        in_impulse = 0;
 
        if (cls.netcon->message.overflowed)
        in_impulse = 0;
 
        if (cls.netcon->message.overflowed)
-               CL_Disconnect(true, "Lost connection to server");
+               CL_DisconnectEx(true, "Lost connection to server");
 }
 
 /*
 }
 
 /*
index 343aadbac0309e53066f95e8066571e9f7a12bea..744ef854f7daf62c0deaafa34c37abb91e59e10e 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
 =====================
 */
 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];
 {
        va_list argptr;
        char reason[512];
@@ -460,6 +461,11 @@ void CL_Disconnect(qbool kicked, const char *fmt, ... )
                host.hook.SV_Shutdown();
 }
 
                host.hook.SV_Shutdown();
 }
 
+void CL_Disconnect(void)
+{
+       CL_DisconnectEx(false, NULL);
+}
+
 /*
 ==================
 CL_Reconnect_f
 /*
 ==================
 CL_Reconnect_f
@@ -538,7 +544,7 @@ static void CL_Connect_f(cmd_state_t *cmd)
 
 void CL_Disconnect_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));
 }
 
 
 }
 
 
@@ -2950,7 +2956,7 @@ void CL_Shutdown (void)
        S_StopAllSounds();
        
        // disconnect client from server if active
        S_StopAllSounds();
        
        // disconnect client from server if active
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
        
        CL_Video_Shutdown();
 
        
        CL_Video_Shutdown();
 
@@ -3130,7 +3136,7 @@ void CL_Init (void)
                NetConn_UpdateSockets_Client();
 
                host.hook.ConnectLocal = CL_EstablishConnection_Local;
                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;
        }
                host.hook.CL_Intermission = CL_Intermission;
                host.hook.ToggleMenu = CL_ToggleMenu_Hook;
        }
index 326c1fc0eff4e2a6ce8eb15c43eacfd9642c2e3f..ecd250fc56da0f21100b204b00e5ff74cc9a1232 100644 (file)
@@ -3531,7 +3531,7 @@ void CL_ParseServerMessage(void)
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
-                                       CL_Disconnect(true, NULL);
+                                       CL_DisconnectEx(true, "Server disconnected");
                                break;
 
                        case qw_svc_print:
                                break;
 
                        case qw_svc_print:
@@ -3911,7 +3911,7 @@ void CL_ParseServerMessage(void)
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
-                                       CL_Disconnect(true, cls.protocol == PROTOCOL_DARKPLACES8 ? MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)) : NULL);
+                                       CL_DisconnectEx(true, cls.protocol == PROTOCOL_DARKPLACES8 ? MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)) : "Server disconnected");
                                break;
 
                        case svc_print:
                                break;
 
                        case svc_print:
index 3e007c70bde34b181c6f6739917f2a2e4def9d21..fdf1a7881f5b1c9316056c65ff514c93feaaeee5 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1223,7 +1223,8 @@ void CL_StartVideo(void);
 
 void CL_EstablishConnection(const char *host, int firstarg);
 
 
 void CL_EstablishConnection(const char *host, int firstarg);
 
-void CL_Disconnect (qbool kicked, const char *reason, ... );
+void CL_Disconnect(void);
+void CL_DisconnectEx(qbool kicked, const char *reason, ... );
 void CL_Disconnect_f(cmd_state_t *cmd);
 
 void CL_UpdateRenderEntity(entity_render_t *ent);
 void CL_Disconnect_f(cmd_state_t *cmd);
 
 void CL_UpdateRenderEntity(entity_render_t *ent);
index 47ac1ef22a4b77b627fb85ce47de3523e9326943..4bacb5632e8a595d00d98ed5962766a128b7a67a 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -1043,7 +1043,7 @@ void CL_VM_Init (void)
                        else
                        {
                                Mem_Free(csprogsdata);
                        else
                        {
                                Mem_Free(csprogsdata);
-                               CL_Disconnect(false, "Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
+                               CL_DisconnectEx(false, "Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
                                return;
                        }
                }
                                return;
                        }
                }
@@ -1051,7 +1051,7 @@ void CL_VM_Init (void)
        else
        {
                if (requiredcrc >= 0)
        else
        {
                if (requiredcrc >= 0)
-                       CL_Disconnect(false, CON_ERROR "CL_VM_Init: %s requires CSQC, but \"%s\" wasn't found\n", cls.demoplayback ? "demo" : "server", csqc_progname.string);
+                       CL_DisconnectEx(false, CON_ERROR "CL_VM_Init: %s requires CSQC, but \"%s\" wasn't found\n", cls.demoplayback ? "demo" : "server", csqc_progname.string);
                return;
        }
 
                return;
        }
 
diff --git a/fs.c b/fs.c
index f5f4d6b917f0d458fc89065ccc9f8bae626b64fd..f8266c71a2a7e7e10b4ee3c21f1d533f6e657010 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1578,7 +1578,7 @@ qbool FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qbool compl
 
        if (cls.demoplayback)
        {
 
        if (cls.demoplayback)
        {
-               CL_Disconnect(false, NULL);
+               CL_Disconnect();
                cls.demonum = 0;
        }
 
                cls.demonum = 0;
        }
 
@@ -1629,7 +1629,7 @@ static void FS_GameDir_f(cmd_state_t *cmd)
        }
 
        // halt demo playback to close the file
        }
 
        // halt demo playback to close the file
-       CL_Disconnect(false, NULL);
+       CL_Disconnect();
 
        FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
 }
 
        FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
 }
diff --git a/host.c b/host.c
index 21650a24c9f1f190f0349e80c9b8c93bd0fe56cf..aa8fb4c32bf9d712113f2bce98d71ec6d06f77e9 100644 (file)
--- a/host.c
+++ b/host.c
@@ -134,7 +134,7 @@ void Host_Error (const char *error, ...)
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_Error: %s",hosterrorstring2);  // dedicated servers exit
 
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_Error: %s",hosterrorstring2);  // dedicated servers exit
 
-       CL_Disconnect (false, NULL);
+       CL_Disconnect();
        cls.demonum = -1;
 
        hosterror = false;
        cls.demonum = -1;
 
        hosterror = false;
index 5c5f127295ab7810c613f758338fa6df0a677503..fd3e7a61583a6dbaaa88a6f29a1e8541d7c09553 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -1484,7 +1484,7 @@ static void Curl_Curl_f(cmd_state_t *cmd)
                                                dpsnprintf(donecommand, sizeof(donecommand), "connect %s", cls.netcon->address);
                                                Curl_CommandWhenDone(donecommand);
                                                noclear = true;
                                                dpsnprintf(donecommand, sizeof(donecommand), "connect %s", cls.netcon->address);
                                                Curl_CommandWhenDone(donecommand);
                                                noclear = true;
-                                               CL_Disconnect(false, NULL);
+                                               CL_Disconnect();
                                                noclear = false;
                                                Curl_CheckCommandWhenDone();
                                        }
                                                noclear = false;
                                                Curl_CheckCommandWhenDone();
                                        }
index ac481ca6df030e6d3d602ce11f0885880ab81b72..98d26019e0cc388918e0ded10da13bf22fc925f1 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1529,7 +1529,7 @@ static void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_
 #endif
        // Disconnect from the current server or stop demo playback
        if(cls.state == ca_connected || cls.demoplayback)
 #endif
        // Disconnect from the current server or stop demo playback
        if(cls.state == ca_connected || cls.demoplayback)
-               CL_Disconnect(false, NULL);
+               CL_Disconnect();
        // allocate a net connection to keep track of things
        cls.netcon = NetConn_Open(mysocket, peeraddress);
        crypto = &cls.netcon->crypto;
        // allocate a net connection to keep track of things
        cls.netcon = NetConn_Open(mysocket, peeraddress);
        crypto = &cls.netcon->crypto;
@@ -2488,7 +2488,7 @@ void NetConn_ClientFrame(void)
        NetConn_QueryQueueFrame();
 #endif
        if (cls.netcon && host.realtime > cls.netcon->timeout && !sv.active)
        NetConn_QueryQueueFrame();
 #endif
        if (cls.netcon && host.realtime > cls.netcon->timeout && !sv.active)
-               CL_Disconnect(true, "Connection timed out");
+               CL_DisconnectEx(true, "Connection timed out");
 }
 
 static void NetConn_BuildChallengeString(char *buffer, int bufferlength)
 }
 
 static void NetConn_BuildChallengeString(char *buffer, int bufferlength)
index 814e2db13cdad1f34ce03671438b81c2618516fa..ea5ab7046224e1e0083adba742eec3aeeeef3eb8 100644 (file)
--- a/sv_save.c
+++ b/sv_save.c
@@ -272,7 +272,7 @@ void SV_Loadgame_f(cmd_state_t *cmd)
 
        // stop playing demos
        if (cls.demoplayback)
 
        // stop playing demos
        if (cls.demoplayback)
-               CL_Disconnect (false, NULL);
+               CL_Disconnect();
 
 #ifdef CONFIG_MENU
        // remove menu
 
 #ifdef CONFIG_MENU
        // remove menu