]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize hud code displaying race/cts records/rankings
authorterencehill <piuntn@gmail.com>
Thu, 17 Jan 2019 18:10:02 +0000 (19:10 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 17 Jan 2019 18:10:02 +0000 (19:10 +0100)
qcsrc/client/hud/panel/modicons.qc
qcsrc/client/hud/panel/scoreboard.qc

index 4d1691a7fd57798ac639b7023f6a04f81e476a36..6a905a8d5b00d236ccb2b3cb9979048d56a73097 100644 (file)
@@ -496,11 +496,16 @@ string race_status_name_prev;
 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
 int race_CheckName(string net_name)
 {
 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
 int race_CheckName(string net_name)
 {
-       int i;
-       for (i=RANKINGS_CNT-1;i>=0;--i)
-               if(strdecolorize(grecordholder[i]) == strdecolorize(net_name))
-                       return i+1;
-       return 0;
+       int rank = 0;
+       string zoned_name = strzone(strdecolorize(entcs_GetName(player_localnum)));
+       for (int i = RANKINGS_CNT - 1; i >= 0; --i)
+               if (strdecolorize(grecordholder[i]) == zoned_name)
+               {
+                       rank = i + 1;
+                       break;
+               }
+       strfree(zoned_name);
+       return rank;
 }
 
 void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
 }
 
 void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
index 4989aac508cdb221238a6593ad28fbfd677e7ccc..54bb4671d3a19b55371b9dc68562aec50c1fda43 100644 (file)
@@ -1459,6 +1459,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz
        vector text_ofs = vec2(0.5 * hud_fontsize.x, (1.25 - 1) / 2 * hud_fontsize.y); // center text vertically
        string str = "";
        int column = 0, j = 0;
        vector text_ofs = vec2(0.5 * hud_fontsize.x, (1.25 - 1) / 2 * hud_fontsize.y); // center text vertically
        string str = "";
        int column = 0, j = 0;
+       string zoned_name_self = strzone(strdecolorize(entcs_GetName(player_localnum)));
        for(i = 0; i < RANKINGS_RECEIVED_CNT; ++i)
        {
                float t;
        for(i = 0; i < RANKINGS_RECEIVED_CNT; ++i)
        {
                float t;
@@ -1466,7 +1467,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz
                if (t == 0)
                        continue;
 
                if (t == 0)
                        continue;
 
-               if(strdecolorize(grecordholder[i]) == strdecolorize(entcs_GetName(player_localnum)))
+               if(strdecolorize(grecordholder[i]) == zoned_name_self)
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha_self, DRAWFLAG_NORMAL);
                else if(!((j + column) & 1) && sbt_highlight)
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL);
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha_self, DRAWFLAG_NORMAL);
                else if(!((j + column) & 1) && sbt_highlight)
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL);
@@ -1489,6 +1490,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz
                        pos.y = panel_pos.y;
                }
        }
                        pos.y = panel_pos.y;
                }
        }
+       strfree(zoned_name_self);
 
        panel_size.x += panel_bg_padding * 2; // restore initial width
        return end_pos;
 
        panel_size.x += panel_bg_padding * 2; // restore initial width
        return end_pos;