]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/all.qh
Create aliases for commands on roughly their correct VM, restores settemp functionality
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / all.qh
index a993b9218a22cf77ae2df4f80870d2115b3b9fde..9dedc89cb780253a184b45ed3f1dba2da1744d9b 100644 (file)
@@ -1,7 +1,6 @@
-#ifndef TURRETS_ALL_H
-#define TURRETS_ALL_H
+#pragma once
 
-#include <common/command/all.qh>
+#include <common/command/_mod.qh>
 #include "config.qh"
 
 #include "turret.qh"
@@ -12,8 +11,53 @@ REGISTRY(Turrets, BITS(5))
 REGISTER_REGISTRY(Turrets)
 REGISTRY_CHECK(Turrets)
 
+#define TR_PROPS_COMMON(P, class, prefix) \
+       P(class, prefix, aim_firetolerance_dist, float) \
+       P(class, prefix, aim_maxpitch, float) \
+       P(class, prefix, aim_maxrot, float) \
+       P(class, prefix, aim_speed, float) \
+       P(class, prefix, ammo_max, float) \
+       P(class, prefix, ammo_recharge, float) \
+       P(class, prefix, health, float) \
+       P(class, prefix, respawntime, float) \
+       P(class, prefix, shot_dmg, float) \
+       P(class, prefix, shot_force, float) \
+       P(class, prefix, shot_radius, float) \
+       P(class, prefix, shot_refire, float) \
+       P(class, prefix, shot_speed, float) \
+       P(class, prefix, shot_spread, float) \
+       P(class, prefix, shot_volly, float) \
+       P(class, prefix, shot_volly_refire, float) \
+       P(class, prefix, target_range, float) \
+       P(class, prefix, target_range_min, float) \
+       P(class, prefix, target_range_optimal, float) \
+       P(class, prefix, target_select_anglebias, float) \
+       P(class, prefix, target_select_missilebias, float) \
+       P(class, prefix, target_select_playerbias, float) \
+       P(class, prefix, target_select_rangebias, float) \
+       P(class, prefix, target_select_samebias, float) \
+       P(class, prefix, track_accel_pitch, float) \
+       P(class, prefix, track_accel_rot, float) \
+       P(class, prefix, track_blendrate, float) \
+       P(class, prefix, track_type, float) \
+       /**/
 
-GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
+#define TR_PROPS(L, class, prefix) \
+       L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
+       /**/
+
+#define TR_CONFIG(class, turname, fld, T)     _TR_CONFIG(class, fld, T, turname)
+#ifdef SVQC
+       #define TR_CONFIG_BEGIN(class) METHOD(class, tr_config, void(class this)) {
+               #define _TR_CONFIG(class, fld, T, turname) if (#turname == this.netname) TUR_CONFIG_WRITE_CVARS(turname, fld, T);
+       #define TR_CONFIG_END() }
+#else
+       #define TR_CONFIG_BEGIN(class)
+               #define _TR_CONFIG(class, fld, T, turname)
+       #define TR_CONFIG_END()
+#endif
+
+GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt", false)
 {
     switch(request)
     {
@@ -39,17 +83,17 @@ GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
             if(tur_config_file >= 0)
             {
                 Dump_Turret_Settings();
-                LOG_INFO(sprintf("Dumping turrets... File located in ^2data/data/%s^7.\n", filename));
+                LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", 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));
+                LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
             }
             #else
-            LOG_INFO(_("Turrets dump command only works with sv_cmd.\n"));
+            LOG_INFO(_("Turrets dump command only works with sv_cmd."));
             #endif
             return;
         }
@@ -57,10 +101,10 @@ GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
         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");
+            LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]");
+            LOG_INFO("  Where 'filename' is the file to write (default is turrets_dump.cfg),");
+            LOG_INFO("  if supplied with '-' output to console as well as default,");
+            LOG_INFO("  if left blank, it will only write to default.");
             return;
         }
     }
@@ -74,6 +118,4 @@ const int TUR_FIRST = 1;
 
 REGISTER_TURRET(Null, NEW(Turret));
 
-#include "turret/_mod.inc"
-
-#endif
+#include "turret/_mod.qh"