Reorder join process so password is authenticated before attempting to download

This commit is contained in:
James R 2020-04-13 17:30:42 -07:00
parent 1fac0505a4
commit b25acfa782
2 changed files with 24 additions and 40 deletions

View file

@ -1995,40 +1995,7 @@ static boolean CL_FinishedFileList(void)
else if (i == 1)
cl_mode = CL_ASKJOIN;
else
{
// must download something
// can we, though?
#ifdef HAVE_CURL
if (http_source[0] == '\0' || curl_failedwebdownload)
#endif
{
if (!CL_CheckDownloadable()) // nope!
{
D_QuitNetGame();
CL_Reset();
D_StartTitle();
M_StartMessage(M_GetText(
"You cannot connect to this server\n"
"because you cannot download the files\n"
"that you are missing from the server.\n\n"
"See the console or log file for\n"
"more details.\n\n"
"Press ESC\n"
), NULL, MM_NOTHING);
return false;
}
cl_mode = CL_ASKDOWNLOADFILES;
return true;
}
#ifdef HAVE_CURL
else
{
cl_mode = CL_PREPAREHTTPFILES;
return true;
}
#endif
}
cl_mode = CL_ASKDOWNLOADFILES;
return true;
}
@ -2163,10 +2130,9 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
#ifdef HAVE_CURL
case CL_PREPAREHTTPFILES:
if (http_source[0])
{
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status == FS_NOTFOUND)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
curl_transfers++;
cl_mode = CL_DOWNLOADHTTPFILES;
@ -2176,7 +2142,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
case CL_DOWNLOADHTTPFILES:
waitmore = false;
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status == FS_NOTFOUND)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
{
if (!curl_running)
CURLPrepareFile(http_source, i);
@ -3912,7 +3878,9 @@ static void HandleConnect(SINT8 node)
if (netbuffer->u.clientcfg.needsdownload)
{
netbuffer->packettype = PT_DOWNLOADFILESOKAY;
HSendPacket(node, true, 0, 0);
strncpy(netbuffer->u.filecfg.http_source, cv_httpsource.string,
MAX_MIRROR_LENGTH);
HSendPacket(node, true, 0, sizeof netbuffer->u.filecfg);
return;
}
@ -4193,7 +4161,17 @@ static void HandlePacketFromAwayNode(SINT8 node)
SERVERONLY
// This should've already been checked, but just to be safe...
#ifdef HAVE_CURL
if (! curl_failedwebdownload &&
netbuffer->u.filecfg.http_source[0] != '\0'
){
strlcpy(http_source, netbuffer->u.filecfg.http_source,
MAX_MIRROR_LENGTH);
cl_mode = CL_PREPAREHTTPFILES;
}
else
#endif
if (!CL_CheckDownloadable())
{
D_QuitNetGame();
@ -4215,7 +4193,7 @@ static void HandlePacketFromAwayNode(SINT8 node)
cl_challengeattempted = 2;
CONS_Printf("trying to download\n");
if (CL_SendRequestFile())
if (cl_mode == CL_WAITDOWNLOADFILESRESPONSE && CL_SendRequestFile())
cl_mode = CL_DOWNLOADFILES;
break;

View file

@ -443,6 +443,11 @@ typedef struct
UINT8 files[MAXFILENEEDED]; // is filled with writexxx (byteptr.h)
} ATTRPACK filesneededconfig_pak;
typedef struct
{
char http_source[MAX_MIRROR_LENGTH];/* first byte 0? no die! */
} ATTRPACK fileconfig;
//
// Network packet data
//
@ -477,6 +482,7 @@ typedef struct
plrconfig playerconfig[MAXPLAYERS]; // (up to) 528 bytes(?)
INT32 filesneedednum; // 4 bytes
filesneededconfig_pak filesneededcfg; // ??? bytes
fileconfig filecfg;
UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes
} u; // This is needed to pack diff packet types data together
} ATTRPACK doomdata_t;