]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/config.qc
Merge branch 'Mario/bot_maxplayers' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / config.qc
index 454ee22a2396b93458a4461c72d6561dd9d1c711..d2443f1670d360767cbc6721f6a2722d2764997c 100644 (file)
+#include "config.qh"
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+    #include <common/util.qh>
+    #include "all.qh"
+#endif
+
 // ==========================
 //  Balance Config Generator
 // ==========================
 
-void Dump_Weapon_Settings(float fh, float alsoprint)
+void W_Config_Queue_Swap(int root, int child, entity pass)
 {
-       float i;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               WEP_ACTION(i, WR_CONFIG)
-       }
-
-                       
-       #define WEP_BAL_WRITE(a) { \
-               fputs(fh, a); \
-               if(alsoprint) { print(a); } }
-       #define WEP_BAL_WRITE_ENTITY(description) { \
-               notif_msg = \
-                       sprintf( \
-                               "seta notification_%s \"%d\" \"%s\"\n", \
-                               e.nent_name, e.nent_default, description \
-                       ); \
-               WEP_BAL_WRITE(notif_msg) }
-       #define WEP_BAL_WRITE_HARDCODED(cvar,default,description) { \
-               notif_msg = \
-                       sprintf( \
-                               "seta notification_%s \"%s\" \"%s\"\n", \
-                               cvar, default, description \
-                       ); \
-               WEP_BAL_WRITE(notif_msg) }
-
-       string notif_msg;
-       float i;
-       entity e;
-
-       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
-       for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_ANNCE, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
-       for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_INFO, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = print to console, "
-                       "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
-       for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_CENTER, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = centerprint"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
-       for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_MULTI, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = trigger subcalls"
-               );
-       }
+       string oldroot = config_queue[root];
+       config_queue[root] = config_queue[child];
+       config_queue[child] = oldroot;
+}
 
-       // edit these to match whichever cvars are used for specific notification options
-       NOTIF_WRITE("\n// HARD CODED notification variables:\n");
-       
-       NOTIF_WRITE_HARDCODED(
-               "allow_chatboxprint", "1",
-               "Allow notifications to be printed to chat box by setting notification cvar to 2 "
-               "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
-       );
+float W_Config_Queue_Compare(int root, int child, entity pass)
+{
+       return strcmp(config_queue[root], config_queue[child]);
+}
 
-       NOTIF_WRITE(sprintf(
-               strcat(
-                       "\n// Notification counts (total = %d): ",
-                       "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n"
-               ),
-               (
-                       NOTIF_ANNCE_COUNT +
-                       NOTIF_INFO_COUNT +
-                       NOTIF_CENTER_COUNT +
-                       NOTIF_MULTI_COUNT
-               ),
-               NOTIF_ANNCE_COUNT,
-               NOTIF_INFO_COUNT,
-               NOTIF_CENTER_COUNT,
-               NOTIF_MULTI_COUNT
-       ));
-       
-       return;
-       #undef NOTIF_WRITE_HARDCODED
-       #undef NOTIF_WRITE_ENTITY
-       #undef NOTIF_WRITE
+void Dump_Weapon_Settings()
+{
+       int totalweapons = 0, totalsettings = 0;
+       FOREACH(Weapons, it != WEP_Null, {
+               // step 1: clear the queue
+               WEP_CONFIG_COUNT = 0;
+               for (int x = 0; x <= MAX_CONFIG_SETTINGS; ++x)
+                       config_queue[x] = string_null;
+
+               // step 2: build new queue
+               it.wr_config(it);
+
+               // step 3: sort queue
+               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,
+                       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]); }
+               WEP_CONFIG_WRITETOFILE("// }}}\n");
+
+               // step 5: debug info
+               LOG_INFOF("#%d: %s: %d settings...", i, it.m_name, WEP_CONFIG_COUNT);
+               totalweapons += 1;
+               totalsettings += WEP_CONFIG_COUNT;
+       });
+
+       // clear queue now that we're finished
+       WEP_CONFIG_COUNT = 0;
+       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);
 }