]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Create a way to check notification broadcast and client arguments
authorSamual Lenks <samual@xonotic.org>
Sat, 9 Feb 2013 01:44:40 +0000 (20:44 -0500)
committerSamual Lenks <samual@xonotic.org>
Sat, 9 Feb 2013 01:44:40 +0000 (20:44 -0500)
qcsrc/common/notifications.qc
qcsrc/server/mutators/gamemode_ctf.qh

index 1fb583a24c9eaa60ae17053af7638aa0b235b07a..9b19d169b8114d218defe73750e80e2ec03f4072 100644 (file)
@@ -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)
index 00576ee3c1bc5a9345373d2a3ff13c0c75ba9a8c..4a9164a22ba0fc261ddf05dc9e86af1add87612b 100644 (file)
@@ -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;