From 0c5ce37b4f1cd9d271b7e7fb3e3e3b296034d87a Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Fri, 8 Feb 2013 20:44:40 -0500 Subject: [PATCH] Create a way to check notification broadcast and client arguments --- qcsrc/common/notifications.qc | 42 +++++++++++++++++++++++++-- qcsrc/server/mutators/gamemode_ctf.qh | 6 ++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 1fb583a24..9b19d169b 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -307,9 +307,47 @@ float Write_Notification(entity client, float sf) return send; } +string Send_Notification_CheckTarget(float broadcast, entity client) +{ + switch(broadcast) + { + case NOTIF_ONE: + case NOTIF_ONE_ONLY: + { + if(clienttype(client) != CLIENTTYPE_REAL) { return "No real client provided!"; } + else { return ""; } + } + + case NOTIF_TEAM: + case NOTIF_TEAM_EXCEPT: + { + if not(teamplay) { return "Teamplay not active!"; } + else if(clienttype(client) == CLIENTTYPE_NOTACLIENT) { return "No real client provided!"; } + else if((broadcast == NOTIF_TEAM_EXCEPT) && (clienttype(client) != CLIENTTYPE_REAL)) { return "Exception can't be a non-real client!"; } + else { return ""; } + } + + case NOTIF_ANY_EXCEPT: + { + if(clienttype(client) != CLIENTTYPE_REAL) { return "Exception can't be a non-real client!"; } + else { return ""; } + } + + case NOTIF_ANY: + { + if(client) { return "Entity provided when world was required!"; } + else { return ""; } + } + } + + return strcat("Improper broadcast type: ", ftos(broadcast), "!"); +} + void Send_Notification(float broadcast, entity client, float net_type, float net_name, ...count) { - if(broadcast && net_type && net_name) + string checktarget = Send_Notification_CheckTarget(broadcast, client); + + if((checktarget == "") && net_type && net_name) { float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name)); float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name)); @@ -341,7 +379,7 @@ void Send_Notification(float broadcast, entity client, float net_type, float net Local_Notification_Without_VarArgs(net_type, net_name, stringcount, floatcount, IFSTR(0), IFSTR(1), IFSTR(2), IFSTR(3), IFFL(0), IFFL(1), IFFL(2), IFFL(3)); } } - else { backtrace("Incorrect usage of Send_Notification!\n"); } + else { backtrace(strcat("Incorrect usage of Send_Notification: ", checktarget, "\n")); } } void Send_Notification_Without_VarArgs(float broadcast, entity client, float net_type, float net_name, float stringcount, float floatcount, string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4) diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh index 00576ee3c..4a9164a22 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qh +++ b/qcsrc/server/mutators/gamemode_ctf.qh @@ -136,8 +136,8 @@ void havocbot_role_ctf_setrole(entity bot, float role); .float CAPTURE_VERBOSE; .float PICKUP_TEAM_VERBOSE; .float PICKUP_ENEMY_VERBOSE; -#endif -var float autocvar_notification_ctf_capture_verbose = TRUE; +#else var float autocvar_notification_ctf_pickup_team_verbose = TRUE; var float autocvar_notification_ctf_pickup_enemy_verbose = TRUE; - +#endif +var float autocvar_notification_ctf_capture_verbose = TRUE; -- 2.39.2