]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Stats: remove dependence on engine assigned stats
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 24cfe46abdfe5dc0d6d49f3ac91f5b25c091827f..f25a368fb472ac6be4427012bfb8a52a68f558c2 100644 (file)
@@ -1,7 +1,7 @@
 #include "scoreboard.qh"
 
 #include "quickmenu.qh"
-#include "hud.qh"
+#include "hud/all.qh"
 
 #include "../common/constants.qh"
 #include "../common/mapinfo.qh"
@@ -995,35 +995,28 @@ float HUD_WouldDrawScoreboard() {
 
 float average_accuracy;
 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
-{SELFPARAM();
+{
+       SELFPARAM();
        WepSet weapons_stat = WepSet_GetFromStat();
        WepSet weapons_inmap = WepSet_GetFromStat_InMap();
        float initial_posx = pos.x;
-       int i;
-       float weapon_stats;
        int disownedcnt = 0;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
+       for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
                setself(get_weaponinfo(i));
-               if(!self.weapon)
-                       continue;
+               if (!self.weapon) continue;
 
-               weapon_stats = weapon_accuracy[i-WEP_FIRST];
+               int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+               if (weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
                        ++disownedcnt;
        }
 
        int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt;
+       if (weapon_cnt <= 0) return pos;
 
-       if(weapon_cnt <= 0)
-               return pos;
-
-       int rows;
-       if(autocvar_scoreboard_accuracy_doublerows && weapon_cnt >= floor((Weapons_COUNT - 1) * 0.5))
+       int rows = 1;
+       if (autocvar_scoreboard_accuracy_doublerows && weapon_cnt >= floor((Weapons_COUNT - 1) * 0.5))
                rows = 2;
-       else
-               rows = 1;
        int columnns = ceil(weapon_cnt / rows);
 
        float height = 40;
@@ -1044,24 +1037,24 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // column highlighting
-       for(i = 0; i < columnns; ++i)
+       for (int i = 0; i < columnns; ++i)
        {
-               if(!(i % 2))
+               if ((i % 2) == 0)
                        drawfill(pos + '1 0 0' * weapon_width * rows * i, '0 1 0' * height * rows + '1 0 0' * weapon_width * rows, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
        }
 
        // row highlighting
-       for(i = 0; i < rows; ++i)
+       for (int i = 0; i < rows; ++i)
        {
                drawfill(pos + '0 1 0' * weapon_height + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
        }
 
        average_accuracy = 0;
        int weapons_with_stats = 0;
-       if(rows == 2)
+       if (rows == 2)
                pos.x += weapon_width / 2;
 
-       if(autocvar_scoreboard_accuracy_nocolors)
+       if (autocvar_scoreboard_accuracy_nocolors)
                rgb = '1 1 1';
        else
                Accuracy_LoadColors();
@@ -1069,19 +1062,17 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        float oldposx = pos.x;
        vector tmpos = pos;
 
-       int column;
-       for(i = WEP_FIRST, column = 0; i <= WEP_LAST; ++i)
-       {
+       int column = 0;
+       for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
                setself(get_weaponinfo(i));
-               if (!self.weapon)
-                       continue;
-               weapon_stats = weapon_accuracy[i-WEP_FIRST];
+               if (!self.weapon) continue;
+               int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+               if (weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
                        continue;
 
                float weapon_alpha;
-               if(weapon_stats >= 0)
+               if (weapon_stats >= 0)
                        weapon_alpha = scoreboard_alpha_fg;
                else
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;
@@ -1089,7 +1080,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                // weapon icon
                drawpic_aspect_skin(tmpos, self.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
                // the accuracy
-               if(weapon_stats >= 0) {
+               if (weapon_stats >= 0) {
                        weapons_with_stats += 1;
                        average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy
 
@@ -1106,7 +1097,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                }
                tmpos.x += weapon_width * rows;
                pos.x += weapon_width * rows;
-               if(rows == 2 && column == columnns - 1) {
+               if (rows == 2 && column == columnns - 1) {
                        tmpos.x = oldposx;
                        tmpos.y += height;
                        pos.y += height;
@@ -1114,7 +1105,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                ++column;
        }
 
-       if(weapons_with_stats)
+       if (weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
 
        pos.y += height;
@@ -1142,12 +1133,12 @@ vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
        string val;
 
        // get monster stats
-       stat_monsters_killed = getstatf(STAT_MONSTERS_KILLED);
-       stat_monsters_total = getstatf(STAT_MONSTERS_TOTAL);
+       stat_monsters_killed = STAT(MONSTERS_KILLED);
+       stat_monsters_total = STAT(MONSTERS_TOTAL);
 
        // get secrets stats
-       stat_secrets_found = getstatf(STAT_SECRETS_FOUND);
-       stat_secrets_total = getstatf(STAT_SECRETS_TOTAL);
+       stat_secrets_found = STAT(SECRETS_FOUND);
+       stat_secrets_total = STAT(SECRETS_TOTAL);
 
        // get number of rows
        if(stat_secrets_total)
@@ -1370,7 +1361,7 @@ void HUD_DrawScoreboard()
                }
                pos = HUD_DrawScoreboardRankings(pos, playerslots[player_localnum], rgb, bg_size);
        }
-       else if(autocvar_scoreboard_accuracy && spectatee_status == 0 && !warmup_stage && gametype != MAPINFO_TYPE_NEXBALL) {
+       else if (autocvar_scoreboard_accuracy && !warmup_stage && gametype != MAPINFO_TYPE_NEXBALL) {
                if(teamplay)
                        pos = HUD_DrawScoreboardAccuracyStats(pos, Team_ColorRGB(myteam), bg_size);
                else
@@ -1411,9 +1402,9 @@ void HUD_DrawScoreboard()
        // Print info string
        float tl, fl, ll;
        str = sprintf(_("playing ^3%s^7 on ^2%s^7"), MapInfo_Type_ToText(gametype), shortmapname);
-       tl = getstatf(STAT_TIMELIMIT);
-       fl = getstatf(STAT_FRAGLIMIT);
-       ll = getstatf(STAT_LEADLIMIT);
+       tl = STAT(TIMELIMIT);
+       fl = STAT(FRAGLIMIT);
+       ll = STAT(LEADLIMIT);
        if(gametype == MAPINFO_TYPE_LMS)
        {
                if(tl > 0)
@@ -1467,7 +1458,7 @@ void HUD_DrawScoreboard()
        drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, true, hud_fontsize)), str, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
 
        // print information about respawn status
-       float respawn_time = getstatf(STAT_RESPAWN_TIME);
+       float respawn_time = STAT(RESPAWN_TIME);
        if(!intermission)
        if(respawn_time)
        {