6 #include <common/util.qh>
7 #include <common/weapons/all.qh>
10 // ==========================
11 // Balance Config Generator
12 // ==========================
14 void W_Config_Queue(string setting)
16 if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
17 config_queue[WEP_CONFIG_COUNT++] = setting;
20 void W_Config_Queue_Swap(int root, int child, entity pass)
22 string oldroot = config_queue[root];
23 config_queue[root] = config_queue[child];
24 config_queue[child] = oldroot;
27 float W_Config_Queue_Compare(int root, int child, entity pass)
29 return strcmp(config_queue[root], config_queue[child]);
32 void Dump_Weapon_Settings()
34 int totalweapons = 0, totalsettings = 0;
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
42 for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
43 config_queue[x] = string_null;
45 // step 2: build new queue
48 if (WEP_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1)
50 LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS);
55 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, NULL);
57 // step 4: write queue
58 WEP_CONFIG_WRITETOFILE(sprintf(
62 ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
64 for (int x = 0; x < WEP_CONFIG_COUNT; ++x)
65 WEP_CONFIG_WRITETOFILE(config_queue[x]);
66 WEP_CONFIG_WRITETOFILE("// }}}\n");
69 LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT);
71 totalsettings += WEP_CONFIG_COUNT;
74 #undef WEP_CONFIG_WRITETOFILE
77 if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
78 LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings);
80 // clear queue now that we're finished
82 for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
83 config_queue[x] = string_null;