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
1 changed files with 27 additions and 6 deletions

View File

@ -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)