]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
Merge remote-tracking branch 'origin/master' into samual/notification_rewrite
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index d2cc61db3346cb3405ca086e9d025657fd2a4c6f..f23988c7e8c2c15e97135690e1867cb5af6414e2 100644 (file)
@@ -308,32 +308,13 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed)
        GameLogEcho(s);
 }
 
-void Send_KillNotification (string s1, string s2, string s3, float msg, float type)
+void Obituary_Notification(entity notif_target, string s1, string s2, string s3, float deathtype)
 {
-       WriteByte(MSG_ALL, SVC_TEMPENTITY);
-       WriteByte(MSG_ALL, TE_CSQC_KILLNOTIFY);
-       WriteString(MSG_ALL, s1);
-       WriteString(MSG_ALL, s2);
-       WriteString(MSG_ALL, s3);
-       WriteShort(MSG_ALL, msg);
-       WriteByte(MSG_ALL, type);
-}
+       #define DEATHTYPE(name,type,notification) \
+               { if(deathtype == max(0, name)) { Send_Notification(type, notif_target, notification, s1, s2, s3); return; } }
 
-// Function is used to send a generic centerprint whose content CSQC gets to decide (gentle version or not in the below cases)
-void Send_CSQC_KillCenterprint(entity e, string s1, string s2, float msg, float type)
-{
-       if (clienttype(e) == CLIENTTYPE_REAL)
-       {
-               msg_entity = e;
-               WRITESPECTATABLE_MSG_ONE({
-                       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-                       WriteByte(MSG_ONE, TE_CSQC_KILLCENTERPRINT);
-                       WriteString(MSG_ONE, s1);
-                       WriteString(MSG_ONE, s2);
-                       WriteShort(MSG_ONE, msg);
-                       WriteByte(MSG_ONE, type);
-               });
-       }
+       DEATHTYPES
+       backtrace("Unhandled deathtype. Please notify Samual!\n");
 }
 
 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
@@ -341,6 +322,8 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
        string  s, a, msg;
        float w, type;
 
+       string s1, s2, s3;
+
        if (targ.classname == "player")
        {
                s = targ.netname;
@@ -348,12 +331,10 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
 
                if (targ == attacker) // suicides
                {
-                       if (deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
-                               msg = ColoredTeamName(targ.team); // TODO: check if needed?
-                       else
-                               msg = "";
-            if(!g_cts) // no "killed your own dumb self" message in CTS
-                Send_CSQC_KillCenterprint(targ, msg, "", deathtype, MSG_SUICIDE);
+                       s1 = ((deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE) ? ColoredTeamName(targ.team) : "");
+
+                       // no "killed your own dumb self" message in CTS
+            if(!g_cts) { Obituary_Notification(targ, s1, "", "", deathtype); }
 
                        if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
                        {
@@ -361,32 +342,24 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                GiveFrags(attacker, targ, -1, deathtype);
                        }
 
-                       if (targ.killcount > 2)
-                               msg = ftos(targ.killcount);
-                       else
-                               msg = "";
-                       if(teamplay && deathtype == DEATH_MIRRORDAMAGE)
-                       {
-                               if(attacker.team == COLOR_TEAM1)
-                                       deathtype = KILL_TEAM_RED;
-                               else
-                                       deathtype = KILL_TEAM_BLUE;
-                       }
+                       s1 = targ.netname;
+                       s2 = ((targ.killcount > 2) ? ftos(targ.killcount) : "");
+                               
+                       //if(teamplay && deathtype == DEATH_MIRRORDAMAGE)
+                       //      { deathtype = ((attacker.team == COLOR_TEAM1) ? KILL_TEAM_SUICIDE_RED : KILL_TEAM_SUICIDE_BLUE); }
 
-                       Send_KillNotification(s, msg, ftos(w), deathtype, MSG_SUICIDE);
+                       Obituary_Notification(world, s1, s2, "", deathtype);
+                       //Send_KillNotification(s, s2, ftos(w), deathtype, MSG_SUICIDE);
                }
                else if (attacker.classname == "player")
                {
                        if(!IsDifferentTeam(attacker, targ))
                        {
-                               if(attacker.team == COLOR_TEAM1)
-                                       type = KILL_TEAM_RED;
-                               else
-                                       type = KILL_TEAM_BLUE;
+                               //type = ((attacker.team == COLOR_TEAM1) ? KILL_TEAM_FRAG_RED : KILL_TEAM_FRAG_BLUE);
 
                                GiveFrags(attacker, targ, -1, deathtype);
 
-                               Send_CSQC_KillCenterprint(attacker, s, "", type, MSG_KILL);
+                               //Send_CSQC_KillCenterprint(attacker, s, "", type);
 
                                if (targ.killcount > 2)
                                        msg = ftos(targ.killcount);