From: Samual Lenks Date: Sun, 3 Mar 2013 23:25:38 +0000 (-0500) Subject: Start working on moving deathtypes to be entities too X-Git-Tag: xonotic-v0.7.0~62^2~23^2~15 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=bff86c3c3ffb8b39e7130ff03ecc2eee4deb4226;p=xonotic%2Fxonotic-data.pk3dir.git Start working on moving deathtypes to be entities too --- diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index 335a17e54..0439bd8b4 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -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 diff --git a/qcsrc/common/deathtypes.qh b/qcsrc/common/deathtypes.qh index 8438a7379..033779567 100644 --- a/qcsrc/common/deathtypes.qh +++ b/qcsrc/common/deathtypes.qh @@ -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) diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index e177ce46a..ec818cfcf 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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; diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index ef4bc98cf..54bc0b8c7 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -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