Merge branch 'master' into terencehill/music_player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qh
1 // ==========================
2 //  Balance Config Generator
3 // ==========================
4
5 void Dump_Weapon_Settings(void);
6 float wep_config_file;
7 float wep_config_alsoprint;
8
9 #define MAX_WEP_CONFIG 256
10 float WEP_CONFIG_COUNT;
11 string wep_config_queue[MAX_WEP_CONFIG];
12
13 #define WEP_CONFIG_QUEUE(a) { \
14         wep_config_queue[WEP_CONFIG_COUNT] = a; \
15         ++WEP_CONFIG_COUNT; }
16
17 #define WEP_CONFIG_WRITETOFILE(a) { \
18         fputs(wep_config_file, a); \
19         if(wep_config_alsoprint) { print(a); } }
20
21 #define WEP_CONFIG_WRITE_CVARS_NONE(wepname,name) \
22         { WEP_CONFIG_QUEUE( \
23                 sprintf("set g_balance_%s_%s %g\n", #wepname, #name, \
24                 cvar(sprintf("g_balance_%s_%s", #wepname, #name)))) }
25
26 #define WEP_CONFIG_WRITE_CVARS_PRI(wepname,name) WEP_CONFIG_WRITE_CVARS_NONE(wepname, primary_##name)
27 #define WEP_CONFIG_WRITE_CVARS_SEC(wepname,name) WEP_CONFIG_WRITE_CVARS_NONE(wepname, secondary_##name)
28 #define WEP_CONFIG_WRITE_CVARS_BOTH(wepname,name) \
29         WEP_CONFIG_WRITE_CVARS_PRI(wepname, name) \
30         WEP_CONFIG_WRITE_CVARS_SEC(wepname, name)
31         
32 #define WEP_CONFIG_WRITE_CVARS(wepid,wepname,mode,name) WEP_CONFIG_WRITE_CVARS_##mode(wepname, name)
33
34 #define WEP_CONFIG_WRITE_PROPS_string(wepname,name) \
35         { WEP_CONFIG_QUEUE( \
36                 sprintf("set g_balance_%s_%s \"%s\"\n", #wepname, #name, \
37                 cvar_string(sprintf("g_balance_%s_%s", #wepname, #name)))) }
38
39 #define WEP_CONFIG_WRITE_PROPS_float(wepname,name) \
40         { WEP_CONFIG_QUEUE( \
41                 sprintf("set g_balance_%s_%s %g\n", #wepname, #name, \
42                 cvar(sprintf("g_balance_%s_%s", #wepname, #name)))) }
43
44 #define WEP_CONFIG_WRITE_PROPS(wepid,wepname,type,prop,name) WEP_CONFIG_WRITE_PROPS_##type(wepname,name)