From 386360ff43ba83d84e87d47010a79500dffbceb7 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 9 Mar 2019 23:36:11 -0600 Subject: [PATCH] Properly close and reopen the client connection for password challenges --- src/d_clisrv.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6734b544..b05babd6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1909,7 +1909,7 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) /** Called by CL_ServerConnectionTicker * * \param viams ??? - * \param asksent ??? + * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. * \return False if the connection was aborted * \sa CL_ServerConnectionTicker * \sa CL_ConnectToServer @@ -2037,7 +2037,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) * \param viams ??? * \param tmpsave The name of the gamestate file??? * \param oldtic Used for knowing when to poll events and redraw - * \param asksent ??? + * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. * \return False if the connection was aborted * \sa CL_ServerConnectionSearchTicker * \sa CL_ConnectToServer @@ -2109,6 +2109,9 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic #endif case CL_CHALLENGE: + (*asksent) = I_GetTime() - NEWTICRATE + 2; // This is SUPPOSED to remove the delay from sending the password but it doesn't work... + break; + case CL_WAITJOINRESPONSE: case CL_WAITDOWNLOADFILESRESPONSE: case CL_CONNECTED: @@ -2226,10 +2229,26 @@ boolean CL_Responder(event_t *ev) } else if (ch == KEY_ENTER) { - // Done? - D_ComputeChallengeAnswer(cl_challengequestion, cl_challengepassword, cl_challengeanswer); - cl_mode = cl_needsdownload ? CL_ASKDOWNLOADFILES : CL_ASKJOIN; - cl_challengeattempted = 1; + // Done? Try to reconnect to the server... + if (!netgame && I_NetOpenSocket) + { + MSCloseUDPSocket(); // Tidy up before wiping the slate. + if (I_NetOpenSocket()) + { + netgame = true; + multiplayer = true; + +#ifndef NONET + SL_ClearServerList(servernode); +#endif + cl_mode = CL_SEARCHING; + + D_ComputeChallengeAnswer(cl_challengequestion, cl_challengepassword, cl_challengeanswer); + cl_challengeattempted = 1; + } + } + else + I_Error("haha that ain't it"); } return true; @@ -3956,6 +3975,8 @@ static void HandlePacketFromAwayNode(SINT8 node) cl_challengenum = netbuffer->u.joinchallenge.challengenum; memcpy(cl_challengequestion, netbuffer->u.joinchallenge.question, 16); + D_CloseConnection(); // Don't need to stay connected while challenging + cl_mode = CL_CHALLENGE; if (cl_challengeattempted == 2)