3 #include <common/command/_mod.qh>
8 REGISTRY(Turrets, BITS(5))
9 #define Turrets_from(i) _Turrets_from(i, TUR_Null)
10 #define get_turretinfo(i) Turrets_from(i)
11 REGISTER_REGISTRY(Turrets)
12 REGISTRY_CHECK(Turrets)
14 #define TR_PROPS(L, class, prefix) \
15 L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
18 #define TR_CONFIG(class, turname, fld, T) _TR_CONFIG(class, fld, T, turname)
19 #define TR_CONFIG_BEGIN(class) METHOD(class, tr_config, void(class this)) {
21 #define _TR_CONFIG(class, fld, T, turname) if (#turname == this.netname) TUR_CONFIG_WRITE_CVARS(turname, fld, T);
23 #define _TR_CONFIG(class, fld, T, turname)
25 #define TR_CONFIG_END() }
27 GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
31 case CMD_REQUEST_COMMAND:
35 tur_config_alsoprint = -1;
36 string filename = argv(1);
40 filename = "turrets_dump.cfg";
41 tur_config_alsoprint = false;
43 else if(filename == "-")
45 filename = "turrets_dump.cfg";
46 tur_config_alsoprint = true;
48 tur_config_file = fopen(filename, FILE_WRITE);
50 if(tur_config_file >= 0)
52 Dump_Turret_Settings();
53 LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", filename);
54 fclose(tur_config_file);
56 tur_config_alsoprint = -1;
60 LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
63 LOG_INFO(_("Turrets dump command only works with sv_cmd."));
69 case CMD_REQUEST_USAGE:
71 LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]");
72 LOG_INFO(" Where 'filename' is the file to write (default is turrets_dump.cfg),");
73 LOG_INFO(" if supplied with '-' output to console as well as default,");
74 LOG_INFO(" if left blank, it will only write to default.");
81 const int TUR_FIRST = 1;
82 #define TUR_LAST (Turrets_COUNT - 1)
84 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
86 REGISTER_TURRET(Null, NEW(Turret));
88 #include "turret/_mod.qh"