From: divverent Date: Fri, 7 Aug 2009 05:55:43 +0000 (+0000) Subject: add a fs_gamedir cvar containing the currently active gamedirs (for use by menu QC... X-Git-Tag: xonotic-v0.1.0preview~1526 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=995b8e62733d66cf8ba63b62af1ba802612c80c3;p=xonotic%2Fdarkplaces.git add a fs_gamedir cvar containing the currently active gamedirs (for use by menu QC to know which one is active) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9103 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cvar.c b/cvar.c index 94fd37fc..4dba58a9 100644 --- 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 9014c50f..8fb6ca2c 100644 --- 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 c7721ef2..41f279cc 100644 --- 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");