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