------------------------------------------------------------------------
r4214 | acceptthis | 2013-02-18 03:33:35 +0000 (Mon, 18 Feb 2013) | 1 line my attempt at manifest file support. ------------------------------------------------------------------------ git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4211 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
55cb101be1
commit
f7c0eff8c6
|
@ -862,21 +862,13 @@ static int CL_BootDownload_Extract(const char *fname, int fsize, void *ptr)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean FS_LoadPackageFromFile(vfsfile_t *vfs, char *pname, char *localname, int *crc, qboolean copyprotect, qboolean istemporary, qboolean isexplicit);
|
||||
|
||||
void FS_GenCachedPakName(char *pname, char *crc, char *local, int llen);
|
||||
static void CL_BootDownload_Complete(struct dl_download *dl)
|
||||
{
|
||||
void *zip;
|
||||
/*
|
||||
int sz;
|
||||
char *buf;
|
||||
FILE *f;
|
||||
sz = VFS_GETLEN(dl->file);
|
||||
buf = malloc(sz);
|
||||
VFS_READ(dl->file, buf, sz);
|
||||
f = fopen("C:/Games/Quake/test/emptybasedir/test.zip", "wb");
|
||||
fwrite(buf, 1, sz, f);
|
||||
fclose(f);
|
||||
free(buf);
|
||||
*/
|
||||
if (dl->status == DL_FINISHED)
|
||||
zip = zipfilefuncs.OpenNew(dl->file, dl->url);
|
||||
else
|
||||
|
@ -884,12 +876,72 @@ static void CL_BootDownload_Complete(struct dl_download *dl)
|
|||
/*the zip code will have eaten the file handle*/
|
||||
dl->file = NULL;
|
||||
if (zip)
|
||||
{
|
||||
if (dl->user_ctx)
|
||||
{
|
||||
vfsfile_t *in, *out;
|
||||
flocation_t loc;
|
||||
qboolean found = false;
|
||||
int crc;
|
||||
|
||||
found = zipfilefuncs.FindFile(zip, &loc, dl->user_ctx, NULL);
|
||||
if (!found)
|
||||
{
|
||||
char *s = COM_SkipPath(dl->user_ctx);
|
||||
if (s != dl->user_ctx)
|
||||
found = zipfilefuncs.FindFile(zip, &loc, s, NULL);
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
in = zipfilefuncs.OpenVFS(zip, &loc, "rb");
|
||||
if (in)
|
||||
{
|
||||
char local[MAX_OSPATH];
|
||||
FS_GenCachedPakName(dl->user_ctx, va("%i", dl->user_num), local, sizeof(local));
|
||||
FS_CreatePath(local, FS_ROOT);
|
||||
out = FS_OpenVFS(local, "wb", FS_ROOT);
|
||||
if (out)
|
||||
{
|
||||
char buffer[8192];
|
||||
int read;
|
||||
for(;;)
|
||||
{
|
||||
read = VFS_READ(in, buffer, sizeof(buffer));
|
||||
if (read <= 0)
|
||||
break;
|
||||
if (VFS_WRITE(out, buffer, read) != read)
|
||||
{
|
||||
Con_Printf("write failed writing %s. disk full?\n", local);
|
||||
break;
|
||||
}
|
||||
}
|
||||
VFS_CLOSE(out);
|
||||
out = FS_OpenVFS(local, "rb", FS_ROOT);
|
||||
crc = dl->user_num;
|
||||
if (!FS_LoadPackageFromFile(out, dl->user_ctx, local, &crc, true, false, true))
|
||||
{
|
||||
if (crc == dl->user_num)
|
||||
Con_Printf(CON_WARNING "Manifest package \"%s\" is unusable.\n", dl->user_ctx);
|
||||
else
|
||||
Con_Printf(CON_WARNING "Manifest package \"%s\" is unusable or has invalid crc. Stated crc %#x is not calculated crc %#x\n", dl->user_ctx, dl->user_num, crc);
|
||||
FS_Remove(local, FS_ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
VFS_CLOSE(in);
|
||||
}
|
||||
|
||||
free(dl->user_ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*scan it to extract its contents*/
|
||||
zipfilefuncs.EnumerateFiles(zip, "*/*.pk3", CL_BootDownload_Extract, zip);
|
||||
zipfilefuncs.EnumerateFiles(zip, "*/*.pak", CL_BootDownload_Extract, zip);
|
||||
zipfilefuncs.EnumerateFiles(zip, "*/*/*.pk3", CL_BootDownload_Extract, zip);
|
||||
zipfilefuncs.EnumerateFiles(zip, "*/*/*.pak", CL_BootDownload_Extract, zip);
|
||||
}
|
||||
|
||||
/*close it, delete the temp file from disk, etc*/
|
||||
zipfilefuncs.ClosePath(zip);
|
||||
|
@ -907,6 +959,71 @@ static void CL_BootDownload_Complete(struct dl_download *dl)
|
|||
}
|
||||
}
|
||||
|
||||
static void CL_Manifest_Complete(struct dl_download *dl)
|
||||
{
|
||||
if (dl->file)
|
||||
{
|
||||
vfsfile_t *f;
|
||||
char buffer[1024];
|
||||
char *fname;
|
||||
int crc;
|
||||
char local[MAX_OSPATH];
|
||||
while(VFS_GETS(dl->file, buffer, sizeof(buffer)))
|
||||
{
|
||||
Cmd_TokenizeString(buffer, false, false);
|
||||
if (!Cmd_Argc())
|
||||
continue;
|
||||
fname = Cmd_Argv(0);
|
||||
crc = strtoul(Cmd_Argv(1), NULL, 0);
|
||||
|
||||
f = FS_OpenVFS(fname, "rb", FS_ROOT);
|
||||
if (f)
|
||||
{
|
||||
//should be loaded as needed
|
||||
VFS_CLOSE(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
FS_GenCachedPakName(fname, va("%i", crc), local, sizeof(local));
|
||||
f = FS_OpenVFS(local, "rb", FS_ROOT);
|
||||
if (f)
|
||||
{
|
||||
int truecrc = crc;
|
||||
if (!FS_LoadPackageFromFile(f, fname, local, &truecrc, true, false, true))
|
||||
{
|
||||
if (crc == truecrc)
|
||||
Con_Printf(CON_WARNING "Manifest package \"%s\" is unusable.\n", fname);
|
||||
else
|
||||
Con_Printf(CON_WARNING "Manifest package \"%s\" is unusable or has invalid crc. Stated crc %#x is not calculated crc %#x\n", fname, crc, truecrc);
|
||||
FS_Remove(local, FS_ROOT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf("Downloading %s from %s\n", fname, Cmd_Argv(2));
|
||||
dl = HTTP_CL_Get(Cmd_Argv(2), "", CL_BootDownload_Complete);
|
||||
if (dl)
|
||||
{
|
||||
dl->user_ctx = strdup(fname);
|
||||
dl->user_num = crc;
|
||||
#ifdef MULTITHREAD
|
||||
DL_CreateThread(dl, FS_OpenTemp(), CL_BootDownload_Complete);
|
||||
#endif
|
||||
numbootdownloads++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!--numbootdownloads)
|
||||
{
|
||||
CL_ExecInitialConfigs();
|
||||
Cmd_StuffCmds();
|
||||
Cbuf_Execute ();
|
||||
Cmd_ExecuteString("vid_restart\n", RESTRICT_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean CL_CheckBootDownloads(void)
|
||||
{
|
||||
char *downloads = fs_gamedownload.string;
|
||||
|
@ -916,6 +1033,23 @@ qboolean CL_CheckBootDownloads(void)
|
|||
struct dl_download *dl;
|
||||
int mirrors;
|
||||
|
||||
int man = COM_CheckParm("-manifest");
|
||||
if (man)
|
||||
{
|
||||
const char *fname = com_argv[man+1];
|
||||
|
||||
Con_Printf("Checking manifest from \"%s\"\n", fname);
|
||||
|
||||
dl = HTTP_CL_Get(fname, token, CL_Manifest_Complete);
|
||||
if (dl)
|
||||
{
|
||||
#ifdef MULTITHREAD
|
||||
DL_CreateThread(dl, FS_OpenTemp(), CL_Manifest_Complete);
|
||||
#endif
|
||||
numbootdownloads++;
|
||||
}
|
||||
}
|
||||
|
||||
while ((downloads = COM_ParseOut(downloads, token, sizeof(token))))
|
||||
{
|
||||
//FIXME: do we want to add some sort of file size indicator?
|
||||
|
|
|
@ -1866,6 +1866,47 @@ void FS_GenCachedPakName(char *pname, char *crc, char *local, int llen)
|
|||
}
|
||||
}
|
||||
|
||||
qboolean FS_LoadPackageFromFile(vfsfile_t *vfs, char *pname, char *localname, int *crc, qboolean copyprotect, qboolean istemporary, qboolean isexplicit)
|
||||
{
|
||||
int i;
|
||||
char *ext = COM_FileExtension(pname);
|
||||
void *handle;
|
||||
|
||||
searchpath_t *sp;
|
||||
|
||||
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
|
||||
{
|
||||
if (!searchpathformats[i].extension || !searchpathformats[i].funcs || !searchpathformats[i].funcs->OpenNew)
|
||||
continue;
|
||||
if (!strcmp(ext, searchpathformats[i].extension))
|
||||
{
|
||||
handle = searchpathformats[i].funcs->OpenNew (vfs, localname);
|
||||
if (!handle)
|
||||
break;
|
||||
if (crc)
|
||||
{
|
||||
int truecrc = searchpathformats[i].funcs->GeneratePureCRC(handle, 0, false);
|
||||
if (truecrc != *crc)
|
||||
{
|
||||
*crc = truecrc;
|
||||
VFS_CLOSE(vfs);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sp = FS_AddPathHandle(pname, localname, searchpathformats[i].funcs, handle, copyprotect, istemporary, isexplicit, (unsigned int)-1);
|
||||
|
||||
if (sp)
|
||||
{
|
||||
FS_FlushFSHashReally();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VFS_CLOSE(vfs);
|
||||
return false;
|
||||
}
|
||||
|
||||
//if a server is using private pak files then load the same version of those, but deprioritise them
|
||||
//crcs are not used, but matched only if the server has a different version from a previous file
|
||||
void FS_ImpurePacks(const char *names, const char *crcs)
|
||||
|
@ -1873,6 +1914,7 @@ void FS_ImpurePacks(const char *names, const char *crcs)
|
|||
int crc;
|
||||
searchpath_t *sp;
|
||||
char *pname;
|
||||
qboolean success;
|
||||
|
||||
while(names)
|
||||
{
|
||||
|
@ -1899,31 +1941,14 @@ void FS_ImpurePacks(const char *names, const char *crcs)
|
|||
char local[MAX_OSPATH];
|
||||
vfsfile_t *vfs;
|
||||
char *ext = COM_FileExtension(pname);
|
||||
void *handle;
|
||||
int i;
|
||||
|
||||
FS_GenCachedPakName(pname, va("%i", crc), local, sizeof(local));
|
||||
vfs = FS_OpenVFS(local, "rb", FS_ROOT);
|
||||
success = false;
|
||||
if (vfs)
|
||||
{
|
||||
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
|
||||
{
|
||||
if (!searchpathformats[i].extension || !searchpathformats[i].funcs || !searchpathformats[i].funcs->OpenNew)
|
||||
continue;
|
||||
if (!strcmp(ext, searchpathformats[i].extension))
|
||||
{
|
||||
handle = searchpathformats[i].funcs->OpenNew (vfs, local);
|
||||
if (!handle)
|
||||
break;
|
||||
sp = FS_AddPathHandle(pname, local, searchpathformats[i].funcs, handle, true, true, false, (unsigned int)-1);
|
||||
success = FS_LoadPackageFromFile(vfs, pname, local, NULL, true, true, false);
|
||||
|
||||
FS_FlushFSHashReally();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sp)
|
||||
if (!success)
|
||||
Con_DPrintf("Unable to load matching package file %s\n", pname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,41 +200,41 @@ qboolean EGL_Init (rendererstate_t *info, unsigned char *palette, EGLNativeWindo
|
|||
//NOTE: mesa's egl really loves to crash on this call, and I define crash as 'anything that fails to return to caller', which fucks everything up.
|
||||
if (!qeglInitialize(egldpy, &major, &minor))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't initialize display!");
|
||||
Con_Printf(CON_ERROR "EGL: can't initialize display!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!qeglGetConfigs(egldpy, NULL, 0, &numconfigs) || !numconfigs)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't get configs!");
|
||||
Con_Printf(CON_ERROR "EGL: can't get configs!\n");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!qeglChooseConfig(egldpy, attrib, &cfg, 1, &numconfig))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't choose config!");
|
||||
Con_Printf(CON_ERROR "EGL: can't choose config!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
eglsurf = qeglCreateWindowSurface(egldpy, cfg, window, NULL);
|
||||
if (eglsurf == EGL_NO_SURFACE)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: no surface!");
|
||||
Con_Printf(CON_ERROR "EGL: no surface!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
eglctx = qeglCreateContext(egldpy, cfg, EGL_NO_SURFACE, contextattr);
|
||||
if (eglctx == EGL_NO_CONTEXT)
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: no context!");
|
||||
Con_Printf(CON_ERROR "EGL: no context!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!qeglMakeCurrent(egldpy, eglsurf, eglsurf, eglctx))
|
||||
{
|
||||
Con_Printf(CON_ERROR "EGL: can't make current!");
|
||||
Con_Printf(CON_ERROR "EGL: can't make current!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,5 +14,8 @@
|
|||
</Description>
|
||||
</em:targetApplication>
|
||||
<em:unpack>true</em:unpack>
|
||||
<em:creator>The FTE Contributors</em:creator>
|
||||
<em:description>Run quake in your browser and stuff!</em:creator>
|
||||
<em:homepageURL>http://fteqw.com/</em:creator>
|
||||
</Description>
|
||||
</RDF>
|
||||
|
|
Loading…
Reference in New Issue