Separate file search from loading.

QFS_LoadFile (and its wrappers) now  take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
This commit is contained in:
Bill Currie 2014-01-23 11:57:57 +09:00
parent 328b997843
commit 3efb0c538f
47 changed files with 108 additions and 112 deletions

View file

@ -216,17 +216,12 @@ void QFS_WriteFile (const char *filename, const void *data, int len);
substitution.
\param filename The name of the file to open.
\param gzfile Address of file handle pointer.
\param zip If true and the file has been compressed with gzip, the
file will be opened such that it decompresses on the fly.
Otherwise, the file will be read as-is.
\return The amount of bytes that can be read from the file handle.
This will be either the files true size if \a zip is true,
or the compressed size of \a zip is false. If an error
occurs while opening the file, this will be -1 and
\a *gzfile will be set to NULL.
\return The file handle or NULL if there is an error.
*/
int _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip);
QFile *_QFS_FOpenFile (const char *filename, int zip);
/** Open a file for reading.
@ -235,31 +230,28 @@ int _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip);
_QFS_FOpenFile() for more details.
\param filename The name of the file to open.
\param gzfile Address of file handle pointer.
\return The amount of bytes that can be read from the file handle.
If an error occurs while opening the file, this will be
-1 and \a *gzfile will be set to NULL.
\return The file handle pointer, or NULL if there is an error.
*/
int QFS_FOpenFile (const char *filename, QFile **gzfile);
QFile *QFS_FOpenFile (const char *filename);
/** Load a file into memory.
This is a convenience wrapper for QFS_FOpenFile(). The file will be loaded
in memory allocated from the location inicated by usehunk.
The file will be loaded into memory allocated from the location indicated
by \a usehunk.
\param path The name of the file to load.
\param file The handle of the file to load.
\param usehunk The location from which to allocate memory for the file's
data. Use 0.
\return Pointer to the file's data, or NULL on error.
\todo remove \a usehunk
*/
byte *QFS_LoadFile (const char *path, int usehunk);
byte *QFS_LoadFile (QFile *file, int usehunk);
/** Load a file into memeory.
The file is loaded into memory allocated from the hunk.
*/
byte *QFS_LoadHunkFile (const char *path);
byte *QFS_LoadHunkFile (QFile *file);
/** Load a file into memeory.
@ -267,7 +259,7 @@ byte *QFS_LoadHunkFile (const char *path);
\deprecated This should go away soon.
*/
void QFS_LoadCacheFile (const char *path, struct cache_user_s *cu);
void QFS_LoadCacheFile (QFile *file, struct cache_user_s *cu);
/** Rename a file.

View file

@ -143,7 +143,7 @@ Load_Tracklist (void)
{
QFile *oggfile = NULL;
char *buffile = NULL;
int size = -1;
int size;
/* kill off the old tracklist, and make sure we're not playing anything */
I_OGGMus_Shutdown ();
@ -155,8 +155,8 @@ Load_Tracklist (void)
return -1; // bail if we don't have a valid filename
}
size = QFS_FOpenFile (mus_ogglist->string, &oggfile);
if (size < 0) {
oggfile = QFS_FOpenFile (mus_ogglist->string);
if (!oggfile) {
Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n",
mus_ogglist->string);
return -1;

View file

@ -315,7 +315,7 @@ flac_callback_load (void *object, cache_allocator_t allocator)
sfxblock_t *block = (sfxblock_t *) object;
QFS_FOpenFile (block->file, &file);
file = QFS_FOpenFile (block->file);
if (!file)
return; //FIXME Sys_Error?
@ -374,7 +374,7 @@ flac_stream_open (sfx_t *sfx)
QFile *file;
void *f;
QFS_FOpenFile (stream->file, &file);
file = QFS_FOpenFile (stream->file);
if (!file)
return 0;

View file

@ -148,7 +148,7 @@ midi_stream_open (sfx_t *sfx)
unsigned long int local_buffer_size;
midi_file_t *mf;
QFS_FOpenFile (stream->file, &file);
file = QFS_FOpenFile (stream->file);
local_buffer_size = Qfilesize (file);

View file

@ -302,7 +302,7 @@ SND_Load (sfx_t *sfx)
sfx->close = snd_noop;
sfx->open = snd_open_fail;
QFS_FOpenFile (sfx->name, &file);
file = QFS_FOpenFile (sfx->name);
if (!file) {
Sys_Printf ("Couldn't load %s\n", sfx->name);
return -1;

View file

@ -196,7 +196,7 @@ vorbis_callback_load (void *object, cache_allocator_t allocator)
sfxblock_t *block = (sfxblock_t *) object;
QFS_FOpenFile (block->file, &file);
file = QFS_FOpenFile (block->file);
if (!file)
return; //FIXME Sys_Error?
@ -260,7 +260,7 @@ vorbis_stream_open (sfx_t *sfx)
QFile *file;
vorbis_file_t *f;
QFS_FOpenFile (stream->file, &file);
file = QFS_FOpenFile (stream->file);
if (!file)
return 0;

View file

@ -67,7 +67,7 @@ wav_callback_load (void *object, cache_allocator_t allocator)
sfxbuffer_t *buffer;
wavinfo_t *info = &block->wavinfo;
QFS_FOpenFile (name, &file);
file = QFS_FOpenFile (name);
if (!file)
return; //FIXME Sys_Error?
@ -152,7 +152,7 @@ wav_stream_open (sfx_t *sfx)
QFile *file;
wav_file_t *wf;
QFS_FOpenFile (stream->file, &file);
file = QFS_FOpenFile (stream->file);
if (!file)
return 0;

View file

@ -512,7 +512,7 @@ menu_free_progs_mem (progs_t *pr, void *mem)
static void *
menu_load_file (progs_t *pr, const char *path)
{
return QFS_LoadFile (path, 0);
return QFS_LoadFile (QFS_FOpenFile (path), 0);
}
static builtin_t builtins[] = {
@ -615,7 +615,8 @@ Menu_Load (void)
top_menu = 0;
menu_pr_state.progs = 0;
if ((size = QFS_FOpenFile (menu_pr_state.progs_name, &file)) != -1) {
if ((file = QFS_FOpenFile (menu_pr_state.progs_name))) {
size = Qfilesize (file);
PR_LoadProgsFile (&menu_pr_state, file, size, 0, 1024 * 1024);
Qclose (file);

View file

@ -83,7 +83,7 @@ file_error (progs_t *pr, const char *path)
static void *
load_file (progs_t *pr, const char *path)
{
return QFS_LoadHunkFile (path);
return QFS_LoadHunkFile (QFS_FOpenFile (path));
}
static void *
@ -382,7 +382,7 @@ VISIBLE void
PR_LoadProgs (progs_t *pr, const char *progsname, int max_edicts, int zone)
{
QFile *file;
QFS_FOpenFile (progsname, &file);
file = QFS_FOpenFile (progsname);
pr->progs_name = progsname;
if (file) {

View file

@ -792,7 +792,7 @@ GIB_File_Read_f (void)
if (!(ret = GIB_Return (0)))
return;
path = GIB_Argv (1);
QFS_FOpenFile (path, &file);
file = QFS_FOpenFile (path);
if (file) {
len = Qfilesize (file);
ret->size = len + 1;

View file

@ -70,7 +70,7 @@ GIB_Exec_Override_f (void)
}
mark = Hunk_LowMark ();
f = (char *) QFS_LoadHunkFile (Cmd_Argv (1));
f = (char *) QFS_LoadHunkFile (QFS_FOpenFile (Cmd_Argv (1)));
if (!f) {
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
return;

View file

@ -62,7 +62,7 @@ LoadImage (const char *imageFile)
// Check for a .png
dstring_replace (tmpFile, tmp, tmpFile->size, ".png", 5);
QFS_FOpenFile (tmpFile->str, &fp);
fp = QFS_FOpenFile (tmpFile->str);
if (fp) {
tex = LoadPNG (fp);
Qclose (fp);
@ -72,7 +72,7 @@ LoadImage (const char *imageFile)
// Check for a .tga
dstring_replace (tmpFile, tmp, tmpFile->size, ".tga", 5);
QFS_FOpenFile (tmpFile->str, &fp);
fp = QFS_FOpenFile (tmpFile->str);
if (fp) {
tex = LoadTGA (fp);
Qclose (fp);
@ -83,7 +83,7 @@ LoadImage (const char *imageFile)
/*
// Check for a .jpg
dstring_replace (tmpFile, tmp, tmpFile->size, ".jpg", 5);
QFS_FOpenFile (tmpFile->str, &fp);
fp = QFS_FOpenFile (tmpFile->str);
if (fp) {
tex = LoadJPG (fp);
Qclose (fp);
@ -94,7 +94,7 @@ LoadImage (const char *imageFile)
// Check for a .pcx
dstring_replace (tmpFile, tmp, tmpFile->size, ".pcx", 5);
QFS_FOpenFile (tmpFile->str, &fp);
fp = QFS_FOpenFile (tmpFile->str);
if (fp) {
tex = LoadPCX (fp, 1, NULL); // Convert, some users don't grok paletted
Qclose (fp);

View file

@ -366,7 +366,7 @@ gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
cache->str + strlen ("glquake/"));
dstring_appendstr (cache, ".qfms");
QFS_FOpenFile (cache->str, &f);
f = QFS_FOpenFile (cache->str);
if (f) {
unsigned char d1[MDFOUR_DIGEST_BYTES];
unsigned char d2[MDFOUR_DIGEST_BYTES];

View file

@ -148,7 +148,7 @@ gl_Mod_LoadLighting (bsp_t *bsp)
// LordHavoc: check for a .lit file to load
QFS_StripExtension (litfilename->str, litfilename->str);
dstring_appendstr (litfilename, ".lit");
data = (byte *) QFS_LoadHunkFile (litfilename->str);
data = (byte *) QFS_LoadHunkFile (QFS_FOpenFile (litfilename->str));
if (data) {
if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I'
&& data[3] == 'T') {

View file

@ -171,7 +171,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
uint32_t *buf;
// load the file
buf = (uint32_t *) QFS_LoadFile (mod->name, 0);
buf = (uint32_t *) QFS_LoadFile (QFS_FOpenFile (mod->name), 0);
if (!buf) {
if (crash)
Sys_Error ("Mod_LoadModel: %s not found", mod->name);

View file

@ -177,7 +177,7 @@ Skin_SetSkin (skin_t *skin, int cmap, const char *skinname)
break;
}
QFS_FOpenFile (va ("skins/%s.pcx", name), &file);
file = QFS_FOpenFile (va ("skins/%s.pcx", name));
if (!file) {
Sys_Printf ("Couldn't load skin %s\n", name);
free (name);

View file

@ -106,7 +106,7 @@ bi_QFS_LoadFile (progs_t *pr)
int size;
void *buffer;
QFS_FOpenFile (filename, &file);
file = QFS_FOpenFile (filename);
if (!file) {
RETURN_POINTER (pr, 0);
return;
@ -129,7 +129,7 @@ bi_QFS_OpenFile (progs_t *pr)
QFile *file;
const char *filename = P_GSTRING (pr, 0);
QFS_FOpenFile (filename, &file);
file = QFS_FOpenFile (filename);
if (!file) {
R_INT (pr) = 0;
return;

View file

@ -490,7 +490,7 @@ Cmd_Exec_f (void)
}
mark = Hunk_LowMark ();
f = (char *) QFS_LoadHunkFile (Cmd_Argv (1));
f = (char *) QFS_LoadHunkFile (QFS_FOpenFile (Cmd_Argv (1)));
if (!f) {
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
return;
@ -638,7 +638,7 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
if (!path || !*path)
return;
if (qfs) {
QFS_FOpenFile (path, &file);
file = QFS_FOpenFile (path);
} else {
char *newpath = Sys_ExpandSquiggle (path);
file = Qopen (newpath, "r");

View file

@ -1032,9 +1032,10 @@ open_file (int_findfile_t *found, QFile **gzfile, int zip)
}
}
VISIBLE int
_QFS_FOpenFile (const char *filename, QFile **gzfile, int zip)
VISIBLE QFile *
_QFS_FOpenFile (const char *filename, int zip)
{
QFile *gzfile;
int_findfile_t *found;
char *path;
const char *fnames[4];
@ -1083,26 +1084,25 @@ _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip)
found = qfs_findfile (fnames, 0, 0);
if (found) {
open_file (found, gzfile, zip_flags[found->fname_index]);
open_file (found, &gzfile, zip_flags[found->fname_index]);
free(path);
return qfs_filesize;
return gzfile;
}
Sys_MaskPrintf (SYS_FS_NF, "FindFile: can't find %s\n", filename);
error:
*gzfile = NULL;
qfs_filesize = -1;
free (path);
return -1;
return 0;
}
VISIBLE int
QFS_FOpenFile (const char *filename, QFile **gzfile)
VISIBLE QFile *
QFS_FOpenFile (const char *filename)
{
return _QFS_FOpenFile (filename, gzfile, 1);
return _QFS_FOpenFile (filename, 1);
}
cache_user_t *loadcache;
static cache_user_t *loadcache;
/*
QFS_LoadFile
@ -1111,20 +1111,22 @@ cache_user_t *loadcache;
Always appends a 0 byte to the loaded data.
*/
VISIBLE byte *
QFS_LoadFile (const char *path, int usehunk)
QFS_LoadFile (QFile *file, int usehunk)
{
QFile *h;
byte *buf = NULL;
char *base;
int len;
// look for it in the filesystem or pack files
len = qfs_filesize = QFS_FOpenFile (path, &h);
if (!h)
if (!file)
return NULL;
base = strdup ("QFS_LoadFile");
len = qfs_filesize = Qfilesize (file);
// extract the filename base name for hunk tag
base = QFS_FileBase (path);
//base = QFS_FileBase (path);
if (usehunk == 1)
buf = Hunk_AllocName (len + 1, base);
@ -1138,11 +1140,12 @@ QFS_LoadFile (const char *path, int usehunk)
Sys_Error ("QFS_LoadFile: bad usehunk");
if (!buf)
Sys_Error ("QFS_LoadFile: not enough space for %s", path);
Sys_Error ("QFS_LoadFile: not enough space");
//Sys_Error ("QFS_LoadFile: not enough space for %s", path);
buf[len] = 0;
Qread (h, buf, len);
Qclose (h);
Qread (file, buf, len);
Qclose (file);
free (base);
@ -1150,16 +1153,16 @@ QFS_LoadFile (const char *path, int usehunk)
}
VISIBLE byte *
QFS_LoadHunkFile (const char *path)
QFS_LoadHunkFile (QFile *file)
{
return QFS_LoadFile (path, 1);
return QFS_LoadFile (file, 1);
}
VISIBLE void
QFS_LoadCacheFile (const char *path, struct cache_user_s *cu)
QFS_LoadCacheFile (QFile *file, struct cache_user_s *cu)
{
loadcache = cu;
QFS_LoadFile (path, 3);
QFS_LoadFile (file, 3);
}
/*

View file

@ -81,7 +81,7 @@ W_LoadWadFile (const char *filename)
int i;
int infotableofs;
wad_base = QFS_LoadHunkFile (filename);
wad_base = QFS_LoadHunkFile (QFS_FOpenFile (filename));
if (!wad_base)
Sys_Error ("W_LoadWadFile: unable to load %s", filename);

View file

@ -229,7 +229,7 @@ gl_Draw_CachePic (const char *path, qboolean alpha)
if (!strcmp (path + strlen (path) - 4, ".lmp")) {
// Load the picture..
qpic_t *dat = (qpic_t *) QFS_LoadFile (path, 0);
qpic_t *dat = (qpic_t *) QFS_LoadFile (QFS_FOpenFile (path), 0);
if (!dat)
Sys_Error ("Draw_CachePic: failed to load %s", path);

View file

@ -213,7 +213,7 @@ gl_R_ReadPointFile_f (void)
name = va ("%s.pts", mapname);
free (mapname);
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;

View file

@ -744,7 +744,7 @@ GL_SetPalette (const byte *palette)
return;
palflag = true;
QFS_FOpenFile ("glquake/15to8.pal", &f);
f = QFS_FOpenFile ("glquake/15to8.pal");
if (f) {
Qread (f, gl_15to8table, 1 << 15);
Qclose (f);

View file

@ -283,7 +283,7 @@ glsl_Draw_CachePic (const char *path, qboolean alpha)
if ((cpic = Hash_Find (pic_cache, path)))
return cpic->pic;
if (strlen (path) < 4 || strcmp (path + strlen (path) - 4, ".lmp")
|| !(p = (qpic_t *) QFS_LoadFile (path, 0))) {
|| !(p = (qpic_t *) QFS_LoadFile (QFS_FOpenFile (path), 0))) {
//FIXME load a null texture
Sys_Error ("Draw_CachePic: failed to load %s", path);
}
@ -407,7 +407,7 @@ glsl_Draw_Init (void)
conchars = pic_data ("conchars", 128, 128, draw_chars);
pic = (qpic_t *) QFS_LoadFile ("gfx/conback.lmp", 0);
pic = (qpic_t *) QFS_LoadFile (QFS_FOpenFile ("gfx/conback.lmp"), 0);
if (pic) {
SwapPic (pic);
conback_texture = GLSL_LoadQuakeTexture ("conback",

View file

@ -321,7 +321,7 @@ glsl_R_ReadPointFile_f (void)
name = va ("%s.pts", mapname);
free (mapname);
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;

View file

@ -148,7 +148,7 @@ Draw_CachePic (const char *path, qboolean alpha)
return dat;
// load the pic from disk
QFS_LoadCacheFile (path, &pic->cache);
QFS_LoadCacheFile (QFS_FOpenFile (path), &pic->cache);
dat = (qpic_t *) pic->cache.data;
if (!dat) {

View file

@ -91,7 +91,7 @@ R_ReadPointFile_f (void)
name = va ("maps/%s.pts", mapname);
free (mapname);
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;

View file

@ -151,7 +151,7 @@ sw32_Draw_CachePic (const char *path, qboolean alpha)
return dat;
// load the pic from disk
QFS_LoadCacheFile (path, &pic->cache);
QFS_LoadCacheFile (QFS_FOpenFile (path), &pic->cache);
dat = (qpic_t *) pic->cache.data;
if (!dat) {

View file

@ -96,7 +96,7 @@ sw32_R_ReadPointFile_f (void)
name = va ("maps/%s.pts", mapname);
free (mapname);
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (!f) {
Sys_Printf ("couldn't open %s\n", name);
return;

View file

@ -454,7 +454,7 @@ CL_StartDemo (void)
QFS_DefaultExtension (name, ".dem");
Sys_Printf ("Playing demo from %s.\n", name->str);
QFS_FOpenFile (name->str, &cls.demofile);
cls.demofile = QFS_FOpenFile (name->str);
if (!cls.demofile) {
Sys_Printf ("ERROR: couldn't open.\n");
cls.demonum = -1; // stop demo loop

View file

@ -529,10 +529,10 @@ CL_Init (cbuf_t *cbuf)
{
byte *basepal, *colormap;
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");

View file

@ -268,7 +268,7 @@ map_cfg (const char *mapname, int all)
QFS_StripExtension (mapname, name);
strcat (name, ".cfg");
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (f) {
Qclose (f);
Cmd_Exec_File (cbuf, name, 1);
@ -294,7 +294,7 @@ map_ent (const char *mapname)
QFS_StripExtension (mapname, name);
strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (name, 0))) {
if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
edicts = ED_Parse (&edpr, buf);
free (buf);
} else {

View file

@ -57,7 +57,7 @@ Game_CheckRegistered (void)
{
QFile *h;
QFS_FOpenFile ("gfx/pop.lmp", &h);
h = QFS_FOpenFile ("gfx/pop.lmp");
static_registered = 0;
if (h) {

View file

@ -817,7 +817,7 @@ check_quakerc (void)
int ret = 1;
QFile *f;
QFS_FOpenFile ("quake.rc", &f);
f = QFS_FOpenFile ("quake.rc");
if (!f)
return 1;
while ((l = Qgetline (f))) {

View file

@ -279,7 +279,7 @@ Host_Map_f (void)
// check to make sure the level exists
expanded = va ("maps/%s.bsp", Cmd_Argv (1));
QFS_FOpenFile (expanded, &f);
f = QFS_FOpenFile (expanded);
if (!f) {
Sys_Printf ("Can't find %s\n", expanded);
return;

View file

@ -1101,7 +1101,7 @@ SV_SaveSpawnparms (void)
void
SV_SpawnServer (const char *server)
{
char *buf;
byte *buf;
int i;
edict_t *ent;
@ -1211,8 +1211,8 @@ SV_SpawnServer (const char *server)
*sv_globals.serverflags = svs.serverflags;
*sv_globals.time = sv.time;
if ((buf = (char *) QFS_LoadFile (va ("maps/%s.ent", server), 0))) {
ED_LoadFromFile (&sv_pr_state, buf);
if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf);
} else {
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);

View file

@ -993,11 +993,11 @@ CL_StartDemo (void)
name = dstring_strdup (demoname);
QFS_DefaultExtension (name, ".mvd");
QFS_FOpenFile (name->str, &cls.demofile);
cls.demofile = QFS_FOpenFile (name->str);
if (!cls.demofile) {
dstring_copystr (name, demoname);
QFS_DefaultExtension (name, ".qwd");
QFS_FOpenFile (name->str, &cls.demofile);
cls.demofile = QFS_FOpenFile (name->str);
}
if (!cls.demofile) {

View file

@ -1169,10 +1169,10 @@ CL_Init (void)
{
byte *basepal, *colormap;
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");
@ -1716,7 +1716,7 @@ check_quakerc (void)
int ret = 1;
QFile *f;
QFS_FOpenFile ("quake.rc", &f);
f = QFS_FOpenFile ("quake.rc");
if (!f)
return 1;
while ((l = Qgetline (f))) {

View file

@ -237,7 +237,7 @@ CL_CheckOrDownloadFile (const char *filename)
return true;
}
*/
QFS_FOpenFile (filename, &f);
f = QFS_FOpenFile (filename);
if (f) { // it exists, no need to download
Qclose (f);
return true;
@ -280,7 +280,7 @@ map_ent (const char *mapname)
QFS_StripExtension (mapname, name);
strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (name, 0))) {
if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
edicts = ED_Parse (&edpr, buf);
free (buf);
} else {

View file

@ -62,7 +62,7 @@ Game_CheckRegistered (void)
{
QFile *h;
QFS_FOpenFile ("gfx/pop.lmp", &h);
h = QFS_FOpenFile ("gfx/pop.lmp");
static_registered = 0;
if (h) {

View file

@ -136,7 +136,7 @@ locs_load (const char *filename)
QFile *file;
tmp = va ("maps/%s", filename);
QFS_FOpenFile (tmp, &file);
file = QFS_FOpenFile (tmp);
if (!file) {
Sys_Printf ("Couldn't load %s\n", tmp);
return;

View file

@ -55,7 +55,7 @@ map_cfg (const char *mapname, int all)
QFS_StripExtension (mapname, name);
strcat (name, ".cfg");
QFS_FOpenFile (name, &f);
f = QFS_FOpenFile (name);
if (f) {
Qclose (f);
Cmd_Exec_File (cbuf, name, 1);

View file

@ -453,7 +453,7 @@ SV_Map_f (void)
// check to make sure the level exists
expanded = nva ("maps/%s.bsp", level);
QFS_FOpenFile (expanded, &f);
f = QFS_FOpenFile (expanded);
if (!f) {
SV_Printf ("Can't find %s\n", expanded);
free (expanded);

View file

@ -290,7 +290,7 @@ SV_CheckModel (const char *mdl)
// int len;
buf = (byte *) QFS_LoadFile (mdl, 0);
buf = (byte *) QFS_LoadFile (QFS_FOpenFile (mdl), 0);
if (buf) {
crc = CRC_Block (buf, qfs_filesize);
free (buf);
@ -312,7 +312,7 @@ SV_CheckModel (const char *mdl)
void
SV_SpawnServer (const char *server)
{
char *buf;
byte *buf;
edict_t *ent;
int i;
void *so_buffers;
@ -433,8 +433,8 @@ SV_SpawnServer (const char *server)
// load and spawn all other entities
*sv_globals.time = sv.time;
if ((buf = (char *) QFS_LoadFile (va ("maps/%s.ent", server), 0))) {
ED_LoadFromFile (&sv_pr_state, buf);
if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf);
} else {
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);

View file

@ -390,7 +390,7 @@ PF_validatefile (progs_t *pr)
st = P_GSTRING (pr, 0);
QFS_FOpenFile (st, &f);
f = QFS_FOpenFile (st);
if (!f) {
retval = 0.0;
} else {

View file

@ -717,7 +717,7 @@ static void
SV_BeginDownload_f (void *unused)
{
const char *name;
int http, size, zip;
int http, zip;
QFile *file;
name = Cmd_Argv (1);
@ -753,10 +753,10 @@ SV_BeginDownload_f (void *unused)
http = sv_http_url_base->string[0]
&& strchr (Info_ValueForKey (host_client->userinfo, "*cap"), 'h');
size = _QFS_FOpenFile (name, &file, !zip);
file = _QFS_FOpenFile (name, !zip);
host_client->download = file;
host_client->downloadsize = size;
host_client->downloadsize = Qfilesize (file);
host_client->downloadcount = 0;
if (!host_client->download

View file

@ -167,10 +167,10 @@ BI_Init (progs_t *pr)
Mod_Init_Cvars ();
S_Init_Cvars ();
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");