]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 126cc904d02aab36c43c7f903e3a769f6b53d375..7dcf9876983761fb500f562da5fd62c026c1218f 100644 (file)
@@ -1,15 +1,14 @@
 #include "scoreboard.qh"
-#include "_all.qh"
 
-#include "hud.qh"
-#include "sortlist.qh"
+#include "hud/panel/quickmenu.qh"
+#include "hud/all.qh"
 
-#include "../common/constants.qh"
-#include "../common/counting.qh"
-#include "../common/mapinfo.qh"
-#include "../common/stats.qh"
-#include "../common/teams.qh"
-#include "../common/util.qh"
+#include <common/ent_cs.qh>
+#include <common/constants.qh>
+#include <common/mapinfo.qh>
+#include <common/minigames/cl_minigames.qh>
+#include <common/stats.qh>
+#include <common/teams.qh>
 
 float scoreboard_alpha_bg;
 float scoreboard_alpha_fg;
@@ -35,6 +34,8 @@ string TranslateScoresLabel(string l)
                case "captime": return CTX(_("SCO^captime"));
                case "deaths": return CTX(_("SCO^deaths"));
                case "destroyed": return CTX(_("SCO^destroyed"));
+               case "dmg": return CTX(_("SCO^dmg"));
+               case "dmgtaken": return CTX(_("SCO^dmgtaken"));
                case "drops": return CTX(_("SCO^drops"));
                case "faults": return CTX(_("SCO^faults"));
                case "fckills": return CTX(_("SCO^fckills"));
@@ -109,7 +110,7 @@ void HUD_UpdatePlayerTeams()
        for(pl = players.sort_next; pl; pl = pl.sort_next)
        {
                num += 1;
-               Team = GetPlayerColor(pl.sv_entnum);
+               Team = entcs_GetScoreTeam(pl.sv_entnum);
                if(SetTeam(pl, Team))
                {
                        tmp = pl.sort_prev;
@@ -127,8 +128,9 @@ void HUD_UpdatePlayerTeams()
        */
 }
 
-int HUD_CompareScore(float vl, float vr, int f)
+int HUD_CompareScore(int vl, int vr, int f)
 {
+    TC(int, vl); TC(int, vr); TC(int, f);
        if(f & SFL_ZERO_IS_WORST)
        {
                if(vl == 0 && vr != 0)
@@ -146,8 +148,8 @@ int HUD_CompareScore(float vl, float vr, int f)
 float HUD_ComparePlayerScores(entity left, entity right)
 {
        float vl, vr, r;
-       vl = GetPlayerColor(left.sv_entnum);
-       vr = GetPlayerColor(right.sv_entnum);
+       vl = entcs_GetTeam(left.sv_entnum);
+       vr = entcs_GetTeam(right.sv_entnum);
 
        if(!left.gotscores)
                vl = NUM_SPECTATOR;
@@ -246,71 +248,75 @@ void HUD_UpdateTeamPos(entity Team)
 
 void Cmd_HUD_Help()
 {
-       print(_("You can modify the scoreboard using the ^2scoreboard_columns_set command.\n"));
-       print(_("^3|---------------------------------------------------------------|\n"));
-       print(_("Usage:\n"));
-       print(_("^2scoreboard_columns_set default\n"));
-       print(_("^2scoreboard_columns_set ^7field1 field2 ...\n"));
-       print(_("The following field names are recognized (case insensitive):\n"));
-       print(_("You can use a ^3|^7 to start the right-aligned fields.\n\n"));
-
-       print(_("^3name^7 or ^3nick^7             Name of a player\n"));
-       print(_("^3ping^7                     Ping time\n"));
-       print(_("^3pl^7                       Packet loss\n"));
-       print(_("^3kills^7                    Number of kills\n"));
-       print(_("^3deaths^7                   Number of deaths\n"));
-       print(_("^3suicides^7                 Number of suicides\n"));
-       print(_("^3frags^7                    kills - suicides\n"));
-       print(_("^3kd^7                       The kill-death ratio\n"));
-       print(_("^3sum^7                      frags - deaths\n"));
-       print(_("^3caps^7                     How often a flag (CTF) or a key (KeyHunt) was captured\n"));
-       print(_("^3pickups^7                  How often a flag (CTF) or a key (KeyHunt) or a ball (Keepaway) was picked up\n"));
-       print(_("^3captime^7                  Time of fastest cap (CTF)\n"));
-       print(_("^3fckills^7                  Number of flag carrier kills\n"));
-       print(_("^3returns^7                  Number of flag returns\n"));
-       print(_("^3drops^7                    Number of flag drops\n"));
-       print(_("^3lives^7                    Number of lives (LMS)\n"));
-       print(_("^3rank^7                     Player rank\n"));
-       print(_("^3pushes^7                   Number of players pushed into void\n"));
-       print(_("^3destroyed^7                Number of keys destroyed by pushing them into void\n"));
-       print(_("^3kckills^7                  Number of keys carrier kills\n"));
-       print(_("^3losses^7                   Number of times a key was lost\n"));
-       print(_("^3laps^7                     Number of laps finished (race/cts)\n"));
-       print(_("^3time^7                     Total time raced (race/cts)\n"));
-       print(_("^3fastest^7                  Time of fastest lap (race/cts)\n"));
-       print(_("^3ticks^7                    Number of ticks (DOM)\n"));
-       print(_("^3takes^7                    Number of domination points taken (DOM)\n"));
-       print(_("^3bckills^7                  Number of ball carrier kills\n"));
-       print(_("^3bctime^7                   Total amount of time holding the ball in Keepaway\n"));
-       print(_("^3score^7                    Total score\n\n"));
-
-       print(_("Before a field you can put a + or - sign, then a comma separated list\n"
+       LOG_INFO(_("You can modify the scoreboard using the ^2scoreboard_columns_set command.\n"));
+       LOG_INFO(_("^3|---------------------------------------------------------------|\n"));
+       LOG_INFO(_("Usage:\n"));
+       LOG_INFO(_("^2scoreboard_columns_set default\n"));
+       LOG_INFO(_("^2scoreboard_columns_set ^7field1 field2 ...\n"));
+       LOG_INFO(_("The following field names are recognized (case insensitive):\n"));
+       LOG_INFO(_("You can use a ^3|^7 to start the right-aligned fields.\n\n"));
+
+       LOG_INFO(_("^3name^7 or ^3nick^7             Name of a player\n"));
+       LOG_INFO(_("^3ping^7                     Ping time\n"));
+       LOG_INFO(_("^3pl^7                       Packet loss\n"));
+       LOG_INFO(_("^3kills^7                    Number of kills\n"));
+       LOG_INFO(_("^3deaths^7                   Number of deaths\n"));
+       LOG_INFO(_("^3suicides^7                 Number of suicides\n"));
+       LOG_INFO(_("^3frags^7                    kills - suicides\n"));
+       LOG_INFO(_("^3kd^7                       The kill-death ratio\n"));
+       LOG_INFO(_("^3dmg^7                      The total damage done\n"));
+       LOG_INFO(_("^3dmgtaken^7                 The total damage taken\n"));
+       LOG_INFO(_("^3sum^7                      frags - deaths\n"));
+       LOG_INFO(_("^3caps^7                     How often a flag (CTF) or a key (KeyHunt) was captured\n"));
+       LOG_INFO(_("^3pickups^7                  How often a flag (CTF) or a key (KeyHunt) or a ball (Keepaway) was picked up\n"));
+       LOG_INFO(_("^3captime^7                  Time of fastest cap (CTF)\n"));
+       LOG_INFO(_("^3fckills^7                  Number of flag carrier kills\n"));
+       LOG_INFO(_("^3returns^7                  Number of flag returns\n"));
+       LOG_INFO(_("^3drops^7                    Number of flag drops\n"));
+       LOG_INFO(_("^3lives^7                    Number of lives (LMS)\n"));
+       LOG_INFO(_("^3rank^7                     Player rank\n"));
+       LOG_INFO(_("^3pushes^7                   Number of players pushed into void\n"));
+       LOG_INFO(_("^3destroyed^7                Number of keys destroyed by pushing them into void\n"));
+       LOG_INFO(_("^3kckills^7                  Number of keys carrier kills\n"));
+       LOG_INFO(_("^3losses^7                   Number of times a key was lost\n"));
+       LOG_INFO(_("^3laps^7                     Number of laps finished (race/cts)\n"));
+       LOG_INFO(_("^3time^7                     Total time raced (race/cts)\n"));
+       LOG_INFO(_("^3fastest^7                  Time of fastest lap (race/cts)\n"));
+       LOG_INFO(_("^3ticks^7                    Number of ticks (DOM)\n"));
+       LOG_INFO(_("^3takes^7                    Number of domination points taken (DOM)\n"));
+       LOG_INFO(_("^3bckills^7                  Number of ball carrier kills\n"));
+       LOG_INFO(_("^3bctime^7                   Total amount of time holding the ball in Keepaway\n"));
+       LOG_INFO(_("^3score^7                    Total score\n\n"));
+
+       LOG_INFO(_("Before a field you can put a + or - sign, then a comma separated list\n"
                "of game types, then a slash, to make the field show up only in these\n"
                "or in all but these game types. You can also specify 'all' as a\n"
                "field to show all fields available for the current game mode.\n\n"));
 
-       print(_("The special game type names 'teams' and 'noteams' can be used to\n"
+       LOG_INFO(_("The special game type names 'teams' and 'noteams' can be used to\n"
                "include/exclude ALL teams/noteams game modes.\n\n"));
 
-       print(_("Example: scoreboard_columns_set name ping pl | +ctf/field3 -dm/field4\n"));
-       print(_("will display name, ping and pl aligned to the left, and the fields\n"
+       LOG_INFO(_("Example: scoreboard_columns_set name ping pl | +ctf/field3 -dm/field4\n"));
+       LOG_INFO(_("will display name, ping and pl aligned to the left, and the fields\n"
                "right of the vertical bar aligned to the right.\n"));
-       print(_("'field3' will only be shown in CTF, and 'field4' will be shown in all\n"
+       LOG_INFO(_("'field3' will only be shown in CTF, and 'field4' will be shown in all\n"
                "other gamemodes except DM.\n"));
 }
 
 #define HUD_DefaultColumnLayout() \
 "ping pl name | " \
-"-teams,race,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,race,ka/suicides +ft,tdm/suicides -race,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \
+"-teams,cts,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,rc,ka/suicides +ft,tdm/suicides -cts,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \
+"-rc,cts,nb/dmg -rc,cts,nb/dmgtaken " \
 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns +ons/caps +ons/takes " \
 "+lms/lives +lms/rank " \
 "+kh/caps +kh/pushes +kh/destroyed " \
-"?+race/laps ?+race/time ?+race/fastest " \
+"?+rc/laps ?+rc/time ?+rc/fastest " \
 "+as/objectives +nb/faults +nb/goals +ka/pickups +ka/bckills +ka/bctime +ft/revivals " \
-"-lms,race,nb/score"
+"-lms,rc,nb/score"
 
-void Cmd_HUD_SetFields(float argc)
+void Cmd_HUD_SetFields(int argc)
 {
+    TC(int, argc);
        int i, j, slash;
        string str, pattern;
        float have_name = 0, have_primary = 0, have_secondary = 0, have_separator = 0;
@@ -387,41 +393,40 @@ void Cmd_HUD_SetFields(float argc)
                hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize);
                str = strtolower(str);
 
-               if(str == "ping") {
-                       hud_field[hud_num_fields] = SP_PING;
-               } else if(str == "pl") {
-                       hud_field[hud_num_fields] = SP_PL;
-               } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
-                       hud_field[hud_num_fields] = SP_KDRATIO;
-               } else if(str == "sum" || str == "diff" || str == "k-d") {
-                       hud_field[hud_num_fields] = SP_SUM;
-               } else if(str == "name" || str == "nick") {
-                       hud_field[hud_num_fields] = SP_NAME;
-                       have_name = 1;
-               } else if(str == "|") {
-                       hud_field[hud_num_fields] = SP_SEPARATOR;
-                       have_separator = 1;
-               } else {
-                       for(j = 0; j < MAX_SCORE; ++j)
-                               if(str == strtolower(scores_label[j]))
-                                       goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
-:notfound
-                       if(str == "frags")
-                       {
-                               j = SP_FRAGS;
-                       }
-                       else
+               switch(str)
+               {
+                       case "ping": hud_field[hud_num_fields] = SP_PING; break;
+                       case "pl": hud_field[hud_num_fields] = SP_PL; break;
+                       case "pl": hud_field[hud_num_fields] = SP_PL; break;
+                       case "kd": case "kdr": case "kdratio": case "k/d": hud_field[hud_num_fields] = SP_KDRATIO; break;
+                       case "sum": case "diff": case "k-d": hud_field[hud_num_fields] = SP_SUM; break;
+                       case "name": case "nick": hud_field[hud_num_fields] = SP_NAME; have_name = true; break;
+                       case "|": hud_field[hud_num_fields] = SP_SEPARATOR; have_separator = true; break;
+                       case "dmg": hud_field[hud_num_fields] = SP_DMG; break;
+                       case "dmgtaken": hud_field[hud_num_fields] = SP_DMGTAKEN; break;
+                       default:
                        {
-                               if (!nocomplain)
-                                       printf("^1Error:^7 Unknown score field: '%s'\n", str);
-                               continue;
+                               for(j = 0; j < MAX_SCORE; ++j)
+                                       if(str == strtolower(scores_label[j]))
+                                               goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
+
+LABEL(notfound)
+                               if(str == "frags")
+                                       j = SP_FRAGS;
+                               else
+                               {
+                                       if(!nocomplain)
+                                               LOG_INFOF("^1Error:^7 Unknown score field: '%s'\n", str);
+                                       continue;
+                               }
+LABEL(found)
+                               hud_field[hud_num_fields] = j;
+                               if(j == ps_primary)
+                                       have_primary = 1;
+                               if(j == ps_secondary)
+                                       have_secondary = 1;
+
                        }
-:found
-                       hud_field[hud_num_fields] = j;
-                       if(j == ps_primary)
-                               have_primary = 1;
-                       if(j == ps_secondary)
-                               have_secondary = 1;
                }
                ++hud_num_fields;
                if(hud_num_fields >= MAX_HUD_FIELDS)
@@ -450,7 +455,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_title[0] = strzone(TranslateScoresLabel("name"));
                        hud_field[0] = SP_NAME;
                        ++hud_num_fields;
-                       print("fixed missing field 'name'\n");
+                       LOG_INFO("fixed missing field 'name'\n");
 
                        if(!have_separator)
                        {
@@ -465,7 +470,7 @@ void Cmd_HUD_SetFields(float argc)
                                hud_field[1] = SP_SEPARATOR;
                                hud_size[1] = stringwidth("|", false, hud_fontsize);
                                ++hud_num_fields;
-                               print("fixed missing field '|'\n");
+                               LOG_INFO("fixed missing field '|'\n");
                        }
                }
                else if(!have_separator)
@@ -475,7 +480,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth("|", false, hud_fontsize);
                        hud_field[hud_num_fields] = SP_SEPARATOR;
                        ++hud_num_fields;
-                       print("fixed missing field '|'\n");
+                       LOG_INFO("fixed missing field '|'\n");
                }
                if(!have_secondary)
                {
@@ -484,7 +489,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize);
                        hud_field[hud_num_fields] = ps_secondary;
                        ++hud_num_fields;
-                       printf("fixed missing field '%s'\n", scores_label[ps_secondary]);
+                       LOG_INFOF("fixed missing field '%s'\n", scores_label[ps_secondary]);
                }
                if(!have_primary)
                {
@@ -493,7 +498,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize);
                        hud_field[hud_num_fields] = ps_primary;
                        ++hud_num_fields;
-                       printf("fixed missing field '%s'\n", scores_label[ps_primary]);
+                       LOG_INFOF("fixed missing field '%s'\n", scores_label[ps_primary]);
                }
        }
 
@@ -513,6 +518,7 @@ float hud_field_icon1_alpha;
 float hud_field_icon2_alpha;
 string HUD_GetField(entity pl, int field)
 {
+    TC(int, field);
        float tmp, num, denom;
        int f;
        string str;
@@ -569,7 +575,7 @@ string HUD_GetField(entity pl, int field)
                                        hud_field_icon2_rgb = colormapPaletteColor(f % 16, 1);
                                }
                        }
-                       return GetPlayerName(pl.sv_entnum);
+                       return entcs_GetName(pl.sv_entnum);
 
                case SP_FRAGS:
                        f = pl.(scores[SP_KILLS]);
@@ -603,6 +609,20 @@ string HUD_GetField(entity pl, int field)
                        }
                        return ftos(f);
 
+               case SP_DMG:
+                       num = pl.(scores[SP_DMG]);
+                       denom = 1000;
+
+                       str = sprintf("%.1f k", num/denom);
+                       return str;
+
+               case SP_DMGTAKEN:
+                       num = pl.(scores[SP_DMGTAKEN]);
+                       denom = 1000;
+
+                       str = sprintf("%.1f k", num/denom);
+                       return str;
+
                default:
                        tmp = pl.(scores[field]);
                        f = scores_flags[field];
@@ -623,6 +643,7 @@ float hud_fixscoreboardcolumnwidth_marginlen;
 
 string HUD_FixScoreboardColumnWidth(int i, string str)
 {
+    TC(int, i);
        float field, f;
        vector sz;
        field = hud_field[i];
@@ -687,14 +708,15 @@ string HUD_FixScoreboardColumnWidth(int i, string str)
        return str;
 }
 
-void HUD_PrintScoreboardItem(vector pos, vector item_size, entity pl, float is_self, int pl_number)
+void HUD_PrintScoreboardItem(vector pos, vector item_size, entity pl, bool is_self, int pl_number)
 {
+    TC(bool, is_self); TC(int, pl_number);
        vector tmp, rgb;
        rgb = Team_ColorRGB(pl.team);
        string str;
        int field;
        float is_spec;
-       is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+       is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
 
        if((rgb == '1 1 1') && (!is_spec)) {
                rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
@@ -960,6 +982,8 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
 float HUD_WouldDrawScoreboard() {
        if (autocvar__hud_configure)
                return 0;
+       else if (QuickMenu_IsOpened())
+               return 0;
        else if (HUD_Radar_Clickable())
                return 0;
        else if (scoreboard_showscores)
@@ -968,7 +992,7 @@ float HUD_WouldDrawScoreboard() {
                return 1;
        else if (intermission == 2)
                return 0;
-       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS)
+       else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame)
                return 1;
        else if (scoreboard_showscores_force)
                return 1;
@@ -981,31 +1005,21 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        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)
-       {
-               self = get_weaponinfo(i);
-               if(!self.weapon)
-                       continue;
+       FOREACH(Weapons, it != WEP_Null, {
+               int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               weapon_stats = weapon_accuracy[i-WEP_FIRST];
-
-               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+               WepSet set = it.m_wepset;
+               if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
                        ++disownedcnt;
-       }
+       });
 
-       int weapon_cnt = WEP_COUNT - 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(WEP_COUNT * 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;
@@ -1026,24 +1040,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();
@@ -1051,27 +1065,24 @@ 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)
-       {
-               self = get_weaponinfo(i);
-               if (!self.weapon)
-                       continue;
-               weapon_stats = weapon_accuracy[i-WEP_FIRST];
+       int column = 0;
+       FOREACH(Weapons, it != WEP_Null, {
+               int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
-               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+               WepSet set = it.m_wepset;
+               if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
                        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;
 
                // 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);
+               drawpic_aspect_skin(tmpos, it.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
 
@@ -1088,15 +1099,15 @@ 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;
                }
                ++column;
-       }
+       });
 
-       if(weapons_with_stats)
+       if (weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
 
        pos.y += height;
@@ -1124,12 +1135,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)
@@ -1188,7 +1199,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
                return pos;
 
        float is_spec;
-       is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+       is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
        vector hl_rgb;
        hl_rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
        hl_rgb.y = autocvar_scoreboard_color_bg_g + 0.5;
@@ -1217,7 +1228,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
                        continue;
                n = grecordholder[i];
                p = count_ordinal(i+1);
-               if(grecordholder[i] == GetPlayerName(player_localnum))
+               if(grecordholder[i] == entcs_GetName(player_localnum))
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
                else if(!(i % 2) && scoreboard_highlight)
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
@@ -1297,7 +1308,7 @@ void HUD_DrawScoreboard()
        pos.y += sb_heading_fontsize.y + hud_fontsize.y * 0.25;
 
        // Draw the scoreboard
-       vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * autocvar_scoreboard_bg_scale;
+       vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * ((autocvar_scoreboard_bg_scale > 0) ? autocvar_scoreboard_bg_scale : 0.25);
 
        if(teamplay)
        {
@@ -1307,6 +1318,8 @@ void HUD_DrawScoreboard()
                {
                        if(tm.team == NUM_SPECTATOR)
                                continue;
+                       if(!tm.team && teamplay)
+                               continue;
 
                        draw_beginBoldFont();
                        rgb = Team_ColorRGB(tm.team);
@@ -1336,6 +1349,8 @@ void HUD_DrawScoreboard()
                {
                        if(tm.team == NUM_SPECTATOR)
                                continue;
+                       if(!tm.team && teamplay)
+                               continue;
 
                        pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
                }
@@ -1352,7 +1367,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
@@ -1393,9 +1408,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)
@@ -1449,7 +1464,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)
        {