From: z411 Date: Thu, 18 Nov 2021 16:56:14 +0000 (-0300) Subject: Colorize player names in info messages X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0d2848d3f7d6e50e525f73e514edce1af6687bd1;p=xonotic%2Fxonotic-data.pk3dir.git Colorize player names in info messages --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 670b00fa4..c95e62eeb 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -113,16 +113,17 @@ void ctf_CaptureRecord(entity flag, entity player) float cap_record = ctf_captimerecord; float cap_time = (time - flag.ctf_pickuptime); string refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname")); + string player_cname = playername(player.netname, player.team, autocvar_g_chat_teamcolors); // notify about shit if(ctf_oneflag) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_CTF_CAPTURE_NEUTRAL, player.netname); else if(!ctf_captimerecord) - Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_TIME), player.netname, TIME_ENCODE(cap_time)); + Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_TIME), player_cname, TIME_ENCODE(cap_time)); else if(cap_time < cap_record) - Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_BROKEN), player.netname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record)); + Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_BROKEN), player_cname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record)); else - Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_UNBROKEN), player.netname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record)); + Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_UNBROKEN), player_cname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record)); // write that shit in the database if(!ctf_oneflag) // but not in 1-flag mode @@ -349,6 +350,7 @@ void ctf_Handle_Drop(entity flag, entity player, int droptype) { // declarations player = (player ? player : flag.pass_sender); + string player_cname = playername(player.netname, player.team, autocvar_g_chat_teamcolors); // main set_movetype(flag, MOVETYPE_TOSS); @@ -360,7 +362,7 @@ void ctf_Handle_Drop(entity flag, entity player, int droptype) flag.ctf_status = FLAG_DROPPED; // messages and sounds - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_LOST), player.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_LOST), player_cname); _sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE); ctf_EventLog("dropped", player.team, player); @@ -637,6 +639,8 @@ void ctf_Handle_Capture(entity flag, entity toucher, int capturetype) void ctf_Handle_Return(entity flag, entity player) { + string player_cname = playername(player.netname, player.team, autocvar_g_chat_teamcolors); + // messages and sounds if(IS_MONSTER(player)) { @@ -645,7 +649,7 @@ void ctf_Handle_Return(entity flag, entity player) else if(flag.team) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_NUM(flag.team, CENTER_CTF_RETURN)); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(flag.team, INFO_CTF_RETURN), player.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(flag.team, INFO_CTF_RETURN), player_cname); } _sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE); ctf_EventLog("return", flag.team, player); @@ -682,6 +686,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) { // declarations float pickup_dropped_score; // used to calculate dropped pickup score + string player_cname = playername(player.netname, player.team, autocvar_g_chat_teamcolors); // attach the flag to the player flag.owner = player; @@ -714,7 +719,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) } // messages and sounds - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_PICKUP), player.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_PICKUP), player_cname); if(ctf_stalemate) Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); if(!flag.team) diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index d480c229b..78892f104 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -236,6 +236,10 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en float kill_count_to_attacker, kill_count_to_target; bool notif_anonymous = false; string attacker_name = attacker.netname; + + // Colorize names + string targ_cname = playername(targ.netname, targ.team, autocvar_g_chat_teamcolors); + string attacker_cname = playername(attacker.netname, attacker.team, autocvar_g_chat_teamcolors); // Set final information for the death targ.death_origin = targ.origin; @@ -245,8 +249,10 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en if (MUTATOR_CALLHOOK(ClientObituary, inflictor, attacker, targ, deathtype, attacker.(weaponentity))) { CS(targ).killcount = 0; return; } notif_anonymous = M_ARGV(5, bool); - if(notif_anonymous) + if(notif_anonymous) { attacker_name = "Anonymous player"; + attacker_cname = "Anonymous player"; + } #ifdef NOTIFICATIONS_DEBUG Debug_Notification( @@ -270,7 +276,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en { if(deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id) { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.team, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ_cname, deathlocation, "", targ.team, 0, 0); } else { @@ -278,21 +284,21 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en { case DEATH_MIRRORDAMAGE: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ_cname, deathlocation, "", CS(targ).killcount, 0, 0); break; } case DEATH_HURTTRIGGER: - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, inflictor.message, deathlocation, CS(targ).killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ_cname, inflictor.message, deathlocation, CS(targ).killcount, 0, 0); break; default: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ_cname, deathlocation, "", CS(targ).killcount, 0, 0); break; } } } } - else if (!Obituary_WeaponDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0)) + else if (!Obituary_WeaponDeath(targ, false, deathtype, targ_cname, deathlocation, "", CS(targ).killcount, 0)) { backtrace("SUICIDE: what the hell happened here?\n"); return; @@ -316,7 +322,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAG, targ.netname); Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAGGED, attacker_name); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ.netname, attacker_name, deathlocation, CS(targ).killcount); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ_cname, attacker_cname, deathlocation, CS(targ).killcount); // In this case, the death message will ALWAYS be "foo was betrayed by bar" // No need for specific death/weapon messages... @@ -415,8 +421,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en if(deathtype == DEATH_BUFF.m_id) f3 = buff_FirstFromFlags(attacker).m_id; - if (!Obituary_WeaponDeath(targ, true, deathtype, targ.netname, attacker_name, deathlocation, CS(targ).killcount, kill_count_to_attacker)) - Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker_name, deathlocation, CS(targ).killcount, kill_count_to_attacker, f3); + if (!Obituary_WeaponDeath(targ, true, deathtype, targ_cname, attacker_cname, deathlocation, CS(targ).killcount, kill_count_to_attacker)) + Obituary_SpecialDeath(targ, true, deathtype, targ_cname, attacker_cname, deathlocation, CS(targ).killcount, kill_count_to_attacker, f3); } } @@ -433,7 +439,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en case DEATH_HURTTRIGGER: { Obituary_SpecialDeath(targ, false, deathtype, - targ.netname, + targ_cname, inflictor.message, deathlocation, CS(targ).killcount, @@ -445,7 +451,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en case DEATH_CUSTOM: { Obituary_SpecialDeath(targ, false, deathtype, - targ.netname, + targ_cname, ((strstrofs(deathmessage, "%", 0) < 0) ? strcat("%s ", deathmessage) : deathmessage), deathlocation, CS(targ).killcount, @@ -456,7 +462,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en default: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ_cname, deathlocation, "", CS(targ).killcount, 0, 0); break; } }