8db08079769a930a8a24bcb1afd20b5b10a6a09f
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qc
1 #if defined(CSQC)
2 #elif defined(MENUQC)
3 #elif defined(SVQC)
4         #include "../../dpdefs/progsdefs.qh"
5     #include "../../dpdefs/dpextensions.qh"
6     #include "../util.qh"
7     #include "config.qh"
8     #include "all.qh"
9 #endif
10
11 // ==========================
12 //  Balance Config Generator
13 // ==========================
14
15 void W_Config_Queue_Swap(int root, int child, entity pass)
16 {
17         string oldroot = wep_config_queue[root];
18         wep_config_queue[root] = wep_config_queue[child];
19         wep_config_queue[child] = oldroot;
20 }
21
22 float W_Config_Queue_Compare(int root, int child, entity pass)
23 {
24         return strcmp(wep_config_queue[root], wep_config_queue[child]);
25 }
26
27 void Dump_Weapon_Settings(void)
28 {
29         int i, x, totalsettings = 0;
30         for(i = WEP_FIRST; i <= WEP_LAST; ++i)
31         {
32                 // step 1: clear the queue
33                 WEP_CONFIG_COUNT = 0;
34                 for(x = 0; x <= MAX_WEP_CONFIG; ++x)
35                         { wep_config_queue[x] = string_null; }
36
37                 // step 2: build new queue
38                 _WEP_ACTION(i, WR_CONFIG);
39
40                 // step 3: sort queue
41                 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, world);
42
43                 // step 4: write queue
44                 WEP_CONFIG_WRITETOFILE(sprintf(
45                         "// {{{ #%d: %s%s\n",
46                         i,
47                         WEP_NAME(i),
48                         (((get_weaponinfo(i)).spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
49                 ));
50                 for(x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); }
51                 WEP_CONFIG_WRITETOFILE("// }}}\n");
52
53                 // step 5: debug info
54                 LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, WEP_NAME(i), WEP_CONFIG_COUNT));
55                 totalsettings += WEP_CONFIG_COUNT;
56         }
57
58         // clear queue now that we're finished
59         WEP_CONFIG_COUNT = 0;
60         for(x = 0; x <= MAX_WEP_CONFIG; ++x)
61                 { wep_config_queue[x] = string_null; }
62
63         // extra information
64         LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", (i - 1), totalsettings));
65 }