]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/config.qc
Fix dumpweapons including the special attacks
[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         int wepcount = 1;
29         FOREACH(Weapons, it != WEP_Null, {
30                 if((it.spawnflags & WEP_FLAG_HIDDEN) && (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_NORMAL))
31                         continue; // never include the attacks
32                 // step 1: clear the queue
33                 WEP_CONFIG_COUNT = 0;
34                 for (int x = 0; x <= MAX_CONFIG_SETTINGS; ++x)
35                         config_queue[x] = string_null;
36
37                 // step 2: build new queue
38                 it.wr_config(it);
39
40                 // step 3: sort queue
41                 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, NULL);
42
43                 // step 4: write queue
44                 WEP_CONFIG_WRITETOFILE(sprintf(
45                         "// {{{ #%d: %s%s\n",
46                         wepcount,
47                         it.m_name,
48                         ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
49                 ));
50                 for (int x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(config_queue[x]); }
51                 WEP_CONFIG_WRITETOFILE("// }}}\n");
52
53                 // step 5: debug info
54                 LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT);
55                 totalweapons += 1;
56                 totalsettings += WEP_CONFIG_COUNT;
57                 wepcount += 1;
58         });
59
60         // clear queue now that we're finished
61         WEP_CONFIG_COUNT = 0;
62         for(int x = 0; x <= MAX_CONFIG_SETTINGS; ++x)
63                 config_queue[x] = string_null;
64
65         // extra information
66         LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings);
67 }