]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/cvar.qh
Merge branch 'Mario/vaporizer_damage' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / cvar.qh
1 #ifndef CVAR_H
2 #define CVAR_H
3
4 #include "static.qh"
5
6 void RegisterCvars(void(string name, string desc, bool archive, string file) f) { }
7
8 void RegisterCvars_Set(string name, string desc, bool archive, string file)
9 {
10     localcmd(sprintf("\n%1$s %2$s \"$%2$s\" \"%3$s\"\n", (archive ? "seta" : "set"), name, desc));
11 }
12
13 STATIC_INIT_LATE(Cvars) { RegisterCvars(RegisterCvars_Set); }
14
15 #define AUTOCVAR_5(file, archive, var, type, desc) \
16     [[accumulate]] void RegisterCvars(void(string, string, bool, string) f) { f(#var, desc, archive, file); } \
17     type autocvar_##var
18 #define AUTOCVAR_6(file, archive, var, type, default, desc) \
19     AUTOCVAR_5(file, archive, var, type, desc) = default
20 #define _AUTOCVAR(...) EVAL(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
21 #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__)
22 #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
23
24 #endif