From e40ea7c3324b3ebec21f0c0265b763219a1bb75f Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 19 Mar 2010 14:29:02 +0100 Subject: [PATCH] vfs: support .pk3dir like in darkplaces engine - directories auto-added to the search path --- plugins/vfspk3/vfs.cpp | 20 ++++++++++++++++++++ tools/quake3/common/vfs.c | 12 ++++++++++++ tools/quake3/common/vfs.h | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 68837483..6220f773 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -353,6 +353,26 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules) break; const char *ext = strrchr (name, '.'); + + if(ext && !string_compare_nocase_upper(ext, ".pk3dir")) + { + if (g_numDirs == (VFS_MAXDIRS-1)) + continue; + snprintf(g_strDirs[g_numDirs], PATH_MAX, "%s%s/", path, name); + g_strDirs[g_numDirs][PATH_MAX] = '\0'; + FixDOSName (g_strDirs[g_numDirs]); + AddSlash (g_strDirs[g_numDirs]); + g_numDirs++; + + { + archive_entry_t entry; + entry.name = g_strDirs[g_numDirs-1]; + entry.archive = OpenArchive(g_strDirs[g_numDirs-1]); + entry.is_pakfile = false; + g_archives.push_back(entry); + } + } + if ((ext == 0) || *(++ext) == '\0' || GetArchiveTable(archiveModules, ext) == 0) continue; diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 25865661..f706aee5 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -195,6 +195,18 @@ void vfsInitDirectory (const char *path) { char *ext = strrchr (dirlist, '.'); + + if(ext && !Q_stricmp(ext, ".pk3dir")) + { + if (g_numDirs == (VFS_MAXDIRS-1)) + continue; + snprintf(g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name); + g_strDirs[g_numDirs][PATH_MAX] = '\0'; + vfsFixDOSName (g_strDirs[g_numDirs]); + vfsAddSlash (g_strDirs[g_numDirs]); + ++g_numDirs; + } + if ((ext == NULL) || (Q_stricmp (ext, ".pk3") != 0)) continue; } diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index 44b3ffad..d2e4d6fd 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _VFS_H_ #define _VFS_H_ -#define VFS_MAXDIRS 8 +#define VFS_MAXDIRS 64 void vfsInitDirectory (const char *path); void vfsShutdown (); -- 2.39.2