]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/all.qh
Merge branch 'master' into DefaultUser/armormega
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / all.qh
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 Turrets_from(i) _Turrets_from(i, TUR_Null)
10 #define get_turretinfo(i) Turrets_from(i)
11 REGISTER_REGISTRY(Turrets)
12 REGISTRY_CHECK(Turrets)
13
14
15 GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
16 {
17     switch(request)
18     {
19         case CMD_REQUEST_COMMAND:
20         {
21             #ifdef SVQC
22             tur_config_file = -1;
23             tur_config_alsoprint = -1;
24             string filename = argv(1);
25
26             if(filename == "")
27             {
28                 filename = "turrets_dump.cfg";
29                 tur_config_alsoprint = false;
30             }
31             else if(filename == "-")
32             {
33                 filename = "turrets_dump.cfg";
34                 tur_config_alsoprint = true;
35             }
36             tur_config_file = fopen(filename, FILE_WRITE);
37
38             if(tur_config_file >= 0)
39             {
40                 Dump_Turret_Settings();
41                 LOG_INFO(sprintf("Dumping turrets... File located in ^2data/data/%s^7.\n", filename));
42                 fclose(tur_config_file);
43                 tur_config_file = -1;
44                 tur_config_alsoprint = -1;
45             }
46             else
47             {
48                 LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
49             }
50             #else
51             LOG_INFO(_("Turrets dump command only works with sv_cmd.\n"));
52             #endif
53             return;
54         }
55
56         default:
57         case CMD_REQUEST_USAGE:
58         {
59             LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
60             LOG_INFO("  Where 'filename' is the file to write (default is turrets_dump.cfg),\n");
61             LOG_INFO("  if supplied with '-' output to console as well as default,\n");
62             LOG_INFO("  if left blank, it will only write to default.\n");
63             return;
64         }
65     }
66 }
67
68
69 const int TUR_FIRST = 1;
70 #define TUR_LAST (Turrets_COUNT - 1)
71
72 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
73
74 REGISTER_TURRET(Null, NEW(Turret));
75
76 #include "turret/_mod.inc"