]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working more on deathtypes/obituary, add VAR_TO_TEXT() function
authorSamual Lenks <samual@xonotic.org>
Wed, 26 Sep 2012 19:06:43 +0000 (15:06 -0400)
committerSamual Lenks <samual@xonotic.org>
Wed, 26 Sep 2012 19:06:43 +0000 (15:06 -0400)
qcsrc/common/notifications.qc
qcsrc/server/g_damage.qc

index 1d22144b161f68f28f2919afaf11359cef4e03f7..c132888327889ecba87c4b3242f6d50dc096f154 100644 (file)
@@ -48,6 +48,8 @@ string CCR(string input)
        return input;
 }
 
+#define VAR_TO_TEXT(var) #var
+#define CHECK_MATCH(a,b) if(min(NOTIF_MAX, a) == b)
 
 // ====================================
 //  Notifications List and Information
@@ -178,7 +180,7 @@ void Local_Notification(float net_type, float net_name, string s1, string s2, st
                case MSG_INFO:
                {
                        #define MSG_INFO_NOTIF(name,args,normal,gentle) \
-                               { if(min(NOTIF_MAX, name) == net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
+                               { CHECK_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
 
                        MSG_INFO_NOTIFICATIONS
                        break;
@@ -192,7 +194,7 @@ void Local_Notification(float net_type, float net_name, string s1, string s2, st
                case MSG_CENTER:
                {
                        #define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
-                               { if(min(NOTIF_MAX, name) == net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } }
+                               { CHECK_MATCH(name, net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } }
 
                        MSG_CENTER_NOTIFICATIONS
                        break;
@@ -211,9 +213,47 @@ void Local_Notification(float net_type, float net_name, string s1, string s2, st
 //  Notification Networking
 // =========================
 
+string Get_Notif_Name(float net_type, float net_name)
+{
+       switch(net_type)
+       {
+               case MSG_INFO:
+               {
+                       #define MSG_INFO_NOTIF(name,args,normal,gentle) \
+                               { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+                       MSG_INFO_NOTIFICATIONS
+                       break;
+               }
+               case MSG_NOTIFY:
+               {
+                       #define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
+                               { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+                       MSG_NOTIFY_NOTIFICATIONS
+                       break;
+               }
+               case MSG_CENTER:
+               {
+                       #define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
+                               { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+                       MSG_CENTER_NOTIFICATIONS
+                       break;
+               }
+               case MSG_WEAPON:
+               {
+                       #define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
+                               { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+                       MSG_WEAPON_NOTIFICATIONS
+                       break;
+               }
+       }
+
+       return "";
+}
+
 #ifdef SVQC
 void Send_Notification(float net_type, entity client, float net_name, string s1, string s2, string s3)
 {
+       print("notification: ", Get_Notif_Name(net_type, net_name), ": ", ftos(net_name), ".\n");
        if(net_type && net_name)
        {
                if(client && (clienttype(client) == CLIENTTYPE_REAL) && (client.flags & FL_CLIENT))
@@ -281,7 +321,7 @@ void Send_Notification_ToAll(entity except, float spectators, float net_type, fl
 }
 
 // LEGACY NOTIFICATION SYSTEMS
-void Send_KillNotification (string s1, string s2, string s3, float msg, float type)
+void Send_KillNotification(string s1, string s2, string s3, float msg, float type)
 {
        WriteByte(MSG_ALL, SVC_TEMPENTITY);
        WriteByte(MSG_ALL, TE_CSQC_KILLNOTIFY);
index 592bf4653004a699408ca516522229c659ad3ba2..57b00a9b48852d4628e0b2b54a1f49cfd8250d4e 100644 (file)
@@ -308,22 +308,43 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed)
        GameLogEcho(s);
 }
 
-void Obituary_Notification(string s1, string s2, float deathtype)
-{
+void Obituary_Notification(entity notif_target, string s1, string s2, string s3, float deathtype)
+{/*
+       print("Obituary_Notification(): ", ftos(deathtype), ".\n");
        switch(deathtype)
        {
+               // suicide
                case DEATH_AUTOTEAMCHANGE:
                case DEATH_CAMP:
                case DEATH_NOAMMO:
                case DEATH_ROT:
                case DEATH_TEAMCHANGE:
+               
+               case KILL_TEAM_SUICIDE_RED:
+               case KILL_TEAM_SUICIDE_BLUE:
+
+               // murder
+               case KILL_TEAM_FRAG_RED:
+               case KILL_TEAM_FRAG_BLUE:
+
+               case KILL_FIRST_BLOOD:
+               case KILL_FIRST_VICTIM:
+               
+               case KILL_FRAG:
+               case KILL_TYPEFRAG:
+               case KILL_FRAGGED:
+               case KILL_TYPEFRAGGED:
 
-               case KILL_TEAM_RED
+               // accident
+               case WATCH_STEP: 
                
-               case DEATH_QUIET:
+               case DEATH_QUIET: break;
+
+               // ideally we should have ALL deathtypes listed here
                default:
+                       backtrace(strcat("Unhandled deathtype: ", ftos(deathtype), ". Please notify Samual!\n"));
                        break;
-       }
+       }*/
 }
 
 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
@@ -331,6 +352,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;
@@ -338,12 +361,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)
                        {
@@ -351,32 +372,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);