Annotation of quake1/cvar.h, revision 1.1

1.1     ! root        1: // cvar.h
        !             2: 
        !             3: /*
        !             4: 
        !             5: 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
        !             6: in C code.
        !             7: 
        !             8: it is sufficient to initialize a cvar_t with just the first two fields, or
        !             9: you can add a ,true flag for variables that you want saved to the configuration
        !            10: file when the game is quit:
        !            11: 
        !            12: cvar_t r_draworder = {"r_draworder","1"};
        !            13: cvar_t scr_screensize = {"screensize","1",true};
        !            14: 
        !            15: Cvars must be registered before use, or they will have a 0 value instead of the float interpretation of the string.  Generally, all cvar_t declarations should be registered in the apropriate init function before any console commands are executed:
        !            16: Cvar_RegisterVariable (&host_framerate);
        !            17: 
        !            18: 
        !            19: C code usually just references a cvar in place:
        !            20: if ( r_draworder.value )
        !            21: 
        !            22: It could optionally ask for the value to be looked up for a string name:
        !            23: if (Cvar_VariableValue ("r_draworder"))
        !            24: 
        !            25: Interpreted prog code can access cvars with the cvar(name) or
        !            26: cvar_set (name, value) internal functions:
        !            27: teamplay = cvar("teamplay");
        !            28: cvar_set ("registered", "1");
        !            29: 
        !            30: The user can access cvars from the console in two ways:
        !            31: r_draworder                    prints the current value
        !            32: r_draworder 0          sets the current value to 0
        !            33: Cvars are restricted from having the same names as commands to keep this
        !            34: interface from being ambiguous.
        !            35: */
        !            36: 
        !            37: typedef struct cvar_s
        !            38: {
        !            39:        char    *name;
        !            40:        char    *string;
        !            41:        qboolean archive;               // set to true to cause it to be saved to vars.rc
        !            42:        qboolean server;                // notifies players when changed
        !            43:        float   value;
        !            44:        struct cvar_s *next;
        !            45: } cvar_t;
        !            46: 
        !            47: void   Cvar_RegisterVariable (cvar_t *variable);
        !            48: // registers a cvar that allready has the name, string, and optionally the
        !            49: // archive elements set.
        !            50: 
        !            51: void   Cvar_Set (char *var_name, char *value);
        !            52: // equivelant to "<name> <variable>" typed at the console
        !            53: 
        !            54: void   Cvar_SetValue (char *var_name, float value);
        !            55: // expands value to a string and calls Cvar_Set
        !            56: 
        !            57: float  Cvar_VariableValue (char *var_name);
        !            58: // returns 0 if not defined or non numeric
        !            59: 
        !            60: char   *Cvar_VariableString (char *var_name);
        !            61: // returns an empty string if not defined
        !            62: 
        !            63: char   *Cvar_CompleteVariable (char *partial);
        !            64: // attempts to match a partial variable name for command line completion
        !            65: // returns NULL if nothing fits
        !            66: 
        !            67: qboolean Cvar_Command (void);
        !            68: // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
        !            69: // command.  Returns true if the command was a variable reference that
        !            70: // was handled. (print or change)
        !            71: 
        !            72: void   Cvar_WriteVariables (FILE *f);
        !            73: // Writes lines containing "set variable value" for all variables
        !            74: // with the archive flag set to true.
        !            75: 
        !            76: cvar_t *Cvar_FindVar (char *var_name);
        !            77: 
        !            78: extern cvar_t  *cvar_vars;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.