summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/cvar.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/cvar.h')
-rw-r--r--apps/plugins/sdl/progs/quake/cvar.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/cvar.h b/apps/plugins/sdl/progs/quake/cvar.h
new file mode 100644
index 0000000000..009b74783f
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/cvar.h
@@ -0,0 +1,97 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// cvar.h
21
22/*
23
24cvar_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
25in C code.
26
27it is sufficient to initialize a cvar_t with just the first two fields, or
28you can add a ,true flag for variables that you want saved to the configuration
29file when the game is quit:
30
31cvar_t r_draworder = {"r_draworder","1"};
32cvar_t scr_screensize = {"screensize","1",true};
33
34Cvars 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:
35Cvar_RegisterVariable (&host_framerate);
36
37
38C code usually just references a cvar in place:
39if ( r_draworder.value )
40
41It could optionally ask for the value to be looked up for a string name:
42if (Cvar_VariableValue ("r_draworder"))
43
44Interpreted prog code can access cvars with the cvar(name) or
45cvar_set (name, value) internal functions:
46teamplay = cvar("teamplay");
47cvar_set ("registered", "1");
48
49The user can access cvars from the console in two ways:
50r_draworder prints the current value
51r_draworder 0 sets the current value to 0
52Cvars are restricted from having the same names as commands to keep this
53interface from being ambiguous.
54*/
55
56typedef struct cvar_s
57{
58 char *name;
59 char *string;
60 qboolean archive; // set to true to cause it to be saved to vars.rc
61 qboolean server; // notifies players when changed
62 float value;
63 struct cvar_s *next;
64} cvar_t;
65
66void Cvar_RegisterVariable (cvar_t *variable);
67// registers a cvar that allready has the name, string, and optionally the
68// archive elements set.
69
70void Cvar_Set (char *var_name, char *value);
71// equivelant to "<name> <variable>" typed at the console
72
73void Cvar_SetValue (char *var_name, float value);
74// expands value to a string and calls Cvar_Set
75
76float Cvar_VariableValue (char *var_name);
77// returns 0 if not defined or non numeric
78
79char *Cvar_VariableString (char *var_name);
80// returns an empty string if not defined
81
82char *Cvar_CompleteVariable (char *partial);
83// attempts to match a partial variable name for command line completion
84// returns NULL if nothing fits
85
86qboolean Cvar_Command (void);
87// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
88// command. Returns true if the command was a variable reference that
89// was handled. (print or change)
90
91void Cvar_WriteVariables (FILE *f);
92// Writes lines containing "set variable value" for all variables
93// with the archive flag set to true.
94
95cvar_t *Cvar_FindVar (char *var_name);
96
97extern cvar_t *cvar_vars;