]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/effectinfo.qc
Registry: use BITS everywhere
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / effectinfo.qc
index 932ce9b7264a54ba7317d548aed8efec0a99b673..f85ad06b127f1063ce7f9919129cd1c5520ca17c 100644 (file)
@@ -283,21 +283,49 @@ void effectinfo_dump(int fh, bool alsoprint)
     #undef WRITE
 }
 
+GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt")
+{
+    switch (request) {
+        case CMD_REQUEST_COMMAND: {
+            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);
+            }
+            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;
+        }
+    }
+}
 
-void RegisterEffectInfo();
-const int MAX_EFFECTINFOS = 512;
-entity EFFECTINFOS[MAX_EFFECTINFOS], EFFECTINFOS_first, EFFECTINFOS_last;
-int EFFECTINFOS_COUNT;
 
+REGISTRY(EffectInfos, BITS(9))
+REGISTER_REGISTRY(RegisterEffectInfos)
 #define EFFECTINFO(name) \
     [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
-    REGISTER(RegisterEffectInfo, EFFECTINFO, EFFECTINFOS, EFFECTINFOS_COUNT, name, m_id, NEW(EffectInfoGroup)) { \
+    REGISTER(RegisterEffectInfos, EFFECTINFO, EffectInfos, name, m_id, NEW(EffectInfoGroup)) { \
         effectinfo_##name(this, NULL); \
     }
-REGISTER_REGISTRY(RegisterEffectInfo)
-
-
-#define REGISTER_EFFECTINFO(id) var void effectinfo_##id(EffectInfoGroup parent)
 
 #define MY(f) this.effectinfo_##f
 #define DEF(name) EFFECTINFO(name)