Properly close and reopen the client connection for password challenges

This commit is contained in:
fickleheart 2019-03-09 23:36:11 -06:00
parent 3e1570c59d
commit 386360ff43

View file

@ -1909,7 +1909,7 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
/** Called by CL_ServerConnectionTicker /** Called by CL_ServerConnectionTicker
* *
* \param viams ??? * \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 * \return False if the connection was aborted
* \sa CL_ServerConnectionTicker * \sa CL_ServerConnectionTicker
* \sa CL_ConnectToServer * \sa CL_ConnectToServer
@ -2037,7 +2037,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
* \param viams ??? * \param viams ???
* \param tmpsave The name of the gamestate file??? * \param tmpsave The name of the gamestate file???
* \param oldtic Used for knowing when to poll events and redraw * \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 * \return False if the connection was aborted
* \sa CL_ServerConnectionSearchTicker * \sa CL_ServerConnectionSearchTicker
* \sa CL_ConnectToServer * \sa CL_ConnectToServer
@ -2109,6 +2109,9 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
#endif #endif
case CL_CHALLENGE: 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_WAITJOINRESPONSE:
case CL_WAITDOWNLOADFILESRESPONSE: case CL_WAITDOWNLOADFILESRESPONSE:
case CL_CONNECTED: case CL_CONNECTED:
@ -2226,10 +2229,26 @@ boolean CL_Responder(event_t *ev)
} }
else if (ch == KEY_ENTER) else if (ch == KEY_ENTER)
{ {
// Done? // Done? Try to reconnect to the server...
D_ComputeChallengeAnswer(cl_challengequestion, cl_challengepassword, cl_challengeanswer); if (!netgame && I_NetOpenSocket)
cl_mode = cl_needsdownload ? CL_ASKDOWNLOADFILES : CL_ASKJOIN; {
cl_challengeattempted = 1; 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; return true;
@ -3956,6 +3975,8 @@ static void HandlePacketFromAwayNode(SINT8 node)
cl_challengenum = netbuffer->u.joinchallenge.challengenum; cl_challengenum = netbuffer->u.joinchallenge.challengenum;
memcpy(cl_challengequestion, netbuffer->u.joinchallenge.question, 16); memcpy(cl_challengequestion, netbuffer->u.joinchallenge.question, 16);
D_CloseConnection(); // Don't need to stay connected while challenging
cl_mode = CL_CHALLENGE; cl_mode = CL_CHALLENGE;
if (cl_challengeattempted == 2) if (cl_challengeattempted == 2)