]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/all.qh
Merge branch 'TimePath/cleanup'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / all.qh
index 04bb10f6a548e67da5fba28ed487c71a1300f52c..3f9eba4f37d4e942aac5ccdd160dfb226dee42de 100644 (file)
@@ -1,12 +1,85 @@
-#include "unit/ewheel.qc"
-#include "unit/flac.qc"
-#include "unit/fusionreactor.qc"
-#include "unit/hellion.qc"
-#include "unit/hk.qc"
-#include "unit/machinegun.qc"
-#include "unit/mlrs.qc"
-#include "unit/phaser.qc"
-#include "unit/plasma.qc"
-#include "unit/plasma_dual.qc"
-#include "unit/tesla.qc"
-#include "unit/walker.qc"
+#ifndef TURRETS_ALL_H
+#define TURRETS_ALL_H
+
+#include "../command/all.qh"
+#include "config.qh"
+
+#include "turret.qh"
+
+REGISTRY(Turrets, BIT(5))
+REGISTER_REGISTRY(RegisterTurrets)
+
+
+GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
+{
+    switch(request)
+    {
+        case CMD_REQUEST_COMMAND:
+        {
+            #ifdef SVQC
+            tur_config_file = -1;
+            tur_config_alsoprint = -1;
+            string filename = argv(1);
+
+            if(filename == "")
+            {
+                filename = "turrets_dump.cfg";
+                tur_config_alsoprint = FALSE;
+            }
+            else if(filename == "-")
+            {
+                filename = "turrets_dump.cfg";
+                tur_config_alsoprint = TRUE;
+            }
+            tur_config_file = fopen(filename, FILE_WRITE);
+
+            if(tur_config_file >= 0)
+            {
+                Dump_Turret_Settings();
+                LOG_INFO(sprintf("Dumping turrets... File located in ^2data/data/%s^7.\n", filename));
+                fclose(tur_config_file);
+                tur_config_file = -1;
+                tur_config_alsoprint = -1;
+            }
+            else
+            {
+                LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+            }
+            #else
+            LOG_INFO(_("Turrets dump command only works with sv_cmd.\n"));
+            #endif
+            return;
+        }
+
+        default:
+        case CMD_REQUEST_USAGE:
+        {
+            LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
+            LOG_INFO("  Where 'filename' is the file to write (default is turrets_dump.cfg),\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;
+        }
+    }
+}
+
+
+const int TUR_FIRST = 1;
+#define TUR_LAST (Turrets_COUNT - 1)
+
+#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, Turrets, id, m_id, inst)
+
+REGISTER_TURRET(Null, NEW(Turret));
+
+Turret get_turretinfo(int id)
+{
+    if (id >= TUR_FIRST && id <= TUR_LAST) {
+        Turret t = Turrets[id];
+        if (t) return t;
+    }
+    return TUR_Null;
+}
+
+#include "all.inc"
+
+#endif