2005-08-26 22:52:26 +00:00
|
|
|
#include "quakedef.h"
|
2007-08-20 02:24:43 +00:00
|
|
|
#include "netinc.h"
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
//#define com_gamedir com__gamedir
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
#include <ctype.h>
|
2009-04-01 22:03:56 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <errno.h>
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
#include "fs.h"
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-06-03 09:13:55 +00:00
|
|
|
#if defined(MINGW) && defined(_SDL)
|
2009-06-07 13:25:02 +00:00
|
|
|
#include "./mingw-libs/SDL_syswm.h" // mingw sdl cross binary complains off sys_parentwindow
|
2009-06-03 09:13:55 +00:00
|
|
|
#endif
|
2009-06-03 09:09:35 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
hashtable_t filesystemhash;
|
|
|
|
qboolean com_fschanged = true;
|
2010-07-11 02:22:39 +00:00
|
|
|
static unsigned int fs_restarts;
|
2005-08-26 22:52:26 +00:00
|
|
|
extern cvar_t com_fs_cache;
|
|
|
|
int active_fs_cachetype;
|
|
|
|
|
2009-06-03 09:09:35 +00:00
|
|
|
struct
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
const char *extension;
|
|
|
|
searchpathfuncs_t *funcs;
|
|
|
|
} searchpathformats[64];
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
int FS_RegisterFileSystemType(const char *extension, searchpathfuncs_t *funcs)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
if (searchpathformats[i].extension && !strcmp(searchpathformats[i].extension, extension))
|
|
|
|
break; //extension match always replaces
|
|
|
|
if (!searchpathformats[i].extension && !searchpathformats[i].funcs)
|
|
|
|
break;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
if (i == sizeof(searchpathformats)/sizeof(searchpathformats[0]))
|
|
|
|
return 0;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
searchpathformats[i].extension = extension;
|
|
|
|
searchpathformats[i].funcs = funcs;
|
|
|
|
com_fschanged = true;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
return i+1;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
void FS_UnRegisterFileSystemType(int idx)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
if ((unsigned int)(idx-1) >= sizeof(searchpathformats)/sizeof(searchpathformats[0]))
|
2005-08-26 22:52:26 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
searchpathformats[idx-1].funcs = NULL;
|
|
|
|
com_fschanged = true;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
//FS_Restart will be needed
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 14:09:02 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
vfsfile_t *FS_OpenVFSLoc(flocation_t *loc, char *mode);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char *VFS_GETS(vfsfile_t *vf, char *buffer, int buflen)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
char in;
|
|
|
|
char *out = buffer;
|
|
|
|
int len;
|
|
|
|
len = buflen-1;
|
|
|
|
if (len == 0)
|
|
|
|
return NULL;
|
|
|
|
while (len > 0)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2010-03-25 22:56:11 +00:00
|
|
|
if (VFS_READ(vf, &in, 1) != 1)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
if (len == buflen-1)
|
|
|
|
return NULL;
|
|
|
|
*out = '\0';
|
|
|
|
return buffer;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
if (in == '\n')
|
|
|
|
break;
|
|
|
|
*out++ = in;
|
|
|
|
len--;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
*out = '\0';
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
return buffer;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 00:34:32 +00:00
|
|
|
void VARGS VFS_PRINTF(vfsfile_t *vf, char *format, ...)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
va_start (argptr, format);
|
|
|
|
vsnprintf (string,sizeof(string)-1, format,argptr);
|
|
|
|
va_end (argptr);
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
VFS_PUTS(vf, string);
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
|
|
|
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char gamedirfile[MAX_OSPATH];
|
2006-03-15 20:05:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
//the various COM_LoadFiles set these on return
|
|
|
|
int com_filesize;
|
|
|
|
qboolean com_file_copyprotected;
|
2005-12-21 03:07:33 +00:00
|
|
|
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
//char *com_basedir; //obsolete
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char com_quakedir[MAX_OSPATH];
|
|
|
|
char com_homedir[MAX_OSPATH];
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char com_configdir[MAX_OSPATH]; //homedir/fte/configs
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
int fs_hash_dups;
|
|
|
|
int fs_hash_files;
|
2005-12-21 03:07:33 +00:00
|
|
|
|
|
|
|
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2006-01-02 22:53:29 +00:00
|
|
|
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
static const char *FS_GetCleanPath(const char *pattern, char *outbuf, int outlen);
|
|
|
|
void FS_RegisterDefaultFileSystems(void);
|
2010-07-18 08:42:59 +00:00
|
|
|
static void COM_CreatePath (char *path);
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
#define ENFORCEFOPENMODE(mode) {if (strcmp(mode, "r") && strcmp(mode, "w")/* && strcmp(mode, "rw")*/)Sys_Error("fs mode %s is not permitted here\n");}
|
2005-12-21 03:07:33 +00:00
|
|
|
|
|
|
|
|
2006-03-15 20:05:25 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//======================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct searchpath_s
|
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
const searchpathfuncs_t *funcs;
|
2005-08-26 22:52:26 +00:00
|
|
|
qboolean copyprotected; //don't allow downloads from here.
|
|
|
|
qboolean istemporary;
|
2009-04-01 22:03:56 +00:00
|
|
|
qboolean isexplicit; //explicitly loaded (ie: id1|qw|$gamedir|fte)
|
2005-08-26 22:52:26 +00:00
|
|
|
void *handle;
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
char purepath[256]; //server tracks the path used to load them so it can tell the client
|
2005-08-26 22:52:26 +00:00
|
|
|
int crc_check; //client sorts packs according to this checksum
|
|
|
|
int crc_reply; //client sends a different crc back to the server, for the paks it's actually loaded.
|
|
|
|
|
|
|
|
struct searchpath_s *next;
|
|
|
|
struct searchpath_s *nextpure;
|
|
|
|
} searchpath_t;
|
|
|
|
|
|
|
|
searchpath_t *com_searchpaths;
|
|
|
|
searchpath_t *com_purepaths;
|
|
|
|
searchpath_t *com_base_searchpaths; // without gamedirs
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
COM_filelength
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int COM_filelength (FILE *f)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
int end;
|
|
|
|
|
|
|
|
pos = ftell (f);
|
|
|
|
fseek (f, 0, SEEK_END);
|
|
|
|
end = ftell (f);
|
|
|
|
fseek (f, pos, SEEK_SET);
|
|
|
|
|
|
|
|
return end;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
/*
|
|
|
|
static int COM_FileOpenRead (char *path, FILE **hndl)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
f = fopen(path, "rb");
|
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
*hndl = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
*hndl = f;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
return COM_filelength(f);
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
*/
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
int COM_FileSize(const char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
int len;
|
2005-12-21 03:07:33 +00:00
|
|
|
flocation_t loc;
|
|
|
|
len = FS_FLocateFile(path, FSLFRT_LENGTH, &loc);
|
2005-08-26 22:52:26 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_Path_f
|
|
|
|
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void COM_Path_f (void)
|
|
|
|
{
|
|
|
|
searchpath_t *s;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
Con_TPrintf (TL_CURRENTSEARCHPATH);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
if (com_purepaths)
|
|
|
|
{
|
2007-09-17 20:35:39 +00:00
|
|
|
Con_Printf ("Pure paths:\n");
|
2005-08-26 22:52:26 +00:00
|
|
|
for (s=com_purepaths ; s ; s=s->nextpure)
|
|
|
|
{
|
|
|
|
s->funcs->PrintPath(s->handle);
|
|
|
|
}
|
|
|
|
Con_Printf ("----------\n");
|
2007-09-17 20:35:39 +00:00
|
|
|
Con_Printf ("Impure paths:\n");
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (s=com_searchpaths ; s ; s=s->next)
|
|
|
|
{
|
|
|
|
if (s == com_base_searchpaths)
|
|
|
|
Con_Printf ("----------\n");
|
|
|
|
|
|
|
|
s->funcs->PrintPath(s->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_Dir_f
|
|
|
|
|
|
|
|
============
|
|
|
|
*/
|
2009-04-01 22:03:56 +00:00
|
|
|
static int COM_Dir_List(const char *name, int size, void *parm)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
Con_Printf("%s (%i)\n", name, size);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void COM_Dir_f (void)
|
|
|
|
{
|
|
|
|
char match[MAX_QPATH];
|
|
|
|
|
|
|
|
Q_strncpyz(match, Cmd_Argv(1), sizeof(match));
|
|
|
|
if (Cmd_Argc()>2)
|
|
|
|
{
|
|
|
|
strncat(match, "/*.", sizeof(match)-1);
|
|
|
|
match[sizeof(match)-1] = '\0';
|
|
|
|
strncat(match, Cmd_Argv(2), sizeof(match)-1);
|
|
|
|
match[sizeof(match)-1] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strncat(match, "/*", sizeof(match)-1);
|
|
|
|
|
|
|
|
COM_EnumerateFiles(match, COM_Dir_List, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_Locate_f
|
|
|
|
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void COM_Locate_f (void)
|
|
|
|
{
|
|
|
|
flocation_t loc;
|
2005-10-16 03:47:26 +00:00
|
|
|
if (FS_FLocateFile(Cmd_Argv(1), FSLFRT_LENGTH, &loc)>=0)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (!*loc.rawname)
|
2005-10-16 03:47:26 +00:00
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
Con_Printf("File is %i bytes compressed inside ", loc.len);
|
2005-10-16 03:47:26 +00:00
|
|
|
loc.search->funcs->PrintPath(loc.search->handle);
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
else
|
2006-01-02 22:53:29 +00:00
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
Con_Printf("Inside %s (%i bytes)\n", loc.rawname, loc.len);
|
2006-01-02 22:53:29 +00:00
|
|
|
loc.search->funcs->PrintPath(loc.search->handle);
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Con_Printf("Not found\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_WriteFile
|
|
|
|
|
|
|
|
The filename will be prefixed by the current game directory
|
|
|
|
============
|
|
|
|
*/
|
2009-04-02 22:25:54 +00:00
|
|
|
void COM_WriteFile (const char *filename, const void *data, int len)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2006-03-11 03:12:10 +00:00
|
|
|
vfsfile_t *vfs;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2006-03-11 03:12:10 +00:00
|
|
|
Sys_Printf ("COM_WriteFile: %s\n", filename);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2006-03-11 03:12:10 +00:00
|
|
|
FS_CreatePath(filename, FS_GAMEONLY);
|
|
|
|
vfs = FS_OpenVFS(filename, "wb", FS_GAMEONLY);
|
|
|
|
if (vfs)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2006-03-11 03:12:10 +00:00
|
|
|
VFS_WRITE(vfs, data, len);
|
|
|
|
VFS_CLOSE(vfs);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
com_fschanged=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE *COM_WriteFileOpen (char *filename) //like fopen, but based around quake's paths.
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char name[MAX_OSPATH];
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!FS_NativePath(filename, FS_GAMEONLY, name, sizeof(name)))
|
|
|
|
return NULL;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
COM_CreatePath(name);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
f = fopen (name, "wb");
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_CreatePath
|
|
|
|
|
|
|
|
Only used for CopyFile and download
|
|
|
|
============
|
|
|
|
*/
|
2010-07-18 08:42:59 +00:00
|
|
|
static void COM_CreatePath (char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
char *ofs;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
for (ofs = path+1 ; *ofs ; ofs++)
|
|
|
|
{
|
|
|
|
if (*ofs == '/')
|
|
|
|
{ // create the directory
|
|
|
|
*ofs = 0;
|
|
|
|
Sys_mkdir (path);
|
|
|
|
*ofs = '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
COM_CopyFile
|
|
|
|
|
|
|
|
Copies a file over from the net to the local cache, creating any directories
|
|
|
|
needed. This is for the convenience of developers using ISDN from home.
|
|
|
|
===========
|
|
|
|
*/
|
2009-03-03 01:52:30 +00:00
|
|
|
/*
|
|
|
|
static void COM_CopyFile (char *netpath, char *cachepath)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
FILE *in, *out;
|
|
|
|
int remaining, count;
|
|
|
|
char buf[4096];
|
2005-11-21 21:09:11 +00:00
|
|
|
|
|
|
|
remaining = COM_FileOpenRead (netpath, &in);
|
2005-08-26 22:52:26 +00:00
|
|
|
COM_CreatePath (cachepath); // create directories up to the cache file
|
|
|
|
out = fopen(cachepath, "wb");
|
|
|
|
if (!out)
|
|
|
|
Sys_Error ("Error opening %s", cachepath);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
while (remaining)
|
|
|
|
{
|
|
|
|
if (remaining < sizeof(buf))
|
|
|
|
count = remaining;
|
|
|
|
else
|
|
|
|
count = sizeof(buf);
|
|
|
|
fread (buf, 1, count, in);
|
|
|
|
fwrite (buf, 1, count, out);
|
|
|
|
remaining -= count;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose (in);
|
|
|
|
fclose (out);
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
//*/
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
int fs_hash_dups;
|
|
|
|
int fs_hash_files;
|
|
|
|
|
|
|
|
void FS_FlushFSHash(void)
|
|
|
|
{
|
|
|
|
if (filesystemhash.numbuckets)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
bucket_t *bucket, *next;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
for (i = 0; i < filesystemhash.numbuckets; i++)
|
|
|
|
{
|
|
|
|
bucket = filesystemhash.bucket[i];
|
|
|
|
filesystemhash.bucket[i] = NULL;
|
|
|
|
while(bucket)
|
|
|
|
{
|
|
|
|
next = bucket->next;
|
2007-09-17 20:35:39 +00:00
|
|
|
if (bucket->key.string == (char*)(bucket+1))
|
2005-08-26 22:52:26 +00:00
|
|
|
Z_Free(bucket);
|
|
|
|
bucket = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
com_fschanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FS_RebuildFSHash(void)
|
|
|
|
{
|
|
|
|
searchpath_t *search;
|
|
|
|
if (!filesystemhash.numbuckets)
|
|
|
|
{
|
|
|
|
filesystemhash.numbuckets = 1024;
|
2008-05-25 01:06:37 +00:00
|
|
|
filesystemhash.bucket = (bucket_t**)Z_Malloc(Hash_BytesForBuckets(filesystemhash.numbuckets));
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FS_FlushFSHash();
|
|
|
|
}
|
|
|
|
Hash_InitTable(&filesystemhash, filesystemhash.numbuckets, filesystemhash.bucket);
|
|
|
|
|
|
|
|
fs_hash_dups = 0;
|
|
|
|
fs_hash_files = 0;
|
|
|
|
|
|
|
|
if (com_purepaths)
|
|
|
|
{ //go for the pure paths first.
|
|
|
|
for (search = com_purepaths; search; search = search->nextpure)
|
|
|
|
{
|
|
|
|
search->funcs->BuildHash(search->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (search = com_searchpaths ; search ; search = search->next)
|
|
|
|
{
|
|
|
|
search->funcs->BuildHash(search->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
com_fschanged = false;
|
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
Con_DPrintf("%i unique files, %i duplicates\n", fs_hash_files, fs_hash_dups);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
COM_FindFile
|
|
|
|
|
|
|
|
Finds the file in the search path.
|
|
|
|
Sets com_filesize and one of handle or file
|
|
|
|
===========
|
|
|
|
*/
|
|
|
|
//if loc is valid, loc->search is always filled in, the others are filled on success.
|
|
|
|
//returns -1 if couldn't find.
|
2009-04-01 22:03:56 +00:00
|
|
|
int FS_FLocateFile(const char *filename, FSLF_ReturnType_e returntype, flocation_t *loc)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
int depth=0, len;
|
|
|
|
searchpath_t *search;
|
2009-04-01 22:03:56 +00:00
|
|
|
char cleanpath[MAX_QPATH];
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
void *pf;
|
|
|
|
//Con_Printf("Finding %s: ", filename);
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
filename = FS_GetCleanPath(filename, cleanpath, sizeof(cleanpath));
|
|
|
|
if (!filename)
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
pf = NULL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (com_fs_cache.ival)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (com_fschanged)
|
|
|
|
FS_RebuildFSHash();
|
|
|
|
pf = Hash_GetInsensative(&filesystemhash, filename);
|
|
|
|
if (!pf)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pf = NULL;
|
|
|
|
|
|
|
|
if (com_purepaths)
|
|
|
|
{
|
|
|
|
for (search = com_purepaths ; search ; search = search->nextpure)
|
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
if (search->funcs->FindFile(search->handle, loc, filename, pf))
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (loc)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2005-08-26 22:52:26 +00:00
|
|
|
loc->search = search;
|
2005-12-21 03:07:33 +00:00
|
|
|
len = loc->len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
len = 0;
|
2008-11-09 22:29:28 +00:00
|
|
|
com_file_copyprotected = search->copyprotected;
|
2005-08-26 22:52:26 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
depth += (search->isexplicit || returntype == FSLFRT_DEPTH_ANYPATH);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// search through the path, one element at a time
|
|
|
|
//
|
|
|
|
for (search = com_searchpaths ; search ; search = search->next)
|
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
if (search->funcs->FindFile(search->handle, loc, filename, pf))
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (loc)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2005-08-26 22:52:26 +00:00
|
|
|
loc->search = search;
|
2005-12-21 03:07:33 +00:00
|
|
|
len = loc->len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
len = 1;
|
2008-11-09 22:29:28 +00:00
|
|
|
com_file_copyprotected = search->copyprotected;
|
2005-08-26 22:52:26 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
depth += (search->isexplicit || returntype == FSLFRT_DEPTH_ANYPATH);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
fail:
|
|
|
|
if (loc)
|
|
|
|
loc->search = NULL;
|
|
|
|
depth = 0x7fffffff;
|
|
|
|
len = -1;
|
|
|
|
out:
|
|
|
|
|
|
|
|
/* if (len>=0)
|
|
|
|
{
|
|
|
|
if (loc)
|
|
|
|
Con_Printf("Found %s:%i\n", loc->rawname, loc->len);
|
|
|
|
else
|
|
|
|
Con_Printf("Found %s\n", filename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Con_Printf("Failed\n");
|
2006-03-04 20:43:48 +00:00
|
|
|
*/
|
2006-01-28 19:34:21 +00:00
|
|
|
if (returntype == FSLFRT_IFFOUND)
|
|
|
|
return len != -1;
|
|
|
|
else if (returntype == FSLFRT_LENGTH)
|
2005-08-26 22:52:26 +00:00
|
|
|
return len;
|
|
|
|
else
|
|
|
|
return depth;
|
|
|
|
}
|
2006-01-02 22:53:29 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
char *FS_WhichPackForLocation(flocation_t *loc)
|
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
if (!loc->search)
|
|
|
|
return NULL; //huh? not a valid location.
|
|
|
|
|
|
|
|
ret = strchr(loc->search->purepath, '/');
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret++;
|
|
|
|
if (strchr(ret, '/'))
|
|
|
|
return NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-02 22:53:29 +00:00
|
|
|
|
|
|
|
char *FS_GetPackHashes(char *buffer, int buffersize, qboolean referencedonly)
|
|
|
|
{
|
|
|
|
searchpath_t *search;
|
|
|
|
buffersize--;
|
|
|
|
*buffer = 0;
|
|
|
|
|
|
|
|
if (com_purepaths)
|
|
|
|
{
|
|
|
|
for (search = com_purepaths ; search ; search = search->nextpure)
|
|
|
|
{
|
|
|
|
Q_strncatz(buffer, va("%i ", search->crc_check), buffersize);
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (search = com_searchpaths ; search ; search = search->next)
|
|
|
|
{
|
|
|
|
if (!search->crc_check && search->funcs->GeneratePureCRC)
|
|
|
|
search->crc_check = search->funcs->GeneratePureCRC(search->handle, 0, 0);
|
|
|
|
if (search->crc_check)
|
|
|
|
{
|
|
|
|
Q_strncatz(buffer, va("%i ", search->crc_check), buffersize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char *FS_GetPackNames(char *buffer, int buffersize, qboolean referencedonly)
|
|
|
|
{
|
2010-11-10 03:32:47 +00:00
|
|
|
char temp[MAX_OSPATH];
|
2008-11-09 22:29:28 +00:00
|
|
|
searchpath_t *search;
|
|
|
|
buffersize--;
|
|
|
|
*buffer = 0;
|
2009-06-03 09:09:35 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
if (com_purepaths)
|
|
|
|
{
|
|
|
|
for (search = com_purepaths ; search ; search = search->nextpure)
|
|
|
|
{
|
2010-11-10 03:32:47 +00:00
|
|
|
COM_StripExtension(search->purepath, temp, sizeof(temp));
|
|
|
|
Q_strncatz(buffer, va("%s ", temp), buffersize);
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (search = com_searchpaths ; search ; search = search->next)
|
|
|
|
{
|
|
|
|
if (!search->crc_check && search->funcs->GeneratePureCRC)
|
|
|
|
search->crc_check = search->funcs->GeneratePureCRC(search->handle, 0, 0);
|
|
|
|
if (search->crc_check)
|
|
|
|
{
|
2010-11-10 03:32:47 +00:00
|
|
|
COM_StripExtension(search->purepath, temp, sizeof(temp));
|
|
|
|
Q_strncatz(buffer, va("%s ", temp), buffersize);
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
2006-01-02 22:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
#if 0
|
2005-08-26 22:52:26 +00:00
|
|
|
int COM_FOpenLocationFILE(flocation_t *loc, FILE **file)
|
|
|
|
{
|
|
|
|
if (!*loc->rawname)
|
|
|
|
{
|
|
|
|
if (!loc->len)
|
|
|
|
{
|
|
|
|
*file = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loc->search->funcs->ReadFile)
|
|
|
|
{//create a new, temp file, bung the contents of the compressed file into it, then continue.
|
|
|
|
char *buf;
|
|
|
|
FILE *f = tmpfile();
|
|
|
|
buf = BZ_Malloc(loc->len);
|
|
|
|
loc->search->funcs->ReadFile(loc->search->handle, loc, buf);
|
|
|
|
fwrite(buf, 1, loc->len, f);
|
|
|
|
BZ_Free(buf);
|
|
|
|
fseek(f, 0, SEEK_SET);
|
|
|
|
|
|
|
|
*file = f;
|
|
|
|
com_pathforfile = loc->search;
|
|
|
|
return loc->len;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
// Con_Printf("Opening %s\n", loc->rawname);
|
|
|
|
*file = fopen(loc->rawname, "rb");
|
|
|
|
if (!*file)
|
|
|
|
return -1;
|
|
|
|
fseek(*file, loc->offset, SEEK_SET);
|
|
|
|
com_pathforfile = loc->search;
|
|
|
|
return loc->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
int COM_FOpenFile(char *filename, FILE **file)
|
|
|
|
{
|
|
|
|
flocation_t loc;
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_ERROR "COM_FOpenFile is obsolete\n");
|
2005-08-26 22:52:26 +00:00
|
|
|
FS_FLocateFile(filename, FSLFRT_LENGTH, &loc);
|
|
|
|
|
|
|
|
com_filesize = -1;
|
|
|
|
if (loc.search)
|
|
|
|
{
|
|
|
|
com_file_copyprotected = loc.search->copyprotected;
|
|
|
|
com_filesize = COM_FOpenLocationFILE(&loc, file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*file = NULL;
|
|
|
|
return com_filesize;
|
|
|
|
}
|
2005-12-21 03:07:33 +00:00
|
|
|
/*
|
2005-08-26 22:52:26 +00:00
|
|
|
int COM_FOpenWriteFile(char *filename, FILE **file)
|
|
|
|
{
|
|
|
|
COM_CreatePath(filename);
|
|
|
|
*file = fopen(filename, "wb");
|
|
|
|
return !!*file;
|
|
|
|
}
|
2005-12-21 03:07:33 +00:00
|
|
|
*/
|
|
|
|
#endif
|
2005-08-26 22:52:26 +00:00
|
|
|
//int COM_FOpenFile (char *filename, FILE **file) {file_from_pak=0;return COM_FOpenFile2 (filename, file, false);} //FIXME: TEMPORARY
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
//outbuf might not be written into
|
|
|
|
static const char *FS_GetCleanPath(const char *pattern, char *outbuf, int outlen)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2009-03-03 01:52:30 +00:00
|
|
|
char *s;
|
2009-04-01 22:03:56 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
if (strchr(pattern, '\\'))
|
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
Q_strncpyz(outbuf, pattern, outlen);
|
|
|
|
pattern = outbuf;
|
|
|
|
|
2008-01-28 13:27:30 +00:00
|
|
|
Con_Printf("Warning: \\ characters in filename %s\n", pattern);
|
2006-03-04 20:43:48 +00:00
|
|
|
while((s = strchr(pattern, '\\')))
|
2009-04-01 22:03:56 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
*s = '/';
|
2009-04-01 22:03:56 +00:00
|
|
|
|
|
|
|
}
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
if (strstr(pattern, "//"))
|
|
|
|
{
|
|
|
|
//amiga uses // as equivelent to /../
|
2010-12-18 17:02:47 +00:00
|
|
|
//so strip those out
|
|
|
|
//any other system ignores the extras
|
2009-04-01 22:03:56 +00:00
|
|
|
|
|
|
|
Q_strncpyz(outbuf, pattern, outlen);
|
|
|
|
pattern = outbuf;
|
|
|
|
|
2010-12-18 17:02:47 +00:00
|
|
|
Con_DPrintf("Warning: // characters in filename %s\n", pattern);
|
2009-04-02 22:25:54 +00:00
|
|
|
while ((s=strstr(pattern, "//")))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
s++;
|
|
|
|
while (*s)
|
|
|
|
{
|
|
|
|
*s = *(s+1);
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-18 17:02:47 +00:00
|
|
|
if (*pattern == '/')
|
|
|
|
{
|
|
|
|
/*'fix up' and ignore, compat with q3*/
|
|
|
|
Con_DPrintf("Error: absolute path in filename %s\n", pattern);
|
|
|
|
pattern++;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
if (strstr(pattern, ".."))
|
2008-01-28 13:27:30 +00:00
|
|
|
Con_Printf("Error: '..' characters in filename %s\n", pattern);
|
2009-03-03 01:52:30 +00:00
|
|
|
else if (strstr(pattern, ":")) //win32 drive seperator (or mac path seperator, but / works there and they're used to it) (or amiga device separator)
|
2005-12-21 03:07:33 +00:00
|
|
|
Con_Printf("Error: absolute path in filename %s\n", pattern);
|
|
|
|
else
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
return pattern;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
return NULL;
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
vfsfile_t *VFS_Filter(const char *filename, vfsfile_t *handle)
|
2006-02-11 02:09:43 +00:00
|
|
|
{
|
|
|
|
// char *ext;
|
|
|
|
|
|
|
|
if (!handle || handle->WriteBytes || handle->seekingisabadplan) //only on readonly files
|
|
|
|
return handle;
|
|
|
|
// ext = COM_FileExtension (filename);
|
2006-10-05 21:59:43 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
2006-02-11 02:09:43 +00:00
|
|
|
// if (!stricmp(ext, ".gz"))
|
|
|
|
{
|
2010-11-11 04:03:16 +00:00
|
|
|
return FS_DecompressGZip(handle);
|
2006-02-11 02:09:43 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
#endif
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out, int outlen)
|
|
|
|
{
|
|
|
|
char cleanname[MAX_QPATH];
|
|
|
|
fname = FS_GetCleanPath(fname, cleanname, sizeof(cleanname));
|
|
|
|
if (!fname)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (relativeto)
|
|
|
|
{
|
|
|
|
case FS_GAMEONLY:
|
|
|
|
case FS_GAME:
|
|
|
|
if (*com_homedir)
|
|
|
|
snprintf(out, outlen, "%s%s/%s", com_homedir, gamedirfile, fname);
|
|
|
|
else
|
|
|
|
snprintf(out, outlen, "%s%s/%s", com_quakedir, gamedirfile, fname);
|
|
|
|
break;
|
|
|
|
case FS_SKINS:
|
|
|
|
if (*com_homedir)
|
|
|
|
snprintf(out, outlen, "%sqw/skins/%s", com_homedir, fname);
|
|
|
|
else
|
|
|
|
snprintf(out, outlen, "%sqw/skins/%s", com_quakedir, fname);
|
|
|
|
break;
|
|
|
|
case FS_ROOT:
|
|
|
|
if (*com_homedir)
|
|
|
|
snprintf(out, outlen, "%s%s", com_homedir, fname);
|
|
|
|
else
|
|
|
|
snprintf(out, outlen, "%s%s", com_quakedir, fname);
|
|
|
|
break;
|
|
|
|
case FS_CONFIGONLY:
|
|
|
|
if (*com_homedir)
|
|
|
|
snprintf(out, outlen, "%sfte/%s", com_homedir, fname);
|
|
|
|
else
|
|
|
|
snprintf(out, outlen, "%sfte/%s", com_quakedir, fname);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Sys_Error("FS_Rename case not handled\n");
|
|
|
|
}
|
|
|
|
return true;
|
2006-02-11 02:09:43 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative relativeto)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
char cleanname[MAX_QPATH];
|
2005-12-21 03:07:33 +00:00
|
|
|
char fullname[MAX_OSPATH];
|
|
|
|
flocation_t loc;
|
|
|
|
vfsfile_t *vfs;
|
|
|
|
|
|
|
|
//eventually, this function will be the *ONLY* way to get at files
|
|
|
|
|
|
|
|
//blanket-bans
|
|
|
|
|
2009-06-03 09:09:35 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
filename = FS_GetCleanPath(filename, cleanname, sizeof(cleanname));
|
|
|
|
if (!filename)
|
2005-12-21 03:07:33 +00:00
|
|
|
return NULL;
|
|
|
|
|
2006-01-02 22:53:29 +00:00
|
|
|
|
|
|
|
if (strcmp(mode, "rb"))
|
2010-07-11 02:22:39 +00:00
|
|
|
if (strcmp(mode, "r+b"))
|
|
|
|
if (strcmp(mode, "wb"))
|
|
|
|
if (strcmp(mode, "w+b"))
|
|
|
|
if (strcmp(mode, "ab"))
|
|
|
|
return NULL; //urm, unable to write/append
|
2006-01-02 22:53:29 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
//if there can only be one file (eg: write access) find out where it is.
|
2005-12-21 03:07:33 +00:00
|
|
|
switch (relativeto)
|
|
|
|
{
|
|
|
|
case FS_GAMEONLY: //OS access only, no paks
|
|
|
|
if (*com_homedir)
|
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s/%s", com_homedir, gamedirfile, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
vfs = VFSOS_Open(fullname, mode);
|
|
|
|
if (vfs)
|
|
|
|
return vfs;
|
|
|
|
}
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s/%s", com_quakedir, gamedirfile, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
return VFSOS_Open(fullname, mode);
|
|
|
|
case FS_GAME:
|
|
|
|
if (*com_homedir)
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s/%s", com_homedir, gamedirfile, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
else
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s/%s", com_quakedir, gamedirfile, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
break;
|
2006-03-11 05:12:33 +00:00
|
|
|
case FS_SKINS:
|
|
|
|
if (*com_homedir)
|
2006-03-11 05:14:56 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%sqw/skins/%s", com_homedir, filename);
|
2006-03-11 05:12:33 +00:00
|
|
|
else
|
2006-03-11 05:14:56 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%sqw/skins/%s", com_quakedir, filename);
|
2006-03-11 05:12:33 +00:00
|
|
|
break;
|
2008-12-23 02:55:20 +00:00
|
|
|
case FS_ROOT:
|
2005-12-21 03:07:33 +00:00
|
|
|
if (*com_homedir)
|
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s", com_homedir, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
vfs = VFSOS_Open(fullname, mode);
|
|
|
|
if (vfs)
|
|
|
|
return vfs;
|
|
|
|
}
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%s%s", com_quakedir, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
return VFSOS_Open(fullname, mode);
|
|
|
|
case FS_CONFIGONLY:
|
|
|
|
if (*com_homedir)
|
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%sfte/%s", com_homedir, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
vfs = VFSOS_Open(fullname, mode);
|
|
|
|
if (vfs)
|
|
|
|
return vfs;
|
|
|
|
}
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(fullname, sizeof(fullname), "%sfte/%s", com_quakedir, filename);
|
2005-12-21 03:07:33 +00:00
|
|
|
return VFSOS_Open(fullname, mode);
|
|
|
|
default:
|
2006-03-11 05:12:33 +00:00
|
|
|
Sys_Error("FS_OpenVFS: Bad relative path (%i)", relativeto);
|
2005-12-21 03:07:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FS_FLocateFile(filename, FSLFRT_IFFOUND, &loc);
|
|
|
|
|
|
|
|
if (loc.search)
|
|
|
|
{
|
|
|
|
com_file_copyprotected = loc.search->copyprotected;
|
2006-02-11 02:09:43 +00:00
|
|
|
return VFS_Filter(filename, loc.search->funcs->OpenVFS(loc.search->handle, &loc, mode));
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
|
|
|
|
2006-01-02 23:46:44 +00:00
|
|
|
//if we're meant to be writing, best write to it.
|
2007-07-27 21:24:31 +00:00
|
|
|
if (strchr(mode , 'w') || strchr(mode , 'a'))
|
2006-01-02 23:46:44 +00:00
|
|
|
return VFSOS_Open(fullname, mode);
|
2005-12-21 03:07:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
vfsfile_t *FS_OpenReadLocation(flocation_t *location)
|
|
|
|
{
|
|
|
|
if (location->search)
|
|
|
|
{
|
|
|
|
com_file_copyprotected = location->search->copyprotected;
|
|
|
|
return VFS_Filter(NULL, location->search->funcs->OpenVFS(location->search->handle, location, "rb"));
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
int FS_Rename2(const char *oldf, const char *newf, enum fs_relative oldrelativeto, enum fs_relative newrelativeto)
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
|
|
|
char oldfullname[MAX_OSPATH];
|
|
|
|
char newfullname[MAX_OSPATH];
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!FS_NativePath(oldf, oldrelativeto, oldfullname, sizeof(oldfullname)))
|
|
|
|
return EPERM;
|
|
|
|
if (!FS_NativePath(newf, newrelativeto, newfullname, sizeof(newfullname)))
|
|
|
|
return EPERM;
|
2006-01-28 06:41:20 +00:00
|
|
|
|
|
|
|
FS_CreatePath(newf, newrelativeto);
|
|
|
|
return rename(oldfullname, newfullname);
|
2006-01-21 00:06:49 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
int FS_Rename(const char *oldf, const char *newf, enum fs_relative relativeto)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
return FS_Rename2(oldf, newf, relativeto, relativeto);
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
int FS_Remove(const char *fname, enum fs_relative relativeto)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2006-01-28 06:41:20 +00:00
|
|
|
char fullname[MAX_OSPATH];
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!FS_NativePath(fname, relativeto, fullname, sizeof(fullname)))
|
|
|
|
return EPERM;
|
2006-01-28 06:41:20 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
return Sys_remove (fullname);
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
//create a path for the given filename (dir-only must have trailing slash)
|
|
|
|
void FS_CreatePath(const char *pname, enum fs_relative relativeto)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
|
|
|
char fullname[MAX_OSPATH];
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!FS_NativePath(pname, relativeto, fullname, sizeof(fullname)))
|
|
|
|
return;
|
2009-06-03 09:09:35 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
COM_CreatePath(fullname);
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-02 22:25:54 +00:00
|
|
|
qboolean FS_WriteFile (const char *filename, const void *data, int len, enum fs_relative relativeto)
|
2006-01-02 22:53:29 +00:00
|
|
|
{
|
|
|
|
vfsfile_t *f;
|
|
|
|
FS_CreatePath(filename, relativeto);
|
|
|
|
f = FS_OpenVFS(filename, "wb", relativeto);
|
|
|
|
if (!f)
|
|
|
|
return false;
|
|
|
|
VFS_WRITE(f, data, len);
|
|
|
|
VFS_CLOSE(f);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
qboolean FS_Copy(const char *source, const char *dest, enum fs_relative relativesource, enum fs_relative relativedest)
|
|
|
|
{
|
|
|
|
vfsfile_t *d, *s;
|
|
|
|
char buffer[8192*8];
|
|
|
|
int read;
|
|
|
|
qboolean result = false;
|
|
|
|
FS_CreatePath(dest, relativedest);
|
|
|
|
s = FS_OpenVFS(source, "rb", relativesource);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
d = FS_OpenVFS(dest, "wb", relativedest);
|
|
|
|
if (d)
|
|
|
|
{
|
|
|
|
result = true;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
read = VFS_READ(s, buffer, sizeof(buffer));
|
|
|
|
if (read <= 0)
|
|
|
|
break;
|
|
|
|
if (VFS_WRITE(d, buffer, read) != read)
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VFS_CLOSE(d);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
FS_Remove(dest, relativedest);
|
|
|
|
}
|
|
|
|
VFS_CLOSE(s);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-01-02 22:53:29 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
static cache_user_t *loadcache;
|
|
|
|
static qbyte *loadbuf;
|
|
|
|
static int loadsize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
COM_LoadFile
|
|
|
|
|
|
|
|
Filename are reletive to the quake directory.
|
|
|
|
Always appends a 0 qbyte to the loaded data.
|
|
|
|
============
|
|
|
|
*/
|
2009-04-01 22:03:56 +00:00
|
|
|
qbyte *COM_LoadFile (const char *path, int usehunk)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *f;
|
2005-08-26 22:52:26 +00:00
|
|
|
qbyte *buf;
|
|
|
|
int len;
|
2006-06-04 01:43:52 +00:00
|
|
|
char base[MAX_OSPATH];
|
2005-08-26 22:52:26 +00:00
|
|
|
flocation_t loc;
|
|
|
|
FS_FLocateFile(path, FSLFRT_LENGTH, &loc);
|
|
|
|
|
|
|
|
if (!loc.search)
|
|
|
|
return NULL; //wasn't found
|
|
|
|
|
|
|
|
|
2006-01-02 22:53:29 +00:00
|
|
|
f = loc.search->funcs->OpenVFS(loc.search->handle, &loc, "rb");
|
2005-12-21 03:07:33 +00:00
|
|
|
if (!f)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
com_filesize = len = VFS_GETLEN(f);
|
2005-08-26 22:52:26 +00:00
|
|
|
// extract the filename base name for hunk tag
|
2006-03-11 03:12:10 +00:00
|
|
|
COM_FileBase (path, base, sizeof(base));
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
if (usehunk == 0)
|
|
|
|
buf = (qbyte*)Z_Malloc (len+1);
|
|
|
|
else if (usehunk == 1)
|
|
|
|
buf = (qbyte*)Hunk_AllocName (len+1, base);
|
|
|
|
else if (usehunk == 2)
|
|
|
|
buf = (qbyte*)Hunk_TempAlloc (len+1);
|
|
|
|
else if (usehunk == 3)
|
|
|
|
buf = (qbyte*)Cache_Alloc (loadcache, len+1, base);
|
|
|
|
else if (usehunk == 4)
|
|
|
|
{
|
|
|
|
if (len+1 > loadsize)
|
|
|
|
buf = (qbyte*)Hunk_TempAlloc (len+1);
|
|
|
|
else
|
|
|
|
buf = loadbuf;
|
|
|
|
}
|
|
|
|
else if (usehunk == 5)
|
|
|
|
buf = (qbyte*)BZ_Malloc(len+1);
|
|
|
|
else if (usehunk == 6)
|
|
|
|
buf = (qbyte*)Hunk_TempAllocMore (len+1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sys_Error ("COM_LoadFile: bad usehunk");
|
|
|
|
buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
Sys_Error ("COM_LoadFile: not enough space for %s", path);
|
|
|
|
|
|
|
|
((qbyte *)buf)[len] = 0;
|
|
|
|
#ifndef SERVERONLY
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer != QR_NONE)
|
2005-08-26 22:52:26 +00:00
|
|
|
if (Draw_BeginDisc)
|
|
|
|
Draw_BeginDisc ();
|
|
|
|
#endif
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_READ(f, buf, len);
|
|
|
|
VFS_CLOSE(f);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
#ifndef SERVERONLY
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer != QR_NONE)
|
2005-08-26 22:52:26 +00:00
|
|
|
if (Draw_EndDisc)
|
|
|
|
Draw_EndDisc ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qbyte *FS_LoadMallocFile (const char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
return COM_LoadFile (path, 5);
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
qbyte *COM_LoadHunkFile (const char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
return COM_LoadFile (path, 1);
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
qbyte *COM_LoadTempFile (const char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
return COM_LoadFile (path, 2);
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
qbyte *COM_LoadTempFile2 (const char *path)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
return COM_LoadFile (path, 6);
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
void COM_LoadCacheFile (const char *path, struct cache_user_s *cu)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
loadcache = cu;
|
|
|
|
COM_LoadFile (path, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
// uses temp hunk if larger than bufsize
|
2009-04-01 22:03:56 +00:00
|
|
|
qbyte *COM_LoadStackFile (const char *path, void *buffer, int bufsize)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
qbyte *buf;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
loadbuf = (qbyte *)buffer;
|
|
|
|
loadsize = bufsize;
|
|
|
|
buf = COM_LoadFile (path, 4);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
/*warning: at some point I'll change this function to return only read-only buffers*/
|
2009-03-03 01:52:30 +00:00
|
|
|
int FS_LoadFile(char *name, void **file)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
*file = FS_LoadMallocFile(name);
|
2009-05-24 10:11:17 +00:00
|
|
|
if (!*file)
|
|
|
|
return -1;
|
2009-03-03 01:52:30 +00:00
|
|
|
return com_filesize;
|
|
|
|
}
|
|
|
|
void FS_FreeFile(void *file)
|
|
|
|
{
|
|
|
|
BZ_Free(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *), void *parm)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
searchpath_t *search;
|
|
|
|
for (search = com_searchpaths; search ; search = search->next)
|
|
|
|
{
|
|
|
|
// is the element a pak file?
|
|
|
|
if (!search->funcs->EnumerateFiles(search->handle, match, func, parm))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void COM_FlushTempoaryPacks(void)
|
|
|
|
{
|
|
|
|
searchpath_t *next;
|
|
|
|
while (com_searchpaths && com_searchpaths->istemporary)
|
|
|
|
{
|
|
|
|
com_searchpaths->funcs->ClosePath(com_searchpaths->handle);
|
|
|
|
next = com_searchpaths->next;
|
|
|
|
Z_Free (com_searchpaths);
|
|
|
|
com_searchpaths = next;
|
|
|
|
|
|
|
|
com_fschanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
qboolean COM_LoadMapPackFile (const char *filename, int ofs)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
return false;
|
|
|
|
/*
|
2005-08-26 22:52:26 +00:00
|
|
|
dpackheader_t header;
|
|
|
|
int i;
|
|
|
|
packfile_t *newfiles;
|
|
|
|
int numpackfiles;
|
|
|
|
pack_t *pack;
|
|
|
|
FILE *packhandle;
|
|
|
|
dpackfile_t info;
|
|
|
|
int fstart;
|
|
|
|
char *ballsup;
|
|
|
|
|
|
|
|
flocation_t loc;
|
|
|
|
|
|
|
|
FS_FLocateFile(filename, FSLFRT_LENGTH, &loc);
|
|
|
|
|
|
|
|
if (!loc.search)
|
|
|
|
{
|
|
|
|
Con_Printf("Couldn't refind file\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*loc.rawname)
|
|
|
|
{
|
|
|
|
Con_Printf("File %s is compressed\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
packhandle = fopen(loc.rawname, "rb");
|
|
|
|
if (!packhandle)
|
|
|
|
{
|
|
|
|
Con_Printf("Couldn't reopen file\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
fseek(packhandle, loc.offset, SEEK_SET);
|
|
|
|
|
|
|
|
fstart = loc.offset;
|
|
|
|
fseek(packhandle, ofs+fstart, SEEK_SET);
|
|
|
|
|
|
|
|
fread (&header, 1, sizeof(header), packhandle);
|
|
|
|
if (header.id[0] != 'P' || header.id[1] != 'A'
|
|
|
|
|| header.id[2] != 'C' || header.id[3] != 'K')
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
header.dirofs = LittleLong (header.dirofs);
|
|
|
|
header.dirlen = LittleLong (header.dirlen);
|
|
|
|
|
|
|
|
numpackfiles = header.dirlen / sizeof(dpackfile_t);
|
|
|
|
|
|
|
|
newfiles = (packfile_t*)Z_Malloc (numpackfiles * sizeof(packfile_t));
|
|
|
|
|
|
|
|
fseek (packhandle, header.dirofs+fstart, SEEK_SET);
|
|
|
|
|
|
|
|
pack = (pack_t*)Z_Malloc (sizeof (pack_t));
|
|
|
|
|
|
|
|
// parse the directory
|
|
|
|
for (i=0 ; i<numpackfiles ; i++)
|
|
|
|
{
|
|
|
|
fread (&info, 1, sizeof(info), packhandle);
|
|
|
|
|
|
|
|
strcpy (newfiles[i].name, info.name);
|
|
|
|
Q_strlwr(newfiles[i].name);
|
|
|
|
while ((ballsup = strchr(newfiles[i].name, '\\')))
|
|
|
|
*ballsup = '/';
|
|
|
|
newfiles[i].filepos = LittleLong(info.filepos)+fstart;
|
|
|
|
newfiles[i].filelen = LittleLong(info.filelen);
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy (pack->filename, loc.rawname);
|
|
|
|
pack->handle = packhandle;
|
|
|
|
pack->numfiles = numpackfiles;
|
|
|
|
pack->files = newfiles;
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
Con_TPrintf (TL_ADDEDPACKFILE, filename, numpackfiles);
|
|
|
|
|
|
|
|
COM_AddPathHandle(&packfilefuncs, pack, true, true);
|
|
|
|
return true;
|
2005-12-21 03:07:33 +00:00
|
|
|
*/
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
static searchpath_t *FS_AddPathHandle(const char *purepath, const char *probablepath, const searchpathfuncs_t *funcs, void *handle, qboolean copyprotect, qboolean istemporary, qboolean isexplicit, unsigned int loadstuff);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
typedef struct {
|
2009-04-01 22:03:56 +00:00
|
|
|
const searchpathfuncs_t *funcs;
|
2005-12-21 03:07:33 +00:00
|
|
|
searchpath_t *parentpath;
|
2009-04-01 22:03:56 +00:00
|
|
|
const char *parentdesc;
|
|
|
|
const char *puredesc;
|
2005-12-21 03:07:33 +00:00
|
|
|
} wildpaks_t;
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
static int FS_AddWildDataFiles (const char *descriptor, int size, void *vparam)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
wildpaks_t *param = vparam;
|
|
|
|
vfsfile_t *vfs;
|
2009-04-01 22:03:56 +00:00
|
|
|
const searchpathfuncs_t *funcs = param->funcs;
|
2005-08-26 22:52:26 +00:00
|
|
|
searchpath_t *search;
|
2009-04-01 22:03:56 +00:00
|
|
|
void *pak;
|
2005-08-26 22:52:26 +00:00
|
|
|
char pakfile[MAX_OSPATH];
|
2008-11-09 22:29:28 +00:00
|
|
|
char purefile[MAX_OSPATH];
|
2005-12-21 03:07:33 +00:00
|
|
|
flocation_t loc;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
sprintf (pakfile, "%s%s", param->parentdesc, descriptor);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
for (search = com_searchpaths; search; search = search->next)
|
|
|
|
{
|
|
|
|
if (search->funcs != funcs)
|
|
|
|
continue;
|
|
|
|
if (!stricmp((char*)search->handle, pakfile)) //assumption: first member of structure is a char array
|
|
|
|
return true; //already loaded (base paths?)
|
|
|
|
}
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
search = param->parentpath;
|
|
|
|
|
|
|
|
if (!search->funcs->FindFile(search->handle, &loc, descriptor, NULL))
|
|
|
|
return true; //not found..
|
2006-01-02 22:53:29 +00:00
|
|
|
vfs = search->funcs->OpenVFS(search->handle, &loc, "rb");
|
2005-12-21 03:07:33 +00:00
|
|
|
pak = funcs->OpenNew (vfs, pakfile);
|
2005-08-26 22:52:26 +00:00
|
|
|
if (!pak)
|
|
|
|
return true;
|
2005-12-21 03:07:33 +00:00
|
|
|
|
|
|
|
sprintf (pakfile, "%s%s/", param->parentdesc, descriptor);
|
2008-11-09 22:29:28 +00:00
|
|
|
if (*param->puredesc)
|
|
|
|
snprintf (purefile, sizeof(purefile), "%s/%s", param->puredesc, descriptor);
|
|
|
|
else
|
|
|
|
Q_strncpyz(purefile, descriptor, sizeof(purefile));
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_AddPathHandle(purefile, pakfile, funcs, pak, true, false, false, (unsigned int)-1);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
static void FS_AddDataFiles(const char *purepath, const char *pathto, searchpath_t *search, const char *extension, searchpathfuncs_t *funcs)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
//search is the parent
|
2005-08-26 22:52:26 +00:00
|
|
|
int i;
|
2005-12-21 03:07:33 +00:00
|
|
|
void *handle;
|
2005-08-26 22:52:26 +00:00
|
|
|
char pakfile[MAX_OSPATH];
|
2008-11-09 22:29:28 +00:00
|
|
|
char purefile[MAX_OSPATH];
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *vfs;
|
|
|
|
flocation_t loc;
|
|
|
|
wildpaks_t wp;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
//first load all the numbered pak files
|
2005-08-26 22:52:26 +00:00
|
|
|
for (i=0 ; ; i++)
|
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf (pakfile, sizeof(pakfile), "pak%i.%s", i, extension);
|
2005-12-21 03:07:33 +00:00
|
|
|
if (!search->funcs->FindFile(search->handle, &loc, pakfile, NULL))
|
|
|
|
break; //not found..
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf (pakfile, sizeof(pakfile), "%spak%i.%s", pathto, i, extension);
|
2005-12-21 03:07:33 +00:00
|
|
|
vfs = search->funcs->OpenVFS(search->handle, &loc, "r");
|
|
|
|
if (!vfs)
|
|
|
|
break;
|
|
|
|
Con_Printf("Opened %s\n", pakfile);
|
|
|
|
handle = funcs->OpenNew (vfs, pakfile);
|
2005-08-26 22:52:26 +00:00
|
|
|
if (!handle)
|
|
|
|
break;
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf (pakfile, sizeof(pakfile), "%spak%i.%s/", pathto, i, extension);
|
2009-07-14 15:11:31 +00:00
|
|
|
snprintf (purefile, sizeof(pakfile), "%s/pak%i.%s", purepath, i, extension);
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_AddPathHandle(purefile, pakfile, funcs, handle, true, false, false, (unsigned int)-1);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
//now load the random ones
|
2005-08-26 22:52:26 +00:00
|
|
|
sprintf (pakfile, "*.%s", extension);
|
2005-12-21 03:07:33 +00:00
|
|
|
wp.funcs = funcs;
|
|
|
|
wp.parentdesc = pathto;
|
|
|
|
wp.parentpath = search;
|
2008-11-09 22:29:28 +00:00
|
|
|
wp.puredesc = purepath;
|
2009-04-01 22:03:56 +00:00
|
|
|
search->funcs->EnumerateFiles(search->handle, pakfile, FS_AddWildDataFiles, &wp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static searchpath_t *FS_AddPathHandle(const char *purepath, const char *probablepath, const searchpathfuncs_t *funcs, void *handle, qboolean copyprotect, qboolean istemporary, qboolean isexplicit, unsigned int loadstuff)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
searchpath_t *search;
|
|
|
|
|
|
|
|
if (!funcs)
|
|
|
|
{
|
|
|
|
Con_Printf("COM_AddPathHandle: %s format not supported in this build\n", probablepath);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
search = (searchpath_t*)Z_Malloc (sizeof(searchpath_t));
|
|
|
|
search->copyprotected = copyprotect;
|
|
|
|
search->istemporary = istemporary;
|
|
|
|
search->isexplicit = isexplicit;
|
|
|
|
search->handle = handle;
|
|
|
|
search->funcs = funcs;
|
|
|
|
Q_strncpyz(search->purepath, purepath, sizeof(search->purepath));
|
|
|
|
|
|
|
|
search->next = com_searchpaths;
|
|
|
|
com_searchpaths = search;
|
|
|
|
|
|
|
|
com_fschanged = true;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
|
|
|
|
{
|
|
|
|
if (!searchpathformats[i].extension || !searchpathformats[i].funcs || !searchpathformats[i].funcs->OpenNew)
|
|
|
|
continue;
|
|
|
|
if (loadstuff & (1<<i))
|
|
|
|
{
|
|
|
|
FS_AddDataFiles(purepath, probablepath, search, searchpathformats[i].extension, searchpathformats[i].funcs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return search;
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COM_RefreshFSCache_f(void)
|
|
|
|
{
|
|
|
|
com_fschanged=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void COM_FlushFSCache(void)
|
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
if (com_fs_cache.ival != 2)
|
2005-08-26 22:52:26 +00:00
|
|
|
com_fschanged=true;
|
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
|
|
|
|
/*since should start as 0, otherwise this can be used to poll*/
|
|
|
|
qboolean FS_Restarted(unsigned int *since)
|
|
|
|
{
|
|
|
|
if (*since < fs_restarts)
|
|
|
|
{
|
|
|
|
*since = fs_restarts;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
/*
|
|
|
|
================
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_AddGameDirectory
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
Sets com_gamedir, adds the directory to the head of the path,
|
2005-11-21 21:09:11 +00:00
|
|
|
then loads and adds pak1.pak pak2.pak ...
|
2005-08-26 22:52:26 +00:00
|
|
|
================
|
|
|
|
*/
|
2009-04-01 22:03:56 +00:00
|
|
|
void FS_AddGameDirectory (const char *puredir, const char *dir, unsigned int loadstuff)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
searchpath_t *search;
|
|
|
|
|
|
|
|
char *p;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
fs_restarts++;
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
if ((p = strrchr(dir, '/')) != NULL)
|
|
|
|
strcpy(gamedirfile, ++p);
|
|
|
|
else
|
2006-03-06 01:41:09 +00:00
|
|
|
strcpy(gamedirfile, dir);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
for (search = com_searchpaths; search; search = search->next)
|
|
|
|
{
|
|
|
|
if (search->funcs != &osfilefuncs)
|
|
|
|
continue;
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!stricmp(search->handle, dir))
|
2005-08-26 22:52:26 +00:00
|
|
|
return; //already loaded (base paths?)
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// add the directory to the search path
|
|
|
|
//
|
2005-10-31 00:52:03 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
p = Z_Malloc(strlen(dir)+1);
|
|
|
|
strcpy(p, dir);
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_AddPathHandle((*dir?puredir:""), va("%s/", dir), &osfilefuncs, p, false, false, true, loadstuff);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *COM_NextPath (char *prevpath)
|
|
|
|
{
|
|
|
|
searchpath_t *s;
|
|
|
|
char *prev;
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
prev = NULL;
|
2005-08-26 22:52:26 +00:00
|
|
|
for (s=com_searchpaths ; s ; s=s->next)
|
|
|
|
{
|
|
|
|
if (s->funcs != &osfilefuncs)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (prevpath == prev)
|
|
|
|
return s->handle;
|
|
|
|
prev = s->handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CLIENTONLY
|
|
|
|
char *COM_GetPathInfo (int i, int *crc)
|
|
|
|
{
|
2009-05-24 10:11:17 +00:00
|
|
|
//#ifdef WEBSERVER
|
|
|
|
// extern cvar_t httpserver;
|
|
|
|
//#endif
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
searchpath_t *s;
|
|
|
|
static char name[MAX_OSPATH];
|
2008-11-09 22:29:28 +00:00
|
|
|
// char adr[MAX_ADR_SIZE];
|
2005-08-26 22:52:26 +00:00
|
|
|
char *protocol;
|
|
|
|
|
|
|
|
for (s=com_searchpaths ; s ; s=s->next)
|
|
|
|
{
|
|
|
|
i--;
|
|
|
|
if (!i)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i) //too high.
|
|
|
|
return NULL;
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
/*
|
2005-08-26 22:52:26 +00:00
|
|
|
#ifdef WEBSERVER
|
|
|
|
if (httpserver.value)
|
2008-06-08 14:37:57 +00:00
|
|
|
protocol = va("http://%s/", NET_AdrToString(adr, sizeof(adr), net_local_sv_ipadr));
|
2005-08-26 22:52:26 +00:00
|
|
|
else
|
|
|
|
#endif
|
2008-11-09 22:29:28 +00:00
|
|
|
*/
|
2005-08-26 22:52:26 +00:00
|
|
|
protocol = "qw://";
|
|
|
|
|
|
|
|
*crc = 0;//s->crc;
|
|
|
|
strcpy(name, "FIXME");
|
|
|
|
// Q_strncpyz(name, va("%s%s", protocol, COM_SkipPath(s->filename)), sizeof(name));
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char *FS_GetGamedir(void)
|
|
|
|
{
|
|
|
|
return gamedirfile;
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
COM_Gamedir
|
|
|
|
|
|
|
|
Sets the gamedir and path to a different directory.
|
|
|
|
================
|
|
|
|
*/
|
2009-04-01 22:03:56 +00:00
|
|
|
void COM_Gamedir (const char *dir)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
searchpath_t *next;
|
2009-04-01 22:03:56 +00:00
|
|
|
int plen, dlen;
|
|
|
|
char *p;
|
2009-11-04 21:16:50 +00:00
|
|
|
qboolean isbase;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!*dir || !strcmp(dir, ".") || strstr(dir, "..") || strstr(dir, "/")
|
2005-08-26 22:52:26 +00:00
|
|
|
|| strstr(dir, "\\") || strstr(dir, ":") )
|
|
|
|
{
|
|
|
|
Con_TPrintf (TL_GAMEDIRAINTPATH);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
isbase = false;
|
2009-04-01 22:03:56 +00:00
|
|
|
dlen = strlen(dir);
|
2009-11-04 21:16:50 +00:00
|
|
|
for (next = com_searchpaths; next; next = next->next)
|
2009-04-01 22:03:56 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (next == com_base_searchpaths)
|
|
|
|
isbase = true;
|
2009-04-01 22:03:56 +00:00
|
|
|
if (next->funcs == &osfilefuncs)
|
|
|
|
{
|
|
|
|
p = next->handle;
|
|
|
|
plen = strlen(p);
|
|
|
|
if (plen == dlen)
|
|
|
|
{
|
|
|
|
//no basedir, maybe
|
|
|
|
if (!strcmp(p, dir))
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
if (isbase && com_searchpaths == com_base_searchpaths)
|
|
|
|
{
|
|
|
|
Q_strncpyz (gamedirfile, dir, sizeof(gamedirfile));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isbase)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
}
|
|
|
|
else if (plen > dlen)
|
|
|
|
{
|
|
|
|
if (*(p+plen-dlen-1) == '/')
|
|
|
|
{
|
2009-05-30 23:54:41 +00:00
|
|
|
if (!strcmp(p+plen-dlen, dir))
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
if (isbase && com_searchpaths == com_base_searchpaths)
|
|
|
|
{
|
|
|
|
Q_strncpyz (gamedirfile, dir, sizeof(gamedirfile));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isbase)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-03 09:09:35 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
FS_ForceToPure(NULL, NULL, 0);
|
|
|
|
|
|
|
|
#ifndef SERVERONLY
|
|
|
|
Host_WriteConfiguration(); //before we change anything.
|
|
|
|
#endif
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
Q_strncpyz (gamedirfile, dir, sizeof(gamedirfile));
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
#ifndef CLIENTONLY
|
|
|
|
sv.gamedirchanged = true;
|
|
|
|
#endif
|
|
|
|
#ifndef SERVERONLY
|
|
|
|
cl.gamedirchanged = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FS_FlushFSHash();
|
|
|
|
|
|
|
|
//
|
|
|
|
// free up any current game dir info
|
|
|
|
//
|
|
|
|
while (com_searchpaths != com_base_searchpaths)
|
|
|
|
{
|
|
|
|
com_searchpaths->funcs->ClosePath(com_searchpaths->handle);
|
|
|
|
next = com_searchpaths->next;
|
|
|
|
Z_Free (com_searchpaths);
|
|
|
|
com_searchpaths = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
com_fschanged = true;
|
|
|
|
|
|
|
|
//
|
|
|
|
// flush all data, so it will be forced to reload
|
|
|
|
//
|
|
|
|
Cache_Flush ();
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (strchr(dir, ';'))
|
|
|
|
{
|
|
|
|
//separate case because parsestringset splits by whitespace too
|
2010-07-11 10:53:13 +00:00
|
|
|
while ((dir = COM_ParseStringSet(dir)))
|
2009-04-01 22:03:56 +00:00
|
|
|
{
|
|
|
|
if (!strcmp(dir, ";"))
|
|
|
|
continue;
|
|
|
|
if (!*dir)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
FS_AddGameDirectory(dir, va("%s%s", com_quakedir, com_token), ~0);
|
|
|
|
if (*com_homedir)
|
|
|
|
FS_AddGameDirectory(dir, va("%s%s", com_homedir, com_token), ~0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FS_AddGameDirectory(dir, va("%s%s", com_quakedir, dir), ~0);
|
|
|
|
if (*com_homedir)
|
|
|
|
FS_AddGameDirectory(dir, va("%s%s", com_homedir, dir), ~0);
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef SERVERONLY
|
2008-11-09 22:29:28 +00:00
|
|
|
if (!isDedicated)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2010-02-06 01:25:04 +00:00
|
|
|
// if (qrenderer != QR_NONE) //only do this if we have already started the renderer
|
2005-08-26 22:52:26 +00:00
|
|
|
// Cbuf_InsertText("vid_restart\n", RESTRICT_LOCAL);
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
|
|
|
|
if (COM_FDepthFile("config.cfg", true) <= (*com_homedir?1:0))
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
Cbuf_InsertText("cl_warncmd 0\n"
|
|
|
|
"exec config.cfg\n"
|
|
|
|
"exec fte.cfg\n"
|
|
|
|
"exec frontend.cfg\n"
|
2006-02-06 01:06:17 +00:00
|
|
|
"cl_warncmd 1\n", RESTRICT_LOCAL, false);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
extern void Shader_Init(void);
|
|
|
|
Shader_Init(); //FIXME!
|
|
|
|
}
|
|
|
|
|
2008-11-28 20:34:51 +00:00
|
|
|
COM_Effectinfo_Clear();
|
2008-11-09 22:29:28 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
Validation_FlushFileList(); //prevent previous hacks from making a difference.
|
|
|
|
|
|
|
|
//FIXME: load new palette, if different cause a vid_restart.
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-07-18 08:42:59 +00:00
|
|
|
#define DPCOMPAT "set dpcompat_set 1\nset dpcompat_trailparticles 1\n"
|
2010-08-28 17:14:38 +00:00
|
|
|
#define NEXCFG DPCOMPAT "set r_particlesdesc effectinfo\nset sv_maxairspeed \"400\"\nset sv_jumpvelocity 270\nset sv_mintic \"0.01\"\ncl_nolerp 0\nset r_particlesdesc effectinfo\n"
|
2009-06-21 17:45:33 +00:00
|
|
|
#define DMFCFG "set com_parseutf8 1\npm_airstep 1\n"
|
2010-08-28 17:14:38 +00:00
|
|
|
#define HEX2CFG "set r_particlesdesc \"spikeset tsshaft h2part\"\nset sv_maxspeed 640\nset watervis 1\nset r_wateralpha 0.5\nset sv_pupglow 1\nset cl_model_bobbing 1\n"
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2009-04-12 16:57:30 +00:00
|
|
|
const char *protocolname; //sent to the master server when this is the current gamemode.
|
2009-04-01 22:03:56 +00:00
|
|
|
const char *exename; //used if the exe name contains this
|
|
|
|
const char *argname; //used if this was used as a parameter.
|
2010-11-02 23:17:25 +00:00
|
|
|
const char *auniquefile[4]; //used if this file is relative from the gamedir
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
const char *customexec;
|
2007-06-20 00:02:54 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
const char *dir[4];
|
2009-04-12 16:57:30 +00:00
|
|
|
const char *poshname; //Full name for the game.
|
2005-08-26 22:52:26 +00:00
|
|
|
} gamemode_info_t;
|
2009-04-01 22:03:56 +00:00
|
|
|
const gamemode_info_t gamemode_info[] = {
|
2005-08-26 22:52:26 +00:00
|
|
|
//note that there is no basic 'fte' gamemode, this is because we aim for network compatability. Darkplaces-Quake is the closest we get.
|
|
|
|
//this is to avoid having too many gamemodes anyway.
|
2007-06-20 00:02:54 +00:00
|
|
|
|
|
|
|
//rogue/hipnotic have no special files - the detection conflicts and stops us from running regular quake
|
2009-06-21 17:45:33 +00:00
|
|
|
//protocol name(dpmaster) exename cmdline switch identifying file exec dir1 dir2 dir3 dir(fte) full name
|
2010-11-02 23:17:25 +00:00
|
|
|
{"Darkplaces-Quake", "darkplaces", "-quake", {"id1/pak0.pak"}, NULL, {"id1", "qw", "fte"}, "Quake"},
|
|
|
|
{"Darkplaces-Hipnotic", "hipnotic", "-hipnotic", {NULL}, NULL, {"id1", "qw", "hipnotic", "fte"}, "Quake: Scourge of Armagon"},
|
|
|
|
{"Darkplaces-Rogue", "rogue", "-rogue", {NULL}, NULL, {"id1", "qw", "rogue", "fte"}, "Quake: Dissolution of Eternity"},
|
|
|
|
{"Nexuiz", "nexuiz", "-nexuiz", {"nexuiz.exe"}, NEXCFG, {"data", "ftedata"}, "Nexuiz"},
|
|
|
|
{"DMF", "dmf", "-dmf", {"base/src/progs.src"}, DMFCFG, {"base", }, "DMF"},
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
//supported commercial mods (some are currently only partially supported)
|
2010-11-02 23:17:25 +00:00
|
|
|
{"FTE-H2MP", "h2mp", "-portals", {"portals/hexen.rc",
|
|
|
|
"portals/pak3.pak"}, HEX2CFG,{"data1", "portals", "fteh2"}, "Hexen II MP"},
|
|
|
|
{"FTE-Hexen2", "hexen", "-hexen2", {"data1/pak0.pak"}, HEX2CFG,{"data1", "fteh2"}, "Hexen II"},
|
|
|
|
{"FTE-Quake2", "q2", "-q2", {"baseq2/pak0.pak"}, NULL, {"baseq2", "fteq2"}, "Quake II"},
|
|
|
|
{"FTE-Quake3", "q3", "-q3", {"baseq3/pak0.pk3"}, NULL, {"baseq3", "fteq3"}, "Quake III Arena"},
|
|
|
|
{"FTE-Quake4", "q4", "-q4", {"q4base/pak00.pk4"}, NULL, {"q4base", "fteq4"}, "Quake 4"},
|
|
|
|
{"FTE-EnemyTerritory", "et", "-et", {"etmain/pak0.pk3"}, NULL, {"etmain", "fteet"}, "Wolfenstein - Enemy Territory"},
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
{"FTE-JK2", "jk2", "-jk2", {"base/assets0.pk3"}, NULL, {"base", "fte"}, "Jedi Knight II: Jedi Outcast"},
|
2005-08-26 22:52:26 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
{"FTE-HalfLife", "hl", "-halflife", {"valve/liblist.gam"} ,NULL, {"valve", "ftehl"}, "Half-Life"},
|
2009-03-03 01:52:30 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
//space-seperate pk3 names followed by space-seperated crcs
|
|
|
|
//note that we'll need to reorder and filter out files that don't match the crc.
|
2009-04-01 22:03:56 +00:00
|
|
|
void FS_ForceToPure(const char *str, const char *crcs, int seed)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
//pure files are more important than non-pure.
|
|
|
|
|
|
|
|
searchpath_t *sp;
|
|
|
|
searchpath_t *lastpure = NULL;
|
|
|
|
int crc;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
{ //pure isn't in use.
|
2007-09-17 20:35:39 +00:00
|
|
|
if (com_purepaths)
|
|
|
|
Con_Printf("Pure FS deactivated\n");
|
2005-08-26 22:52:26 +00:00
|
|
|
com_purepaths = NULL;
|
|
|
|
FS_FlushFSHash();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-17 20:35:39 +00:00
|
|
|
if (!com_purepaths)
|
|
|
|
Con_Printf("Pure FS activated\n");
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
for (sp = com_searchpaths; sp; sp = sp->next)
|
|
|
|
{
|
|
|
|
if (sp->funcs->GeneratePureCRC)
|
|
|
|
{
|
|
|
|
sp->nextpure = (void*)0x1;
|
|
|
|
sp->crc_check = sp->funcs->GeneratePureCRC(sp->handle, seed, 0);
|
|
|
|
sp->crc_reply = sp->funcs->GeneratePureCRC(sp->handle, seed, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sp->crc_check = 0;
|
|
|
|
sp->crc_reply = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while(crcs)
|
|
|
|
{
|
|
|
|
crcs = COM_Parse(crcs);
|
|
|
|
crc = atoi(com_token);
|
2005-11-21 21:09:11 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
if (!crc)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (sp = com_searchpaths; sp; sp = sp->next)
|
|
|
|
{
|
|
|
|
if (sp->nextpure == (void*)0x1) //don't add twice.
|
|
|
|
if (sp->crc_check == crc)
|
|
|
|
{
|
|
|
|
if (lastpure)
|
|
|
|
lastpure->nextpure = sp;
|
|
|
|
else
|
|
|
|
com_purepaths = sp;
|
|
|
|
sp->nextpure = NULL;
|
|
|
|
lastpure = sp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!sp)
|
|
|
|
Con_Printf("Pure crc %i wasn't found\n", crc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't add any extras.
|
|
|
|
for (sp = com_searchpaths; sp; sp = sp->next)
|
|
|
|
{
|
|
|
|
if (sp->nextpure == (void*)0x1)
|
|
|
|
{
|
|
|
|
if (lastpure)
|
|
|
|
lastpure->nextpure = sp;
|
|
|
|
sp->nextpure = NULL;
|
|
|
|
lastpure = sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
FS_FlushFSHash();
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char *FSQ3_GenerateClientPacksList(char *buffer, int maxlen, int basechecksum)
|
|
|
|
{ //this is for q3 compatibility.
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
flocation_t loc;
|
|
|
|
int numpaks = 0;
|
|
|
|
searchpath_t *sp;
|
|
|
|
|
|
|
|
FS_FLocateFile("vm/cgame.qvm", FSLFRT_LENGTH, &loc);
|
|
|
|
Q_strncatz(buffer, va("%i ", loc.search->crc_reply), maxlen);
|
|
|
|
basechecksum ^= loc.search->crc_reply;
|
|
|
|
|
|
|
|
FS_FLocateFile("vm/ui.qvm", FSLFRT_LENGTH, &loc);
|
|
|
|
Q_strncatz(buffer, va("%i ", loc.search->crc_reply), maxlen);
|
|
|
|
basechecksum ^= loc.search->crc_reply;
|
|
|
|
|
|
|
|
Q_strncatz(buffer, "@ ", maxlen);
|
|
|
|
|
|
|
|
for (sp = com_purepaths; sp; sp = sp->nextpure)
|
|
|
|
{
|
|
|
|
if (sp->crc_reply)
|
|
|
|
{
|
|
|
|
Q_strncatz(buffer, va("%i ", sp->crc_reply), maxlen);
|
|
|
|
basechecksum ^= sp->crc_reply;
|
|
|
|
numpaks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
basechecksum ^= numpaks;
|
|
|
|
Q_strncatz(buffer, va("%i ", basechecksum), maxlen);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2005-10-16 12:49:15 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
FS_ReloadPackFiles
|
|
|
|
================
|
|
|
|
|
|
|
|
Called when the client has downloaded a new pak/pk3 file
|
|
|
|
*/
|
2005-10-31 00:52:03 +00:00
|
|
|
void FS_ReloadPackFilesFlags(unsigned int reloadflags)
|
2005-10-16 12:49:15 +00:00
|
|
|
{
|
|
|
|
searchpath_t *oldpaths;
|
|
|
|
searchpath_t *oldbase;
|
|
|
|
searchpath_t *next;
|
|
|
|
|
|
|
|
|
|
|
|
//a lame way to fix pure paks
|
|
|
|
#ifndef SERVERONLY
|
2008-11-09 22:29:28 +00:00
|
|
|
if (cls.state && com_purepaths)
|
2005-10-16 12:49:15 +00:00
|
|
|
{
|
|
|
|
CL_Disconnect_f();
|
|
|
|
CL_Reconnect_f();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FS_FlushFSHash();
|
|
|
|
|
|
|
|
oldpaths = com_searchpaths;
|
|
|
|
com_searchpaths = NULL;
|
|
|
|
com_purepaths = NULL;
|
|
|
|
oldbase = com_base_searchpaths;
|
|
|
|
com_base_searchpaths = NULL;
|
|
|
|
|
|
|
|
//invert the order
|
|
|
|
next = NULL;
|
|
|
|
while(oldpaths)
|
|
|
|
{
|
|
|
|
oldpaths->nextpure = next;
|
|
|
|
next = oldpaths;
|
|
|
|
oldpaths = oldpaths->next;
|
|
|
|
}
|
|
|
|
oldpaths = next;
|
|
|
|
|
|
|
|
com_base_searchpaths = NULL;
|
|
|
|
|
|
|
|
while(oldpaths)
|
|
|
|
{
|
|
|
|
next = oldpaths->nextpure;
|
|
|
|
|
|
|
|
if (oldbase == oldpaths)
|
|
|
|
com_base_searchpaths = com_searchpaths;
|
|
|
|
|
|
|
|
if (oldpaths->funcs == &osfilefuncs)
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_AddGameDirectory(oldpaths->purepath, oldpaths->handle, reloadflags);
|
2005-10-16 12:49:15 +00:00
|
|
|
|
|
|
|
oldpaths->funcs->ClosePath(oldpaths->handle);
|
|
|
|
Z_Free(oldpaths);
|
|
|
|
oldpaths = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!com_base_searchpaths)
|
|
|
|
com_base_searchpaths = com_searchpaths;
|
|
|
|
}
|
|
|
|
|
2006-01-28 06:41:20 +00:00
|
|
|
void FS_UnloadPackFiles(void)
|
|
|
|
{
|
|
|
|
FS_ReloadPackFilesFlags(1);
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:52:03 +00:00
|
|
|
void FS_ReloadPackFiles(void)
|
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_ReloadPackFilesFlags(~0);
|
2005-10-31 00:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FS_ReloadPackFiles_f(void)
|
|
|
|
{
|
|
|
|
if (atoi(Cmd_Argv(1)))
|
|
|
|
FS_ReloadPackFilesFlags(atoi(Cmd_Argv(1)));
|
|
|
|
else
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_ReloadPackFilesFlags(~0);
|
2005-10-31 00:52:03 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
2009-05-24 10:11:17 +00:00
|
|
|
#ifdef MINGW
|
|
|
|
#define byte BYTE //some versions of mingw headers are broken slightly. this lets it compile.
|
|
|
|
#endif
|
2009-04-12 16:57:30 +00:00
|
|
|
#include <shlobj.h>
|
2010-08-16 02:03:02 +00:00
|
|
|
static qboolean Sys_SteamHasFile(char *basepath, int basepathlen, char *steamdir, char *fname)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Find where Valve's Steam distribution platform is installed.
|
|
|
|
Then take a look at that location for the relevent installed app.
|
|
|
|
*/
|
|
|
|
FILE *f;
|
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Valve\\Steam", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
|
|
|
RegQueryValueEx(key, "InstallPath", NULL, NULL, basepath, &resultlen);
|
|
|
|
RegCloseKey(key);
|
|
|
|
Q_strncatz(basepath, va("/SteamApps/common/%s", steamdir), basepathlen);
|
|
|
|
if (f = fopen(va("%s/%s", basepath, fname), "rb"))
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-12 16:57:30 +00:00
|
|
|
qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *basepath, int basepathlen)
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2009-04-12 16:57:30 +00:00
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
|
|
|
|
|
|
|
#ifndef INVALID_FILE_ATTRIBUTES
|
|
|
|
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//first, try and find it in our game paths location
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\" FULLENGINENAME "\\GamePaths", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
|
|
|
if (!RegQueryValueEx(key, gamename, NULL, NULL, basepath, &resultlen))
|
|
|
|
{
|
|
|
|
if (GetFileAttributes(basepath) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
if (!strcmp(gamename, "q1"))
|
|
|
|
{
|
2010-08-16 02:03:02 +00:00
|
|
|
FILE *f;
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
//try and find it via steam
|
|
|
|
//reads HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam\InstallPath
|
|
|
|
//append SteamApps\common\quake
|
|
|
|
//use it if we find winquake.exe there
|
2010-08-16 02:03:02 +00:00
|
|
|
if (Sys_SteamHasFile(basepath, basepathlen, "quake", "Winquake.exe"))
|
|
|
|
return true;
|
2009-03-03 01:52:30 +00:00
|
|
|
//well, okay, so they don't have quake installed from steam.
|
|
|
|
|
|
|
|
//quite a lot of people have it in c:\quake, as that's the default install location from the quake cd.
|
|
|
|
if (f = fopen("c:/quake/quake.exe", "rb"))
|
|
|
|
{
|
|
|
|
//HAHAHA! Found it!
|
|
|
|
fclose(f);
|
|
|
|
Q_strncpyz(basepath, "c:/quake", basepathlen);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(gamename, "q2"))
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
2010-08-16 02:03:02 +00:00
|
|
|
|
|
|
|
//look for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Quake2_exe\Path
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Quake2_exe", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
2010-08-16 02:03:02 +00:00
|
|
|
RegQueryValueEx(key, "Path", NULL, NULL, basepath, &resultlen);
|
2009-03-03 01:52:30 +00:00
|
|
|
RegCloseKey(key);
|
|
|
|
if (f = fopen(va("%s/quake2.exe", basepath), "rb"))
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-16 02:03:02 +00:00
|
|
|
if (Sys_SteamHasFile(basepath, basepathlen, "quake 2", "quake2.exe"))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(gamename, "et"))
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
|
|
|
//reads HKEY_LOCAL_MACHINE\SOFTWARE\Activision\Wolfenstein - Enemy Territory
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Activision\\Wolfenstein - Enemy Territory", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
2010-08-16 02:03:02 +00:00
|
|
|
RegQueryValueEx(key, "InstallPath", NULL, NULL, basepath, &resultlen);
|
2009-03-03 01:52:30 +00:00
|
|
|
RegCloseKey(key);
|
2010-08-16 02:03:02 +00:00
|
|
|
|
|
|
|
if (f = fopen(va("%s/ET.exe", basepath), "rb"))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-16 02:03:02 +00:00
|
|
|
return true;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(gamename, "q3"))
|
|
|
|
{
|
2010-08-16 02:03:02 +00:00
|
|
|
FILE *f;
|
2009-03-03 01:52:30 +00:00
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
2010-08-16 02:03:02 +00:00
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
//reads HKEY_LOCAL_MACHINE\SOFTWARE\id\Quake III Arena\InstallPath
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\id\\Quake III Arena", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
|
|
|
RegQueryValueEx(key, "InstallPath", NULL, NULL, basepath, &resultlen);
|
|
|
|
RegCloseKey(key);
|
2010-08-16 02:03:02 +00:00
|
|
|
|
|
|
|
if (f = fopen(va("%s/quake3.exe", basepath), "rb"))
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
2010-08-16 02:03:02 +00:00
|
|
|
|
|
|
|
if (Sys_SteamHasFile(basepath, basepathlen, "quake 3 arena", "quake3.exe"))
|
|
|
|
return true;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
|
|
|
|
if (!strcmp(gamename, "wop"))
|
|
|
|
{
|
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
|
|
|
//reads HKEY_LOCAL_MACHINE\SOFTWARE\World Of Padman\Path
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\World Of Padman", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
|
|
|
RegQueryValueEx(key, "Path", NULL, NULL, basepath, &resultlen);
|
|
|
|
RegCloseKey(key);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
/*
|
|
|
|
if (!strcmp(gamename, "d3"))
|
|
|
|
{
|
|
|
|
DWORD resultlen;
|
|
|
|
HKEY key = NULL;
|
|
|
|
//reads HKEY_LOCAL_MACHINE\SOFTWARE\id\Doom 3\InstallPath
|
|
|
|
if (!FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\id\\Doom 3", 0, STANDARD_RIGHTS_READ|KEY_QUERY_VALUE, &key)))
|
|
|
|
{
|
|
|
|
resultlen = basepathlen;
|
|
|
|
RegQueryValueEx(key, "InstallPath", NULL, NULL, basepath, &resultlen);
|
|
|
|
RegCloseKey(key);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!strcmp(gamename, "h2"))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
//append SteamApps\common\hexen 2
|
2010-08-16 02:03:02 +00:00
|
|
|
if (Sys_SteamHasFile(basepath, basepathlen, "hexen 2", "h2.exe"))
|
|
|
|
return true;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
#if !defined(NPQTV) && !defined(SERVERONLY) //this is *really* unfortunate, but doing this crashes the browser
|
2009-04-12 16:57:30 +00:00
|
|
|
if (poshname)
|
|
|
|
{
|
|
|
|
char resultpath[MAX_PATH];
|
|
|
|
BROWSEINFO bi;
|
|
|
|
LPITEMIDLIST il;
|
|
|
|
memset(&bi, 0, sizeof(bi));
|
2009-06-03 09:09:35 +00:00
|
|
|
|
|
|
|
#if defined(_SDL) && defined (WIN32) && defined (MINGW) // mingw32 sdl cross compiled binary, code completely untested, doesn't crash so good sign ~moodles
|
|
|
|
SDL_SysWMinfo wmInfo;
|
|
|
|
SDL_GetWMInfo(&wmInfo);
|
|
|
|
HWND sys_parentwindow = wmInfo.window;
|
|
|
|
|
2009-04-12 16:57:30 +00:00
|
|
|
if (sys_parentwindow)
|
|
|
|
bi.hwndOwner = sys_parentwindow; //note that this is usually still null
|
|
|
|
else
|
2010-08-11 23:55:35 +00:00
|
|
|
#endif
|
2009-04-12 16:57:30 +00:00
|
|
|
bi.hwndOwner = mainwindow; //note that this is usually still null
|
|
|
|
bi.pidlRoot = NULL;
|
|
|
|
bi.pszDisplayName = resultpath;
|
|
|
|
bi.lpszTitle = va("Please locate your existing %s installation", poshname);
|
|
|
|
bi.ulFlags = BIF_RETURNONLYFSDIRS;
|
|
|
|
bi.lpfn = NULL;
|
|
|
|
bi.lParam = 0;
|
|
|
|
bi.iImage = 0;
|
|
|
|
|
|
|
|
il = SHBrowseForFolder(&bi);
|
|
|
|
if (il)
|
|
|
|
{
|
|
|
|
SHGetPathFromIDList(il, resultpath);
|
|
|
|
CoTaskMemFree(il);
|
|
|
|
Q_strncpyz(basepath, resultpath, basepathlen-1);
|
|
|
|
|
|
|
|
//and save it into the windows registry
|
|
|
|
if (!FAILED(RegCreateKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\" FULLENGINENAME "\\GamePaths",
|
|
|
|
0, NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_WRITE,
|
|
|
|
NULL,
|
|
|
|
&key,
|
|
|
|
NULL)))
|
|
|
|
{
|
|
|
|
RegSetValueEx(key, gamename, 0, REG_SZ, basepath, strlen(basepath));
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-04-19 00:50:42 +00:00
|
|
|
#endif
|
2009-04-12 16:57:30 +00:00
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#else
|
2009-04-13 12:54:18 +00:00
|
|
|
qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *basepath, int basepathlen)
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
void FS_Shutdown(void)
|
|
|
|
{
|
|
|
|
searchpath_t *next;
|
|
|
|
FS_FlushFSHash();
|
|
|
|
|
|
|
|
//
|
|
|
|
// free up any current game dir info
|
|
|
|
//
|
|
|
|
while (com_searchpaths)
|
|
|
|
{
|
|
|
|
com_searchpaths->funcs->ClosePath(com_searchpaths->handle);
|
|
|
|
next = com_searchpaths->next;
|
|
|
|
Z_Free (com_searchpaths);
|
|
|
|
com_searchpaths = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
com_fschanged = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-16 02:03:02 +00:00
|
|
|
void FS_StartupWithGame(int gamenum)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-11-11 04:03:16 +00:00
|
|
|
LibZ_Init();
|
|
|
|
|
2010-08-16 02:03:02 +00:00
|
|
|
Cvar_Set(&com_gamename, gamemode_info[gamenum].protocolname);
|
|
|
|
|
|
|
|
//
|
|
|
|
// start up with id1 by default
|
|
|
|
//
|
|
|
|
i = COM_CheckParm ("-basegame");
|
|
|
|
if (i && i < com_argc-1)
|
|
|
|
{
|
|
|
|
do //use multiple -basegames
|
|
|
|
{
|
|
|
|
FS_AddGameDirectory (com_argv[i+1], va("%s%s", com_quakedir, com_argv[i+1]), ~0);
|
|
|
|
if (*com_homedir)
|
|
|
|
FS_AddGameDirectory (com_argv[i+1], va("%s%s", com_homedir, com_argv[i+1]), ~0);
|
|
|
|
|
|
|
|
i = COM_CheckNextParm ("-basegame", i);
|
|
|
|
}
|
|
|
|
while (i && i < com_argc-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < sizeof(gamemode_info[gamenum].dir)/sizeof(gamemode_info[gamenum].dir[0]); i++)
|
|
|
|
{
|
|
|
|
if (gamemode_info[gamenum].dir[i])
|
|
|
|
{
|
|
|
|
FS_AddGameDirectory (gamemode_info[gamenum].dir[i], va("%s%s", com_quakedir, gamemode_info[gamenum].dir[i]), ~0);
|
|
|
|
if (*com_homedir)
|
|
|
|
FS_AddGameDirectory (gamemode_info[gamenum].dir[i], va("%s%s", com_homedir, gamemode_info[gamenum].dir[i]), ~0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i = COM_CheckParm ("-addbasegame");
|
|
|
|
while (i && i < com_argc-1) //use multiple -addbasegames (this is so the basic dirs don't die)
|
|
|
|
{
|
|
|
|
FS_AddGameDirectory (com_argv[i+1], va("%s%s", com_quakedir, com_argv[i+1]), ~0);
|
|
|
|
if (*com_homedir)
|
|
|
|
FS_AddGameDirectory (com_argv[i+1], va("%s%s", com_homedir, com_argv[i+1]), ~0);
|
|
|
|
|
|
|
|
i = COM_CheckNextParm ("-addbasegame", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// any set gamedirs will be freed up to here
|
|
|
|
com_base_searchpaths = com_searchpaths;
|
|
|
|
|
|
|
|
//-game specifies the mod gamedir to use in NQ
|
|
|
|
i = COM_CheckParm ("-game"); //effectivly replace with +gamedir x (But overridable)
|
|
|
|
if (i && i < com_argc-1)
|
|
|
|
{
|
|
|
|
COM_Gamedir(com_argv[i+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//+gamedir specifies the mod gamedir to use in QW
|
|
|
|
//hack - we parse the commandline after the config so commandline always overrides
|
|
|
|
//but this means ktpro/server.cfg (for example) is not found
|
|
|
|
//so if they specify a gamedir on the commandline, let the default configs be loaded from that gamedir
|
|
|
|
//note that -game +gamedir will result in both being loaded. but hey, who cares
|
|
|
|
i = COM_CheckParm ("+gamedir"); //effectivly replace with +gamedir x (But overridable)
|
|
|
|
if (i && i < com_argc-1)
|
|
|
|
{
|
|
|
|
COM_Gamedir(com_argv[i+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (gamemode_info[gamenum].customexec)
|
|
|
|
Cbuf_AddText(gamemode_info[gamenum].customexec, RESTRICT_LOCAL);
|
|
|
|
}
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
COM_InitFilesystem
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void COM_InitFilesystem (void)
|
|
|
|
{
|
|
|
|
FILE *f;
|
2010-11-02 23:17:25 +00:00
|
|
|
int i, j;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
char *ev;
|
2008-06-13 05:03:54 +00:00
|
|
|
qboolean usehome;
|
2010-12-05 02:46:07 +00:00
|
|
|
qboolean autobasedir = true;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
int gamenum=-1;
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
FS_RegisterDefaultFileSystems();
|
|
|
|
|
2005-10-31 00:52:03 +00:00
|
|
|
Cmd_AddCommand("fs_restart", FS_ReloadPackFiles_f);
|
2005-10-16 12:49:15 +00:00
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
//
|
|
|
|
// -basedir <path>
|
|
|
|
// Overrides the system supplied base directory (under id1)
|
|
|
|
//
|
|
|
|
i = COM_CheckParm ("-basedir");
|
|
|
|
if (i && i < com_argc-1)
|
2010-12-05 02:46:07 +00:00
|
|
|
{
|
2005-08-26 22:52:26 +00:00
|
|
|
strcpy (com_quakedir, com_argv[i+1]);
|
2010-12-05 02:46:07 +00:00
|
|
|
autobasedir = false;
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
else
|
|
|
|
strcpy (com_quakedir, host_parms.basedir);
|
|
|
|
|
2006-03-06 01:41:09 +00:00
|
|
|
if (*com_quakedir)
|
|
|
|
{
|
|
|
|
if (com_quakedir[strlen(com_quakedir)-1] == '\\')
|
|
|
|
com_quakedir[strlen(com_quakedir)-1] = '/';
|
|
|
|
else if (com_quakedir[strlen(com_quakedir)-1] != '/')
|
|
|
|
{
|
|
|
|
com_quakedir[strlen(com_quakedir)+1] = '\0';
|
|
|
|
com_quakedir[strlen(com_quakedir)] = '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
Cvar_Register(&com_gamename, "evil hacks");
|
2009-04-01 22:03:56 +00:00
|
|
|
Cvar_Register(&com_modname, "evil hacks");
|
2005-08-26 22:52:26 +00:00
|
|
|
//identify the game from a telling file
|
2010-11-02 23:17:25 +00:00
|
|
|
for (i = 0; gamemode_info[i].argname && gamenum==-1; i++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
for (j = 0; j < 4; j++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
if (!gamemode_info[i].auniquefile[j])
|
|
|
|
continue; //no more
|
|
|
|
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile[j]), "rb");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
gamenum = i;
|
|
|
|
break;
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
//use the game based on an exe name over the filesystem one (could easily have multiple fs path matches).
|
2009-04-12 16:57:30 +00:00
|
|
|
for (i = 0; gamemode_info[i].argname; i++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (strstr(com_argv[0], gamemode_info[i].exename))
|
|
|
|
gamenum = i;
|
|
|
|
}
|
|
|
|
//use the game based on an parameter over all else.
|
2009-04-12 16:57:30 +00:00
|
|
|
for (i = 0; gamemode_info[i].argname; i++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (COM_CheckParm(gamemode_info[i].argname))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2005-08-26 22:52:26 +00:00
|
|
|
gamenum = i;
|
2009-03-03 01:52:30 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
for (j = 0; j < 4; j++)
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
if (gamemode_info[gamenum].auniquefile[j])
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile[j]), "rb");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
//we found it, its all okay
|
|
|
|
fclose(f);
|
|
|
|
break;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
#ifdef _WIN32
|
2010-11-02 23:17:25 +00:00
|
|
|
if (Sys_FindGameData(gamemode_info[i].poshname, gamemode_info[i].exename, com_quakedir, sizeof(com_quakedir)))
|
2009-03-03 01:52:30 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
if (com_quakedir[strlen(com_quakedir)-1] == '\\')
|
|
|
|
com_quakedir[strlen(com_quakedir)-1] = '/';
|
|
|
|
else if (com_quakedir[strlen(com_quakedir)-1] != '/')
|
|
|
|
{
|
|
|
|
com_quakedir[strlen(com_quakedir)+1] = '\0';
|
|
|
|
com_quakedir[strlen(com_quakedir)] = '/';
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
2010-11-02 23:17:25 +00:00
|
|
|
else
|
2009-03-03 01:52:30 +00:00
|
|
|
#endif
|
2010-11-02 23:17:25 +00:00
|
|
|
{
|
|
|
|
Con_Printf("Couldn't find the gamedata for this game mode!\n");
|
|
|
|
}
|
|
|
|
break;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
//still failed? find quake and use that one by default
|
2005-08-26 22:52:26 +00:00
|
|
|
if (gamenum<0)
|
|
|
|
{
|
2009-04-12 16:57:30 +00:00
|
|
|
for (i = 0; gamemode_info[i].argname; i++)
|
2005-08-26 22:52:26 +00:00
|
|
|
{
|
|
|
|
if (!strcmp(gamemode_info[i].argname, "-quake"))
|
2010-12-05 02:46:07 +00:00
|
|
|
{
|
2005-08-26 22:52:26 +00:00
|
|
|
gamenum = i;
|
2010-12-05 02:46:07 +00:00
|
|
|
|
|
|
|
if (autobasedir)
|
|
|
|
{
|
|
|
|
if (Sys_FindGameData(gamemode_info[i].poshname, gamemode_info[i].exename, com_quakedir, sizeof(com_quakedir)))
|
|
|
|
{
|
|
|
|
if (com_quakedir[strlen(com_quakedir)-1] == '\\')
|
|
|
|
com_quakedir[strlen(com_quakedir)-1] = '/';
|
|
|
|
else if (com_quakedir[strlen(com_quakedir)-1] != '/')
|
|
|
|
{
|
|
|
|
com_quakedir[strlen(com_quakedir)+1] = '\0';
|
|
|
|
com_quakedir[strlen(com_quakedir)] = '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
|
2008-06-13 05:03:54 +00:00
|
|
|
usehome = false;
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
{ //win32 sucks.
|
2008-06-13 05:03:54 +00:00
|
|
|
HMODULE shfolder = LoadLibrary("shfolder.dll");
|
|
|
|
DWORD winver = (DWORD)LOBYTE(LOWORD(GetVersion()));
|
|
|
|
|
|
|
|
if (shfolder)
|
|
|
|
{
|
|
|
|
HRESULT (WINAPI *dSHGetFolderPath) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);
|
|
|
|
dSHGetFolderPath = (void *)GetProcAddress(shfolder, "SHGetFolderPathA");
|
|
|
|
if (dSHGetFolderPath)
|
|
|
|
{
|
|
|
|
char folder[MAX_PATH];
|
|
|
|
// 0x5 == CSIDL_PERSONAL
|
|
|
|
if (dSHGetFolderPath(NULL, 0x5, NULL, 0, folder) == S_OK)
|
|
|
|
Q_snprintfz(com_homedir, sizeof(com_homedir), "%s/My Games/%s/", folder, FULLENGINENAME);
|
|
|
|
}
|
|
|
|
FreeLibrary(shfolder);
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
if (!*com_homedir)
|
|
|
|
{
|
|
|
|
ev = getenv("USERPROFILE");
|
|
|
|
if (ev)
|
|
|
|
Q_snprintfz(com_homedir, sizeof(com_homedir), "%s/My Documents/My Games/%s/", ev, FULLENGINENAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NPQTV
|
|
|
|
if (!*com_homedir)
|
2009-04-07 01:26:47 +00:00
|
|
|
Q_snprintfz(com_homedir, sizeof(com_homedir), "/%s/", FULLENGINENAME);
|
2009-04-01 22:03:56 +00:00
|
|
|
//as a browser plugin, always use their home directory
|
|
|
|
usehome = true;
|
|
|
|
#else
|
2010-08-16 02:03:02 +00:00
|
|
|
/*would it not be better to just check to see if we have write permission to the basedir?*/
|
2008-06-13 05:03:54 +00:00
|
|
|
if (winver >= 0x6) // Windows Vista and above
|
|
|
|
usehome = true; // always use home directory by default, as Vista+ mimics this behavior anyway
|
|
|
|
else if (winver >= 0x5) // Windows 2000/XP/2003
|
|
|
|
{
|
2009-04-07 01:26:47 +00:00
|
|
|
HMODULE advapi32;
|
2008-06-13 07:24:11 +00:00
|
|
|
advapi32 = LoadLibrary("advapi32.dll");
|
|
|
|
|
|
|
|
if (advapi32)
|
2009-06-03 09:09:35 +00:00
|
|
|
{
|
2008-06-13 07:24:11 +00:00
|
|
|
BOOL (WINAPI *dCheckTokenMembership) (HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember);
|
|
|
|
dCheckTokenMembership = (void *)GetProcAddress(advapi32, "CheckTokenMembership");
|
2008-06-13 05:03:54 +00:00
|
|
|
|
2008-06-13 07:24:11 +00:00
|
|
|
if (dCheckTokenMembership)
|
|
|
|
{
|
2009-06-03 09:09:35 +00:00
|
|
|
// on XP systems, only use a home directory by default if we're a limited user or if we're on a network
|
2008-06-13 07:24:11 +00:00
|
|
|
BOOL isadmin, isonnetwork;
|
|
|
|
SID_IDENTIFIER_AUTHORITY ntauth = SECURITY_NT_AUTHORITY;
|
|
|
|
PSID adminSID, networkSID;
|
|
|
|
|
|
|
|
isadmin = AllocateAndInitializeSid(&ntauth,
|
|
|
|
2,
|
|
|
|
SECURITY_BUILTIN_DOMAIN_RID,
|
|
|
|
DOMAIN_ALIAS_RID_ADMINS,
|
|
|
|
0, 0, 0, 0, 0, 0,
|
2009-06-03 09:09:35 +00:00
|
|
|
&adminSID);
|
2008-06-13 07:24:11 +00:00
|
|
|
|
|
|
|
// just checking the network rid should be close enough to matching domain logins
|
|
|
|
isonnetwork = AllocateAndInitializeSid(&ntauth,
|
|
|
|
1,
|
|
|
|
SECURITY_NETWORK_RID,
|
|
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
|
|
&networkSID);
|
|
|
|
|
|
|
|
if (isadmin && !dCheckTokenMembership(0, adminSID, &isadmin))
|
|
|
|
isadmin = 0;
|
|
|
|
|
|
|
|
if (isonnetwork && !dCheckTokenMembership(0, networkSID, &isonnetwork))
|
|
|
|
isonnetwork = 0;
|
|
|
|
|
|
|
|
usehome = isonnetwork || !isadmin;
|
|
|
|
|
|
|
|
FreeSid(networkSID);
|
|
|
|
FreeSid(adminSID);
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeLibrary(advapi32);
|
|
|
|
}
|
|
|
|
}
|
2009-04-01 22:03:56 +00:00
|
|
|
#endif
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
//yay for unix!.
|
|
|
|
ev = getenv("HOME");
|
2009-02-03 00:12:50 +00:00
|
|
|
if (ev && *ev)
|
2008-06-13 05:03:54 +00:00
|
|
|
{
|
2009-02-03 00:12:50 +00:00
|
|
|
if (ev[strlen(ev)-1] == '/')
|
|
|
|
Q_snprintfz(com_homedir, sizeof(com_homedir), "%s.fte/", ev);
|
|
|
|
else
|
|
|
|
Q_snprintfz(com_homedir, sizeof(com_homedir), "%s/.fte/", ev);
|
2008-06-13 05:03:54 +00:00
|
|
|
usehome = true; // always use home on unix unless told not to
|
|
|
|
}
|
2005-08-26 22:52:26 +00:00
|
|
|
else
|
|
|
|
*com_homedir = '\0';
|
|
|
|
#endif
|
|
|
|
|
2008-06-13 05:03:54 +00:00
|
|
|
if (!usehome && !COM_CheckParm("-usehome"))
|
2005-08-26 22:52:26 +00:00
|
|
|
*com_homedir = '\0';
|
|
|
|
|
2005-11-30 01:20:53 +00:00
|
|
|
if (COM_CheckParm("-nohome"))
|
|
|
|
*com_homedir = '\0';
|
|
|
|
|
2005-08-26 22:52:26 +00:00
|
|
|
if (*com_homedir)
|
2005-10-31 00:52:03 +00:00
|
|
|
Con_Printf("Using home directory \"%s\"\n", com_homedir);
|
2005-08-26 22:52:26 +00:00
|
|
|
|
|
|
|
|
2010-08-16 02:03:02 +00:00
|
|
|
FS_StartupWithGame(gamenum);
|
2005-08-26 22:52:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this is at the bottom of the file to ensure these globals are not used elsewhere
|
|
|
|
extern searchpathfuncs_t packfilefuncs;
|
|
|
|
extern searchpathfuncs_t zipfilefuncs;
|
|
|
|
extern searchpathfuncs_t doomwadfilefuncs;
|
|
|
|
void FS_RegisterDefaultFileSystems(void)
|
|
|
|
{
|
|
|
|
FS_RegisterFileSystemType("pak", &packfilefuncs);
|
2010-07-11 10:53:13 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
/*for systems that have case sensitive paths, also include *.PAK */
|
|
|
|
FS_RegisterFileSystemType("PAK", &packfilefuncs);
|
|
|
|
#endif
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
|
|
|
FS_RegisterFileSystemType("pk3", &zipfilefuncs);
|
|
|
|
FS_RegisterFileSystemType("pk4", &zipfilefuncs);
|
|
|
|
#endif
|
|
|
|
#ifdef DOOMWADS
|
|
|
|
FS_RegisterFileSystemType("wad", &doomwadfilefuncs);
|
|
|
|
#endif
|
2009-04-02 22:25:54 +00:00
|
|
|
}
|