]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Get the accuracy stats when displaying the scoreboard to see them updated in real...
authorterencehill <piuntn@gmail.com>
Tue, 2 Nov 2010 23:44:34 +0000 (00:44 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 2 Nov 2010 23:44:34 +0000 (00:44 +0100)
And in the HUD get them only if we really display them...

qcsrc/client/hud.qc
qcsrc/client/scoreboard.qc

index 43658f31b200b8c5634835e0a43de104e9ee05f6..214d09106c24caf81ee55c40f6e0df2b65cf2500 100644 (file)
@@ -1588,7 +1588,7 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, wpnalpha, weapon_stats, weapon_number, weapon_cnt;
+       float i, weapid, wpnalpha, weapon_cnt;
        weapon_cnt = 0;
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
@@ -1631,15 +1631,6 @@ void HUD_Weapons(void)
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
-       // hits
-       weapon_stats = getstati(STAT_DAMAGE_HITS);
-       weapon_number = weapon_stats & 63;
-       weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-       // fired
-       weapon_stats = getstati(STAT_DAMAGE_FIRED);
-       weapon_number = weapon_stats & 63;
-       weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-
        if(cvar_or("hud_panel_weapons_fade", 1))
        {
                wpnalpha = 3.2 - 2 * (time - weapontime);
@@ -1697,12 +1688,21 @@ void HUD_Weapons(void)
        }
 
        float show_accuracy;
+       float weapon_stats, weapon_number;
        if(cvar("hud_panel_weapons_accuracy") && acc_levels)
        {
+               show_accuracy = true;
+               // hits
+               weapon_stats = getstati(STAT_DAMAGE_HITS);
+               weapon_number = weapon_stats & 63;
+               weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+               // fired
+               weapon_stats = getstati(STAT_DAMAGE_FIRED);
+               weapon_number = weapon_stats & 63;
+               weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
                if (acc_col_x[0] == -1)
                        for (i = 0; i < acc_levels; ++i)
                                acc_col[i] = stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))));
-               show_accuracy = true;
        }
        float label = cvar("hud_panel_weapons_label");
 
index f6aaeed46f76de968a7d3892c8f879a098736e88..b016da7632e0edfb551b38a870fe4a67094807d7 100644 (file)
@@ -942,6 +942,16 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX)
                g_minstagib = 1; // TODO: real detection for minstagib?
 
+       float weapon_stats, weapon_number;
+       // hits
+       weapon_stats = getstati(STAT_DAMAGE_HITS);
+       weapon_number = weapon_stats & 63;
+       weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+       // fired
+       weapon_stats = getstati(STAT_DAMAGE_FIRED);
+       weapon_number = weapon_stats & 63;
+       weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+
        if (!acc_levels)
                rgb = '1 1 1';
        else if (acc_col_x[0] == -1)
@@ -957,12 +967,13 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        continue;
                weapon_hit = weapon_hits[i-WEP_FIRST];
                weapon_damage = weapon_fired[i-WEP_FIRST];
-               if(weapon_damage)
-                       weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
-               float weapon_alpha;
 
+               float weapon_alpha;
                if(weapon_damage)
+               {
+                       weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
                        weapon_alpha = scoreboard_alpha_fg;
+               }
                else
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;