8 void RegisterCvars(
void(
string name,
string def,
string desc,
bool archive,
string file) f) {}
13 if (
strstrofs(s,
"\"", 0) >= 0)
return false;
14 if (
strstrofs(s,
"\\", 0) >= 0)
return false;
15 if (
strstrofs(s,
";", 0) >= 0)
return false;
16 if (
strstrofs(s,
"$", 0) >= 0)
return false;
17 if (
strstrofs(s,
"\r", 0) >= 0)
return false;
18 if (
strstrofs(s,
"\n", 0) >= 0)
return false;
26 input = strreplace(
"\n",
"", input);
27 input = strreplace(
"\\",
"\\\\", input);
28 input = strreplace(
"$",
"$$", input);
29 input = strreplace(
"\"",
"\\\"", input);
53 }
else if (
str2chr(s, 0) ==
'-') {
57 bool expr_fail =
false;
68 #define BINOP(op, len, expr) \ 69 if ((o = strstrofs(s, op, 0)) >= 0) { \ 70 k = substring(s, 0, o); \ 71 v = substring(s, o + len, -1); \ 90 bool isnum =
ftos(f) == k;
91 X(
boolean(isnum ? f :
cvar(k)) == b);
108 localcmd(sprintf(
"\nseta %1$s \"$%1$s\"\n", name));
115 if (!archive)
return;
116 fputs(RegisterCvars_Save_fd, sprintf(
"seta %s \"%s\"\n", name, def));
122 RegisterCvars_Save_fd =
fopen(sprintf(
"default%s.cfg", PROGNAME),
FILE_WRITE);
123 if (RegisterCvars_Save_fd >= 0)
126 fclose(RegisterCvars_Save_fd);
136 #define repr_cvar_bool(x) ((x) ? "1" : "0") 137 #define repr_cvar_int(x) (ftos(x)) 138 #define repr_cvar_float(x) (ftos(x)) 139 #define repr_cvar_string(x) (x) 140 #define repr_cvar_vector(x) (sprintf("%v", x)) 148 #define __AUTOCVAR(file, archive, var, type, desc, default) \ 149 ACCUMULATE void RegisterCvars(void(string, string, string, bool, string) f) \ 151 f( #var, repr_cvar_##type(default), desc, archive, file); \ 153 type autocvar_##var = default 154 #define AUTOCVAR_5(file, archive, var, type, desc) \ 155 __AUTOCVAR(file, archive, var, type, desc, default_##type) 156 #define AUTOCVAR_6(file, archive, var, type, default, desc) \ 157 __AUTOCVAR(file, archive, var, type, desc, default) 158 #define _AUTOCVAR(...) EVAL__AUTOCVAR(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__)) 159 #define EVAL__AUTOCVAR(...) __VA_ARGS__ 160 #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__) 161 #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
ERASEABLE void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f)
ERASEABLE void RegisterCvars_Save(string name, string def, string desc, bool archive, string file)
int RegisterCvars_Save_fd
ERASEABLE string MakeConsoleSafe(string input)
escape the string to make it safe for consoles
#define BINOP(op, len, expr)
const noref string default_string
ERASEABLE void RegisterCvars_Set(string name, string def, string desc, bool archive, string file)
const noref int default_int
const noref bool default_bool
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const noref vector default_vector
ERASEABLE bool cvar_value_issafe(string s)
const noref float default_float
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...