Xonotic
config.qc
Go to the documentation of this file.
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 
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
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 }
string string_null
Definition: nil.qh:9
float W_Config_Queue_Compare(int root, int child, entity pass)
Definition: config.qc:27
entity() spawn
#define WEP_CONFIG_WRITETOFILE(str)
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
Definition: sort.qh:9
#define strcmp
Definition: dpextensions.qh:51
void W_Config_Queue(string setting)
Definition: config.qc:14
#define LOG_INFOF(...)
Definition: log.qh:71
void W_Config_Queue_Swap(int root, int child, entity pass)
Definition: config.qc:20
for(int slot=0;slot< MAX_WEAPONSLOTS;++slot)
Definition: impulse.qc:97
#define NULL
Definition: post.qh:17
const int WEP_FLAG_SPECIALATTACK
Definition: weapon.qh:211
const int WEP_FLAG_MUTATORBLOCKED
Definition: weapon.qh:203
#define pass(name, colormin, colormax)
#define FOREACH(list, cond, body)
Definition: iter.qh:19
void Dump_Weapon_Settings()
Definition: config.qc:32