From 3d6e33f58da3792e3711a3be23afce8492b32043 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 24 Oct 2017 09:59:55 +0200 Subject: [PATCH] Reduce indentation level of 2 functions thanks to 2 early returns --- qcsrc/server/g_damage.qc | 161 ++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index c48eb20cd..e46ff1fe6 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -167,108 +167,113 @@ void Obituary_SpecialDeath( string s1, string s2, string s3, float f1, float f2, float f3) { - if(DEATH_ISSPECIAL(deathtype)) + if(!DEATH_ISSPECIAL(deathtype)) { - entity deathent = Deathtypes_from(deathtype - DT_FIRST); - if (!deathent) { backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); return; } - - if(g_cts && deathtype == DEATH_KILL.m_id) - return; // TODO: somehow put this in CTS gamemode file! - - if(murder) - { - if(deathent.death_msgmurder) - { - Send_Notification_WOCOVA( - NOTIF_ONE, - notif_target, - MSG_MULTI, - deathent.death_msgmurder, - s1, s2, s3, "", - f1, f2, f3, 0 - ); - Send_Notification_WOCOVA( - NOTIF_ALL_EXCEPT, - notif_target, - MSG_INFO, - deathent.death_msgmurder.nent_msginfo, - s1, s2, s3, "", - f1, f2, f3, 0 - ); - } - } - else - { - if(deathent.death_msgself) - { - Send_Notification_WOCOVA( - NOTIF_ONE, - notif_target, - MSG_MULTI, - deathent.death_msgself, - s1, s2, s3, "", - f1, f2, f3, 0 - ); - Send_Notification_WOCOVA( - NOTIF_ALL_EXCEPT, - notif_target, - MSG_INFO, - deathent.death_msgself.nent_msginfo, - s1, s2, s3, "", - f1, f2, f3, 0 - ); - } - } + backtrace("Obituary_SpecialDeath called without a special deathtype?\n"); + return; } - else { backtrace("Obituary_SpecialDeath called without a special deathtype?\n"); return; } -} -float Obituary_WeaponDeath( - entity notif_target, - float murder, - int deathtype, - string s1, string s2, string s3, - float f1, float f2) -{ - Weapon death_weapon = DEATH_WEAPONOF(deathtype); - if (death_weapon != WEP_Null) + entity deathent = Deathtypes_from(deathtype - DT_FIRST); + if (!deathent) { - w_deathtype = deathtype; - Notification death_message = ((murder) ? death_weapon.wr_killmessage(death_weapon) : death_weapon.wr_suicidemessage(death_weapon)); - w_deathtype = false; + backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); + return; + } + + if(g_cts && deathtype == DEATH_KILL.m_id) + return; // TODO: somehow put this in CTS gamemode file! - if (death_message) + if(murder) + { + if(deathent.death_msgmurder) { Send_Notification_WOCOVA( NOTIF_ONE, notif_target, MSG_MULTI, - death_message, + deathent.death_msgmurder, s1, s2, s3, "", - f1, f2, 0, 0 + f1, f2, f3, 0 ); - // send the info part to everyone Send_Notification_WOCOVA( NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, - death_message.nent_msginfo, + deathent.death_msgmurder.nent_msginfo, s1, s2, s3, "", - f1, f2, 0, 0 + f1, f2, f3, 0 ); } - else + } + else + { + if(deathent.death_msgself) { - LOG_TRACEF( - "Obituary_WeaponDeath(): ^1Deathtype ^7(%d)^1 has no notification for weapon %d!\n", - deathtype, - death_weapon + Send_Notification_WOCOVA( + NOTIF_ONE, + notif_target, + MSG_MULTI, + deathent.death_msgself, + s1, s2, s3, "", + f1, f2, f3, 0 + ); + Send_Notification_WOCOVA( + NOTIF_ALL_EXCEPT, + notif_target, + MSG_INFO, + deathent.death_msgself.nent_msginfo, + s1, s2, s3, "", + f1, f2, f3, 0 ); } + } +} - return true; +float Obituary_WeaponDeath( + entity notif_target, + float murder, + int deathtype, + string s1, string s2, string s3, + float f1, float f2) +{ + Weapon death_weapon = DEATH_WEAPONOF(deathtype); + if (death_weapon == WEP_Null) + return false; + + w_deathtype = deathtype; + Notification death_message = ((murder) ? death_weapon.wr_killmessage(death_weapon) : death_weapon.wr_suicidemessage(death_weapon)); + w_deathtype = false; + + if (death_message) + { + Send_Notification_WOCOVA( + NOTIF_ONE, + notif_target, + MSG_MULTI, + death_message, + s1, s2, s3, "", + f1, f2, 0, 0 + ); + // send the info part to everyone + Send_Notification_WOCOVA( + NOTIF_ALL_EXCEPT, + notif_target, + MSG_INFO, + death_message.nent_msginfo, + s1, s2, s3, "", + f1, f2, 0, 0 + ); } - return false; + else + { + LOG_TRACEF( + "Obituary_WeaponDeath(): ^1Deathtype ^7(%d)^1 has no notification for weapon %d!\n", + deathtype, + death_weapon + ); + } + + return true; } bool frag_centermessage_override(entity attacker, entity targ, int deathtype, int kill_count_to_attacker, int kill_count_to_target) -- 2.39.2