]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 84bc880ba23608c3660d0aec63ecf1a487e0f161..474d41d1e74f5eba38f77312cd5f367529aaca4b 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 438ff5d221c5618eacc1d54109d6040ac22be3d8..04fc75e8f3872054c67da569944506f1740fe66b 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 effabeac275ded29fed4b17d370f6e56e7cd5fb2..d1a980d76e0ce2c358d3f7f7de5462a149b718aa 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 ac09e9e37248f3f5320a1df3267f758820140126..ad9c3846f9a239bd4a9f9eb75609732ca83a2a49 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 66cd016c0ae90746bb584339f65400e41114c1f8..74e337f7498a6249291aa6bb80c245b46e043393 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 a1c0d6785fb416efa1b02c641d409b1e5e05d407..d0a8ab86a1acec5d974fa5ea56001ef8973e4bb8 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 b53e25fde9c95cbdaddc1b987fd30fa16f8f8d16..bf34d53208ae701375bdfef1bd3d8d41b5abf44e 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 883082c97d02ed22df2c6910c1123542f2d09818..b21bf017029dd45e329fa0cb4a9068d2110ead0e 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)