From 2f5dfa4708db4112f682b31146a8db1d456a0482 Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Thu, 22 Jul 2021 19:04:06 -0400 Subject: [PATCH] cl_main: Keep old CL_Disconnect for simplicity. Move guts to CL_DisconnectEx --- cl_demo.c | 12 ++++++------ cl_input.c | 2 +- cl_main.c | 14 ++++++++++---- cl_parse.c | 4 ++-- client.h | 3 ++- csprogs.c | 4 ++-- fs.c | 4 ++-- host.c | 2 +- libcurl.c | 2 +- netconn.c | 4 ++-- sv_save.c | 2 +- 11 files changed, 30 insertions(+), 23 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 4c826c0d..beab8f84 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -256,7 +256,7 @@ void CL_ReadDemoMessage(void) } 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; } @@ -284,7 +284,7 @@ void CL_ReadDemoMessage(void) } else { - CL_Disconnect(false, NULL); + CL_Disconnect(); return; } } @@ -363,7 +363,7 @@ void CL_Record_f(cmd_state_t *cmd) } if (cls.state == ca_connected) - CL_Disconnect(false, NULL); + CL_Disconnect(); // 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 - CL_Disconnect(false, NULL); + CL_Disconnect(); // 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; - CL_Disconnect(false, NULL); + CL_Disconnect(); CL_NextDemo(); } @@ -694,7 +694,7 @@ static void CL_Stopdemo_f(cmd_state_t *cmd) { if (!cls.demoplayback) return; - CL_Disconnect(false, NULL); + CL_Disconnect(); } // LadyHavoc: pausedemo command diff --git a/cl_input.c b/cl_input.c index 7c5598ca..da3104fd 100644 --- a/cl_input.c +++ b/cl_input.c @@ -2167,7 +2167,7 @@ void CL_SendMove(void) in_impulse = 0; if (cls.netcon->message.overflowed) - CL_Disconnect(true, "Lost connection to server"); + CL_DisconnectEx(true, "Lost connection to server"); } /* diff --git a/cl_main.c b/cl_main.c index 343aadba..744ef854 100644 --- 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]; @@ -460,6 +461,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 +544,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)); } @@ -2950,7 +2956,7 @@ void CL_Shutdown (void) S_StopAllSounds(); // disconnect client from server if active - CL_Disconnect(false, NULL); + CL_Disconnect(); CL_Video_Shutdown(); @@ -3130,7 +3136,7 @@ void CL_Init (void) 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; } diff --git a/cl_parse.c b/cl_parse.c index 326c1fc0..ecd250fc 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -3531,7 +3531,7 @@ void CL_ParseServerMessage(void) if (cls.demonum != -1) CL_NextDemo(); else - CL_Disconnect(true, NULL); + CL_DisconnectEx(true, "Server disconnected"); break; case qw_svc_print: @@ -3911,7 +3911,7 @@ void CL_ParseServerMessage(void) 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: diff --git a/client.h b/client.h index 3e007c70..fdf1a788 100644 --- a/client.h +++ b/client.h @@ -1223,7 +1223,8 @@ void CL_StartVideo(void); 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); diff --git a/csprogs.c b/csprogs.c index 47ac1ef2..4bacb563 100644 --- a/csprogs.c +++ b/csprogs.c @@ -1043,7 +1043,7 @@ void CL_VM_Init (void) 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; } } @@ -1051,7 +1051,7 @@ void CL_VM_Init (void) 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; } diff --git a/fs.c b/fs.c index f5f4d6b9..f8266c71 100644 --- a/fs.c +++ b/fs.c @@ -1578,7 +1578,7 @@ qbool FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qbool compl if (cls.demoplayback) { - CL_Disconnect(false, NULL); + CL_Disconnect(); cls.demonum = 0; } @@ -1629,7 +1629,7 @@ static void FS_GameDir_f(cmd_state_t *cmd) } // halt demo playback to close the file - CL_Disconnect(false, NULL); + CL_Disconnect(); FS_ChangeGameDirs(numgamedirs, gamedirs, true, true); } diff --git a/host.c b/host.c index 21650a24..aa8fb4c3 100644 --- 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 - CL_Disconnect (false, NULL); + CL_Disconnect(); cls.demonum = -1; hosterror = false; diff --git a/libcurl.c b/libcurl.c index 5c5f1272..fd3e7a61 100644 --- 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; - CL_Disconnect(false, NULL); + CL_Disconnect(); noclear = false; Curl_CheckCommandWhenDone(); } diff --git a/netconn.c b/netconn.c index ac481ca6..98d26019 100755 --- 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) - 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; @@ -2488,7 +2488,7 @@ void NetConn_ClientFrame(void) 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) diff --git a/sv_save.c b/sv_save.c index 814e2db1..ea5ab704 100644 --- 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) - CL_Disconnect (false, NULL); + CL_Disconnect(); #ifdef CONFIG_MENU // remove menu -- 2.39.2