Introduce the shared function write_String_To_File that can be used by all the dump...
authorterencehill <piuntn@gmail.com>
Thu, 7 Feb 2019 17:48:12 +0000 (18:48 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 7 Feb 2019 18:06:26 +0000 (19:06 +0100)
qcsrc/common/effects/effectinfo.qc
qcsrc/common/notifications/all.qc
qcsrc/common/turrets/config.qc
qcsrc/common/turrets/config.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/config.qh

index 84bc880..474d41d 100644 (file)
@@ -263,10 +263,7 @@ void effectinfo_read()
 
 void effectinfo_dump(int fh, bool alsoprint)
 {
-    #define WRITE(s) MACRO_BEGIN \
-        fputs(fh, s); \
-        if (alsoprint) LOG_INFO(s); \
-    MACRO_END
+       #define WRITE(str) write_String_To_File(fh, str, alsoprint)
     WRITE("// ********************************************** //\n");
     WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
     WRITE("// **                                          ** //\n");
index 438ff5d..04fc75e 100644 (file)
@@ -777,10 +777,7 @@ void Notification_GetCvars(entity this)
 /** used to output notifications.cfg file */
 void Dump_Notifications(int fh, bool alsoprint)
 {
-       #define NOTIF_WRITE(a) MACRO_BEGIN \
-               fputs(fh, a); \
-               if (alsoprint) LOG_INFO(a); \
-       MACRO_END
+       #define NOTIF_WRITE(str) write_String_To_File(fh, str, alsoprint)
 
        #define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN \
                string notif_msg = sprintf( \
index effabea..d1a980d 100644 (file)
@@ -30,6 +30,7 @@ float T_Config_Queue_Compare(float root, float child, entity pass)
 
 void Dump_Turret_Settings()
 {
+       #define TUR_CONFIG_WRITETOFILE(str) write_String_To_File(tur_config_file, str, tur_config_alsoprint)
        int totalsettings = 0;
        FOREACH(Turrets, it != TUR_Null, {
                // step 1: clear the queue
@@ -44,15 +45,16 @@ void Dump_Turret_Settings()
                heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
 
                // step 4: write queue
-               TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
+               TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name));
                for(int j = 0; j <= TUR_CONFIG_COUNT; ++j)
-                       TUR_CONFIG_WRITETOFILE(config_queue[j])
-               TUR_CONFIG_WRITETOFILE("// }}}\n")
+                       TUR_CONFIG_WRITETOFILE(config_queue[j]);
+               TUR_CONFIG_WRITETOFILE("// }}}\n");
 
                // step 5: debug info
                LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
                totalsettings += TUR_CONFIG_COUNT;
        });
+       #undef TUR_CONFIG_WRITETOFILE
 
        // clear queue now that we're finished
        TUR_CONFIG_COUNT = 0;
index ac09e9e..ad9c384 100644 (file)
@@ -7,9 +7,6 @@ float tur_config_file;
 float tur_config_alsoprint;
 
 float TUR_CONFIG_COUNT;
-#define TUR_CONFIG_WRITETOFILE(a) { \
-       fputs(tur_config_file, a); \
-       if(tur_config_alsoprint) { LOG_INFO(a); } }
 
 
 #endif
index 66cd016..74e337f 100644 (file)
@@ -1305,6 +1305,13 @@ float matchacl(string acl, string str)
        return r;
 }
 
+ERASEABLE
+void write_String_To_File(int fh, string str, bool alsoprint)
+{
+       fputs(fh, str);
+       if (alsoprint) LOG_INFO(str);
+}
+
 string get_model_datafilename(string m, float sk, string fil)
 {
        if(m)
index a1c0d67..d0a8ab8 100644 (file)
@@ -135,6 +135,8 @@ string getcurrentmod();
 
 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
 
+void write_String_To_File(int fh, string str, bool alsoprint);
+
 string get_model_datafilename(string mod, float skn, string fil); // skin -1 will return wildcard, mod string_null will also put wildcard there
 string get_model_parameters_modelname;
 float get_model_parameters_modelskin;
index b53e25f..bf34d53 100644 (file)
@@ -26,6 +26,7 @@ void Dump_Weapon_Settings()
 {
        int totalweapons = 0, totalsettings = 0;
        int wepcount = 1;
+       #define WEP_CONFIG_WRITETOFILE(str) write_String_To_File(wep_config_file, str, wep_config_alsoprint)
        FOREACH(Weapons, it != WEP_Null, {
                if((it.spawnflags & WEP_FLAG_HIDDEN) && (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_NORMAL))
                        continue; // never include the attacks
@@ -56,6 +57,7 @@ void Dump_Weapon_Settings()
                totalsettings += WEP_CONFIG_COUNT;
                wepcount += 1;
        });
+       #undef WEP_CONFIG_WRITETOFILE
 
        // clear queue now that we're finished
        WEP_CONFIG_COUNT = 0;
index 883082c..b21bf01 100644 (file)
@@ -14,11 +14,6 @@ int WEP_CONFIG_COUNT;
        config_queue[WEP_CONFIG_COUNT] = a; \
        ++WEP_CONFIG_COUNT; }
 
-#define WEP_CONFIG_WRITETOFILE(a) MACRO_BEGIN \
-       fputs(wep_config_file, a); \
-       if(wep_config_alsoprint) { LOG_INFO(a); } \
-MACRO_END
-
 
 #define WEP_CONFIG_WRITE_CVARS(wepname, name, T) WEP_CONFIG_WRITE_PROPS_##T(wepname, name)