Hack in support for q2pro filelists.

r1q2 places the global filelist at /.filelist, q2pro at
/gamedir/.filelist...

Now I'm feeling even more dirty.
This commit is contained in:
Yamagi Burmeister 2019-01-24 18:00:01 +01:00
parent 67b1a8fd95
commit 900d35ef27
3 changed files with 39 additions and 16 deletions

View file

@ -42,6 +42,19 @@ extern byte *precache_model;
// Forces all downloads to UDP.
qboolean forceudp = false;
/* This - and some more code downn below - are the 'Crazy Fallback
Magic'. First we're trying to download all files over HTTP with
r1q2-style URLs. If we encountered errors we reset the complete
precacher state and retry with HTTP and q2pro-style URLs. If we
still got errors we're falling back to UDP. So:
- 0: Virgin state, r1q2-style URLs.
- 1: Second iteration, q2pro-style URL.
- 3: Third iteration, UDP downloads. */
static unsigned int precacherIteration;
// r1q2 searches the global filelist at /, q2pro at /gamedir...
static qboolean gamedirForFilelist = false;
static const char *env_suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
#define PLAYER_MULT 5
@ -57,16 +70,6 @@ CL_RequestNextDownload(void)
char fn[MAX_OSPATH];
dmdl_t *pheader;
/* This - and some more code downn below - are the 'Crazy Fallback
Magic'. First we're trying to download all files over HTTP with
r1q2-style URLs. If we encountered errors we reset the complete
precacher state and retry with HTTP and q2pro-style URLs. If we
still got errors we're falling back to UDP. So:
- 0: Virgin state, r1q2-style URLs.
- 1: Second iteration, q2pro-style URL.
- 3: Third iteration, UDP downloads. */
static unsigned int precacherIteration;
if (precacherIteration == 0)
{
#if USE_CURL
@ -86,6 +89,10 @@ CL_RequestNextDownload(void)
{
CL_HTTP_SetDownloadGamedir(cl.gamedir);
}
// Force another try with the filelist.
CL_HTTP_EnableGenericFilelist();
gamedirForFilelist = true;
#endif
}
else if (precacherIteration == 2)
@ -496,6 +503,7 @@ CL_RequestNextDownload(void)
/* This map is done, start over for next map. */
forceudp = false;
precacherIteration = 0;
gamedirForFilelist = false;
CL_HTTP_EnableGenericFilelist();
CL_RegisterSounds();
@ -552,7 +560,7 @@ CL_CheckOrDownloadFile(char *filename)
#ifdef USE_CURL
if (!forceudp)
{
if (CL_QueueHTTPDownload(filename))
if (CL_QueueHTTPDownload(filename, gamedirForFilelist))
{
/* We return true so that the precache check
keeps feeding us more files. Since we have
@ -573,6 +581,11 @@ CL_CheckOrDownloadFile(char *filename)
downloads and CL_QueueHTTPDownload() returns
false. */
forceudp = false;
/* We might be connected to an r1q2-style HTTP server
that missed just one file. So reset the precacher
iteration counter to start over. */
precacherIteration = 0;
}
#endif
strcpy(cls.downloadname, filename);

View file

@ -422,7 +422,7 @@ static void CL_CheckAndQueueDownload(char *path)
if (!exists)
{
// Queue the file for download.
CL_QueueHTTPDownload(path);
CL_QueueHTTPDownload(path, false);
}
}
else
@ -994,7 +994,7 @@ void CL_CancelHTTPDownloads(qboolean permKill)
* for the requested files are possible. Queues the download
* and returns true if yes, returns fales if not.
*/
qboolean CL_QueueHTTPDownload(const char *quakePath)
qboolean CL_QueueHTTPDownload(const char *quakePath, qboolean gamedirForFilelist)
{
// Not HTTP servers were send by the server, HTTP is disabled
// or the client is shutting down and we're wrapping up.
@ -1037,7 +1037,17 @@ qboolean CL_QueueHTTPDownload(const char *quakePath)
// Let's download the generic filelist if necessary.
if (needList)
{
CL_QueueHTTPDownload("/.filelist");
if (gamedirForFilelist)
{
char fileList[MAX_OSPATH];
Com_sprintf(fileList, sizeof(fileList), "/%s/%s", downloadGamedir, ".filelist");
CL_QueueHTTPDownload(fileList, false);
}
else
{
CL_QueueHTTPDownload("/.filelist", false);
}
}
// If we just queued a .bsp file ask for it's map
@ -1065,7 +1075,7 @@ qboolean CL_QueueHTTPDownload(const char *quakePath)
COM_StripExtension (filePath, listPath);
Q_strlcat(listPath, ".filelist", sizeof(listPath));
CL_QueueHTTPDownload(listPath);
CL_QueueHTTPDownload(listPath, false);
}
// If we're here CL_FinishHTTPDownload() is guaranteed to be called.

View file

@ -67,7 +67,7 @@ extern cvar_t *cl_http_max_connections;
void CL_CancelHTTPDownloads(qboolean permKill);
void CL_InitHTTPDownloads(void);
qboolean CL_QueueHTTPDownload(const char *quakePath);
qboolean CL_QueueHTTPDownload(const char *quakePath, qboolean gamedirForFilelist);
void CL_RunHTTPDownloads(void);
qboolean CL_PendingHTTPDownloads(void);
void CL_SetHTTPServer(const char *URL);