new cvar fs_empty_files_in_pack_mark_deletions: when set, a pk3 with empty files...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Apr 2007 11:43:24 +0000 (11:43 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Apr 2007 11:43:24 +0000 (11:43 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7145 d7cf8633-e32d-0410-b094-e92efae38249

fs.c

diff --git a/fs.c b/fs.c
index 0c6901b..3e6b8a8 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -278,6 +278,7 @@ int fs_numgamedirs = 0;
 char fs_gamedirs[MAX_GAMEDIRS][MAX_QPATH];
 
 cvar_t scr_screenshot_name = {0, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running)"};
+cvar_t fs_empty_files_in_pack_mark_deletions = {0, "fs_empty_files_in_pack_mark_deletions", "0", "if enabled, empty files in a pak/pk3 count as not existing but cancel the search in further packs, effectively allowing patch pak/pk3 files to 'delete' files"};
 
 
 /*
@@ -1379,6 +1380,7 @@ void FS_Init (void)
 void FS_Init_Commands(void)
 {
        Cvar_RegisterVariable (&scr_screenshot_name);
+       Cvar_RegisterVariable (&fs_empty_files_in_pack_mark_deletions);
 
        Cmd_AddCommand ("gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
        Cmd_AddCommand ("fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
@@ -1672,6 +1674,17 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet)
                                // Found it
                                if (!diff)
                                {
+                                       if (fs_empty_files_in_pack_mark_deletions.integer && pak->files[middle].realsize == 0)
+                                       {
+                                               // yes, but the first one is empty so we treat it as not being there
+                                               if (!quiet && developer.integer >= 10)
+                                                       Con_Printf("FS_FindFile: %s is marked as deleted\n", name);
+
+                                               if (index != NULL)
+                                                       *index = -1;
+                                               return NULL;
+                                       }
+
                                        if (!quiet && developer.integer >= 10)
                                                Con_Printf("FS_FindFile: %s in %s\n",
                                                                        pak->files[middle].name, pak->filename);