From 172a0d7c18d0c33ede2e12fb69790bdaf89ad650 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 3 Nov 2010 00:44:34 +0100 Subject: [PATCH] Get the accuracy stats when displaying the scoreboard to see them updated in real time! (FFS! It was only that...) And in the HUD get them only if we really display them... --- qcsrc/client/hud.qc | 22 +++++++++++----------- qcsrc/client/scoreboard.qc | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 43658f31b..214d09106 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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"); diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index f6aaeed46..b016da763 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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; -- 2.39.2