]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
effectinfo: dumpeffectinfo command
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 26 Sep 2015 10:27:12 +0000 (20:27 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 26 Sep 2015 10:27:12 +0000 (20:27 +1000)
qcsrc/common/command/generic.qc
qcsrc/common/effects/effectinfo.qc

index 0c8f85816f124f2668255db78a3872a8bb81b033..64083a89dac9e8b407fa16cc17df69bcbe198f0a 100644 (file)
@@ -240,6 +240,47 @@ void GenericCommand_dumpcommands(float request)
        }
 }
 
+void effectinfo_dump(int fh, bool alsoprint);
+void GenericCommand_dumpeffectinfo(float request)
+{
+    switch (request) {
+        case CMD_REQUEST_COMMAND: {
+            #ifndef MENUQC
+            string filename = argv(1);
+                       bool alsoprint = false;
+            if (filename == "") {
+                filename = "effectinfo_dump.txt";
+                alsoprint = false;
+            } else if (filename == "-") {
+                filename = "effectinfo_dump.txt";
+                alsoprint = true;
+            }
+            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);
+                fclose(fh);
+            } else {
+                LOG_WARNINGF("Could not open file '%s'!\n", filename);
+            }
+            #else
+            LOG_INFO(_("Effectinfo dump command only works with cl_cmd and sv_cmd.\n"));
+            #endif
+            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");
+            return;
+        }
+    }
+}
+STATIC_INIT(dumpeffectinfo) { localcmd("alias dumpeffectinfo \"qc_cmd_svcl dumpeffectinfo ${* ?}\"\n"); }
+
 void GenericCommand_dumpitems(float request)
 {
        switch(request)
@@ -722,6 +763,7 @@ void GenericCommand_(float request)
 #define GENERIC_COMMANDS(request,arguments,command) \
        GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
+       GENERIC_COMMAND("dumpeffectinfo", GenericCommand_dumpeffectinfo(request), "Dump all effectinfo to effectinfo_dump.txt") \
        GENERIC_COMMAND("dumpitems", GenericCommand_dumpitems(request), "Dump all items to the console") \
        GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \
        GENERIC_COMMAND("dumpturrets", GenericCommand_dumpturrets(request), "Dump all turrets into turrets_dump.txt") \
index 0288f9e9dc3c7cc3eef2bb4b9a54f22dcf73c125..6d5732d2f2e6fd70524218dfc6c0bf325c01f253 100644 (file)
@@ -257,11 +257,13 @@ void effectinfo_read()
     fclose(fh);
 }
 
-void effectinfo_dump()
+void effectinfo_dump(int fh, bool alsoprint)
 {
     for (EffectInfo it = NULL; (it = findfloat(it, instanceOfEffectInfo, true)); ) {
         if (it.classname == "vtbl") continue;
-        print(it.dump(it));
+        string s = it.dump(it);
+        fputs(fh, s);
+        if (alsoprint) print(s);
     }
 }
 
@@ -284,7 +286,7 @@ REGISTER_REGISTRY(RegisterEffectInfo)
 #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); } \
+    [[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