]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
add a fs_gamedir cvar containing the currently active gamedirs (for use by menu QC...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 7 Aug 2009 05:55:43 +0000 (05:55 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 7 Aug 2009 05:55:43 +0000 (05:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9103 d7cf8633-e32d-0410-b094-e92efae38249

cvar.c
cvar.h
fs.c

diff --git a/cvar.c b/cvar.c
index 94fd37fc3e7f9105e388a5bea51a16fa06da8a6e..4dba58a98bbf3bf8e8e32f1fc16c9715e2d3b567 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -617,7 +617,8 @@ void Cvar_ResetToDefaults_All_f (void)
        cvar_t *var;
        // restore the default values of all cvars
        for (var = cvar_vars ; var ; var = var->next)
-               Cvar_SetQuick(var, var->defstring);
+               if((var->flags & CVAR_NORESETTODEFAULTS) == 0)
+                       Cvar_SetQuick(var, var->defstring);
 }
 
 
@@ -626,7 +627,7 @@ void Cvar_ResetToDefaults_NoSaveOnly_f (void)
        cvar_t *var;
        // restore the default values of all cvars
        for (var = cvar_vars ; var ; var = var->next)
-               if (!(var->flags & CVAR_SAVE))
+               if ((var->flags & (CVAR_NORESETTODEFAULTS | CVAR_SAVE)) == 0)
                        Cvar_SetQuick(var, var->defstring);
 }
 
@@ -636,7 +637,7 @@ void Cvar_ResetToDefaults_SaveOnly_f (void)
        cvar_t *var;
        // restore the default values of all cvars
        for (var = cvar_vars ; var ; var = var->next)
-               if (var->flags & CVAR_SAVE)
+               if ((var->flags & (CVAR_NORESETTODEFAULTS | CVAR_SAVE)) == CVAR_SAVE)
                        Cvar_SetQuick(var, var->defstring);
 }
 
diff --git a/cvar.h b/cvar.h
index 9014c50fb5ad4c52ca237ab023e6f2eacb427e26..8fb6ca2c75e50e63f090be0ecbf9385b65f7104c 100644 (file)
--- a/cvar.h
+++ b/cvar.h
@@ -68,7 +68,9 @@ interface from being ambiguous.
 // this means that this cvar should update a userinfo key but the name does not correspond directly to the userinfo key to update, and may require additional conversion ("_cl_color" for example should update "topcolor" and "bottomcolor")
 #define CVAR_NQUSERINFOHACK 64
 // used to determine if flags is valid
-#define CVAR_MAXFLAGSVAL 127
+#define CVAR_NORESETTODEFAULTS 128
+// for engine-owned cvars that must not be reset on gametype switch (e.g. scr_screenshot_name, which otherwise isn't set to the mod name properly)
+#define CVAR_MAXFLAGSVAL 255
 // for internal use only!
 #define CVAR_DEFAULTSET (1<<30)
 #define CVAR_ALLOCATED (1<<31)
diff --git a/fs.c b/fs.c
index c7721ef2efe75b8c1278ec335a5b77d0a3ece7a5..41f279cc8ab725d4ae56740e95deb510748a8802 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -321,8 +321,9 @@ char fs_gamedirs[MAX_GAMEDIRS][MAX_QPATH];
 gamedir_t *fs_all_gamedirs = NULL;
 int fs_all_gamedirs_count = 0;
 
-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; the date is encoded using strftime escapes)"};
+cvar_t scr_screenshot_name = {CVAR_NORESETTODEFAULTS, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running; the date is encoded using strftime escapes)"};
 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"};
+cvar_t cvar_fs_gamedir = {CVAR_READONLY | CVAR_NORESETTODEFAULTS, "fs_gamedir", "", "the list of currently selected gamedirs (use the 'gamedir' command to change this)"};
 
 
 /*
@@ -1204,6 +1205,7 @@ void FS_Rescan (void)
 {
        int i;
        qboolean fs_modified = false;
+       char gamedirbuf[MAX_INPUTLINE];
 
        FS_ClearSearchPath();
 
@@ -1225,13 +1227,19 @@ void FS_Rescan (void)
        // Adds basedir/gamedir as an override game
        // LordHavoc: now supports multiple -game directories
        // set the com_modname (reported in server info)
+       *gamedirbuf = 0;
        for (i = 0;i < fs_numgamedirs;i++)
        {
                fs_modified = true;
                FS_AddGameHierarchy (fs_gamedirs[i]);
                // update the com_modname (used server info)
                strlcpy (com_modname, fs_gamedirs[i], sizeof (com_modname));
+               if(i)
+                       strlcat(gamedirbuf, va(" %s", fs_gamedirs[i]), sizeof(gamedirbuf));
+               else
+                       strlcpy(gamedirbuf, fs_gamedirs[i], sizeof(gamedirbuf));
        }
+       Cvar_SetQuick(&cvar_fs_gamedir, gamedirbuf); // so QC or console code can query it
 
        // set the default screenshot name to either the mod name or the
        // gamemode screenshot name
@@ -1671,6 +1679,7 @@ void FS_Init_Commands(void)
 {
        Cvar_RegisterVariable (&scr_screenshot_name);
        Cvar_RegisterVariable (&fs_empty_files_in_pack_mark_deletions);
+       Cvar_RegisterVariable (&cvar_fs_gamedir);
 
        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");