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