X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fconfig.qc;h=ab0fa0c17ffa8dc0f75702afa25c070a18b20b7e;hb=2eb6d167f09ac43e99dd4d4397983ceb8491b792;hp=7d1b4e3d262067f491fd6a555f46d1bd1f020769;hpb=c51698509e174e343dff48128a1dcfff1527c535;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/config.qc b/qcsrc/common/weapons/config.qc index 7d1b4e3d2..ab0fa0c17 100644 --- a/qcsrc/common/weapons/config.qc +++ b/qcsrc/common/weapons/config.qc @@ -1,64 +1,83 @@ +#include "config.qh" #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) - #include "../util.qh" - #include "config.qh" - #include "all.qh" + #include + #include "all.qh" #endif // ========================== // Balance Config Generator // ========================== +void W_Config_Queue(string setting) +{ + if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1) + config_queue[WEP_CONFIG_COUNT++] = setting; +} + void W_Config_Queue_Swap(int root, int child, entity pass) { - string oldroot = wep_config_queue[root]; - wep_config_queue[root] = wep_config_queue[child]; - wep_config_queue[child] = oldroot; + string oldroot = config_queue[root]; + config_queue[root] = config_queue[child]; + config_queue[child] = oldroot; } float W_Config_Queue_Compare(int root, int child, entity pass) { - return strcmp(wep_config_queue[root], wep_config_queue[child]); + return strcmp(config_queue[root], config_queue[child]); } -void Dump_Weapon_Settings(void) +void Dump_Weapon_Settings() { - int i, x, totalsettings = 0; - for(i = WEP_FIRST; i <= WEP_LAST; ++i) - { + int totalweapons = 0, totalsettings = 0; + int wepcount = 1; + #define WEP_CONFIG_WRITETOFILE(str) write_String_To_File(wep_config_file, str, wep_config_alsoprint) + FOREACH(Weapons, it != WEP_Null, { + if(it.spawnflags & WEP_FLAG_SPECIALATTACK) + continue; // never include the attacks // step 1: clear the queue WEP_CONFIG_COUNT = 0; - for(x = 0; x <= MAX_WEP_CONFIG; ++x) - { wep_config_queue[x] = string_null; } + for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x) + config_queue[x] = string_null; // step 2: build new queue - Weapon w = get_weaponinfo(i); - w.wr_config(w); + it.wr_config(it); + + if (WEP_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1) + { + LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS); + break; + } // step 3: sort queue - heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, world); + heapsort(WEP_CONFIG_COUNT, W_Config_Queue_Swap, W_Config_Queue_Compare, NULL); // step 4: write queue WEP_CONFIG_WRITETOFILE(sprintf( "// {{{ #%d: %s%s\n", - i, - WEP_NAME(i), - (((get_weaponinfo(i)).spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "") + wepcount, + it.m_name, + ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "") )); - for(x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(wep_config_queue[x]); } + for (int x = 0; x < WEP_CONFIG_COUNT; ++x) + WEP_CONFIG_WRITETOFILE(config_queue[x]); WEP_CONFIG_WRITETOFILE("// }}}\n"); // step 5: debug info - LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, WEP_NAME(i), WEP_CONFIG_COUNT)); + LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT); + totalweapons += 1; totalsettings += WEP_CONFIG_COUNT; - } + wepcount += 1; + }); + #undef WEP_CONFIG_WRITETOFILE + + // extra information + if (WEP_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1) + LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings); // clear queue now that we're finished WEP_CONFIG_COUNT = 0; - for(x = 0; x <= MAX_WEP_CONFIG; ++x) - { wep_config_queue[x] = string_null; } - - // extra information - LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", (i - 1), totalsettings)); + for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x) + config_queue[x] = string_null; }