From b72b1394c47edad23bfdcc2a51f8e181eb42d556 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Feb 2017 16:28:08 +1000 Subject: [PATCH] Make team coloring of playername an optional parameter, simplifies some code slightly --- qcsrc/common/minigames/minigame/c4.qc | 8 ++++---- qcsrc/common/minigames/minigame/nmm.qc | 8 ++++---- qcsrc/common/minigames/minigame/pp.qc | 8 ++++---- qcsrc/server/miscfunctions.qc | 6 +++--- qcsrc/server/miscfunctions.qh | 2 +- qcsrc/server/player.qc | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/qcsrc/common/minigames/minigame/c4.qc b/qcsrc/common/minigames/minigame/c4.qc index 2a6cb3d47..b3f5885c2 100644 --- a/qcsrc/common/minigames/minigame/c4.qc +++ b/qcsrc/common/minigames/minigame/c4.qc @@ -299,22 +299,22 @@ void c4_hud_board(vector pos, vector mySize) if ( active_minigame.minigame_flags & C4_TURN_WIN ) { vector winfs = hud_fontsize*2; - string playername = ""; + string pname = ""; FOREACH_MINIGAME_ENTITY(e) if ( e.classname == "minigame_player" && e.team == (active_minigame.minigame_flags & C4_TURN_TEAM) ) - playername = entcs_GetName(e.minigame_playerslot-1); + pname = entcs_GetName(e.minigame_playerslot-1); vector win_pos = pos+eY*(mySize_y-winfs_y)/2; vector win_sz; win_sz = minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, 0, DRAWFLAG_NORMAL, 0.5); drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE); minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5); } } diff --git a/qcsrc/common/minigames/minigame/nmm.qc b/qcsrc/common/minigames/minigame/nmm.qc index 4184c2638..bf26a66cc 100644 --- a/qcsrc/common/minigames/minigame/nmm.qc +++ b/qcsrc/common/minigames/minigame/nmm.qc @@ -474,22 +474,22 @@ void nmm_hud_board(vector pos, vector mySize) if ( active_minigame.minigame_flags & NMM_TURN_WIN ) { vector winfs = hud_fontsize*2; - string playername = ""; + string pname = ""; FOREACH_MINIGAME_ENTITY(e) if ( e.classname == "minigame_player" && e.team == (active_minigame.minigame_flags & NMM_TURN_TEAM) ) - playername = entcs_GetName(e.minigame_playerslot-1); + pname = entcs_GetName(e.minigame_playerslot-1); vector win_pos = pos+eY*(mySize_y-winfs_y)/2; vector win_sz; win_sz = minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, 0, DRAWFLAG_NORMAL, 0.5); drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE); minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5); } } diff --git a/qcsrc/common/minigames/minigame/pp.qc b/qcsrc/common/minigames/minigame/pp.qc index 4ae9fb06b..40ddcca08 100644 --- a/qcsrc/common/minigames/minigame/pp.qc +++ b/qcsrc/common/minigames/minigame/pp.qc @@ -350,22 +350,22 @@ void pp_hud_board(vector pos, vector mySize) if ( active_minigame.minigame_flags & PP_TURN_WIN ) { vector winfs = hud_fontsize*2; - string playername = ""; + string pname = ""; FOREACH_MINIGAME_ENTITY(e) if ( e.classname == "minigame_player" && e.team == (active_minigame.minigame_flags & PP_TURN_TEAM) ) - playername = entcs_GetName(e.minigame_playerslot-1); + pname = entcs_GetName(e.minigame_playerslot-1); vector win_pos = pos+eY*(mySize_y-winfs_y)/2; vector win_sz; win_sz = minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, 0, DRAWFLAG_NORMAL, 0.5); drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE); minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5); } } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 9d0b85385..14457679f 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -476,16 +476,16 @@ void GetCvars(entity this, int f) } // decolorizes and team colors the player name when needed -string playername(entity p) +string playername(entity p, bool team_colorize) { string t; - if (teamplay && !intermission_running && IS_PLAYER(p)) + if (team_colorize && teamplay && !intermission_running && IS_PLAYER(p)) { t = Team_ColorCode(p.team); return strcat(t, strdecolorize(p.netname)); } else - return p.netname; + return ColorTranslateRGB(p.netname); } float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still needs done? diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index b6eab56bb..9016a22c7 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -93,7 +93,7 @@ string NearestLocation(vector p); void play2(entity e, string filename); -string playername(entity p); +string playername(entity p, bool team_colorize); void precache(); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index 289da329f..5e581c2bd 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -727,7 +727,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc string namestr = ""; if (source) - namestr = autocvar_g_chat_teamcolors ? playername(source) : source.netname; + namestr = playername(source, autocvar_g_chat_teamcolors); string colorprefix = (strdecolorize(namestr) == namestr) ? "^3" : "^7"; @@ -744,7 +744,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc msgstr = strcat(msgstr, msgin); cmsgstr = strcat(colorstr, colorprefix, namestr, "^3 tells you:\n^7", msgin); if(autocvar_g_chat_teamcolors) - privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay), ": ^7"); + privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay, true), ": ^7"); else privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", privatesay.netname, ": ^7"); } @@ -886,7 +886,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc } if(flood) - LOG_INFO("NOTE: ", playername(source), "^7 is flooding.\n"); + LOG_INFO("NOTE: ", playername(source, true), "^7 is flooding.\n"); // build sourcemsgstr by cutting off a prefix and replacing it by the other one if(privatesay) @@ -964,7 +964,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc if (source) { sprint(source, sourcemsgstr); dedicated_print(msgstr); // send to server console too - MX_Say(strcat(playername(source), "^7: ", msgin)); + MX_Say(strcat(playername(source, true), "^7: ", msgin)); } FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr)); } -- 2.39.2