]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/config.qc
Logging: tidy
[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         {
21                 r = str2chr(config_queue[root], i);
22                 c = str2chr(config_queue[child], i);
23                 if(r == c) { continue; }
24                 else if(c > r) { return -1; }
25                 else { return 1; }
26         }
27
28         return 0;
29 }
30
31 void Dump_Turret_Settings()
32 {
33         int totalsettings = 0;
34         FOREACH(Turrets, it != TUR_Null, {
35                 // step 1: clear the queue
36                 TUR_CONFIG_COUNT = 0;
37                 for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
38                         config_queue[j] = string_null;
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...\n", i, it.turret_name, TUR_CONFIG_COUNT);
54                 totalsettings += TUR_CONFIG_COUNT;
55         });
56
57         // clear queue now that we're finished
58         TUR_CONFIG_COUNT = 0;
59         for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
60                 config_queue[j] = string_null;
61
62         // extra information
63         LOG_INFOF("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings);
64 }
65
66 #endif