]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/config.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / config.qc
1 #include "config.qh"
2 // ==========================
3 //  Turret Config Generator
4 // ==========================
5
6 #ifdef SVQC
7
8 void T_Config_Queue_Swap(float root, float child, entity pass)
9 {
10         string oldroot = config_queue[root];
11         config_queue[root] = config_queue[child];
12         config_queue[child] = oldroot;
13 }
14
15 float T_Config_Queue_Compare(float root, float child, entity pass)
16 {
17         float i, r, c;
18
19         for (i = 1; i <= 100; ++i) {
20                 r = str2chr(config_queue[root], i);
21                 c = str2chr(config_queue[child], i);
22                 if (r == c) { continue; } else if (c > r) {
23                         return -1;
24                 } else { return 1; }
25         }
26
27         return 0;
28 }
29
30 void Dump_Turret_Settings()
31 {
32         int totalsettings = 0;
33         FOREACH(Turrets, it != TUR_Null, {
34                 // step 1: clear the queue
35                 TUR_CONFIG_COUNT = 0;
36                 for (int j = 0; j <= MAX_CONFIG_SETTINGS; ++j) {
37                         config_queue[j] = string_null;
38                 }
39
40                 // step 2: build new queue
41                 it.tr_config(it);
42
43                 // step 3: sort queue
44                 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
45
46                 // step 4: write queue
47                 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
48                 for (int j = 0; j <= TUR_CONFIG_COUNT; ++j) {
49                         TUR_CONFIG_WRITETOFILE(config_queue[j])
50                         TUR_CONFIG_WRITETOFILE("// }}}\n")
51
52                     // step 5: debug info
53                         LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
54                 }
55                 totalsettings += TUR_CONFIG_COUNT;
56         });
57
58         // clear queue now that we're finished
59         TUR_CONFIG_COUNT = 0;
60         for (int j = 0; j <= MAX_CONFIG_SETTINGS; ++j) {
61                 config_queue[j] = string_null;
62         }
63
64         // extra information
65         LOG_INFOF("Totals: %d turrets, %d settings", (Turrets_COUNT - 1), totalsettings);
66 }
67
68 #endif