From 543a024917a22e03cd9ead016bf0b6cae202c7be Mon Sep 17 00:00:00 2001 From: myT Date: Thu, 25 Jan 2018 04:36:13 +0100 Subject: [PATCH] fixed waiting for a snapshot forever when the server disconnects during client connection --- changelog.txt | 2 ++ code/client/cl_parse.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/changelog.txt b/changelog.txt index 4eac126..05941e9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,8 @@ chg: on Windows, a fatal error will move the early console window to the foregro chg: com_hunkMegs doesn't have a maximum value anymore a value too high would reset it and the engine might fail to load with the default value +fix: getting stuck on "Awaiting snapshot..." when the server shuts down during client connection + fix: demo playback would crash when delta entities/players had an invalid field count fix: strcpy calls with overlapping buffers (undefined behavior), which were responsible for the diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp index aaa138f..48f0818 100644 --- a/code/client/cl_parse.cpp +++ b/code/client/cl_parse.cpp @@ -576,6 +576,21 @@ static void CL_ParseCommandString( msg_t* msg ) int index = seq & (MAX_RELIABLE_COMMANDS-1); Q_strncpyz( clc.serverCommands[ index ], s, sizeof( clc.serverCommands[ index ] ) ); + + // We normally don't process commands before being CA_ACTIVE, + // but it's possible we receive a "disconnect" command while + // still being CA_PRIMED. + // Therefore, we have to make an exception for "disconnect" right here + // to avoid waiting for a snapshot forever. + if ( cls.state == CA_PRIMED ) { + Cmd_TokenizeString(s); + if ( !Q_stricmp( Cmd_Argv(0), "disconnect" ) ) { + if ( Cmd_Argc() >= 2 ) + Com_Error( ERR_DROP, "Server disconnected: %s", Cmd_Argv(1) ); + else + Com_Error( ERR_DROP, "Server disconnected" ); + } + } }