]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 e7c0f946bd5dc75692c4a849a5b1ac7a956934ba..98710d25b8d6f0e5ad9ff1141e9692f9ecd19a40 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';
 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
 
 
 #endif
 
 
index 68cac084649dba3baa49ae258a438d25313d5444..7d1a81d490b1be213ad7d12faa20ca3d6e2d6355 100644 (file)
@@ -5,9 +5,9 @@
 
 void T_Config_Queue_Swap(float root, float child, entity pass)
 {
 
 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)
 }
 
 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)
        {
 
        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; }
                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;
        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);
 
                // 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)
                // 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
                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;
 
        // 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));
 
        // extra information
        LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings));
index caa68a86487dcd3780eb9c277f93aab8eacaa635..ac09e9e37248f3f5320a1df3267f758820140126 100644 (file)
@@ -6,10 +6,7 @@ void Dump_Turret_Settings();
 float tur_config_file;
 float tur_config_alsoprint;
 
 float tur_config_file;
 float tur_config_alsoprint;
 
-const int MAX_TUR_CONFIG = 256;
 float TUR_CONFIG_COUNT;
 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); } }
 #define TUR_CONFIG_WRITETOFILE(a) { \
        fputs(tur_config_file, a); \
        if(tur_config_alsoprint) { LOG_INFO(a); } }
index 4f6177b478f17bc870366358618c21d44133f3a7..7f87388db13b3b1964a360597b45ea013b28373b 100644 (file)
 
 void W_Config_Queue_Swap(int root, int child, entity pass)
 {
 
 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)
 {
 }
 
 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 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;
        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);
 
                // 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)" : "")
                ));
                        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
                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;
 
        // 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));
 
        // extra information
        LOG_INFO(sprintf("Totals: %d weapons, %d settings\n", totalweapons, totalsettings));
index 753147307b3a253e9fb86b5b056bcbdab222c096..9489843654f89db445a844973a14b6cd270f8e65 100644 (file)
@@ -9,12 +9,9 @@ void Dump_Weapon_Settings();
 int wep_config_file;
 bool wep_config_alsoprint;
 
 int wep_config_file;
 bool wep_config_alsoprint;
 
-const int MAX_WEP_CONFIG = 256;
 int WEP_CONFIG_COUNT;
 int WEP_CONFIG_COUNT;
-string wep_config_queue[MAX_WEP_CONFIG];
-
 #define WEP_CONFIG_QUEUE(a) { \
 #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 { \
        ++WEP_CONFIG_COUNT; }
 
 #define WEP_CONFIG_WRITETOFILE(a) MACRO_BEGIN { \