From 3efb0c538fffe77c56a87e3bb15254d450f3e6b3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 23 Jan 2014 11:57:57 +0900 Subject: [PATCH] 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. --- include/QF/quakefs.h | 28 +++++--------- libs/audio/cd_file.c | 6 +-- libs/audio/renderer/flac.c | 4 +- libs/audio/renderer/midi.c | 2 +- libs/audio/renderer/snd_mem.c | 2 +- libs/audio/renderer/vorbis.c | 4 +- libs/audio/renderer/wav.c | 4 +- libs/console/menu.c | 5 ++- libs/gamecode/pr_load.c | 4 +- libs/gib/gib_builtin.c | 2 +- libs/gib/gib_init.c | 2 +- libs/image/image.c | 8 ++-- libs/models/alias/gl_mesh.c | 2 +- libs/models/brush/gl_model_brush.c | 2 +- libs/models/model.c | 2 +- libs/models/skin.c | 2 +- libs/ruamoko/rua_qfs.c | 4 +- libs/util/cmd.c | 4 +- libs/util/quakefs.c | 47 ++++++++++++----------- libs/util/wad.c | 2 +- libs/video/renderer/gl/gl_draw.c | 2 +- libs/video/renderer/gl/gl_dyn_part.c | 2 +- libs/video/renderer/gl/vid_common_gl.c | 2 +- libs/video/renderer/glsl/glsl_draw.c | 4 +- libs/video/renderer/glsl/glsl_particles.c | 2 +- libs/video/renderer/sw/draw.c | 2 +- libs/video/renderer/sw/sw_rpart.c | 2 +- libs/video/renderer/sw32/draw.c | 2 +- libs/video/renderer/sw32/sw32_rpart.c | 2 +- nq/source/cl_demo.c | 2 +- nq/source/cl_main.c | 4 +- nq/source/cl_parse.c | 4 +- nq/source/game.c | 2 +- nq/source/host.c | 2 +- nq/source/host_cmd.c | 2 +- nq/source/sv_main.c | 6 +-- qw/source/cl_demo.c | 4 +- qw/source/cl_main.c | 6 +-- qw/source/cl_parse.c | 4 +- qw/source/game.c | 2 +- qw/source/locs.c | 2 +- qw/source/map_cfg.c | 2 +- qw/source/sv_ccmds.c | 2 +- qw/source/sv_init.c | 8 ++-- qw/source/sv_pr_cpqw.c | 2 +- qw/source/sv_user.c | 6 +-- tools/qwaq/qwaq-bi.c | 4 +- 47 files changed, 108 insertions(+), 112 deletions(-) diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 0a2c63a89..675be7731 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -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. diff --git a/libs/audio/cd_file.c b/libs/audio/cd_file.c index cd5a77094..ce0f2b94f 100644 --- a/libs/audio/cd_file.c +++ b/libs/audio/cd_file.c @@ -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; diff --git a/libs/audio/renderer/flac.c b/libs/audio/renderer/flac.c index 665c68b3e..be7962522 100644 --- a/libs/audio/renderer/flac.c +++ b/libs/audio/renderer/flac.c @@ -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; diff --git a/libs/audio/renderer/midi.c b/libs/audio/renderer/midi.c index 4a32b9f98..86898da65 100644 --- a/libs/audio/renderer/midi.c +++ b/libs/audio/renderer/midi.c @@ -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); diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index 13c460cf7..154618899 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -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; diff --git a/libs/audio/renderer/vorbis.c b/libs/audio/renderer/vorbis.c index d323bdee4..fd14ec965 100644 --- a/libs/audio/renderer/vorbis.c +++ b/libs/audio/renderer/vorbis.c @@ -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; diff --git a/libs/audio/renderer/wav.c b/libs/audio/renderer/wav.c index 756b4566e..b3d59697a 100644 --- a/libs/audio/renderer/wav.c +++ b/libs/audio/renderer/wav.c @@ -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; diff --git a/libs/console/menu.c b/libs/console/menu.c index c055986d6..48df52b7d 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -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); diff --git a/libs/gamecode/pr_load.c b/libs/gamecode/pr_load.c index b32cf71c3..b9a6df13a 100644 --- a/libs/gamecode/pr_load.c +++ b/libs/gamecode/pr_load.c @@ -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) { diff --git a/libs/gib/gib_builtin.c b/libs/gib/gib_builtin.c index 15352e534..c3ba2910a 100644 --- a/libs/gib/gib_builtin.c +++ b/libs/gib/gib_builtin.c @@ -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; diff --git a/libs/gib/gib_init.c b/libs/gib/gib_init.c index 1b74e5f61..b689e141e 100644 --- a/libs/gib/gib_init.c +++ b/libs/gib/gib_init.c @@ -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; diff --git a/libs/image/image.c b/libs/image/image.c index 53f4166a7..7df5d9bb2 100644 --- a/libs/image/image.c +++ b/libs/image/image.c @@ -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); diff --git a/libs/models/alias/gl_mesh.c b/libs/models/alias/gl_mesh.c index 9ddca7d59..22498ddea 100644 --- a/libs/models/alias/gl_mesh.c +++ b/libs/models/alias/gl_mesh.c @@ -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]; diff --git a/libs/models/brush/gl_model_brush.c b/libs/models/brush/gl_model_brush.c index 687e0a141..c15a4308e 100644 --- a/libs/models/brush/gl_model_brush.c +++ b/libs/models/brush/gl_model_brush.c @@ -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') { diff --git a/libs/models/model.c b/libs/models/model.c index cd27be931..bac0223de 100644 --- a/libs/models/model.c +++ b/libs/models/model.c @@ -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); diff --git a/libs/models/skin.c b/libs/models/skin.c index a96317d8d..14c21cd81 100644 --- a/libs/models/skin.c +++ b/libs/models/skin.c @@ -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); diff --git a/libs/ruamoko/rua_qfs.c b/libs/ruamoko/rua_qfs.c index 3a3391d4e..35d69d0c8 100644 --- a/libs/ruamoko/rua_qfs.c +++ b/libs/ruamoko/rua_qfs.c @@ -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; diff --git a/libs/util/cmd.c b/libs/util/cmd.c index f4cdc79d0..dcdbe6855 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -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"); diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index f48797a67..4e4026d68 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -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); } /* diff --git a/libs/util/wad.c b/libs/util/wad.c index f08e628f5..3b4355bbb 100644 --- a/libs/util/wad.c +++ b/libs/util/wad.c @@ -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); diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 9685e7bab..f988ddf66 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -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); diff --git a/libs/video/renderer/gl/gl_dyn_part.c b/libs/video/renderer/gl/gl_dyn_part.c index d3f50f015..5b7f1a63a 100644 --- a/libs/video/renderer/gl/gl_dyn_part.c +++ b/libs/video/renderer/gl/gl_dyn_part.c @@ -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; diff --git a/libs/video/renderer/gl/vid_common_gl.c b/libs/video/renderer/gl/vid_common_gl.c index 08ca45946..ec21df3e5 100644 --- a/libs/video/renderer/gl/vid_common_gl.c +++ b/libs/video/renderer/gl/vid_common_gl.c @@ -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); diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 528dc60da..6a8ef0268 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -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", diff --git a/libs/video/renderer/glsl/glsl_particles.c b/libs/video/renderer/glsl/glsl_particles.c index dba65db08..c4e214c50 100644 --- a/libs/video/renderer/glsl/glsl_particles.c +++ b/libs/video/renderer/glsl/glsl_particles.c @@ -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; diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 08110401a..e3728af66 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -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) { diff --git a/libs/video/renderer/sw/sw_rpart.c b/libs/video/renderer/sw/sw_rpart.c index de59f0ba1..aeb2fa904 100644 --- a/libs/video/renderer/sw/sw_rpart.c +++ b/libs/video/renderer/sw/sw_rpart.c @@ -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; diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index e07e616ad..a420c8ac0 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -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) { diff --git a/libs/video/renderer/sw32/sw32_rpart.c b/libs/video/renderer/sw32/sw32_rpart.c index 3affa45b1..5591b9929 100644 --- a/libs/video/renderer/sw32/sw32_rpart.c +++ b/libs/video/renderer/sw32/sw32_rpart.c @@ -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; diff --git a/nq/source/cl_demo.c b/nq/source/cl_demo.c index b98d3a078..026c59fbb 100644 --- a/nq/source/cl_demo.c +++ b/nq/source/cl_demo.c @@ -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 diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 052b45189..7f6dd9e82 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -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"); diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 2b9597e8a..3294cdf40 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -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 { diff --git a/nq/source/game.c b/nq/source/game.c index 703d13ddc..f67104472 100644 --- a/nq/source/game.c +++ b/nq/source/game.c @@ -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) { diff --git a/nq/source/host.c b/nq/source/host.c index f25562e2c..f6b59cf8b 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -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))) { diff --git a/nq/source/host_cmd.c b/nq/source/host_cmd.c index 4a819d66c..1a827f15b 100644 --- a/nq/source/host_cmd.c +++ b/nq/source/host_cmd.c @@ -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; diff --git a/nq/source/sv_main.c b/nq/source/sv_main.c index d06ec4543..831e946e4 100644 --- a/nq/source/sv_main.c +++ b/nq/source/sv_main.c @@ -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); diff --git a/qw/source/cl_demo.c b/qw/source/cl_demo.c index 5202aa6f7..31ce11620 100644 --- a/qw/source/cl_demo.c +++ b/qw/source/cl_demo.c @@ -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) { diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index dd73f987a..09fb1aec2 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -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))) { diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index c6c77ab17..f8d2cba70 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -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 { diff --git a/qw/source/game.c b/qw/source/game.c index 9c2b66dbd..ac69d83ea 100644 --- a/qw/source/game.c +++ b/qw/source/game.c @@ -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) { diff --git a/qw/source/locs.c b/qw/source/locs.c index 725341fdc..2f94da0f8 100644 --- a/qw/source/locs.c +++ b/qw/source/locs.c @@ -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; diff --git a/qw/source/map_cfg.c b/qw/source/map_cfg.c index 04ab404ea..10b4a5cd5 100644 --- a/qw/source/map_cfg.c +++ b/qw/source/map_cfg.c @@ -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); diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index e52032da8..aa359c576 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -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); diff --git a/qw/source/sv_init.c b/qw/source/sv_init.c index 04e4f860c..a8be620f5 100644 --- a/qw/source/sv_init.c +++ b/qw/source/sv_init.c @@ -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); diff --git a/qw/source/sv_pr_cpqw.c b/qw/source/sv_pr_cpqw.c index 07659f634..594f66219 100644 --- a/qw/source/sv_pr_cpqw.c +++ b/qw/source/sv_pr_cpqw.c @@ -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 { diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 5a063b6b7..5398eff6c 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -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 diff --git a/tools/qwaq/qwaq-bi.c b/tools/qwaq/qwaq-bi.c index 32e8ca9e1..822c8c635 100644 --- a/tools/qwaq/qwaq-bi.c +++ b/tools/qwaq/qwaq-bi.c @@ -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");