]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Fix broken defaut layout caused by recently added tdm columns: strcat accepts max...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 339c8b29bc62fdf7dcb9bb4087c35ccee6a07cfc..d1d06b18675ff9b3d15b8edcd0871b70fde09d33 100644 (file)
@@ -54,20 +54,6 @@ string TranslateScoresLabel(string l)
        }
 }
 
-void MapVote_Draw();
-void HUD_FinaleOverlay()
-{
-       /*vector pos;
-       pos_x = (vid_conwidth - 1)/2;
-       pos_y = 16;
-       pos_z = 0;*/
-
-       //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
-
-       //drawstring(pos, "END", hud_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-       MapVote_Draw();
-}
-
 void Cmd_HUD_SetFields(float argc);
 void HUD_InitScores()
 {
@@ -305,8 +291,7 @@ string HUD_DefaultColumnLayout()
 {
        return strcat( // fteqcc sucks
                "ping pl name | ",
-               "-teams,race,lms/kills +freezetag/kills -teams,lms/deaths +freezetag/deaths -teams,lms,race,ka/suicides +freezetag/suicides -race,dm,tdm,ka,freezetag/frags ", // tdm already has this in "score"
-               "+tdm/kills +tdm/deaths +tdm/suicides ",
+               "-teams,race,lms/kills +freezetag,tdm/kills -teams,lms/deaths +freezetag,tdm/deaths -teams,lms,race,ka/suicides +freezetag,tdm/suicides -race,dm,tdm,ka,freezetag/frags ", // tdm already has this in "score"
                "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
                "+lms/lives +lms/rank ",
                "+kh/caps +kh/pushes +kh/destroyed ",
@@ -375,7 +360,7 @@ void Cmd_HUD_SetFields(float argc)
                        pattern = substring(str, 0, slash);
                        str = substring(str, slash + 1, strlen(str) - (slash + 1));
 
-                       if not(isGametypeInFilter(gametype, teamplay, FALSE, pattern))
+                       if (!isGametypeInFilter(gametype, teamplay, FALSE, pattern))
                                continue;
                }
 
@@ -390,7 +375,7 @@ void Cmd_HUD_SetFields(float argc)
                        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 == "f-d") {
+               } 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;
@@ -409,8 +394,8 @@ void Cmd_HUD_SetFields(float argc)
                        }
                        else
                        {
-                               if not(nocomplain)
-                                       print(sprintf("^1Error:^7 Unknown score field: '%s'\n", str));
+                               if (!nocomplain)
+                                       printf("^1Error:^7 Unknown score field: '%s'\n", str);
                                continue;
                        }
 :found
@@ -481,7 +466,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;
-                       print(sprintf("fixed missing field '%s'\n", scores_label[ps_secondary]));
+                       printf("fixed missing field '%s'\n", scores_label[ps_secondary]);
                }
                if(!have_primary)
                {
@@ -490,7 +475,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;
-                       print(sprintf("fixed missing field '%s'\n", scores_label[ps_primary]));
+                       printf("fixed missing field '%s'\n", scores_label[ps_primary]);
                }
        }
 
@@ -526,7 +511,7 @@ string HUD_GetField(entity pl, float field)
        switch(field)
        {
                case SP_PING:
-                       if not(pl.gotscores)
+                       if (!pl.gotscores)
                                return "\xEE\x82\x8D\xEE\x82\x8D\xEE\x82\x8D"; // >>> sign
                        //str = getplayerkeyvalue(pl.sv_entnum, "ping");
                        f = pl.ping;
@@ -537,7 +522,7 @@ string HUD_GetField(entity pl, float field)
                        return ftos(f);
 
                case SP_PL:
-                       if not(pl.gotscores)
+                       if (!pl.gotscores)
                                return _("N/A");
                        f = pl.ping_packetloss;
                        tmp = pl.ping_movementloss;
@@ -586,7 +571,7 @@ string HUD_GetField(entity pl, float field)
                        } else
                                str = sprintf("%.1f", num/denom);
                        return str;
-                       
+
                case SP_SUM:
                        f = pl.(scores[SP_KILLS]);
                        f -= pl.(scores[SP_DEATHS]);
@@ -979,7 +964,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        float fontsize = height * 1/3;
        float weapon_height = height * 2/3;
        float weapon_width = sbwidth / weapon_cnt;
-       float g_minstagib = 0;
+       float g_instagib = 0;
 
        drawstring(pos, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness;
@@ -1013,7 +998,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                pos_x += weapon_width / 2;
 
        if(switchweapon == WEP_MINSTANEX)
-               g_minstagib = 1; // TODO: real detection for minstagib?
+               g_instagib = 1; // TODO: real detection for instagib?
 
        float weapon_stats;
        if(autocvar_scoreboard_accuracy_nocolors)
@@ -1024,9 +1009,9 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
                self = get_weaponinfo(i);
-               if not(self.weapon)
+               if (!self.weapon)
                        continue;
-               if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA) // skip port-o-launch, nex || minstanex and tuba
+               if ((i == WEP_NEX && g_instagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_instagib) || i == WEP_TUBA) // skip port-o-launch, vortex || vaporizer and tuba
                        continue;
                weapon_stats = weapon_accuracy[i-WEP_FIRST];
 
@@ -1081,31 +1066,39 @@ vector HUD_DrawKeyValue(vector pos, string key, string value) {
        drawstring(pos, value, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_x = px;
        pos_y+= hud_fontsize_y;
-       
+
        return pos;
 }
 
 vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
        float stat_secrets_found, stat_secrets_total;
-       float rows;
+       float stat_monsters_killed, stat_monsters_total;
+       float rows = 0;
        string val;
+       
+       // get monster stats
+       stat_monsters_killed = getstatf(STAT_MONSTERS_KILLED);
+       stat_monsters_total = getstatf(STAT_MONSTERS_TOTAL);
 
        // get secrets stats
        stat_secrets_found = getstatf(STAT_SECRETS_FOUND);
        stat_secrets_total = getstatf(STAT_SECRETS_TOTAL);
 
        // get number of rows
-       rows = (stat_secrets_total ? 1 : 0);
+       if(stat_secrets_total)
+               rows += 1;
+       if(stat_monsters_total)
+               rows += 1;
 
        // if no rows, return
-       if not(rows)
+       if (!rows)
                return pos;
 
        //  draw table header
        drawstring(pos, _("Map stats:"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness;
-       
-       // draw table   
+
+       // draw table
        vector tmp = '0 0 0';
        tmp_x = sbwidth;
        tmp_y = hud_fontsize_y * rows;
@@ -1116,10 +1109,20 @@ vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
                drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
        drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
+       // draw monsters
+       if(stat_monsters_total)
+       {
+               val = sprintf("%d/%d", stat_monsters_killed, stat_monsters_total);
+               pos = HUD_DrawKeyValue(pos, _("Monsters killed:"), val);
+       }
+
        // draw secrets
-       val = sprintf("%d/%d", stat_secrets_found, stat_secrets_total);
-       pos = HUD_DrawKeyValue(pos, _("Secrets found:"), val);
-       
+       if(stat_secrets_total)
+       {
+               val = sprintf("%d/%d", stat_secrets_found, stat_secrets_total);
+               pos = HUD_DrawKeyValue(pos, _("Secrets found:"), val);
+       }
+
        // update position
        pos_y += 1.25 * hud_fontsize_y;
        return pos;
@@ -1207,7 +1210,7 @@ void HUD_DrawScoreboard()
                        scoreboard_fade_alpha = 0;
        }
 
-       if not(scoreboard_fade_alpha)
+       if (!scoreboard_fade_alpha)
                return;
 
        HUD_UpdatePlayerTeams();
@@ -1309,14 +1312,14 @@ void HUD_DrawScoreboard()
                }
                pos = HUD_DrawScoreboardRankings(pos, playerslots[player_localnum], rgb, bg_size);
        }
-       else if(autocvar_scoreboard_accuracy && spectatee_status != -1 && !warmup_stage) {
+       else if(autocvar_scoreboard_accuracy && spectatee_status == 0 && !warmup_stage && gametype != MAPINFO_TYPE_NEXBALL) {
                if(teamplay)
                        pos = HUD_DrawScoreboardAccuracyStats(pos, Team_ColorRGB(myteam), bg_size);
                else
                        pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
        }
 
-               
+
        if(teamplay)
                pos = HUD_DrawMapStats(pos, Team_ColorRGB(myteam), bg_size);
        else
@@ -1345,7 +1348,7 @@ void HUD_DrawScoreboard()
 
        // Print info string
        float tl, fl, ll;
-       str = sprintf(_("playing on ^2%s^7"), shortmapname);
+       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);
@@ -1364,14 +1367,14 @@ void HUD_DrawScoreboard()
                                str = strcat(str, _(" or"));
                        if(teamplay)
                        {
-                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], fl), 
+                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], fl),
                                        (teamscores_label[ts_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(teamscores_label[ts_primary])));
                        }
                        else
                        {
-                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags[ps_primary], fl), 
+                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags[ps_primary], fl),
                                        (scores_label[ps_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(scores_label[ps_primary])));
@@ -1383,14 +1386,14 @@ void HUD_DrawScoreboard()
                                str = strcat(str, _(" or"));
                        if(teamplay)
                        {
-                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], ll), 
+                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], ll),
                                        (teamscores_label[ts_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(teamscores_label[ts_primary])));
                        }
                        else
                        {
-                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags[ps_primary], ll), 
+                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags[ps_primary], ll),
                                        (scores_label[ps_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(scores_label[ps_primary])));
@@ -1403,6 +1406,7 @@ void HUD_DrawScoreboard()
 
        // print information about respawn status
        float respawn_time = getstatf(STAT_RESPAWN_TIME);
+       if(!intermission)
        if(respawn_time)
        {
                if(respawn_time < 0)
@@ -1410,7 +1414,7 @@ void HUD_DrawScoreboard()
                        // a negative number means we are awaiting respawn, time value is still the same
                        respawn_time *= -1; // remove mark now that we checked it
                        respawn_time = max(time, respawn_time); // don't show a negative value while the server is respawning the player (lag)
-                       
+
                        str = sprintf(_("^1Respawning in ^3%s^1..."),
                                (autocvar_scoreboard_respawntime_decimals ?
                                        count_seconds_decs(respawn_time - time, autocvar_scoreboard_respawntime_decimals)