]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/config.qc
Merge branch 'master' into martin-t/available
[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(string setting)
14 {
15         if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
16                 config_queue[WEP_CONFIG_COUNT++] = setting;
17 }
18
19 void W_Config_Queue_Swap(int root, int child, entity pass)
20 {
21         string oldroot = config_queue[root];
22         config_queue[root] = config_queue[child];
23         config_queue[child] = oldroot;
24 }
25
26 float W_Config_Queue_Compare(int root, int child, entity pass)
27 {
28         return strcmp(config_queue[root], config_queue[child]);
29 }
30
31 void Dump_Weapon_Settings()
32 {
33         int totalweapons = 0, totalsettings = 0;
34         int wepcount = 1;
35         #define WEP_CONFIG_WRITETOFILE(str) write_String_To_File(wep_config_file, str, wep_config_alsoprint)
36         FOREACH(Weapons, it != WEP_Null, {
37                 if(it.spawnflags & WEP_FLAG_SPECIALATTACK)
38                         continue; // never include the attacks
39                 // step 1: clear the queue
40                 WEP_CONFIG_COUNT = 0;
41                 for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
42                         config_queue[x] = string_null;
43
44                 // step 2: build new queue
45                 it.wr_config(it);
46
47                 if (WEP_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1)
48                 {
49                         LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS);
50                         break;
51                 }
52
53                 // step 3: sort queue
54                 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, NULL);
55
56                 // step 4: write queue
57                 WEP_CONFIG_WRITETOFILE(sprintf(
58                         "// {{{ #%d: %s%s\n",
59                         wepcount,
60                         it.m_name,
61                         ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
62                 ));
63                 for (int x = 0; x < WEP_CONFIG_COUNT; ++x)
64                         WEP_CONFIG_WRITETOFILE(config_queue[x]);
65                 WEP_CONFIG_WRITETOFILE("// }}}\n");
66
67                 // step 5: debug info
68                 LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT);
69                 totalweapons += 1;
70                 totalsettings += WEP_CONFIG_COUNT;
71                 wepcount += 1;
72         });
73         #undef WEP_CONFIG_WRITETOFILE
74
75         // extra information
76         if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
77                 LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings);
78
79         // clear queue now that we're finished
80         WEP_CONFIG_COUNT = 0;
81         for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
82                 config_queue[x] = string_null;
83 }