X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fcvar.qh;h=e8e2c54880a1a29eed6c48d50a6ac0cd44c016ff;hp=adcb7dfee0393a0685a3869405a68f3bddca56b5;hb=af43b181a15f348a4de2045b716ebc7765ce8f9f;hpb=eac60648c4017e495060dd3ba9e50ac4bad5000a diff --git a/qcsrc/lib/cvar.qh b/qcsrc/lib/cvar.qh index adcb7dfee..e8e2c5488 100644 --- a/qcsrc/lib/cvar.qh +++ b/qcsrc/lib/cvar.qh @@ -4,8 +4,10 @@ #include "progname.qh" #include "static.qh" +ERASEABLE void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {} +ERASEABLE bool cvar_value_issafe(string s) { if (strstrofs(s, "\"", 0) >= 0) return false; @@ -18,6 +20,7 @@ bool cvar_value_issafe(string s) } /** escape the string to make it safe for consoles */ +ERASEABLE string MakeConsoleSafe(string input) { input = strreplace("\n", "", input); @@ -27,16 +30,19 @@ string MakeConsoleSafe(string input) return input; } +ERASEABLE void cvar_describe(string name, string desc) { localcmd(sprintf("\nset %1$s \"$%1$s\" \"%2$s\"\n", name, MakeConsoleSafe(desc))); } +ERASEABLE void cvar_archive(string name) { localcmd(sprintf("\nseta %1$s \"$%1$s\"\n", name)); } +ERASEABLE void RegisterCvars_Set(string name, string def, string desc, bool archive, string file) { cvar_describe(name, desc); @@ -44,6 +50,7 @@ void RegisterCvars_Set(string name, string def, string desc, bool archive, strin } int RegisterCvars_Save_fd; +ERASEABLE void RegisterCvars_Save(string name, string def, string desc, bool archive, string file) { if (!archive) return; @@ -73,8 +80,14 @@ const noref vector default_vector = '0 0 0'; #define repr_cvar_string(x) (x) #define repr_cvar_vector(x) (sprintf("%v", x)) +//pseudo prototypes: +// void AUTOCVAR(, , default_cvar_value, string desc) +// void AUTOCVAR_SAVE(, , default_cvar_value, string desc) +// where default_cvar_value has type +// e.g.: AUTOCVAR(mycvar, float, 2.5, "cvar description") + #define __AUTOCVAR(file, archive, var, type, desc, default) \ - [[accumulate]] void RegisterCvars(void(string, string, string, bool, string) f) \ + ACCUMULATE void RegisterCvars(void(string, string, string, bool, string) f) \ { \ f( #var, repr_cvar_##type(default), desc, archive, file); \ } \