]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/config.qc
Clear weapon config queue when finished dumping settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qc
1 // ==========================
2 //  Balance Config Generator
3 // ==========================
4
5 void W_Config_Queue_Swap(float root, float child, entity pass)
6 {
7         string oldroot = wep_config_queue[root];
8         wep_config_queue[root] = wep_config_queue[child];
9         wep_config_queue[child] = oldroot;
10 }
11
12 float W_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(wep_config_queue[root], i);
19                 c = str2chr(wep_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_Weapon_Settings(void)
29 {
30         float i, x, totalsettings = 0;
31         for(i = WEP_FIRST; i <= WEP_LAST; ++i)
32         {
33                 // step 1: clear the queue
34                 WEP_CONFIG_COUNT = 0;
35                 for(x = 0; x <= MAX_WEP_CONFIG; ++x)
36                         { wep_config_queue[x] = string_null; }
37
38                 // step 2: build new queue
39                 WEP_ACTION(i, WR_CONFIG);
40
41                 // step 3: sort queue
42                 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, world);
43                 
44                 // step 4: write queue
45                 WEP_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, W_Name(i)))
46                 for(x = 0; x <= WEP_CONFIG_COUNT; ++x)
47                         { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]) }
48                 WEP_CONFIG_WRITETOFILE("// }}}\n")
49
50                 // step 5: debug info
51                 print(sprintf("#%d: %s: %d settings...\n", i, W_Name(i), WEP_CONFIG_COUNT));
52                 totalsettings += WEP_CONFIG_COUNT;
53         }
54
55         // clear queue now that we're finished
56         WEP_CONFIG_COUNT = 0;
57         for(x = 0; x <= MAX_WEP_CONFIG; ++x)
58                 { wep_config_queue[x] = string_null; }
59
60         // extra information
61         print(sprintf("Totals: %d weapons, %d settings\n", (i - 1), totalsettings));
62 }