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