From ffe8f893ed53ede79fe26dcc3166c8baa41a9089 Mon Sep 17 00:00:00 2001 From: Yamagi Date: Tue, 2 Jun 2020 07:55:01 +0200 Subject: [PATCH] Abort downloads if a server hasn't a file over UDP. This is a special case, the bug was already present in Vanilla Q2: If a server is offering assets for download but is missing some files the USP download code runs in an endless loop. CL_ParseDownload() detects that something is wrong and calls CL_RequestNextDownload() which tries to download the same file again... Work around this by skippig over that file. This closes #552. --- src/client/cl_download.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/client/cl_download.c b/src/client/cl_download.c index 5275b2f5..def06776 100644 --- a/src/client/cl_download.c +++ b/src/client/cl_download.c @@ -56,6 +56,8 @@ static qboolean httpSecondChance = true; - 3: Third iteration, UDP downloads. */ static unsigned int precacherIteration; +static qboolean skip_textures; + // r1q2 searches the global filelist at /, q2pro at /gamedir... static qboolean gamedirForFilelist; @@ -422,7 +424,10 @@ CL_RequestNextDownload(void) #endif /* precache phase completed */ - precache_check = ENV_CNT + 1; + if (!skip_textures) + { + precache_check = ENV_CNT + 1; + } CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, &map_checksum); @@ -506,6 +511,7 @@ CL_RequestNextDownload(void) precacherIteration = 0; gamedirForFilelist = false; httpSecondChance = true; + skip_textures = false; #ifdef USE_CURL dlquirks.filelist = true; @@ -699,9 +705,9 @@ CL_Download_f(void) void CL_ParseDownload(void) { - int size, percent; char name[MAX_OSPATH]; - int r; + int r, percent, size; + static qboolean second_try; /* read the data */ size = MSG_ReadShort(&net_message); @@ -719,10 +725,23 @@ CL_ParseDownload(void) cls.download = NULL; } + if (second_try) + { + precache_check = ENV_CNT + 999; + skip_textures = true; + second_try = false; + } + else + { + second_try = true; + } + CL_RequestNextDownload(); return; } + second_try = false; + /* open the file if not opened yet */ if (!cls.download) {