Load one file per tic

Prevents game from locking up when loading large file lists
This commit is contained in:
Ashnal 2020-06-27 20:58:33 -04:00
parent f856f18233
commit 12d40a07cc
3 changed files with 16 additions and 9 deletions

View file

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

View file

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

View file

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