From d38929170bb8ad98e987acd795a261326cedc35d Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Wed, 23 Jan 2019 19:32:31 +0100 Subject: [PATCH] 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. --- src/client/cl_download.c | 3 +++ src/client/curl/download.c | 18 +++++++++++++++--- src/client/curl/header/download.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/client/cl_download.c b/src/client/cl_download.c index 1e30a226..3920dd56 100644 --- a/src/client/cl_download.c +++ b/src/client/cl_download.c @@ -455,6 +455,9 @@ CL_RequestNextDownload(void) /* This map was done, allow HTTP again for next map. */ forceudp = false; + /* And generic filelists for next map. */ + CL_HTTP_EnableGenericFilelist(); + CL_RegisterSounds(); CL_PrepRefresh(); diff --git a/src/client/curl/download.c b/src/client/curl/download.c index 849526a3..822fcf09 100644 --- a/src/client/curl/download.c +++ b/src/client/curl/download.c @@ -49,6 +49,7 @@ static int pendingCount = 0; static int abortDownloads = HTTPDL_ABORT_NONE; static qboolean httpDown = false; static qboolean downloadError = false; +static qboolean downloadFilelist = true; // -------- @@ -996,9 +997,10 @@ qboolean CL_QueueHTTPDownload(const char *quakePath) // the generic(!) filelist. qboolean needList = false; - if (!cls.downloadQueue.next && cl_http_filelists->value) + if (downloadFilelist && cl_http_filelists->value) { needList = true; + downloadFilelist = false; } // Queue the download. @@ -1072,10 +1074,11 @@ qboolean CL_PendingHTTPDownloads(void) return pendingCount + handleCount; } -/* Checks if there was an error. Returns +/* + * Checks if there was an error. Returns * true if yes, and false if not. */ -qboolean CL_CheckHTTPError() +qboolean CL_CheckHTTPError(void) { 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. * Must be called every frame, otherwise CURL diff --git a/src/client/curl/header/download.h b/src/client/curl/header/download.h index 3cb2f09d..0cc84650 100644 --- a/src/client/curl/header/download.h +++ b/src/client/curl/header/download.h @@ -73,6 +73,7 @@ qboolean CL_PendingHTTPDownloads(void); void CL_SetHTTPServer(const char *URL); void CL_HTTP_Cleanup(qboolean fullShutdown); qboolean CL_CheckHTTPError(); +void CL_HTTP_EnableGenericFilelist(void); #endif // DOWNLOAD_H #endif // USE_CURL