From 12d40a07ccbd6145e228cc5399a19b0e09966e83 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 27 Jun 2020 20:58:33 -0400 Subject: [PATCH 01/27] Load one file per tic Prevents game from locking up when loading large file lists --- src/d_clisrv.c | 19 ++++++++++++------- src/d_netfil.c | 4 +++- src/d_netfil.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 251f413a..e0bba6bf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1095,6 +1095,7 @@ typedef enum CL_SEARCHING, CL_DOWNLOADFILES, CL_ASKJOIN, + CL_LOADFILES, CL_WAITJOINRESPONSE, #ifdef JOININGAME CL_DOWNLOADSAVEGAME, @@ -1202,7 +1203,10 @@ static inline void CL_DrawConnectionStatus(void) break; #endif case CL_ASKFULLFILELIST: - cltext = M_GetText("This server has a LOT of files!"); + cltext = M_GetText("This server has a LOT of addons!"); + break; + case CL_LOADFILES: + cltext = M_GetText("Loading server addons..."); break; case CL_ASKJOIN: case CL_WAITJOINRESPONSE: @@ -1933,7 +1937,7 @@ static boolean CL_FinishedFileList(void) return false; } else if (i == 1) - cl_mode = CL_ASKJOIN; + cl_mode = CL_LOADFILES; else { // must download something @@ -2143,7 +2147,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic } if (!curl_transfers) - cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now + cl_mode = CL_LOADFILES; // don't break case continue to cljoin request now break; #endif @@ -2159,11 +2163,12 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (waitmore) break; // exit the case - cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now - /* FALLTHRU */ - + cl_mode = CL_LOADFILES; // don't break case continue to cljoin request now + break; + case CL_LOADFILES: + if (!CL_LoadServerFiles()) + break; case CL_ASKJOIN: - CL_LoadServerFiles(); #ifdef JOININGAME // prepare structures to save the file // WARNING: this can be useless in case of server not in GS_LEVEL diff --git a/src/d_netfil.c b/src/d_netfil.c index 821d2a5b..f65959dc 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -457,7 +457,7 @@ INT32 CL_CheckFiles(void) } // Load it now -void CL_LoadServerFiles(void) +boolean CL_LoadServerFiles(void) { INT32 i; @@ -473,6 +473,7 @@ void CL_LoadServerFiles(void) P_AddWadFile(fileneeded[i].filename); G_SetGameModified(true, false); fileneeded[i].status = FS_OPEN; + return false; } else if (fileneeded[i].status == FS_MD5SUMBAD) I_Error("Wrong version of file %s", fileneeded[i].filename); @@ -498,6 +499,7 @@ void CL_LoadServerFiles(void) fileneeded[i].status, s); } } + return true; } // Number of files to send diff --git a/src/d_netfil.h b/src/d_netfil.h index f37df371..3bc2d0d3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -65,7 +65,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave); INT32 CL_CheckFiles(void); -void CL_LoadServerFiles(void); +boolean CL_LoadServerFiles(void); void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid); From fc9f40a177cc9263311e34db994e93517850ad7d Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 21 Mar 2020 21:32:15 -0400 Subject: [PATCH 02/27] New "Overall Download Progress" bar Shows progress of all file downloads pre-join --- src/d_clisrv.c | 49 +++++++++++++++++++++++++++++++++++++------------ src/d_netfil.c | 5 +++++ src/d_netfil.h | 2 ++ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e0bba6bf..0579eb23 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1167,10 +1167,6 @@ static inline void CL_DrawConnectionStatus(void) // Draw background fade V_DrawFadeScreen(0xFF00, 16); - // Draw the bottom box. - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort"); - if (cl_mode != CL_DOWNLOADFILES #ifdef HAVE_CURL && cl_mode != CL_DOWNLOADHTTPFILES @@ -1182,6 +1178,10 @@ static inline void CL_DrawConnectionStatus(void) // 15 pal entries total. const char *cltext; + //Draw bottom box + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort"); + for (i = 0; i < 16; ++i) V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); @@ -1221,13 +1221,18 @@ static inline void CL_DrawConnectionStatus(void) cltext = M_GetText("Connecting to server..."); break; } - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, cltext); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-32, V_YELLOWMAP, cltext); } else { if (lastfilenum != -1) { + // Draw the bottom box. + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP, "Press ESC to abort"); + INT32 dldlength; + INT32 totalfileslength; static char tempname[28]; fileneeded_t *file = &fileneeded[lastfilenum]; char *filename = file->filename; @@ -1236,8 +1241,10 @@ static inline void CL_DrawConnectionStatus(void) dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); if (dldlength > 256) dldlength = 256; - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); + + memset(tempname, 0, sizeof(tempname)); // offset filename to just the name only part @@ -1255,15 +1262,24 @@ static inline void CL_DrawConnectionStatus(void) strncpy(tempname, filename, sizeof(tempname)-1); } - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP, va(M_GetText("Downloading \"%s\""), tempname)); - V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE, va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10)); - V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024)); + + // Download progress + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Total File Download Progress"); + totalfileslength = (INT32)((downloadcompletednum/(double)totalfilesrequestednum) * 256); + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + va(" %2u/%2u",downloadcompletednum,totalfilesrequestednum)); } else - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-32, V_YELLOWMAP, M_GetText("Waiting to download files...")); } } @@ -1963,7 +1979,11 @@ static boolean CL_FinishedFileList(void) } if (CL_SendRequestFile()) + { cl_mode = CL_DOWNLOADFILES; + downloadcompletednum = 0; + totalfilesrequestednum = 0; + } } #ifdef HAVE_CURL else @@ -2108,10 +2128,15 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic case CL_PREPAREHTTPFILES: if (http_source[0]) { + downloadcompletednum = 0; + totalfilesrequestednum = 0; for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + { curl_transfers++; - + totalfilesrequestednum++; + } + cl_mode = CL_DOWNLOADHTTPFILES; } break; diff --git a/src/d_netfil.c b/src/d_netfil.c index f65959dc..7fd9e294 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -108,6 +108,8 @@ char downloaddir[512] = "DOWNLOAD"; #ifdef CLIENT_LOADINGSCREEN // for cl loading screen INT32 lastfilenum = -1; +INT32 downloadcompletednum = 0; +INT32 totalfilesrequestednum = 0; #endif #ifdef HAVE_CURL @@ -330,6 +332,7 @@ boolean CL_SendRequestFile(void) // put it in download dir strcatbf(fileneeded[i].filename, downloaddir, "/"); fileneeded[i].status = FS_REQUESTED; + totalfilesrequestednum++; } WRITEUINT8(p, 0xFF); I_GetDiskFreeSpace(&availablefreespace); @@ -860,6 +863,7 @@ void Got_Filetxpak(void) file->status = FS_FOUND; CONS_Printf(M_GetText("Downloading %s...(done)\n"), filename); + downloadcompletednum++; } } else @@ -1171,6 +1175,7 @@ void CURLGetFile(void) { nameonly(curl_realname); CONS_Printf(M_GetText("Finished downloading %s\n"), curl_realname); + downloadcompletednum++; curl_curfile->status = FS_FOUND; fclose(curl_curfile->file); } diff --git a/src/d_netfil.h b/src/d_netfil.h index 3bc2d0d3..b9fdd00a 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -52,6 +52,8 @@ extern char downloaddir[512]; #ifdef CLIENT_LOADINGSCREEN extern INT32 lastfilenum; +extern INT32 downloadcompletednum; +extern INT32 totalfilesrequestednum; #endif #ifdef HAVE_CURL From 9d9105929b220867d7ef340ad17c63c0fe5a3c12 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 21 Mar 2020 21:35:02 -0400 Subject: [PATCH 03/27] Adjustment to new progress text --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0579eb23..5ef11c1a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1270,13 +1270,13 @@ static inline void CL_DrawConnectionStatus(void) va("%3.1fK/s ", ((double)getbps)/1024)); // Download progress - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Total File Download Progress"); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Overall Download Progress"); totalfileslength = (INT32)((downloadcompletednum/(double)totalfilesrequestednum) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %2u/%2u",downloadcompletednum,totalfilesrequestednum)); + va(" %2u/%2u Files",downloadcompletednum,totalfilesrequestednum)); } else V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-32, V_YELLOWMAP, From d96c938dbf05e012ebbda1c7db4f00bdc8802b57 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 27 Jun 2020 23:26:38 -0400 Subject: [PATCH 04/27] Add progress bar for file loading --- src/d_clisrv.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5ef11c1a..b9a3294a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1167,7 +1167,7 @@ static inline void CL_DrawConnectionStatus(void) // Draw background fade V_DrawFadeScreen(0xFF00, 16); - if (cl_mode != CL_DOWNLOADFILES + if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES #ifdef HAVE_CURL && cl_mode != CL_DOWNLOADHTTPFILES #endif @@ -1221,11 +1221,32 @@ static inline void CL_DrawConnectionStatus(void) cltext = M_GetText("Connecting to server..."); break; } - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-32, V_YELLOWMAP, cltext); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, cltext); } else { - if (lastfilenum != -1) + if (cl_mode == CL_LOADFILES) + { + INT32 totalfileslength; + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Press ESC to abort"); + + //ima just count files here + INT32 loadcompletednum = 0; + INT32 i; + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_OPEN) + loadcompletednum++; + + // Loading progress + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Loading server addons..."); + totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum+1)) * 256); + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + va(" %2u/%2u Files",loadcompletednum,fileneedednum+1)); + } + else if (lastfilenum != -1) { // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); From f2593219a64d37b59aabb71457164c8228600aa7 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 27 Jun 2020 23:40:13 -0400 Subject: [PATCH 05/27] Adjust text position --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b9a3294a..d529aebf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1228,7 +1228,7 @@ static inline void CL_DrawConnectionStatus(void) if (cl_mode == CL_LOADFILES) { INT32 totalfileslength; - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Press ESC to abort"); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort"); //ima just count files here INT32 loadcompletednum = 0; @@ -1238,7 +1238,7 @@ static inline void CL_DrawConnectionStatus(void) loadcompletednum++; // Loading progress - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Loading server addons..."); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Loading server addons..."); totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum+1)) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); From 8eb9a6946f4b1ac084280e71a6ecab2880c321d0 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 1 Jul 2020 21:40:21 -0400 Subject: [PATCH 06/27] Fix X/0 files display bug for legacy downloader Also made "Waiting to Download" consistent with other states --- src/d_clisrv.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d529aebf..afe518e0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1300,8 +1300,21 @@ static inline void CL_DrawConnectionStatus(void) va(" %2u/%2u Files",downloadcompletednum,totalfilesrequestednum)); } else - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-32, V_YELLOWMAP, + { + INT32 i, animtime = ((ccstime / 4) & 15) + 16; + UINT8 palstart = (cl_mode == CL_SEARCHING) ? 128 : 160; + // 15 pal entries total. + + //Draw bottom box + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort"); + + for (i = 0; i < 16; ++i) + V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); + + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, M_GetText("Waiting to download files...")); + } } } #endif @@ -1999,11 +2012,11 @@ static boolean CL_FinishedFileList(void) return false; } + downloadcompletednum = 0; + totalfilesrequestednum = 0; if (CL_SendRequestFile()) { cl_mode = CL_DOWNLOADFILES; - downloadcompletednum = 0; - totalfilesrequestednum = 0; } } #ifdef HAVE_CURL @@ -2147,10 +2160,10 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: + downloadcompletednum = 0; + totalfilesrequestednum = 0; if (http_source[0]) { - downloadcompletednum = 0; - totalfilesrequestednum = 0; for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { From 03d479fdb61108fd8804fff50d107a186d5779c4 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 1 Jul 2020 23:48:14 -0400 Subject: [PATCH 07/27] Connection screen no longer freezes up while searching for addons on disk Game will run one tic after every file status is updated --- src/d_clisrv.c | 6 +++++- src/d_netcmd.c | 6 +++--- src/d_netfil.c | 37 ++++++++++++++++++++++++------------- src/d_netfil.h | 1 + 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index afe518e0..7b419316 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1958,7 +1958,11 @@ static boolean CL_FinishedFileList(void) INT32 i; CONS_Printf(M_GetText("Checking files...\n")); i = CL_CheckFiles(); - if (i == 3) // too many files + if (i == 4) // still checking ... + { + return true; + } + else if (i == 3) // too many files { D_QuitNetGame(); CL_Reset(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7d94d2ed..8d778624 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4088,7 +4088,7 @@ static void Command_RunSOC(void) static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) { char filename[256]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; if (playernum != serverplayer && !IsPlayerAdmin(playernum)) { @@ -4260,7 +4260,7 @@ static void Command_Delfile(void) static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; UINT8 md5sum[16]; boolean kick = false; boolean toomany = false; @@ -4355,7 +4355,7 @@ static void Got_Delfilecmd(UINT8 **cp, INT32 playernum) static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; UINT8 md5sum[16]; READSTRINGN(*cp, filename, 240); diff --git a/src/d_netfil.c b/src/d_netfil.c index 7fd9e294..c4c2edd6 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -209,7 +209,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi p = (UINT8 *)fileneededstr; for (i = firstfile; i < fileneedednum; i++) { - fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet + fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet filestatus = READUINT8(p); // The first byte is the file status fileneeded[i].willsend = (UINT8)(filestatus >> 4); fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size @@ -373,6 +373,8 @@ boolean Got_RequestFilePak(INT32 node) * \return 0 if some files are missing * 1 if all files exist * 2 if some already loaded files are not requested or are in a different order + * 3 too many files, over WADLIMIT + * 4 still checking, continuing next tic * */ INT32 CL_CheckFiles(void) @@ -381,7 +383,8 @@ INT32 CL_CheckFiles(void) char wadfilename[MAX_WADPATH]; INT32 ret = 1; size_t packetsize = 0; - size_t filestoget = 0; + size_t filestoload = 0; + boolean downloadrequired = false; // if (M_CheckParm("-nofiles")) // return 1; @@ -427,6 +430,15 @@ INT32 CL_CheckFiles(void) for (i = 0; i < fileneedednum; i++) { + if (fileneeded[i].status != FS_OPEN) //little messy, but this will count right by the time we get through the last file + filestoload++; + + if (fileneeded[i].status == FS_NOTFOUND) + downloadrequired = true; + + if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics + continue; + CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files @@ -438,25 +450,24 @@ INT32 CL_CheckFiles(void) { CONS_Debug(DBG_NETPLAY, "already loaded\n"); fileneeded[i].status = FS_OPEN; - break; + return 4; } } - if (fileneeded[i].status != FS_NOTFOUND) - continue; packetsize += nameonlylength(fileneeded[i].filename) + 22; - if (mainwads+filestoget >= MAX_WADFILES) - return 3; - - filestoget++; - fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status); - if (fileneeded[i].status != FS_FOUND) - ret = 0; + return 4; } - return ret; + + //now making it here means we've checked the entire list and no FS_NOTCHECKED files remain + if (mainwads+filestoload >= MAX_WADFILES) + return 3; //ensure we wouldn't go over the wad limit + else if (downloadrequired) + return 0; //some stuff is FS_NOTFOUND, needs download + else + return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading } // Load it now diff --git a/src/d_netfil.h b/src/d_netfil.h index b9fdd00a..58ee8b7e 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -25,6 +25,7 @@ typedef enum typedef enum { + FS_NOTCHECKED, FS_NOTFOUND, FS_FOUND, FS_REQUESTED, From 6fe8a6c96af55f6d009d87ca785e77ac06827b0e Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 1 Jul 2020 23:52:43 -0400 Subject: [PATCH 08/27] Changed "this server has a lot of addons!" to "Checking server addon list ..." to be more informative --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7b419316..15b155bf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1203,7 +1203,7 @@ static inline void CL_DrawConnectionStatus(void) break; #endif case CL_ASKFULLFILELIST: - cltext = M_GetText("This server has a LOT of addons!"); + cltext = M_GetText("Checking server addon list ..."); break; case CL_LOADFILES: cltext = M_GetText("Loading server addons..."); From 774b917c0e069bc3eb87ff22e5522a58f698558f Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 2 Jul 2020 17:47:10 -0400 Subject: [PATCH 09/27] Correct total files to load off by one --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 15b155bf..a73df38a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1239,12 +1239,12 @@ static inline void CL_DrawConnectionStatus(void) // Loading progress V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Loading server addons..."); - totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum+1)) * 256); + totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %2u/%2u Files",loadcompletednum,fileneedednum+1)); + va(" %2u/%2u Files",loadcompletednum,fileneedednum)); } else if (lastfilenum != -1) { From b8fdd6b89cde9eceecca9893c5b164b34b9f1311 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 2 Jul 2020 20:57:33 -0400 Subject: [PATCH 10/27] Fix file number accounting Should ensure appropriate accounting and prevent loading of server files if it would put us over MAX_WADFILES --- src/d_netfil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index c4c2edd6..25825d52 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -143,7 +143,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) char wadfilename[MAX_WADPATH] = ""; UINT8 filestatus; - for (i = mainwads; i < numwadfiles; i++) + for (i = mainwads+1; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad { // If it has only music/sound lumps, don't put it in the list if (!wadfiles[i]->important) @@ -430,11 +430,11 @@ INT32 CL_CheckFiles(void) for (i = 0; i < fileneedednum; i++) { - if (fileneeded[i].status != FS_OPEN) //little messy, but this will count right by the time we get through the last file - filestoload++; - if (fileneeded[i].status == FS_NOTFOUND) downloadrequired = true; + + if (fileneeded[i].status == FS_FOUND || fileneeded[i].status == FS_NOTFOUND) + filestoload++; if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics continue; @@ -462,8 +462,8 @@ INT32 CL_CheckFiles(void) } //now making it here means we've checked the entire list and no FS_NOTCHECKED files remain - if (mainwads+filestoload >= MAX_WADFILES) - return 3; //ensure we wouldn't go over the wad limit + if (numwadfiles+filestoload > MAX_WADFILES) + return 3; else if (downloadrequired) return 0; //some stuff is FS_NOTFOUND, needs download else From 7da3d70f6c860a914a22c2dcec84321fb772f8ee Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 2 Jul 2020 21:48:45 -0400 Subject: [PATCH 11/27] Remove Checking Files spam --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a73df38a..13a0ab36 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1956,7 +1956,7 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) static boolean CL_FinishedFileList(void) { INT32 i; - CONS_Printf(M_GetText("Checking files...\n")); + //CONS_Printf(M_GetText("Checking files...\n")); i = CL_CheckFiles(); if (i == 4) // still checking ... { From 2c0671d8fdd3a9c7ca1b7b1c7ceb7953ee9eb7d4 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 4 Jul 2020 01:12:38 -0400 Subject: [PATCH 12/27] Let's just ALWAYS go into ask file list mode Easier to maintain and understand a single code path Rather than switching behavior based on amount of addons --- src/d_clisrv.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 13a0ab36..cc934173 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2085,17 +2085,9 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) if (serverlist[i].info.httpsource[0]) CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", serverlist[i].info.httpsource); #endif - - D_ParseFileneeded(serverlist[i].info.fileneedednum, serverlist[i].info.fileneeded, 0); - if (serverlist[i].info.kartvars & SV_LOTSOFADDONS) - { - cl_mode = CL_ASKFULLFILELIST; - cl_lastcheckedfilecount = 0; - return true; - } - - if (!CL_FinishedFileList()) - return false; + cl_mode = CL_ASKFULLFILELIST; + cl_lastcheckedfilecount = 0; + return true; } else cl_mode = CL_ASKJOIN; // files need not be checked for the server. From 159316b15507a782db7d13fb39218d90047871cd Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 4 Jul 2020 22:25:02 -0400 Subject: [PATCH 13/27] Remove now unused ret var --- src/d_netfil.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 25825d52..3b9d9081 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -381,7 +381,6 @@ INT32 CL_CheckFiles(void) { INT32 i, j; char wadfilename[MAX_WADPATH]; - INT32 ret = 1; size_t packetsize = 0; size_t filestoload = 0; boolean downloadrequired = false; From 4c5eb0d6bc8e4fe7ca137b754ea036ca384b0860 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sun, 9 Aug 2020 00:47:55 -0400 Subject: [PATCH 14/27] Redo logic for lots of files vs not Now new CL state for checking files so it can spread over tics whether we ask for the extended list or not --- src/d_clisrv.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cc934173..06684f83 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1093,6 +1093,7 @@ static INT16 Consistancy(void); typedef enum { CL_SEARCHING, + CL_CHECKFILES, CL_DOWNLOADFILES, CL_ASKJOIN, CL_LOADFILES, @@ -2085,9 +2086,15 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) if (serverlist[i].info.httpsource[0]) CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", serverlist[i].info.httpsource); #endif - cl_mode = CL_ASKFULLFILELIST; - cl_lastcheckedfilecount = 0; - return true; + D_ParseFileneeded(serverlist[i].info.fileneedednum, serverlist[i].info.fileneeded, 0); + if (serverlist[i].info.kartvars & SV_LOTSOFADDONS) + { + cl_mode = CL_ASKFULLFILELIST; + cl_lastcheckedfilecount = 0; + return true; + } + + cl_mode = CL_CHECKFILES; } else cl_mode = CL_ASKJOIN; // files need not be checked for the server. @@ -2140,10 +2147,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved - { - if (!CL_FinishedFileList()) - return false; - } + cl_mode = CL_CHECKFILES; else if (fileneedednum != cl_lastcheckedfilecount || *asksent + NEWTICRATE < I_GetTime()) { if (CL_AskFileList(fileneedednum)) @@ -2153,6 +2157,10 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic } } break; + case CL_CHECKFILES: + if (!CL_FinishedFileList()) + return false; + break; #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: From cc78ef2c7845656ad44cbaedb43c6e61bf3ffa21 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sun, 9 Aug 2020 00:48:53 -0400 Subject: [PATCH 15/27] Now that the server doesn't erroneously send the last mainwad As the first part of fileneeded, we must load file 0 --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 3b9d9081..6bdeab4b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -477,7 +477,7 @@ boolean CL_LoadServerFiles(void) // if (M_CheckParm("-nofiles")) // return; - for (i = 1; i < fileneedednum; i++) + for (i = 0; i < fileneedednum; i++) { if (fileneeded[i].status == FS_OPEN) continue; // Already loaded From f800159bb8a9e2d5f94ae08df86fde54b41dad7b Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 15 Aug 2020 01:03:45 -0400 Subject: [PATCH 16/27] Improve total downloads bar Now has total file size AND number of files --- src/d_clisrv.c | 26 +++++++++++++++++++++++--- src/d_netfil.c | 5 +++++ src/d_netfil.h | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 06684f83..186848fc 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1255,6 +1255,7 @@ static inline void CL_DrawConnectionStatus(void) INT32 dldlength; INT32 totalfileslength; + UINT32 totaldldsize; static char tempname[28]; fileneeded_t *file = &fileneeded[lastfilenum]; char *filename = file->filename; @@ -1292,13 +1293,27 @@ static inline void CL_DrawConnectionStatus(void) va("%3.1fK/s ", ((double)getbps)/1024)); // Download progress + + if (fileneeded[lastfilenum].currentsize != fileneeded[lastfilenum].totalsize) + totaldldsize = downloadcompletedsize+fileneeded[lastfilenum].currentsize; //Add in single file progress download if applicable + else + totaldldsize = downloadcompletedsize; + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Overall Download Progress"); - totalfileslength = (INT32)((downloadcompletednum/(double)totalfilesrequestednum) * 256); + totalfileslength = (INT32)((totaldldsize/(double)totalfilesrequestedsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %2u/%2u Files",downloadcompletednum,totalfilesrequestednum)); + + if (totalfilesrequestedsize>>20 >= 100) //display in MB if over 100MB + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + va(" %4uM/%4uM",totaldldsize>>20,totalfilesrequestedsize>>20)); + else + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + va(" %4uK/%4uK",totaldldsize>>10,totalfilesrequestedsize>>10)); + + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, + va("%2u/%2u Files ",downloadcompletednum,totalfilesrequestednum)); } else { @@ -2018,7 +2033,9 @@ static boolean CL_FinishedFileList(void) } downloadcompletednum = 0; + downloadcompletedsize = 0; totalfilesrequestednum = 0; + totalfilesrequestedsize = 0; if (CL_SendRequestFile()) { cl_mode = CL_DOWNLOADFILES; @@ -2165,7 +2182,9 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: downloadcompletednum = 0; + downloadcompletedsize = 0; totalfilesrequestednum = 0; + totalfilesrequestedsize = 0; if (http_source[0]) { for (i = 0; i < fileneedednum; i++) @@ -2173,6 +2192,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic { curl_transfers++; totalfilesrequestednum++; + totalfilesrequestedsize += fileneeded[i].totalsize; } cl_mode = CL_DOWNLOADHTTPFILES; diff --git a/src/d_netfil.c b/src/d_netfil.c index 6bdeab4b..0a2b1579 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -109,7 +109,9 @@ char downloaddir[512] = "DOWNLOAD"; // for cl loading screen INT32 lastfilenum = -1; INT32 downloadcompletednum = 0; +UINT32 downloadcompletedsize = 0; INT32 totalfilesrequestednum = 0; +UINT32 totalfilesrequestedsize = 0; #endif #ifdef HAVE_CURL @@ -333,6 +335,7 @@ boolean CL_SendRequestFile(void) strcatbf(fileneeded[i].filename, downloaddir, "/"); fileneeded[i].status = FS_REQUESTED; totalfilesrequestednum++; + totalfilesrequestedsize += fileneeded[i].totalsize; } WRITEUINT8(p, 0xFF); I_GetDiskFreeSpace(&availablefreespace); @@ -874,6 +877,7 @@ void Got_Filetxpak(void) CONS_Printf(M_GetText("Downloading %s...(done)\n"), filename); downloadcompletednum++; + downloadcompletedsize += file->totalsize; } } else @@ -1186,6 +1190,7 @@ void CURLGetFile(void) nameonly(curl_realname); CONS_Printf(M_GetText("Finished downloading %s\n"), curl_realname); downloadcompletednum++; + downloadcompletedsize += curl_curfile->totalsize; curl_curfile->status = FS_FOUND; fclose(curl_curfile->file); } diff --git a/src/d_netfil.h b/src/d_netfil.h index 58ee8b7e..905364e3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -54,7 +54,9 @@ extern char downloaddir[512]; #ifdef CLIENT_LOADINGSCREEN extern INT32 lastfilenum; extern INT32 downloadcompletednum; +extern UINT32 downloadcompletedsize; extern INT32 totalfilesrequestednum; +extern UINT32 totalfilesrequestedsize; #endif #ifdef HAVE_CURL From 9a9d81bbe0c4e57e52db7e5eb61319ac5f36d1af Mon Sep 17 00:00:00 2001 From: Ashnal Date: Mon, 17 Aug 2020 03:47:23 -0400 Subject: [PATCH 17/27] New message boxes for downloads and full server waiting Downloads must be confirmed before proceeding Allows downloading mods for full servers Client will wait for a slot to open on a full server to join This has a 5 minute timeout --- src/d_clisrv.c | 212 +++++++++++++++++++++++++++++++++++++++---------- src/d_netfil.c | 4 +- 2 files changed, 170 insertions(+), 46 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 186848fc..3d910d9e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -141,6 +141,9 @@ char connectedservername[MAXSERVERNAME]; /// \todo WORK! boolean acceptnewnode = true; +boolean serverisfull = false; //lets us be aware if the server was full after we check files, but before downloading, so we can ask if the user still wants to download or not +tic_t firstconnectattempttime = 0; + // engine // Must be a power of two @@ -1104,6 +1107,7 @@ typedef enum CL_CONNECTED, CL_ABORTED, CL_ASKFULLFILELIST, + CL_CONFIRMCONNECT, #ifdef HAVE_CURL CL_PREPAREHTTPFILES, CL_DOWNLOADHTTPFILES, @@ -1204,14 +1208,22 @@ static inline void CL_DrawConnectionStatus(void) break; #endif case CL_ASKFULLFILELIST: + case CL_CHECKFILES: cltext = M_GetText("Checking server addon list ..."); break; + case CL_CONFIRMCONNECT: + cltext = ""; + break; case CL_LOADFILES: cltext = M_GetText("Loading server addons..."); break; case CL_ASKJOIN: case CL_WAITJOINRESPONSE: - cltext = M_GetText("Requesting to join..."); + if (serverisfull) + cltext = M_GetText("Server full, waiting for a slot..."); + else + cltext = M_GetText("Requesting to join..."); + break; #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: @@ -1969,9 +1981,42 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) #endif // ifndef NONET +static void M_ConfirmConnect(INT32 ch) +{ + if (ch == ' ' || ch == 'y' || ch == KEY_ENTER) + { + if (totalfilesrequestednum > 0) + { +#ifdef HAVE_CURL + if (http_source[0] == '\0' || curl_failedwebdownload) +#endif + { + if (CL_SendRequestFile()) + { + cl_mode = CL_DOWNLOADFILES; + } + } +#ifdef HAVE_CURL + else + cl_mode = CL_PREPAREHTTPFILES; +#endif + } + else + cl_mode = CL_LOADFILES; + + M_ClearMenus(true); + } + else if (ch == 'n' || ch == KEY_ESCAPE) + { + cl_mode = CL_ABORTED; + M_ClearMenus(true); + } +} + static boolean CL_FinishedFileList(void) { INT32 i; + char *downloadsize; //CONS_Printf(M_GetText("Checking files...\n")); i = CL_CheckFiles(); if (i == 4) // still checking ... @@ -2007,7 +2052,21 @@ static boolean CL_FinishedFileList(void) return false; } else if (i == 1) - cl_mode = CL_LOADFILES; + { + if (serverisfull) + { + M_StartMessage(M_GetText( + "This server is full!\n" + "\n" + "You may load server addons (if any), and wait for a slot.\n" + "\n" + "Press ACCEL to continue or BRAKE to cancel.\n\n" + ), M_ConfirmConnect, MM_YESNO); + cl_mode = CL_CONFIRMCONNECT; + } + else + cl_mode = CL_LOADFILES; + } else { // must download something @@ -2031,20 +2090,55 @@ static boolean CL_FinishedFileList(void) ), NULL, MM_NOTHING); return false; } + } +#ifdef HAVE_CURL + if (!curl_failedwebdownload) +#endif + { downloadcompletednum = 0; downloadcompletedsize = 0; totalfilesrequestednum = 0; totalfilesrequestedsize = 0; - if (CL_SendRequestFile()) - { - cl_mode = CL_DOWNLOADFILES; - } + + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + { + totalfilesrequestednum++; + totalfilesrequestedsize += fileneeded[i].totalsize; + } + + if (totalfilesrequestedsize>>20 >= 100) + downloadsize = Z_StrDup(va("%uM",totalfilesrequestedsize>>20)); + else + downloadsize = Z_StrDup(va("%uK",totalfilesrequestedsize>>10)); + + if (serverisfull) + M_StartMessage(va(M_GetText( + "This server is full!\n" + "Download of %s additional content is required to join.\n" + "\n" + "You may download, load server addons, and wait for a slot.\n" + "\n" + "Press ACCEL to continue or BRAKE to cancel.\n\n" + ), downloadsize), M_ConfirmConnect, MM_YESNO); + else + M_StartMessage(va(M_GetText( + "Download of %s additional content is required to join.\n" + "\n" + "Press ACCEL to continue or BRAKE to cancel.\n\n" + ), downloadsize), M_ConfirmConnect, MM_YESNO); + + Z_Free(downloadsize); + cl_mode = CL_CONFIRMCONNECT; } #ifdef HAVE_CURL else { - cl_mode = CL_PREPAREHTTPFILES; + if (CL_SendRequestFile()) + { + cl_mode = CL_DOWNLOADFILES; + } } #endif } @@ -2085,11 +2179,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) // Quit here rather than downloading files and being refused later. if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer) { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING); - return false; + serverisfull = true; } if (client) @@ -2150,7 +2240,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic { boolean waitmore; INT32 i; - + #ifdef NONET (void)tmpsave; #endif @@ -2178,21 +2268,14 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (!CL_FinishedFileList()) return false; break; - #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: - downloadcompletednum = 0; - downloadcompletedsize = 0; - totalfilesrequestednum = 0; - totalfilesrequestedsize = 0; if (http_source[0]) { for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { curl_transfers++; - totalfilesrequestednum++; - totalfilesrequestedsize += fileneeded[i].totalsize; } cl_mode = CL_DOWNLOADHTTPFILES; @@ -2218,19 +2301,13 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (curl_failedwebdownload && !curl_transfers) { - if (!CL_FinishedFileList()) - break; - CONS_Printf("One or more files failed to download, falling back to internal downloader\n"); - if (CL_SendRequestFile()) - { - cl_mode = CL_DOWNLOADFILES; - break; - } + cl_mode = CL_CHECKFILES; + break; } if (!curl_transfers) - cl_mode = CL_LOADFILES; // don't break case continue to cljoin request now + cl_mode = CL_LOADFILES; break; #endif @@ -2246,22 +2323,49 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (waitmore) break; // exit the case - cl_mode = CL_LOADFILES; // don't break case continue to cljoin request now + cl_mode = CL_LOADFILES; break; case CL_LOADFILES: - if (!CL_LoadServerFiles()) - break; + if (CL_LoadServerFiles()) + { + *asksent = I_GetTime() - (NEWTICRATE*5); //This ensure the first join ask is right away + firstconnectattempttime = I_GetTime(); + cl_mode = CL_ASKJOIN; + } + break; case CL_ASKJOIN: + if (firstconnectattempttime + NEWTICRATE*300 < I_GetTime()) + { + CONS_Printf(M_GetText("5 minute wait time exceeded.\n")); + CONS_Printf(M_GetText("Network game synchronization aborted.\n")); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "5 minute wait time exceeded.\n" + "You may retry connection.\n" + "\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + } #ifdef JOININGAME // prepare structures to save the file // WARNING: this can be useless in case of server not in GS_LEVEL // but since the network layer doesn't provide ordered packets... CL_PrepareDownloadSaveGame(tmpsave); #endif - if (CL_SendJoin()) + if ((*asksent + NEWTICRATE*3) < I_GetTime() && CL_SendJoin()) + { + *asksent = I_GetTime(); cl_mode = CL_WAITJOINRESPONSE; + } + break; + case CL_WAITJOINRESPONSE: + if ((*asksent + NEWTICRATE*3) < I_GetTime()) + { + cl_mode = CL_ASKJOIN; + } break; - #ifdef JOININGAME case CL_DOWNLOADSAVEGAME: // At this state, the first (and only) needed file is the gamestate @@ -2270,13 +2374,13 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic // Gamestate is now handled within CL_LoadReceivedSavegame() CL_LoadReceivedSavegame(); cl_mode = CL_CONNECTED; + break; } // don't break case continue to CL_CONNECTED else break; #endif - - case CL_WAITJOINRESPONSE: case CL_CONNECTED: + case CL_CONFIRMCONNECT: //logic is handled by M_ConfirmConnect default: break; @@ -2297,9 +2401,13 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic INT32 key; I_OsPolling(); + + if (cl_mode == CL_CONFIRMCONNECT) + D_ProcessEvents(); //needed for menu system to receive inputs + key = I_GetKey(); // Only ESC and non-keyboard keys abort connection - if (key == KEY_ESCAPE || key >= KEY_MOUSE1) + if (key == KEY_ESCAPE || key >= KEY_MOUSE1 || cl_mode == CL_ABORTED) { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); D_QuitNetGame(); @@ -2316,6 +2424,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic F_TitleScreenTicker(true); F_TitleScreenDrawer(); CL_DrawConnectionStatus(); + M_Drawer(); //Needed for drawing messageboxes on the connection screen I_UpdateNoVsync(); // page flip or blit buffer if (moviemode) M_SaveFrame(); @@ -2824,6 +2933,12 @@ void CL_Reset(void) fileneedednum = 0; memset(fileneeded, 0, sizeof(fileneeded)); + totalfilesrequestednum = 0; + totalfilesrequestedsize = 0; + firstconnectattempttime = 0; + serverisfull = false; + connectiontimeout = (tic_t)cv_nettimeout.value; //reset this temporary hack + #ifdef HAVE_CURL curl_failedwebdownload = false; curl_transfers = 0; @@ -3746,7 +3861,7 @@ void SV_StopServer(void) D_Clearticcmd(i); consoleplayer = 0; - cl_mode = CL_SEARCHING; + cl_mode = CL_ABORTED; maketic = gametic+1; neededtic = maketic; serverrunning = false; @@ -3772,7 +3887,7 @@ static void SV_SendRefuse(INT32 node, const char *reason) strcpy(netbuffer->u.serverrefuse.reason, reason); netbuffer->packettype = PT_SERVERREFUSE; - HSendPacket(node, true, 0, strlen(netbuffer->u.serverrefuse.reason) + 1); + HSendPacket(node, false, 0, strlen(netbuffer->u.serverrefuse.reason) + 1); Net_CloseConnection(node); } @@ -4044,13 +4159,24 @@ static void HandlePacketFromAwayNode(SINT8 node) if (!reason) I_Error("Out of memory!\n"); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + if (strstr(reason, "Maximum players reached")) + { + serverisfull = true; + //Special timeout for when refusing due to player cap. The client will wait 3 seconds between join requests when waiting for a slot, so we need this to be much longer + //We set it back to the value of cv_nettimeout.value in CL_Reset + connectiontimeout = NEWTICRATE*7; + cl_mode = CL_ASKJOIN; + free(reason); + break; + } M_StartMessage(va(M_GetText("Server refuses connection\n\nReason:\n%s"), reason), NULL, MM_NOTHING); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + free(reason); // Will be reset by caller. Signals refusal. @@ -4070,7 +4196,7 @@ static void HandlePacketFromAwayNode(SINT8 node) } SERVERONLY /// \note how would this happen? and is it doing the right thing if it does? - if (cl_mode != CL_WAITJOINRESPONSE) + if (!(cl_mode == CL_WAITJOINRESPONSE || cl_mode == CL_ASKJOIN)) break; if (client) diff --git a/src/d_netfil.c b/src/d_netfil.c index 0a2b1579..eca0db69 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -334,8 +334,6 @@ boolean CL_SendRequestFile(void) // put it in download dir strcatbf(fileneeded[i].filename, downloaddir, "/"); fileneeded[i].status = FS_REQUESTED; - totalfilesrequestednum++; - totalfilesrequestedsize += fileneeded[i].totalsize; } WRITEUINT8(p, 0xFF); I_GetDiskFreeSpace(&availablefreespace); @@ -432,7 +430,7 @@ INT32 CL_CheckFiles(void) for (i = 0; i < fileneedednum; i++) { - if (fileneeded[i].status == FS_NOTFOUND) + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_FALLBACK) downloadrequired = true; if (fileneeded[i].status == FS_FOUND || fileneeded[i].status == FS_NOTFOUND) From afc6bdbc7ee5567ddf3a1981e7bccea45ad9e3ec Mon Sep 17 00:00:00 2001 From: Ashnal Date: Mon, 17 Aug 2020 03:51:19 -0400 Subject: [PATCH 18/27] Fixes for file accounting mainwads+1 to not use the first mainwad --- src/d_netfil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index eca0db69..fd28413b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -401,7 +401,7 @@ INT32 CL_CheckFiles(void) if (modifiedgame) { CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n"); - for (i = 0, j = mainwads; i < fileneedednum || j < numwadfiles;) + for (i = 0, j = mainwads+1; i < fileneedednum || j < numwadfiles;) { if (j < numwadfiles && !wadfiles[j]->important) { @@ -442,7 +442,7 @@ INT32 CL_CheckFiles(void) CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files - for (j = mainwads; wadfiles[j]; j++) + for (j = mainwads+1; wadfiles[j]; j++) { nameonly(strcpy(wadfilename, wadfiles[j]->filename)); if (!stricmp(wadfilename, fileneeded[i].filename) && From 03150e5fe6998ac6beeb1cf600057326465894b1 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Mon, 17 Aug 2020 03:56:13 -0400 Subject: [PATCH 19/27] Move declaration to appease C90 also remove some extra tab characters --- src/d_clisrv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3d910d9e..bb3fb3e1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1241,15 +1241,16 @@ static inline void CL_DrawConnectionStatus(void) if (cl_mode == CL_LOADFILES) { INT32 totalfileslength; + INT32 loadcompletednum = 0; + INT32 i; + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort"); //ima just count files here - INT32 loadcompletednum = 0; - INT32 i; for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_OPEN) loadcompletednum++; - + // Loading progress V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Loading server addons..."); totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256); @@ -1279,8 +1280,6 @@ static inline void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); - - memset(tempname, 0, sizeof(tempname)); // offset filename to just the name only part filename += strlen(filename) - nameonlylength(filename); @@ -1323,7 +1322,7 @@ static inline void CL_DrawConnectionStatus(void) else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va(" %4uK/%4uK",totaldldsize>>10,totalfilesrequestedsize>>10)); - + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va("%2u/%2u Files ",downloadcompletednum,totalfilesrequestednum)); } From eb81bea943e2b6028332de2362c65907abcd7924 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Mon, 17 Aug 2020 04:03:02 -0400 Subject: [PATCH 20/27] Move code down so declarations are above to appease C90 --- src/d_clisrv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index bb3fb3e1..2212a64b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1262,10 +1262,6 @@ static inline void CL_DrawConnectionStatus(void) } else if (lastfilenum != -1) { - // Draw the bottom box. - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP, "Press ESC to abort"); - INT32 dldlength; INT32 totalfileslength; UINT32 totaldldsize; @@ -1273,6 +1269,10 @@ static inline void CL_DrawConnectionStatus(void) fileneeded_t *file = &fileneeded[lastfilenum]; char *filename = file->filename; + // Draw the bottom box. + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP, "Press ESC to abort"); + Net_GetNetStat(); dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); if (dldlength > 256) From 7c5740d98f1d304576f09cac0170e8dc0838392b Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 19 Aug 2020 18:01:56 -0400 Subject: [PATCH 21/27] COnfirm box now respects rebindable accelerate and brake on keyboards --- src/d_clisrv.c | 53 ++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2212a64b..5b02fc5e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1980,35 +1980,38 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) #endif // ifndef NONET -static void M_ConfirmConnect(INT32 ch) +static void M_ConfirmConnect(event_t *ev) { - if (ch == ' ' || ch == 'y' || ch == KEY_ENTER) + if (ev->type == ev_keydown) { - if (totalfilesrequestednum > 0) + if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[gc_accelerate][0] || ev->data1 == gamecontrol[gc_accelerate][1]) { -#ifdef HAVE_CURL - if (http_source[0] == '\0' || curl_failedwebdownload) -#endif + if (totalfilesrequestednum > 0) { - if (CL_SendRequestFile()) - { - cl_mode = CL_DOWNLOADFILES; - } - } #ifdef HAVE_CURL - else - cl_mode = CL_PREPAREHTTPFILES; + if (http_source[0] == '\0' || curl_failedwebdownload) #endif + { + if (CL_SendRequestFile()) + { + cl_mode = CL_DOWNLOADFILES; + } + } +#ifdef HAVE_CURL + else + cl_mode = CL_PREPAREHTTPFILES; +#endif + } + else + cl_mode = CL_LOADFILES; + + M_ClearMenus(true); + } + else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[gc_brake][0] || ev->data1 == gamecontrol[gc_brake][1]) + { + cl_mode = CL_ABORTED; + M_ClearMenus(true); } - else - cl_mode = CL_LOADFILES; - - M_ClearMenus(true); - } - else if (ch == 'n' || ch == KEY_ESCAPE) - { - cl_mode = CL_ABORTED; - M_ClearMenus(true); } } @@ -2060,7 +2063,7 @@ static boolean CL_FinishedFileList(void) "You may load server addons (if any), and wait for a slot.\n" "\n" "Press ACCEL to continue or BRAKE to cancel.\n\n" - ), M_ConfirmConnect, MM_YESNO); + ), M_ConfirmConnect, MM_EVENTHANDLER); cl_mode = CL_CONFIRMCONNECT; } else @@ -2120,13 +2123,13 @@ static boolean CL_FinishedFileList(void) "You may download, load server addons, and wait for a slot.\n" "\n" "Press ACCEL to continue or BRAKE to cancel.\n\n" - ), downloadsize), M_ConfirmConnect, MM_YESNO); + ), downloadsize), M_ConfirmConnect, MM_EVENTHANDLER); else M_StartMessage(va(M_GetText( "Download of %s additional content is required to join.\n" "\n" "Press ACCEL to continue or BRAKE to cancel.\n\n" - ), downloadsize), M_ConfirmConnect, MM_YESNO); + ), downloadsize), M_ConfirmConnect, MM_EVENTHANDLER); Z_Free(downloadsize); cl_mode = CL_CONFIRMCONNECT; From cadb4719cfb958b60be85256768ad5b63784a31f Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 19 Aug 2020 19:52:24 -0400 Subject: [PATCH 22/27] Added m_menu_mutex to M_Drawer in connection screen --- src/d_clisrv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6b8c107b..3a7626ef 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2484,7 +2484,13 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic F_TitleScreenTicker(true); F_TitleScreenDrawer(); CL_DrawConnectionStatus(); +#ifdef HAVE_THREADS + I_lock_mutex(&m_menu_mutex); +#endif M_Drawer(); //Needed for drawing messageboxes on the connection screen +#ifdef HAVE_THREADS + I_unlock_mutex(m_menu_mutex); +#endif I_UpdateNoVsync(); // page flip or blit buffer if (moviemode) M_SaveFrame(); From 1cd7c3b74764af1bf46e8a81376012dc719ae918 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 19 Aug 2020 17:47:07 -0700 Subject: [PATCH 23/27] Rearrange time comparsion on asksent to make it underflow friendly This fixes '-connect'. NEWTICRATE*5 is subtracted from asksent after CL_LOADFILES. If this happens too early, an underflow will occur. --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3a7626ef..e947964c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2414,14 +2414,14 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // but since the network layer doesn't provide ordered packets... CL_PrepareDownloadSaveGame(tmpsave); #endif - if ((*asksent + NEWTICRATE*3) < I_GetTime() && CL_SendJoin()) + if (( I_GetTime() - NEWTICRATE*3 ) >= *asksent && CL_SendJoin()) { *asksent = I_GetTime(); cl_mode = CL_WAITJOINRESPONSE; } break; case CL_WAITJOINRESPONSE: - if ((*asksent + NEWTICRATE*3) < I_GetTime()) + if (( I_GetTime() - NEWTICRATE*3 ) >= *asksent && CL_SendJoin()) { cl_mode = CL_ASKJOIN; } From 65968f00d3c0ef69fa3d0304fe70ec51651ee6bd Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 19 Aug 2020 17:55:01 -0700 Subject: [PATCH 24/27] Fix tiny mistake with the last commit --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e947964c..929a992c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2421,7 +2421,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic } break; case CL_WAITJOINRESPONSE: - if (( I_GetTime() - NEWTICRATE*3 ) >= *asksent && CL_SendJoin()) + if (( I_GetTime() - NEWTICRATE*3 ) >= *asksent) { cl_mode = CL_ASKJOIN; } From aa2b25e667f90c4d46e914cb191d3004f55d2546 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 20 Aug 2020 00:54:18 -0400 Subject: [PATCH 25/27] Well actually, lets fix all comparisons of askset to use the same comparison If we initialize to I_GetTime() - NEWTICRATE*3 it never underflows and everything is good --- src/d_clisrv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 929a992c..e22ab463 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2271,7 +2271,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) } // Ask the info to the server (askinfo packet) - if (*asksent + NEWTICRATE < I_GetTime()) + if ((I_GetTime() - NEWTICRATE) >= *asksent) { SendAskInfo(servernode); *asksent = I_GetTime(); @@ -2315,7 +2315,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved cl_mode = CL_CHECKFILES; - else if (fileneedednum != cl_lastcheckedfilecount || *asksent + NEWTICRATE < I_GetTime()) + else if (fileneedednum != cl_lastcheckedfilecount || (I_GetTime() - NEWTICRATE) >= *asksent) { if (CL_AskFileList(fileneedednum)) { @@ -2388,7 +2388,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_LOADFILES: if (CL_LoadServerFiles()) { - *asksent = I_GetTime() - (NEWTICRATE*5); //This ensure the first join ask is right away + *asksent = I_GetTime() - (NEWTICRATE*3); //This ensure the first join ask is right away firstconnectattempttime = I_GetTime(); cl_mode = CL_ASKJOIN; } @@ -2557,7 +2557,7 @@ static void CL_ConnectToServer(void) pnumnodes = 1; oldtic = I_GetTime() - 1; #ifndef NONET - asksent = (tic_t) - TICRATE; + asksent = I_GetTime() - NEWTICRATE*3; i = SL_SearchServer(servernode); From 247239c2bc6dd7298697050225111f9d9ac8fcd5 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 20 Aug 2020 23:09:12 -0400 Subject: [PATCH 26/27] Add return false to the connect timeout --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e22ab463..2a138177 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2407,6 +2407,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic "\n" "Press ESC\n" ), NULL, MM_NOTHING); + return false; } #ifdef JOININGAME // prepare structures to save the file From 9e1d7146add13f9443fa36b9e9e742f93cd63986 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Thu, 20 Aug 2020 23:38:04 -0400 Subject: [PATCH 27/27] Fixed retry timeout to no ttrigger when starting a local server --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2a138177..2441659c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2394,7 +2394,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic } break; case CL_ASKJOIN: - if (firstconnectattempttime + NEWTICRATE*300 < I_GetTime()) + if (firstconnectattempttime + NEWTICRATE*300 < I_GetTime() && !server) { CONS_Printf(M_GetText("5 minute wait time exceeded.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n")); @@ -2559,6 +2559,7 @@ static void CL_ConnectToServer(void) oldtic = I_GetTime() - 1; #ifndef NONET asksent = I_GetTime() - NEWTICRATE*3; + firstconnectattempttime = I_GetTime(); i = SL_SearchServer(servernode);