]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/config.qh
Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qh
index 462c988d77b3ab0ee95e4bc39cf9785a3e12ce92..410dbdfadeb8b1f7fe79e4eeacf63bdf1a7e14d0 100644 (file)
@@ -1,29 +1,49 @@
+#ifndef WEAPONS_CONFIG_H
+#define WEAPONS_CONFIG_H
+
 // ==========================
 //  Balance Config Generator
 // ==========================
 
-void Dump_Weapon_Settings(float fh, float alsoprint);
-float wep_config_file;
-float wep_config_alsoprint;
+void Dump_Weapon_Settings(void);
+int wep_config_file;
+bool wep_config_alsoprint;
+
+const int MAX_WEP_CONFIG = 256;
+int WEP_CONFIG_COUNT;
+string wep_config_queue[MAX_WEP_CONFIG];
+
+#define WEP_CONFIG_QUEUE(a) { \
+       wep_config_queue[WEP_CONFIG_COUNT] = a; \
+       ++WEP_CONFIG_COUNT; }
 
-#define WEP_CONFIG_WRITE(a) { \
+#define WEP_CONFIG_WRITETOFILE(a) do { \
        fputs(wep_config_file, a); \
-       if(wep_config_alsoprint) { print(a); } }
-
-#define WEP_CONFIG_WRITE_CVARS(weapon,mode,name) \
-       #if mode == MO_PRI \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
-       #endif \
-       #if mode == MO_SEC \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
-       #endif \
-       #if mode == MO_BOTH \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
-       #endif \
-       #if mode == MO_NONE \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) \
-       #endif
-       
-#define WEP_CONFIG_WRITE_PROPS(weapon,prop,name) \
-       { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) }
+       if(wep_config_alsoprint) { LOG_INFO(a); } \
+} while(0)
+
+#define WEP_CONFIG_WRITE_CVARS_NONE(wepname,name) \
+       { WEP_CONFIG_QUEUE( \
+               sprintf("set g_balance_%s_%s %g\n", #wepname, #name, \
+               cvar(sprintf("g_balance_%s_%s", #wepname, #name)))) }
+
+#define WEP_CONFIG_WRITE_CVARS_PRI(wepname,name) WEP_CONFIG_WRITE_CVARS_NONE(wepname, primary_##name)
+#define WEP_CONFIG_WRITE_CVARS_SEC(wepname,name) WEP_CONFIG_WRITE_CVARS_NONE(wepname, secondary_##name)
+#define WEP_CONFIG_WRITE_CVARS_BOTH(wepname,name) \
+       WEP_CONFIG_WRITE_CVARS_PRI(wepname, name) \
+       WEP_CONFIG_WRITE_CVARS_SEC(wepname, name)
+
+#define WEP_CONFIG_WRITE_CVARS(wepid,wepname,mode,name) WEP_CONFIG_WRITE_CVARS_##mode(wepname, name)
+
+#define WEP_CONFIG_WRITE_PROPS_string(wepname,name) \
+       { WEP_CONFIG_QUEUE( \
+               sprintf("set g_balance_%s_%s \"%s\"\n", #wepname, #name, \
+               cvar_string(sprintf("g_balance_%s_%s", #wepname, #name)))) }
+
+#define WEP_CONFIG_WRITE_PROPS_float(wepname,name) \
+       { WEP_CONFIG_QUEUE( \
+               sprintf("set g_balance_%s_%s %g\n", #wepname, #name, \
+               cvar(sprintf("g_balance_%s_%s", #wepname, #name)))) }
+
+#define WEP_CONFIG_WRITE_PROPS(wepid,wepname,type,prop,name) WEP_CONFIG_WRITE_PROPS_##type(wepname,name)
+#endif