]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/config.qc
Merge branch 'master' into terencehill/tooltips_cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / config.qc
1 // ==========================
2 //  Turret Config Generator
3 // ==========================
4
5 void T_Config_Queue_Swap(float root, float child, entity pass)
6 {
7         string oldroot = tur_config_queue[root];
8         tur_config_queue[root] = tur_config_queue[child];
9         tur_config_queue[child] = oldroot;
10 }
11
12 float T_Config_Queue_Compare(float root, float child, entity pass)
13 {
14         float i, r, c;
15
16         for(i = 1; i <= 100; ++i)
17         {
18                 r = str2chr(tur_config_queue[root], i);
19                 c = str2chr(tur_config_queue[child], i);
20                 if(r == c) { continue; }
21                 else if(c > r) { return -1; }
22                 else { return 1; }
23         }
24
25         return 0;
26 }
27
28 void Dump_Turret_Settings(void)
29 {
30         float x, totalsettings = 0;
31         FOREACH(turret_info, it != TUR_Null, LAMBDA({
32                 // step 1: clear the queue
33                 TUR_CONFIG_COUNT = 0;
34                 for(x = 0; x <= MAX_TUR_CONFIG; ++x)
35                         { tur_config_queue[x] = string_null; }
36
37                 // step 2: build new queue
38                 TUR_ACTION(i, TR_CONFIG);
39
40                 // step 3: sort queue
41                 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, world);
42
43                 // step 4: write queue
44                 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, TUR_NAME(i)))
45                 for(x = 0; x <= TUR_CONFIG_COUNT; ++x)
46                         { TUR_CONFIG_WRITETOFILE(tur_config_queue[x]) }
47                 TUR_CONFIG_WRITETOFILE("// }}}\n")
48
49                 // step 5: debug info
50                 LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, TUR_NAME(i), TUR_CONFIG_COUNT));
51                 totalsettings += TUR_CONFIG_COUNT;
52         }));
53
54         // clear queue now that we're finished
55         TUR_CONFIG_COUNT = 0;
56         for(x = 0; x <= MAX_TUR_CONFIG; ++x)
57                 { tur_config_queue[x] = string_null; }
58
59         // extra information
60         LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (TUR_COUNT - 1), totalsettings));
61 }