Xonotic
all.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <common/command/_mod.qh>
4 #include "config.qh"
5 
6 #include "turret.qh"
7 
8 REGISTRY(Turrets, BITS(5))
9 #define get_turretinfo(i) REGISTRY_GET(Turrets, i)
10 REGISTER_REGISTRY(Turrets)
11 REGISTRY_CHECK(Turrets)
12 
13 #define TR_PROPS_COMMON(P, class, prefix) \
14  P(class, prefix, aim_firetolerance_dist, float) \
15  P(class, prefix, aim_maxpitch, float) \
16  P(class, prefix, aim_maxrot, float) \
17  P(class, prefix, aim_speed, float) \
18  P(class, prefix, ammo_max, float) \
19  P(class, prefix, ammo_recharge, float) \
20  P(class, prefix, health, float) \
21  P(class, prefix, respawntime, float) \
22  P(class, prefix, shot_dmg, float) \
23  P(class, prefix, shot_force, float) \
24  P(class, prefix, shot_radius, float) \
25  P(class, prefix, shot_refire, float) \
26  P(class, prefix, shot_speed, float) \
27  P(class, prefix, shot_spread, float) \
28  P(class, prefix, shot_volly, float) \
29  P(class, prefix, shot_volly_refire, float) \
30  P(class, prefix, target_range, float) \
31  P(class, prefix, target_range_min, float) \
32  P(class, prefix, target_range_optimal, float) \
33  P(class, prefix, target_select_anglebias, float) \
34  P(class, prefix, target_select_missilebias, float) \
35  P(class, prefix, target_select_playerbias, float) \
36  P(class, prefix, target_select_rangebias, float) \
37  P(class, prefix, target_select_samebias, float) \
38  P(class, prefix, track_accel_pitch, float) \
39  P(class, prefix, track_accel_rot, float) \
40  P(class, prefix, track_blendrate, float) \
41  P(class, prefix, track_type, float) \
42 
43 
44 #define TR_PROPS(L, class, prefix) \
45  L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
46 
47 
48 #define TR_CONFIG(class, turname, fld, T) _TR_CONFIG(class, fld, T, turname)
49 #ifdef SVQC
50  #define TR_CONFIG_BEGIN(class) METHOD(class, tr_config, void(class this)) {
51  #define _TR_CONFIG(class, fld, T, turname) if (#turname == this.netname) TUR_CONFIG_WRITE_CVARS(turname, fld, T);
52  #define TR_CONFIG_END() }
53 #else
54  #define TR_CONFIG_BEGIN(class)
55  #define _TR_CONFIG(class, fld, T, turname)
56  #define TR_CONFIG_END()
57 #endif
58 
59 #define DEFAULT_FILENAME "turrets_dump.cfg"
60 // NOTE: dumpeffectinfo, dumpnotifs, dumpturrets and dumpweapons use similar code
61 GENERIC_COMMAND(dumpturrets, "Dump all turrets into " DEFAULT_FILENAME, false)
62 {
63  switch(request)
64  {
66  {
67  #ifdef SVQC
68  tur_config_file = -1;
69  tur_config_alsoprint = -1;
70  string filename = argv(1);
71 
72  if(filename == "")
73  {
74  filename = DEFAULT_FILENAME;
75  tur_config_alsoprint = false;
76  }
77  else if(filename == "-")
78  {
79  filename = DEFAULT_FILENAME;
80  tur_config_alsoprint = true;
81  }
82  tur_config_file = fopen(filename, FILE_WRITE);
83 
84  if(tur_config_file >= 0)
85  {
86  Dump_Turret_Settings();
87  LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", filename);
88  fclose(tur_config_file);
89  tur_config_file = -1;
90  tur_config_alsoprint = -1;
91  }
92  else
93  {
94  LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
95  }
96  #else
97  LOG_INFO("Turrets dump command only works with sv_cmd.");
98  #endif
99  return;
100  }
101 
102  default:
103  case CMD_REQUEST_USAGE:
104  {
105  LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [<filename>]");
106  LOG_HELPF(" Where <filename> is the file to write (default is %s),", DEFAULT_FILENAME);
107  LOG_HELP(" if supplied with '-' output to console as well as default,");
108  LOG_HELP(" if left blank, it will only write to default.");
109  return;
110  }
111  }
112 }
113 #undef DEFAULT_FILENAME
114 
115 
116 const int TUR_FIRST = 1;
117 #define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
118 
119 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
120 
121 REGISTER_TURRET(Null, NEW(Turret));
122 REGISTRY_DEFINE_GET(Turrets, TUR_Null)
123 
124 #include "turret/_mod.qh"
#define LOG_HELPF(...)
Definition: log.qh:96
REGISTRY(Weapons, 72) STATIC_INIT(WeaponPickup)
Definition: all.qh:28
#define NEW(cname,...)
Definition: oo.qh:105
const int CMD_REQUEST_USAGE
Definition: command.qh:4
#define REGISTER_TURRET(id, inst)
Definition: all.qh:119
#define REGISTRY_CHECK(id)
Definition: registry.qh:175
#define LOG_HELP(...)
Definition: log.qh:95
#define REGISTER_REGISTRY(id)
Definition: registry.qh:212
#define REGISTRY_DEFINE_GET(id, null)
Definition: registry.qh:40
#define LOG_INFOF(...)
Definition: log.qh:71
const int CMD_REQUEST_COMMAND
Definition: command.qh:3
#define LOG_INFO(...)
Definition: log.qh:70
const int TUR_FIRST
Definition: all.qh:116
const float FILE_WRITE
Definition: csprogsdefs.qc:233
GENERIC_COMMAND(dumpitems, "Dump all items to the console", false)
Definition: all.qh:36
#define DEFAULT_FILENAME
Definition: all.qh:59
#define BITS(n)
Definition: bits.qh:9
Definition: turret.qh:5