]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make team coloring of playername an optional parameter, simplifies some code slightly
authorMario <mario@smbclan.net>
Sun, 12 Feb 2017 06:28:08 +0000 (16:28 +1000)
committerMario <mario@smbclan.net>
Sun, 12 Feb 2017 06:28:08 +0000 (16:28 +1000)
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/player.qc

index 2a6cb3d475ded6748f10715c5e5e9118e9ce6675..b3f5885c22380c9404284b610094090b1dad0ac1 100644 (file)
@@ -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);
        }
 }
index 4184c2638251f8df15f3b43a4b594166cba73221..bf26a66ccc9e5150cc88b79f8172b50205e0b6cc 100644 (file)
@@ -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);
        }
 }
index 4ae9fb06b21245ff233831d8a3ff7a280e477439..40ddcca08b84c06e251a8165de2fe1e17c8051d7 100644 (file)
@@ -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);
        }
 }
index 9d0b85385ccbfa1a18383a05908ab9929f725a1d..14457679f15c2ab98ba0319046b751d775eb1dd7 100644 (file)
@@ -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?
index b6eab56bb85eddf6f2dc28bd85334d0e4399d248..9016a22c7c6ebf1aaea01c54aa8e67f4dfbce37c 100644 (file)
@@ -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();
 
index 289da329faed4bed16473af9088c7aaf4f289636..5e581c2bd45a06fca4acf31553599390e491b4ae 100644 (file)
@@ -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));
         }