]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/all.qh
Improve registry API by adding REGISTRY_MAX and REGISTRY_COUNT macros
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / all.qh
index 1a77e989121b0cade1ab49e584f93e6e575b29d4..ee0e1918e4b9194c3d5f75b510d864095476b81e 100644 (file)
@@ -11,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)
     {
@@ -38,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;
         }
@@ -56,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;
         }
     }
@@ -67,10 +112,10 @@ GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
 
 
 const int TUR_FIRST = 1;
-#define TUR_LAST (Turrets_COUNT - 1)
+#define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
 
 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
 
 REGISTER_TURRET(Null, NEW(Turret));
 
-#include "turret/_mod.inc"
+#include "turret/_mod.qh"