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