]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Start working on moving deathtypes to be entities too
authorSamual Lenks <samual@xonotic.org>
Sun, 3 Mar 2013 23:25:38 +0000 (18:25 -0500)
committerSamual Lenks <samual@xonotic.org>
Sun, 3 Mar 2013 23:25:38 +0000 (18:25 -0500)
qcsrc/client/progs.src
qcsrc/common/deathtypes.qh
qcsrc/server/g_damage.qc
qcsrc/server/progs.src

index 335a17e5467d9f88780d14f3486c6894c91c92ef..0439bd8b4415153d3dceb138d706e802120cd2dd 100644 (file)
@@ -17,7 +17,6 @@ Defs.qc
 ../common/teams.qh
 ../common/util.qh
 ../common/items.qh
-../common/deathtypes.qh
 ../common/explosion_equation.qh
 ../common/mapinfo.qh
 ../common/command/markup.qh
@@ -31,6 +30,7 @@ command/cl_cmd.qh
 autocvars.qh
 
 ../common/notifications.qh // must be after autocvars
+../common/deathtypes.qh // must be after notifications
 
 damage.qh
 
index 8438a737985c9a198de8819cdd8dfb9b65fdf679..033779567df719559610436305b317e95977d045 100644 (file)
@@ -4,7 +4,9 @@
 #define DT_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
 float DT_COUNT;
 
-#define DT_MATCH(a,b) if(min(DT_MAX, a) == b)
+entity deathtypes[DT_MAX];
+.entity death_msgself;
+.entity death_msgmurder;
 
 #define DEATHTYPE(name,msg_death,msg_death_by,position) \
        float name; \
@@ -14,6 +16,15 @@ float DT_COUNT;
                SET_FIRST_OR_LAST(position, DT_FIRST, DT_COUNT) \
                SET_FIELD_COUNT(name, DT_FIRST, DT_COUNT) \
                CHECK_MAX_COUNT(name, DT_MAX, DT_COUNT, "deathtypes") \
+               \
+               entity deathent = spawn(); \
+               deathtypes[name - 1] = deathent; \
+               #if (msg_death != NO_MSG) \
+                       deathent.death_msgself = msg_multi_notifs[msg_death - 1]; \
+               #endif \
+               #if (msg_death_by != NO_MSG) \
+                       deathent.death_msgmurder = msg_multi_notifs[msg_death_by - 1]; \
+               #endif \
        } \
        ACCUMULATE_FUNCTION(RegisterDeathtypes, RegisterDeathtype_##name)
 
index e177ce46aa3aeeaf9c620468d5158fd55514b91c..ec818cfcf46b3ae050389e3d650b7f46c89717b0 100644 (file)
@@ -259,51 +259,31 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed)
        GameLogEcho(s);
 }
 
-#define INFO_NO_MSG 0 // so that compilation works with the INFO_##msg_death stuff
 void Obituary_SpecialDeath(entity notif_target, float murder, float deathtype, string s1, string s2, string s3, float f1, float f2, float f3)
 {
-       float handled = 0, hits = 0;
        if(DEATH_ISSPECIAL(deathtype))
        {
-               #define DEATHTYPE(name,msg_death,msg_death_by,position) \
-                       { if(deathtype == max(0, name)) \
-                       { \
-                               #if msg_death != NO_MSG \
-                                       if not(murder) \
-                                       { \
-                                               Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, msg_death, s1, s2, s3, "", f1, f2, f3, 0); \
-                                               Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, INFO_##msg_death, s1, s2, s3, "", f1, f2, f3, 0); \
-                                               ++handled; \
-                                       } \
-                               #endif \
-                               #if msg_death_by != NO_MSG \
-                                       if(murder) \
-                                       { \
-                                               Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, msg_death_by, s1, s2, s3, "", f1, f2, f3, 0); \
-                                               Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, INFO_##msg_death_by, s1, s2, s3, "", f1, f2, f3, 0); \
-                                               ++handled; \
-                                       } \
-                               #endif \
-                               ++hits; \
-                       } }
-
-               DEATHTYPES
-               #undef DEATHTYPE
-               
-               if not(hits)
+               entity deathent = deathtypes[deathtype - 1];
+               if not(deathent) { backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); return; }
+
+               if(murder)
                {
-                       backtrace("Obituary_SpecialDeath(): Unhandled deathtype- Please notify Samual!\n");
+                       if(deathent.death_msgmurder)
+                       {
+                               Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, deathent.death_msgmurder.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+                               Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, deathent.death_msgmurder.nent_msginfo.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+                       }
                }
-               if not(handled)
+               else
                {
-                       dprint(sprintf(
-                               "Obituary_SpecialDeath(): ^1Deathtype ^7(%s-%d)^1 has no notification!\n",
-                               Deathtype_Name(deathtype),
-                               deathtype
-                       ));
-                       return;
+                       if(deathent.death_msgself)
+                       {
+                               Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, deathent.death_msgself.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+                               Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, deathent.death_msgself.nent_msginfo.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+                       }
                }
        }
+       else { backtrace("Obituary_SpecialDeath called without a special deathtype?\n"); return; }
 }
 
 float w_deathtype;
index ef4bc98cf2143098826be4705eb51e029bf41086..54bc0b8c77b66b51a63c000b8f7064a2782d2fe6 100644 (file)
@@ -16,7 +16,6 @@ sys-post.qh
 ../common/teams.qh
 ../common/util.qh
 ../common/items.qh
-../common/deathtypes.qh
 ../common/explosion_equation.qh
 ../common/urllib.qh
 ../common/command/markup.qh
@@ -31,6 +30,7 @@ constants.qh
 defs.qh                // Should rename this, it has fields and globals
 
 ../common/notifications.qh // must be after autocvars
+../common/deathtypes.qh // must be after notifications
 
 mutators/base.qh
 mutators/mutators.qh