]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/config.qc
Nades code: don't use booleans as array indexes for m_projectile, optimize spawn_held...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qc
index b53e25fde9c95cbdaddc1b987fd30fa16f8f8d16..596540dd3940c64fe04eb22dfaaa98bf097e3ce1 100644 (file)
@@ -1,15 +1,22 @@
 #include "config.qh"
+
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-    #include <common/util.qh>
-    #include "all.qh"
+       #include <common/util.qh>
+       #include <common/weapons/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 = config_queue[root];
@@ -26,17 +33,24 @@ void Dump_Weapon_Settings()
 {
        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_HIDDEN) && (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_NORMAL))
+               if(it.spawnflags & WEP_FLAG_SPECIALATTACK)
                        continue; // never include the attacks
                // step 1: clear the queue
                WEP_CONFIG_COUNT = 0;
-               for (int x = 0; x <= MAX_CONFIG_SETTINGS; ++x)
+               for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
                        config_queue[x] = string_null;
 
                // step 2: build new queue
                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, NULL);
 
@@ -47,7 +61,8 @@ void Dump_Weapon_Settings()
                        it.m_name,
                        ((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) ? " (MUTATOR WEAPON)" : "")
                ));
-               for (int x = 0; x <= WEP_CONFIG_COUNT; ++x) { WEP_CONFIG_WRITETOFILE(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
@@ -56,12 +71,14 @@ void Dump_Weapon_Settings()
                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(int x = 0; x <= MAX_CONFIG_SETTINGS; ++x)
+       for (int x = 0; x < MAX_CONFIG_SETTINGS; ++x)
                config_queue[x] = string_null;
-
-       // extra information
-       LOG_INFOF("Totals: %d weapons, %d settings", totalweapons, totalsettings);
 }