UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cvar.cpp File Reference

Manage cvars. More...

#include "common.h"
#include "../shared/infostring.h"
#include <vector>

Go to the source code of this file.

Macros

#define CVAR_HASH_SIZE   64
 

Typedefs

typedef std::vector
< CvarListenerPtr
CvarListeners
 

Functions

void Com_SetUserinfoModified (bool modified)
 
bool Com_IsUserinfoModified (void)
 
void Com_SetRenderModified (bool modified)
 
bool Com_IsRenderModified (void)
 
cvar_tCvar_GetFirst (void)
 Return the first cvar of the cvar list. More...
 
static bool Cvar_InfoValidate (const char *s)
 Check that the Cvar identifier name doesn't contain a backslash, a double quote or a semi-colon. More...
 
cvar_tCvar_FindVar (const char *varName)
 Searches for a cvar given by parameter. More...
 
float Cvar_GetValue (const char *varName)
 Returns the float value of a cvar. More...
 
bool Cvar_SetCheckFunction (const char *varName, bool(*check)(cvar_t *cvar))
 Set a checker function for cvar values. More...
 
bool Cvar_AssertValue (cvar_t *cvar, float minVal, float maxVal, bool shouldBeIntegral)
 Checks cvar values. More...
 
int Cvar_GetInteger (const char *varName)
 Returns the int value of a cvar. More...
 
const char * Cvar_GetString (const char *varName)
 Returns the value of cvar as string. More...
 
const char * Cvar_VariableStringOld (const char *varName)
 Returns the old value of cvar as string before we changed it. More...
 
void Cvar_Reset (cvar_t *cvar)
 Sets the cvar value back to the old value. More...
 
int Cvar_CompleteVariable (const char *partial, const char **match)
 Unix like tab completion for console variables. More...
 
bool Cvar_Delete (const char *varName)
 Function to remove the cvar and free the space. More...
 
cvar_tCvar_Get (const char *var_name, const char *var_value, int flags, const char *desc)
 Init or return a cvar. More...
 
void Cvar_RegisterCvarListener (CvarListenerPtr listener)
 Registers a cvar listener. More...
 
void Cvar_UnRegisterCvarListener (CvarListenerPtr listener)
 Unregisters a cvar listener. More...
 
static void Cvar_ExecuteChangeListener (const cvar_t *cvar)
 Executes the change listeners for a cvar. More...
 
static cvarChangeListener_tCvar_GetChangeListener (cvarChangeListenerFunc_t listenerFunc)
 
cvarChangeListener_tCvar_RegisterChangeListener (const char *varName, cvarChangeListenerFunc_t listenerFunc)
 Registers a listener that is executed each time a cvar changed its value. More...
 
void Cvar_UnRegisterChangeListener (const char *varName, cvarChangeListenerFunc_t listenerFunc)
 Unregisters a cvar change listener. More...
 
static cvar_tCvar_Set2 (const char *varName, const char *value, bool force)
 Sets a cvar values Handles write protection and latched cvars as expected. More...
 
cvar_tCvar_ForceSet (const char *varName, const char *value)
 Will set the variable even if NOSET or LATCH. More...
 
cvar_tCvar_Set (const char *varName, const char *value,...)
 Sets a cvar value. More...
 
cvar_tCvar_FullSet (const char *varName, const char *value, int flags)
 Sets a cvar from console with the given flags. More...
 
void Cvar_SetValue (const char *varName, float value)
 Expands value to a string and calls Cvar_Set. More...
 
void Cvar_UpdateLatchedVars (void)
 Any variables with latched values will now be updated. More...
 
bool Cvar_Command (void)
 Handles variable inspection and changing from the console. More...
 
static void Cvar_SetOld_f (void)
 Allows resetting cvars to old value from console. More...
 
static void Cvar_Define_f (void)
 
static void Cvar_Set_f (void)
 Allows setting and defining of arbitrary cvars from console. More...
 
static void Cvar_Switch_f (void)
 Allows switching boolean cvars between zero and not-zero from console. More...
 
static void Cvar_Copy_f (void)
 Allows copying variables Available via console command copy. More...
 
void Cvar_WriteVariables (qFILE *f)
 appends lines containing "set variable value" for all variables with the archive flag set to true. More...
 
bool Cvar_PendingCvars (int flags)
 Checks whether there are pending cvars for the given flags. More...
 
void Cvar_ClearVars (int flags)
 
static void Cvar_List_f (void)
 List all cvars via console command 'cvarlist'. More...
 
static char * Cvar_BitInfo (int bit, char *info, size_t infoSize)
 Return a string with all cvars with bitflag given by parameter set. More...
 
const char * Cvar_Userinfo (char *info, size_t infoSize)
 Returns an info string containing all the CVAR_USERINFO cvars. More...
 
const char * Cvar_Serverinfo (char *info, size_t infoSize)
 Returns an info string containing all the CVAR_SERVERINFO cvars. More...
 
static void Cvar_Del_f (void)
 Delete a cvar - set [cvar] "" isn't working from within the scripts. More...
 
static void Cvar_Add_f (void)
 Add a value to a cvar. More...
 
static void Cvar_Mod_f (void)
 Apply a modulo to a cvar. More...
 
void Cvar_FixCheatVars (void)
 Reset cheat cvar values to default. More...
 
void Cvar_Init (void)
 Reads in all archived cvars. More...
 
void Cvar_Shutdown (void)
 

Variables

static cvar_tcvarVarsHash [CVAR_HASH_SIZE]
 
static CvarListeners cvarListeners
 
static bool renderModified
 This is set each time a CVAR_USERINFO variable is changed so that the renderer knows to update stuff accordingly. More...
 
static bool userinfoModified
 This is set each time a CVAR_USERINFO variable is changed so that the client knows to send it to the server. More...
 
static cvar_tcvarVars
 Cvar list. More...
 

Detailed Description

Manage cvars.

cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly in C code. Cvars are restricted from having the same names as commands to keep this interface from being ambiguous.

Definition in file cvar.cpp.

Macro Definition Documentation

#define CVAR_HASH_SIZE   64

Definition at line 35 of file cvar.cpp.

Referenced by Cvar_Delete(), Cvar_FindVar(), and Cvar_Get().

Typedef Documentation

typedef std::vector<CvarListenerPtr> CvarListeners

Definition at line 41 of file cvar.cpp.

Function Documentation

bool Com_IsRenderModified ( void  )

Definition at line 71 of file cvar.cpp.

References renderModified.

Referenced by R_BeginFrame().

bool Com_IsUserinfoModified ( void  )

Definition at line 61 of file cvar.cpp.

References userinfoModified.

Referenced by CL_SendChangedUserinfos().

void Com_SetRenderModified ( bool  modified)

Definition at line 66 of file cvar.cpp.

References renderModified.

Referenced by Cvar_Set2(), Qcommon_Init(), and R_BeginFrame().

void Com_SetUserinfoModified ( bool  modified)

Definition at line 56 of file cvar.cpp.

References userinfoModified.

Referenced by CL_Connect(), CL_SendChangedUserinfos(), Cvar_FullSet(), Cvar_Set2(), and Qcommon_Init().

static void Cvar_Add_f ( void  )
static

Add a value to a cvar.

Definition at line 1001 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_FindVar(), Cvar_SetValue(), and cvar_s::value.

Referenced by Cvar_Init().

bool Cvar_AssertValue ( cvar_t cvar,
float  minVal,
float  maxVal,
bool  shouldBeIntegral 
)

Checks cvar values.

this function checks cvar ranges and integral values

Returns
true if assert isn't true and the cvar was changed to a valid value, false if the new value is ok and nothing was changed.
Parameters
[in]cvarCvar to check
[in]minValThe minimal value the cvar should have
[in]maxValThe maximal value the cvar should have
[in]shouldBeIntegralNo floats for this cvar please

Definition at line 161 of file cvar.cpp.

References Com_Printf(), Cvar_Set(), Cvar_SetValue(), cvar_s::integer, cvar_s::name, and cvar_s::value.

Referenced by CL_CvarCheckVidGamma(), CL_CvarCheckVidMode(), CL_CvarWorldLevel(), Com_CvarCheckMaxFPS(), R_CvarCheckDynamicLights(), R_CvarCheckMaxLightmap(), R_CvarCheckMultisample(), R_CvarCheckWeather(), R_CvarPostProcess(), R_CvarPrograms(), and SV_CheckMaxSoldiersPerPlayer().

static char* Cvar_BitInfo ( int  bit,
char *  info,
size_t  infoSize 
)
static

Return a string with all cvars with bitflag given by parameter set.

Parameters
bitThe bitflag we search the global cvar array for
infoThe resulting string
infoSizeThe max length of the result (MAX_INFO_STRING is a good idea here)

Definition at line 955 of file cvar.cpp.

References Info_SetValueForKey(), and cvar_s::next.

Referenced by Cvar_Serverinfo(), and Cvar_Userinfo().

void Cvar_ClearVars ( int  flags)

Definition at line 891 of file cvar.cpp.

References cvar_s::next.

Referenced by R_BeginFrame(), and R_Init().

bool Cvar_Command ( void  )

Handles variable inspection and changing from the console.

called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known command. Returns true if the command was a variable reference that was handled. (print or change)

Returns
True if cvar exists - false otherwise

You can print the current value or set a new value with this function To set a new value for a cvar from within the console just type the cvar name followed by the value. To print the current cvar's value just type the cvar name and hit enter

See also
Cvar_Set_f
Cvar_SetValue
Cvar_Set

Definition at line 708 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_FindVar(), Cvar_Set(), cvar_s::name, cvar_s::string, and v.

Referenced by Cmd_vExecuteString().

int Cvar_CompleteVariable ( const char *  partial,
const char **  match 
)

Unix like tab completion for console variables.

attempts to match a partial variable name for command line completion returns nullptr if nothing fits

Parameters
partialThe beginning of the variable we try to complete
[out]matchThe found entry of the list we are searching, in case of more than one entry their common suffix is returned.
See also
Cmd_CompleteCommand
Key_CompleteCommand

Definition at line 258 of file cvar.cpp.

References Cmd_GenericCompleteFunction(), Com_Printf(), CVAR_DEVELOPER, cvar_s::next, and S_COLOR_GREEN.

Referenced by Com_ConsoleCompleteCommand().

static void Cvar_Copy_f ( void  )
static

Allows copying variables Available via console command copy.

Definition at line 851 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_GetString(), and Cvar_Set().

Referenced by Cvar_Init().

static void Cvar_Define_f ( void  )
static

Definition at line 745 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_FindVar(), Cvar_Set(), and name.

Referenced by Cvar_Init().

static void Cvar_Del_f ( void  )
static

Delete a cvar - set [cvar] "" isn't working from within the scripts.

See also
Cvar_Set_f

Definition at line 987 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and Cvar_Delete().

Referenced by Cvar_Init().

static void Cvar_ExecuteChangeListener ( const cvar_t cvar)
static

Executes the change listeners for a cvar.

Parameters
cvarThe cvar which change listeners are executed

Definition at line 424 of file cvar.cpp.

References cvar_s::changeListener, cvarChangeListener_s::data, cvarChangeListener_s::exec, cvar_s::name, cvarChangeListener_s::next, cvar_s::oldString, and cvar_s::string.

Referenced by Cvar_Set2().

void Cvar_FixCheatVars ( void  )

Reset cheat cvar values to default.

See also
CL_SendCommand

Definition at line 1042 of file cvar.cpp.

References com_cvarSysPool, Com_Printf(), Com_ServerState(), CVAR_CHEAT, Cvar_GetInteger(), Mem_Free, Mem_PoolStrDup, cvar_s::next, and Q_streq.

Referenced by CL_SendCommand().

cvar_t* Cvar_ForceSet ( const char *  varName,
const char *  value 
)
cvar_t* Cvar_FullSet ( const char *  varName,
const char *  value,
int  flags 
)

Sets a cvar from console with the given flags.

Note
flags are: CVAR_ARCHIVE These cvars will be saved. CVAR_USERINFO Added to userinfo when changed. CVAR_SERVERINFO Added to serverinfo when changed. CVAR_NOSET Don't allow change from console at all but can be set from the command line. CVAR_LATCH Save changes until server restart.
Parameters
varNameWhich cvar
valueWhich value for the cvar
flagswhich flags
See also
Cvar_Set_f

Definition at line 640 of file cvar.cpp.

References com_cvarSysPool, Com_SetUserinfoModified(), Cvar_FindVar(), Cvar_Get(), CVAR_USERINFO, cvar_s::flags, cvar_s::integer, Mem_Free, Mem_PoolStrDup, cvar_s::modified, cvar_s::oldString, cvar_s::string, and cvar_s::value.

Referenced by Cvar_Set_f(), Cvar_Switch_f(), GAME_SetMode(), and SV_Map().

cvar_t* Cvar_Get ( const char *  var_name,
const char *  var_value,
int  flags,
const char *  desc 
)

Init or return a cvar.

creates the variable if it doesn't exist, or returns the existing one if it exists, the value will not be changed, but flags will be ORed in that allows variables to be unarchived without needing bitflags

Parameters
[in]var_nameThe cvar name
[in]var_valueThe standard cvar value (will be set if the cvar doesn't exist)
[in]flagsCVAR_USERINFO, CVAR_LATCH, CVAR_SERVERINFO, CVAR_ARCHIVE and so on
[in]descThis is a short description of the cvar (see console command cvarlist)
Note
CVAR_ARCHIVE: Cvar will be saved to config.cfg when game shuts down - and will be reloaded when game starts up the next time
CVAR_LATCH: Latched cvars will be updated at the next map load
CVAR_SERVERINFO: This cvar will be send in the server info response strings (server browser)
CVAR_NOSET: This cvar can not be set from the commandline
CVAR_USERINFO: This cvar will be added to the userinfo string when changed (network synced)
CVAR_DEVELOPER: Only changeable if we are in development mode If the variable already exists, the value will not be set The flags will be or'ed in if the variable exists.

Definition at line 342 of file cvar.cpp.

References com_cvarSysPool, Com_HashKey(), Com_Printf(), CVAR_CHEAT, Cvar_FindVar(), CVAR_HASH_SIZE, Cvar_InfoValidate(), CVAR_SERVERINFO, CVAR_USERINFO, cvarListeners, cvarVars, cvar_s::defaultString, cvar_s::description, cvar_s::flags, hash, HASH_Add, i, cvar_s::integer, Mem_Free, Mem_PoolAllocType, Mem_PoolStrDup, cvar_s::modified, cvar_s::name, cvar_s::next, cvar_s::oldString, cvar_s::prev, cvar_s::string, and cvar_s::value.

Referenced by _wrap_getvar__SWIG_0(), _wrap_getvar__SWIG_1(), _wrap_getvar__SWIG_2(), _wrap_getvar__SWIG_3(), ACTOR_InitStartup(), CL_CameraInit(), CL_Init(), CL_InitLocal(), CL_LanguageInit(), CL_ViewInit(), Con_Init(), Cvar_FullSet(), Cvar_Set2(), GAME_GetImportData(), HTTP_InitStartup(), HUD_InitStartup(), IN_Init(), IN_StartupJoystick(), Irc_Init(), M_Init(), NET_Init(), uiTextEntryNode::onFocusGained(), PTL_InitStartup(), Qcommon_Init(), R_InitExtensions(), R_RegisterSystemVars(), R_RestartPrograms_f(), R_SphereInit(), S_Init(), S_MumbleInit(), SCR_Init(), FootStepTest::SetUpTestCase(), MapDefStatsTest::SetUpTestCase(), MapDefTest::SetUpTestCase(), MapDefMassRMATest::SetUpTestCase(), GameTest::SetUpTestCase(), RandomMapAssemblyTest::SetUpTestCase(), CampaignTest::SetUpTestCase(), SV_Init(), SV_InitGameProgs(), Sys_Init(), TEST_F(), TEST_Init(), TOTD_InitStartup(), UI_AbstractOption_SetCvar(), UI_GenInjectedString(), UI_GetFloatFromExpression(), UI_GetFloatFromNodeProperty(), UI_GetStringFromExpression(), UI_Init(), UI_InitDraw(), UI_InitWindows(), UI_RegisterGeoscapeNode(), VID_Init(), WEB_CGameCvars(), and WEB_InitStartup().

static cvarChangeListener_t* Cvar_GetChangeListener ( cvarChangeListenerFunc_t  listenerFunc)
static

Definition at line 433 of file cvar.cpp.

References com_cvarSysPool, cvarChangeListener_s::exec, and Mem_PoolAllocType.

Referenced by Cvar_RegisterChangeListener().

cvar_t* Cvar_GetFirst ( void  )

Return the first cvar of the cvar list.

Definition at line 81 of file cvar.cpp.

References cvarVars.

Referenced by CL_Init(), and CL_Shutdown().

int Cvar_GetInteger ( const char *  varName)
const char* Cvar_GetString ( const char *  varName)

Returns the value of cvar as string.

returns an empty string if not defined

See also
Cvar_GetValue
Cvar_FindVar

Even if the cvar does not exist this function will not return a null pointer but an empty string

Definition at line 210 of file cvar.cpp.

References Cvar_FindVar(), and cvar_s::string.

Referenced by CL_BattlescapeRadarGenerate_f(), CL_ConnectionlessPacket(), Cmd_AddCommand(), Cmd_TokenizeString(), Com_MacroExpandString(), Cvar_Copy_f(), FS_InitFilesystem(), GAME_GetEquipment(), GAME_GetImportData(), GAME_GetTeamDef(), Irc_Client_CmdPrivmsg(), M_Play_f(), SV_InitGameProgs(), SV_Map(), SVC_TeamInfo(), TEST_F(), and UI_MaterialEditorUpdate().

float Cvar_GetValue ( const char *  varName)

Returns the float value of a cvar.

returns 0.0 if not defined or non numeric

See also
Cvar_GetString
Cvar_FindVar
Cvar_GetInteger
Returns
0 if not defined

Definition at line 125 of file cvar.cpp.

References Cvar_FindVar(), and cvar_s::string.

Referenced by uiGeoscapeNode::draw(), GAME_GetImportData(), IN_SetMouseSpace(), R_PreprocessShaderR(), and UI_GetReferenceFloat().

static bool Cvar_InfoValidate ( const char *  s)
static

Check that the Cvar identifier name doesn't contain a backslash, a double quote or a semi-colon.

Parameters
sThe string (holding the name of the Cvar to check).
Returns
True if the name is considered valid.
Todo:
This allows for Cvar identifier names containing spaces. This is probably unwanted so best to extent the check with whitespace.

Definition at line 94 of file cvar.cpp.

Referenced by Cvar_Get(), and Cvar_Set2().

void Cvar_Init ( void  )

Reads in all archived cvars.

See also
Qcommon_Init

Definition at line 1087 of file cvar.cpp.

References Cmd_AddCommand(), Cvar_Add_f(), Cvar_Copy_f(), Cvar_Define_f(), Cvar_Del_f(), Cvar_List_f(), Cvar_Mod_f(), Cvar_Set_f(), Cvar_SetOld_f(), and Cvar_Switch_f().

Referenced by Qcommon_Init(), and TEST_Init().

static void Cvar_List_f ( void  )
static

List all cvars via console command 'cvarlist'.

Definition at line 902 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), CVAR_ARCHIVE, CVAR_DEVELOPER, CVAR_LATCH, CVAR_NOSET, CVAR_R_IMAGES, CVAR_SERVERINFO, CVAR_USERINFO, i, cvar_s::next, and S_COLOR_GREEN.

Referenced by Cvar_Init().

static void Cvar_Mod_f ( void  )
static

Apply a modulo to a cvar.

Definition at line 1021 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_FindVar(), Cvar_SetValue(), and cvar_s::integer.

Referenced by Cvar_Init().

bool Cvar_PendingCvars ( int  flags)

Checks whether there are pending cvars for the given flags.

Parameters
flagsThe CVAR_* flags
Returns
true if there are pending cvars, false otherwise

Definition at line 881 of file cvar.cpp.

References cvar_s::next.

Referenced by R_BeginFrame().

cvarChangeListener_t* Cvar_RegisterChangeListener ( const char *  varName,
cvarChangeListenerFunc_t  listenerFunc 
)

Registers a listener that is executed each time a cvar changed its value.

See also
Cvar_ExecuteChangeListener
Parameters
varNameThe cvar name to register the listener for
listenerFuncThe listener callback to register

Definition at line 446 of file cvar.cpp.

References cvar_s::changeListener, Com_Printf(), Cvar_FindVar(), Cvar_GetChangeListener(), cvarChangeListener_s::exec, and cvarChangeListener_s::next.

Referenced by CL_Init(), HUD_InitStartup(), R_RegisterSystemVars(), UI_AddCvarListener_f(), and UI_CvarListenerNodeBind().

void Cvar_RegisterCvarListener ( CvarListenerPtr  listener)

Registers a cvar listener.

Parameters
listenerThe listener callback to register

Definition at line 406 of file cvar.cpp.

References cvarListeners.

Referenced by GAME_InitStartup().

void Cvar_Reset ( cvar_t cvar)

Sets the cvar value back to the old value.

Parameters
cvarThe cvar to reset

Definition at line 241 of file cvar.cpp.

References Cvar_Set(), Mem_Free, Mem_StrDup, cvar_s::name, and cvar_s::oldString.

Referenced by HUD_CvarCheckMNHud(), and R_CvarGLSLVersionCheck().

const char* Cvar_Serverinfo ( char *  info,
size_t  infoSize 
)

Returns an info string containing all the CVAR_SERVERINFO cvars.

returns an info string containing all the CVAR_SERVERINFO cvars

See also
SV_StatusString

Definition at line 977 of file cvar.cpp.

References Cvar_BitInfo(), and CVAR_SERVERINFO.

Referenced by SV_Serverinfo_f(), SV_ShowServerinfo_f(), and SVC_Status().

cvar_t* Cvar_Set ( const char *  varName,
const char *  value,
  ... 
)

Sets a cvar value.

Parameters
varNameWhich cvar should be set
valueWhich value should the cvar get
Note
Look after the CVAR_LATCH stuff and check for write protected cvars

Definition at line 615 of file cvar.cpp.

References Cvar_Set2(), and Q_vsnprintf().

Referenced by CL_ActorCvars(), CL_CharacterSkillAndScoreCvars(), CL_ConnectionlessPacket(), CL_LanguageTryToSet(), CL_SetClientState(), CL_UGVCvars(), Com_SetGameType(), Cvar_AssertValue(), Cvar_Command(), Cvar_Copy_f(), Cvar_Define_f(), Cvar_Reset(), Cvar_Set_f(), Cvar_SetOld_f(), Cvar_SetValue(), Cvar_Switch_f(), cvar_t_set_value__SWIG_1(), GAME_EndBattlescape(), GAME_GetImportData(), GAME_StartBattlescape(), GAME_UpdateTeamMenuParameters_f(), HUD_InitUI(), HUD_Update(), HUD_UpdateActor(), HUD_UpdateActorCvar(), HUD_UpdateButtons(), IN_StartupJoystick(), INV_ItemDescription(), Irc_Connect_f(), Irc_UserClick_f(), M_Play_f(), M_PlayRandomByCategory(), M_RandomTrack_f(), uiRadioButtonNode::onActivate(), R_InitPrograms(), R_SetMode(), R_VerifyDriver(), SEQ_ExecuteMusic(), GameTest::SetUpTestCase(), SV_GetCvarToken(), SV_InitGameProgs(), SV_NextMapcycle(), SV_SetMaster_f(), TEST_F(), GameTest::testCountSpawnpointsForMapInMultiplayerMode(), GameTest::testCountSpawnpointsForMapInSingleplayerMode(), GameTest::testCountSpawnpointsForMapWithAssembly(), GameTest::testCountSpawnpointsForMapWithAssemblyAndAircraft(), UI_AbstractOption_SetCurrentValue(), UI_EditorNodeSelectNode(), UI_InitStack(), UI_MapInfo(), UI_MaterialEditorUpdate(), UI_Popup(), UI_PopupButton(), UI_PopupList(), WEB_Auth(), WEB_AuthResponse(), and WEB_InitStartup().

static cvar_t* Cvar_Set2 ( const char *  varName,
const char *  value,
bool  force 
)
static

Sets a cvar values Handles write protection and latched cvars as expected.

Parameters
[in]varNameWhich cvar
[in]valueSet the cvar to the value specified by 'value'
[in]forceForce the update of the cvar

Definition at line 512 of file cvar.cpp.

References cvar_s::check, com_cvarSysPool, Com_Printf(), Com_ServerState(), Com_SetRenderModified(), Com_SetUserinfoModified(), CVAR_DEVELOPER, Cvar_ExecuteChangeListener(), Cvar_FindVar(), Cvar_Get(), Cvar_InfoValidate(), CVAR_LATCH, CVAR_NOSET, CVAR_R_MASK, CVAR_SERVERINFO, CVAR_USERINFO, cvar_s::flags, cvar_s::integer, cvar_s::latchedString, Mem_Free, Mem_PoolStrDup, cvar_s::modified, cvar_s::oldString, Q_streq, cvar_s::string, and cvar_s::value.

Referenced by Cvar_ForceSet(), and Cvar_Set().

static void Cvar_Set_f ( void  )
static

Allows setting and defining of arbitrary cvars from console.

Definition at line 761 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), CVAR_ARCHIVE, Cvar_FindVar(), Cvar_FullSet(), CVAR_LATCH, CVAR_NOSET, CVAR_SERVERINFO, Cvar_Set(), CVAR_USERINFO, and cvar_s::flags.

Referenced by Cvar_Init().

bool Cvar_SetCheckFunction ( const char *  varName,
bool(*)(cvar_t *cvar)  check 
)

Set a checker function for cvar values.

Sets the check functions for a cvar (e.g. Cvar_Assert)

See also
Cvar_FindVar
Returns
true if set

Definition at line 139 of file cvar.cpp.

References cvar_s::check, Com_Printf(), and Cvar_FindVar().

Referenced by HUD_InitStartup(), Qcommon_Init(), R_InitExtensions(), R_RegisterSystemVars(), SV_Init(), and VID_Init().

static void Cvar_SetOld_f ( void  )
static

Allows resetting cvars to old value from console.

Definition at line 728 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_FindVar(), Cvar_Set(), cvar_s::oldString, and v.

Referenced by Cvar_Init().

void Cvar_Shutdown ( void  )

Definition at line 1100 of file cvar.cpp.

References OBJZERO.

Referenced by Qcommon_Shutdown(), and TEST_Shutdown().

static void Cvar_Switch_f ( void  )
static

Allows switching boolean cvars between zero and not-zero from console.

Definition at line 805 of file cvar.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), CVAR_ARCHIVE, Cvar_FindVar(), Cvar_FullSet(), Cvar_GetInteger(), CVAR_LATCH, CVAR_NOSET, CVAR_SERVERINFO, Cvar_Set(), CVAR_USERINFO, cvar_s::flags, and va().

Referenced by Cvar_Init().

void Cvar_UnRegisterChangeListener ( const char *  varName,
cvarChangeListenerFunc_t  listenerFunc 
)

Unregisters a cvar change listener.

Parameters
varNameThe cvar name to register the listener for
listenerFuncThe listener callback to unregister

Definition at line 487 of file cvar.cpp.

References cvar_s::changeListener, Com_Printf(), Cvar_FindVar(), cvarChangeListener_s::exec, Mem_Free, and cvarChangeListener_s::next.

Referenced by CL_Shutdown(), uiCvarNode::onWindowClosed(), and UI_RemoveCvarListener_f().

void Cvar_UnRegisterCvarListener ( CvarListenerPtr  listener)

Unregisters a cvar listener.

Parameters
listenerThe listener callback to unregister

Definition at line 415 of file cvar.cpp.

References cvarListeners.

Referenced by GAME_Shutdown().

void Cvar_UpdateLatchedVars ( void  )

Any variables with latched values will now be updated.

any CVAR_LATCHED variables that have been set will now take effect

Note
CVAR_LATCH cvars are not updated during a game (tactical mission)

Definition at line 683 of file cvar.cpp.

References cvar_s::next.

Referenced by SV_InitGame().

const char* Cvar_Userinfo ( char *  info,
size_t  infoSize 
)

Returns an info string containing all the CVAR_USERINFO cvars.

returns an info string containing all the CVAR_USERINFO cvars

Definition at line 967 of file cvar.cpp.

References Cvar_BitInfo(), and CVAR_USERINFO.

Referenced by CL_Connect(), CL_SendChangedUserinfos(), CL_UserInfo_f(), and TEST_F().

const char* Cvar_VariableStringOld ( const char *  varName)

Returns the old value of cvar as string before we changed it.

returns an empty string if not defined

See also
Cvar_GetValue
Cvar_FindVar

Even if the cvar does not exist this function will not return a null pointer but an empty string

Definition at line 226 of file cvar.cpp.

References Cvar_FindVar(), and cvar_s::oldString.

Referenced by GAME_GetImportData().

void Cvar_WriteVariables ( qFILE f)

appends lines containing "set variable value" for all variables with the archive flag set to true.

Note
Stores the archive cvars

Definition at line 868 of file cvar.cpp.

References CVAR_ARCHIVE, FS_Printf(), qFILE_s::name, and cvar_s::next.

Referenced by Com_WriteConfigToFile().

Variable Documentation

CvarListeners cvarListeners
static
cvar_t* cvarVars
static

Cvar list.

Definition at line 79 of file cvar.cpp.

Referenced by Cvar_Get(), and Cvar_GetFirst().

cvar_t* cvarVarsHash[CVAR_HASH_SIZE]
static

Definition at line 37 of file cvar.cpp.

bool renderModified
static

This is set each time a CVAR_USERINFO variable is changed so that the renderer knows to update stuff accordingly.

Definition at line 48 of file cvar.cpp.

Referenced by Com_IsRenderModified(), and Com_SetRenderModified().

bool userinfoModified
static

This is set each time a CVAR_USERINFO variable is changed so that the client knows to send it to the server.

Definition at line 54 of file cvar.cpp.

Referenced by Com_IsUserinfoModified(), and Com_SetUserinfoModified().