]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/effectinfo.qc
Introduce the shared function write_String_To_File that can be used by all the dump...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / effectinfo.qc
index da98946021b611dfc731f597b57ab60832c70249..474d41d1e74f5eba38f77312cd5f367529aaca4b 100644 (file)
@@ -1,3 +1,4 @@
+#include "effectinfo.qh"
 #define EFFECTINFO_PARSER(on, MY) \
     on(type,                                        MY(type) \
     ,{ demand(n == 1 && "type");                    MY(type) = strzone(argv(1)); \
     /**/
 
 CLASS(EffectInfo, Object)
-    ATTRIB(EffectInfo, effectinfo_name, string, string_null)
+    ATTRIB(EffectInfo, effectinfo_name, string);
     CONSTRUCTOR(EffectInfo, string s) {
         CONSTRUCT(EffectInfo);
         this.effectinfo_name = s;
@@ -193,11 +194,13 @@ CLASS(EffectInfo, Object)
     MY(velocityoffset, vector, '0 0 0') \
     /**/
 
-    #define MY(f, type, val) ATTRIB(EffectInfo, effectinfo_##f, type, val)
+    #define MY(f, type, val) ATTRIB(EffectInfo, effectinfo_##f, type, val);
     FIELDS(MY)
     #undef MY
 
-    METHOD(EffectInfo, describe, string(EffectInfo this)) {
+    METHOD(EffectInfo, describe, string(EffectInfo this))
+    {
+        TC(EffectInfo, this);
         string s = sprintf("SUB(%s) {\n", this.effectinfo_name);
         #define str_bool(it) (it ? "true" : "false")
         #define str_float(it) ftos(it)
@@ -209,7 +212,9 @@ CLASS(EffectInfo, Object)
         return strcat(s, "}\n");
     }
 
-    METHOD(EffectInfo, dump, string(EffectInfo this)) {
+    METHOD(EffectInfo, dump, string(EffectInfo this))
+    {
+        TC(EffectInfo, this);
         string s = sprintf("effect %s\n", this.effectinfo_name);
         #define MY(f) this.effectinfo_##f
         #define p(k, isset, parse, unparse) if (isset) { s = strcat(s, "\t", #k, unparse, "\n"); }
@@ -223,8 +228,8 @@ CLASS(EffectInfo, Object)
 ENDCLASS(EffectInfo)
 
 CLASS(EffectInfoGroup, Object)
-    ATTRIBARRAY(EffectInfoGroup, children, EffectInfo, 16)
-    ATTRIB(EffectInfoGroup, children_count, int, 0)
+    ATTRIBARRAY(EffectInfoGroup, children, EffectInfo, 16);
+    ATTRIB(EffectInfoGroup, children_count, int, 0);
 ENDCLASS(EffectInfoGroup)
 
 void effectinfo_read()
@@ -249,7 +254,7 @@ void effectinfo_read()
             #undef p
             #undef MY
             default:
-                LOG_WARNINGF("Unknown property '%s'\n", k);
+                LOG_WARNF("Unknown property '%s'", k);
                 break;
         }
     }
@@ -258,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");
@@ -298,20 +300,20 @@ GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt")
             int fh = fopen(filename, FILE_WRITE);
             if (fh >= 0) {
                effectinfo_dump(fh, alsoprint);
-                LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.\n", filename);
-                               LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.\n", filename);
+                LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.", filename);
+                               LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.", filename);
                 fclose(fh);
             } else {
-                LOG_WARNINGF("Could not open file '%s'!\n", filename);
+                LOG_WARNF("Could not open file '%s'!", filename);
             }
             return;
         }
         default:
         case CMD_REQUEST_USAGE: {
-            LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]"));
-            LOG_INFO("  Where 'filename' is the file to write (default is effectinfo_dump.txt),\n");
-            LOG_INFO("  if supplied with '-' output to console as well as default,\n");
-            LOG_INFO("  if left blank, it will only write to default.\n");
+            LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]");
+            LOG_INFO("  Where 'filename' is the file to write (default is effectinfo_dump.txt),");
+            LOG_INFO("  if supplied with '-' output to console as well as default,");
+            LOG_INFO("  if left blank, it will only write to default.");
             return;
         }
     }
@@ -322,7 +324,7 @@ REGISTRY(EffectInfos, BITS(9))
 #define EffectInfos_from(i) _EffectInfos_from(i, NULL)
 REGISTER_REGISTRY(EffectInfos)
 #define EFFECTINFO(name) \
-    [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
+    ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
     REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \
         effectinfo_##name(this, NULL); \
     }
@@ -330,8 +332,8 @@ REGISTER_REGISTRY(EffectInfos)
 #define MY(f) this.effectinfo_##f
 #define DEF(name) EFFECTINFO(name)
 #define SUB(name) \
-    [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \
-    [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this)
+    ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \
+    ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this)
 #include "effectinfo.inc"
 #undef MY
 #undef DEF