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.
This commit is contained in:
Yamagi 2020-06-02 07:55:01 +02:00
parent 7f339952cb
commit ffe8f893ed

View file

@ -56,6 +56,8 @@ static qboolean httpSecondChance = true;
- 3: Third iteration, UDP downloads. */ - 3: Third iteration, UDP downloads. */
static unsigned int precacherIteration; static unsigned int precacherIteration;
static qboolean skip_textures;
// r1q2 searches the global filelist at /, q2pro at /gamedir... // r1q2 searches the global filelist at /, q2pro at /gamedir...
static qboolean gamedirForFilelist; static qboolean gamedirForFilelist;
@ -422,7 +424,10 @@ CL_RequestNextDownload(void)
#endif #endif
/* precache phase completed */ /* precache phase completed */
if (!skip_textures)
{
precache_check = ENV_CNT + 1; precache_check = ENV_CNT + 1;
}
CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, &map_checksum); CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, &map_checksum);
@ -506,6 +511,7 @@ CL_RequestNextDownload(void)
precacherIteration = 0; precacherIteration = 0;
gamedirForFilelist = false; gamedirForFilelist = false;
httpSecondChance = true; httpSecondChance = true;
skip_textures = false;
#ifdef USE_CURL #ifdef USE_CURL
dlquirks.filelist = true; dlquirks.filelist = true;
@ -699,9 +705,9 @@ CL_Download_f(void)
void void
CL_ParseDownload(void) CL_ParseDownload(void)
{ {
int size, percent;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
int r; int r, percent, size;
static qboolean second_try;
/* read the data */ /* read the data */
size = MSG_ReadShort(&net_message); size = MSG_ReadShort(&net_message);
@ -719,10 +725,23 @@ CL_ParseDownload(void)
cls.download = NULL; cls.download = NULL;
} }
if (second_try)
{
precache_check = ENV_CNT + 999;
skip_textures = true;
second_try = false;
}
else
{
second_try = true;
}
CL_RequestNextDownload(); CL_RequestNextDownload();
return; return;
} }
second_try = false;
/* open the file if not opened yet */ /* open the file if not opened yet */
if (!cls.download) if (!cls.download)
{ {