Download the generic filelist only once.

Cleaning the download queue as soon as a file finished downloading leads
in combination with only one parallel download and multiple precacher
runs to an ugly problem: The generic filelist is requested several time
which can lead to cycles. Hack around this by rembering if we already
requested it and reset set reminder as soon as the precacher finished.

Yes, I'm feeling dirty.
This commit is contained in:
Yamagi Burmeister 2019-01-23 19:32:31 +01:00
parent 5e67596d56
commit d38929170b
3 changed files with 19 additions and 3 deletions

View file

@ -455,6 +455,9 @@ CL_RequestNextDownload(void)
/* This map was done, allow HTTP again for next map. */ /* This map was done, allow HTTP again for next map. */
forceudp = false; forceudp = false;
/* And generic filelists for next map. */
CL_HTTP_EnableGenericFilelist();
CL_RegisterSounds(); CL_RegisterSounds();
CL_PrepRefresh(); CL_PrepRefresh();

View file

@ -49,6 +49,7 @@ static int pendingCount = 0;
static int abortDownloads = HTTPDL_ABORT_NONE; static int abortDownloads = HTTPDL_ABORT_NONE;
static qboolean httpDown = false; static qboolean httpDown = false;
static qboolean downloadError = false; static qboolean downloadError = false;
static qboolean downloadFilelist = true;
// -------- // --------
@ -996,9 +997,10 @@ qboolean CL_QueueHTTPDownload(const char *quakePath)
// the generic(!) filelist. // the generic(!) filelist.
qboolean needList = false; qboolean needList = false;
if (!cls.downloadQueue.next && cl_http_filelists->value) if (downloadFilelist && cl_http_filelists->value)
{ {
needList = true; needList = true;
downloadFilelist = false;
} }
// Queue the download. // Queue the download.
@ -1072,10 +1074,11 @@ qboolean CL_PendingHTTPDownloads(void)
return pendingCount + handleCount; return pendingCount + handleCount;
} }
/* Checks if there was an error. Returns /*
* Checks if there was an error. Returns
* true if yes, and false if not. * true if yes, and false if not.
*/ */
qboolean CL_CheckHTTPError() qboolean CL_CheckHTTPError(void)
{ {
if (downloadError) if (downloadError)
{ {
@ -1088,6 +1091,15 @@ qboolean CL_CheckHTTPError()
} }
} }
/*
* Enables generic file list download starting
* with the next file. Yes, this is dirty.
*/
void CL_HTTP_EnableGenericFilelist(void)
{
downloadFilelist = true;
}
/* /*
* Calls CURL to perform the actual downloads. * Calls CURL to perform the actual downloads.
* Must be called every frame, otherwise CURL * Must be called every frame, otherwise CURL

View file

@ -73,6 +73,7 @@ qboolean CL_PendingHTTPDownloads(void);
void CL_SetHTTPServer(const char *URL); void CL_SetHTTPServer(const char *URL);
void CL_HTTP_Cleanup(qboolean fullShutdown); void CL_HTTP_Cleanup(qboolean fullShutdown);
qboolean CL_CheckHTTPError(); qboolean CL_CheckHTTPError();
void CL_HTTP_EnableGenericFilelist(void);
#endif // DOWNLOAD_H #endif // DOWNLOAD_H
#endif // USE_CURL #endif // USE_CURL