Use a shared array to dump config settings of weapons and turrets, reducing number...
authorterencehill <piuntn@gmail.com>
Fri, 16 Jun 2017 14:34:37 +0000 (16:34 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 16 Jun 2017 14:34:37 +0000 (16:34 +0200)
qcsrc/common/constants.qh
qcsrc/common/turrets/config.qc
qcsrc/common/turrets/config.qh
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/config.qh

index e7c0f94..98710d2 100644 (file)
@@ -256,6 +256,11 @@ vector autocvar_sv_player_crouch_maxs = '16 16 25';
 vector autocvar_sv_player_crouch_mins = '-16 -16 -24';
 vector autocvar_sv_player_crouch_viewoffset = '0 0 20';
 //vector autocvar_sv_player_headsize = '24 24 12';
+
+// temporary array used to dump weapon and turret settings
+const int MAX_CONFIG_SETTINGS = 256;
+string config_queue[MAX_CONFIG_SETTINGS];
+
 #endif
 
 
index 68cac08..7d1a81d 100644 (file)
@@ -5,9 +5,9 @@
 
 void T_Config_Queue_Swap(float root, float child, entity pass)
 {
-       string oldroot = tur_config_queue[root];
-       tur_config_queue[root] = tur_config_queue[child];
-       tur_config_queue[child] = oldroot;
+       string oldroot = config_queue[root];
+       config_queue[root] = config_queue[child];
+       config_queue[child] = oldroot;
 }
 
 float T_Config_Queue_Compare(float root, float child, entity pass)
@@ -16,8 +16,8 @@ float T_Config_Queue_Compare(float root, float child, entity pass)
 
        for(i = 1; i <= 100; ++i)
        {
-               r = str2chr(tur_config_queue[root], i);
-               c = str2chr(tur_config_queue[child], i);
+               r = str2chr(config_queue[root], i);
+               c = str2chr(config_queue[child], i);
                if(r == c) { continue; }
                else if(c > r) { return -1; }
                else { return 1; }
@@ -32,8 +32,8 @@ void Dump_Turret_Settings()
        FOREACH(Turrets, it != TUR_Null, {
                // step 1: clear the queue
                TUR_CONFIG_COUNT = 0;
-               for(int j = 0; j <= MAX_TUR_CONFIG; ++j)
-                       { tur_config_queue[j] = string_null; }
+               for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
+                       config_queue[j] = string_null;
 
                // step 2: build new queue
                it.tr_config(it);
@@ -44,7 +44,7 @@ void Dump_Turret_Settings()
                // step 4: write queue
                TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
                for(int j = 0; j <= TUR_CONFIG_COUNT; ++j)
-                       { TUR_CONFIG_WRITETOFILE(tur_config_queue[j]) }
+                       TUR_CONFIG_WRITETOFILE(config_queue[j])
                TUR_CONFIG_WRITETOFILE("// }}}\n")
 
                // step 5: debug info
@@ -54,8 +54,8 @@ void Dump_Turret_Settings()
 
        // clear queue now that we're finished
        TUR_CONFIG_COUNT = 0;
-       for(int j = 0; j <= MAX_TUR_CONFIG; ++j)
-               { tur_config_queue[j] = string_null; }
+       for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
+               config_queue[j] = string_null;
 
        // extra information
        LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings));
index caa68a8..ac09e9e 100644 (file)
@@ -6,10 +6,7 @@ void Dump_Turret_Settings();
 float tur_config_file;
 float tur_config_alsoprint;
 
-const int MAX_TUR_CONFIG = 256;
 float TUR_CONFIG_COUNT;
-string tur_config_queue[MAX_TUR_CONFIG];
-
 #define TUR_CONFIG_WRITETOFILE(a) { \
        fputs(tur_config_file, a); \
        if(tur_config_alsoprint) { LOG_INFO(a); } }
index 4f6177b..7f87388 100644 (file)
 
 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()
@@ -28,8 +28,8 @@ void Dump_Weapon_Settings()
        FOREACH(Weapons, it != WEP_Null, {
                // step 1: clear the queue
                WEP_CONFIG_COUNT = 0;
-               for (int 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
                it.wr_config(it);
@@ -44,7 +44,7 @@ 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(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
@@ -55,8 +55,8 @@ void Dump_Weapon_Settings()
 
        // clear queue now that we're finished
        WEP_CONFIG_COUNT = 0;
-       for(int 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;
 
        // extra information
        LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", totalweapons, totalsettings));
index 7531473..9489843 100644 (file)
@@ -9,12 +9,9 @@ void Dump_Weapon_Settings();
 int wep_config_file;
 bool wep_config_alsoprint;
 
-const int MAX_WEP_CONFIG = 256;
 int WEP_CONFIG_COUNT;
-string wep_config_queue[MAX_WEP_CONFIG];
-
 #define WEP_CONFIG_QUEUE(a) { \
-       wep_config_queue[WEP_CONFIG_COUNT] = a; \
+       config_queue[WEP_CONFIG_COUNT] = a; \
        ++WEP_CONFIG_COUNT; }
 
 #define WEP_CONFIG_WRITETOFILE(a) MACRO_BEGIN { \