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