From 19e937518c92c28dc7496fc682b629b68d32246b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 30 Jan 2000 22:46:30 +0000 Subject: [PATCH] can find "wadfile".gz as well as just "wadfile". NOTE: .gz files don't acutally work yet. --- common/quakefs.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/common/quakefs.c b/common/quakefs.c index af00a61..258c8af 100644 --- a/common/quakefs.c +++ b/common/quakefs.c @@ -277,6 +277,10 @@ int COM_FOpenFile (char *filename, FILE **file) pack_t *pak; int i; int findtime; + char gzfilename[MAX_OSPATH]; + + strncpy(gzfilename,filename,sizeof(gzfilename)); + strncat(gzfilename,".gz",sizeof(gzfilename)); file_from_pak = 0; @@ -290,29 +294,41 @@ int COM_FOpenFile (char *filename, FILE **file) { // look through all the pak file elements pak = search->pack; - for (i=0 ; inumfiles ; i++) + for (i=0 ; inumfiles ; i++) { + char *fn=0; if (!strcmp (pak->files[i].name, filename)) + fn=filename; + else if (!strcmp (pak->files[i].name, gzfilename)) + fn=gzfilename; + if (fn) { // found it! if(developer.value) - Sys_Printf ("PackFile: %s : %s\n",pak->filename, filename); + Sys_Printf ("PackFile: %s : %s\n",pak->filename, fn); // open a new file on the pakfile *file = fopen (pak->filename, "rb"); if (!*file) - Sys_Error ("Couldn't reopen %s", pak->filename); + Sys_Error ("Couldn't reopen %s", pak->filename); fseek (*file, pak->files[i].filepos, SEEK_SET); com_filesize = pak->files[i].filelen; file_from_pak = 1; return com_filesize; } + } } else { // check a file in the directory tree - snprintf(netpath, sizeof(netpath), "%s/%s",search->filename, filename); + snprintf(netpath, sizeof(netpath), "%s/%s",search->filename, + filename); findtime = Sys_FileTime (netpath); - if (findtime == -1) - continue; + if (findtime == -1) { + snprintf(netpath, sizeof(netpath), "%s/%s",search->filename, + gzfilename); + findtime = Sys_FileTime (netpath); + if (findtime == -1) + continue; + } if(developer.value) Sys_Printf ("FindFile: %s\n",netpath);