From 3a24b9d6cfb5aa003204c0fc2e9c79e4de9f3f23 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 2 Dec 2018 10:13:51 +0100 Subject: [PATCH] Remove the download speed calculation. While the download speed calculations may be useful their implementation is crappy and the integration into the console is rather fragile. If we really want to support the progress bar with HTTP downloads this needs to be reimplemented. --- src/client/cl_http.c | 73 +++++++------------------------------------- 1 file changed, 11 insertions(+), 62 deletions(-) diff --git a/src/client/cl_http.c b/src/client/cl_http.c index 2298a5c9..b43b290e 100644 --- a/src/client/cl_http.c +++ b/src/client/cl_http.c @@ -18,31 +18,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include /* FS: For isalnum */ +#include #include "header/client.h" #ifdef USE_CURL -cvar_t *cl_http_downloads; -cvar_t *cl_http_filelists; -cvar_t *cl_http_proxy; -cvar_t *cl_http_max_connections; +cvar_t *cl_http_downloads; +cvar_t *cl_http_filelists; +cvar_t *cl_http_proxy; +cvar_t *cl_http_max_connections; typedef enum { HTTPDL_ABORT_NONE, HTTPDL_ABORT_SOFT, HTTPDL_ABORT_HARD -}http_abort_t; +} http_abort_t; -static CURLM *multi = NULL; -static int handleCount = 0; -static int pendingCount = 0; -static int abortDownloads = HTTPDL_ABORT_NONE; +static CURLM *multi = NULL; +static int handleCount = 0; +static int pendingCount = 0; +static int abortDownloads = HTTPDL_ABORT_NONE; static qboolean downloading_pak = false; static qboolean httpDown = false; -static qboolean thisMapAbort = false; // Knightmare- whether to fall back to UDP for this map -static int prevSize; // Knightmare- for KBps counter +static qboolean thisMapAbort = false; /* =============================== @@ -59,55 +58,6 @@ on the HTTP server should ideally be gzipped to conserve bandwidth. */ -/* -=============== -CL_HTTP_Calculate_KBps - -Essentially a wrapper for CL_Download_Calcualte_KBps(), -calcuates bytes since last update and calls the above. -=============== -*/ -static void CL_HTTP_Calculate_KBps (int curSize, int totalSize) -{ - int byteDistance = curSize - prevSize; - - //CL_Download_Calculate_KBps (byteDistance, totalSize); - prevSize = curSize; -} - -/* -=============== -CL_HTTP_Progress - -libcurl callback to update progress info. Mainly just used as -a way to cancel the transfer if required. -=============== -*/ -static int /*EXPORT*/ CL_HTTP_Progress (void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) -{ - dlhandle_t *dl; - - dl = (dlhandle_t *)clientp; - - dl->position = (unsigned)dlnow; - - // don't care which download shows as long as something does :) - if (!abortDownloads) - { - Q_strlcpy(cls.downloadname, dl->queueEntry->quakePath, sizeof(cls.downloadname)); - cls.downloadposition = dl->position; - - if (dltotal) - { - CL_HTTP_Calculate_KBps ((int)dlnow, (int)dltotal); // Knightmare- added KB/s counter - cls.downloadpercent = (int)((dlnow / dltotal) * 100.0f); - } - else - cls.downloadpercent = 0; - } - - return abortDownloads; -} /* =============== @@ -332,7 +282,6 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl) curl_easy_setopt(dl->curl, CURLOPT_MAXREDIRS, 5); curl_easy_setopt(dl->curl, CURLOPT_WRITEHEADER, dl); curl_easy_setopt(dl->curl, CURLOPT_HEADERFUNCTION, CL_HTTP_Header); - curl_easy_setopt(dl->curl, CURLOPT_PROGRESSFUNCTION, CL_HTTP_Progress); curl_easy_setopt(dl->curl, CURLOPT_PROGRESSDATA, dl); curl_easy_setopt(dl->curl, CURLOPT_USERAGENT, Cvar_VariableString ("version")); curl_easy_setopt(dl->curl, CURLOPT_REFERER, cls.downloadReferer);