From: terencehill Date: Thu, 17 Jan 2019 18:10:02 +0000 (+0100) Subject: Optimize hud code displaying race/cts records/rankings X-Git-Tag: xonotic-v0.8.5~1659 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3e2e73da5ccfa14e26160b934b9cb35c5b3d4e1f;p=xonotic%2Fxonotic-data.pk3dir.git Optimize hud code displaying race/cts records/rankings --- diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 4d1691a7f..6a905a8d5 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -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) { - 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) diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 4989aac50..54bb4671d 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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; + string zoned_name_self = strzone(strdecolorize(entcs_GetName(player_localnum))); 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(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); @@ -1489,6 +1490,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz pos.y = panel_pos.y; } } + strfree(zoned_name_self); panel_size.x += panel_bg_padding * 2; // restore initial width return end_pos;