5 #include <common/util.qh>
9 // ==========================
10 // Balance Config Generator
11 // ==========================
13 void W_Config_Queue(string setting)
15 if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
16 config_queue[WEP_CONFIG_COUNT++] = setting;
19 void W_Config_Queue_Swap(int root, int child, entity pass)
21 string oldroot = config_queue[root];
22 config_queue[root] = config_queue[child];
23 config_queue[child] = oldroot;
26 float W_Config_Queue_Compare(int root, int child, entity pass)
28 return strcmp(config_queue[root], config_queue[child]);
31 void Dump_Weapon_Settings()
33 int totalweapons = 0, totalsettings = 0;
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
41 for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
42 config_queue[x] = string_null;
44 // step 2: build new queue
47 if (WEP_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1)
49 LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS);
54 heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, NULL);
56 // step 4: write queue
57 WEP_CONFIG_WRITETOFILE(sprintf(
61 ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
63 for (int x = 0; x < WEP_CONFIG_COUNT; ++x)
64 WEP_CONFIG_WRITETOFILE(config_queue[x]);
65 WEP_CONFIG_WRITETOFILE("// }}}\n");
68 LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT);
70 totalsettings += WEP_CONFIG_COUNT;
73 #undef WEP_CONFIG_WRITETOFILE
76 if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
77 LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings);
79 // clear queue now that we're finished
81 for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
82 config_queue[x] = string_null;