]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Disable a notification if it has errors
authorSamual Lenks <samual@xonotic.org>
Mon, 18 Feb 2013 22:40:53 +0000 (17:40 -0500)
committerSamual Lenks <samual@xonotic.org>
Mon, 18 Feb 2013 22:40:53 +0000 (17:40 -0500)
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh

index d5f1ffa88e984d52845e5adf64d9ee8eefdb521a..3caccb5f835f268639bc6a37693f580453844f0b 100644 (file)
@@ -86,34 +86,29 @@ string Local_Notification_sprintf(string input, string args,
        string tmp_s;
        #endif
        
-       if((remaining != "") && (input != ""))
+       arg_slot[0] = ""; arg_slot[1] = ""; arg_slot[2] = ""; arg_slot[3] = ""; arg_slot[4] = ""; arg_slot[5] = ""; arg_slot[6] = "";
+       for(;(remaining != "");)
        {
-               arg_slot[0] = ""; arg_slot[1] = ""; arg_slot[2] = ""; arg_slot[3] = ""; arg_slot[4] = ""; arg_slot[5] = ""; arg_slot[6] = "";
-               for(;remaining;)
+               selected = car(remaining); remaining = cdr(remaining);
+               if(sel_num == 7) { backtrace("Local_Notification_sprintf: Hit maximum arguments!\n"); break; }
+               switch(strtolower(selected))
                {
-                       selected = car(remaining); remaining = cdr(remaining);
-                       if(sel_num == 7) { backtrace("Local_Notification_sprintf: Hit maximum arguments!\n"); break; }
-                       switch(strtolower(selected))
-                       {
-                               #define ARG_CASE(prog,selected,result) \
-                                       #ifdef CSQC \
-                                       #if (prog == ARG_BOTH) || (prog == ARG_CSQC) \
-                                               case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
-                                       #endif \
-                                       #else \
-                                       #if (prog == ARG_BOTH) || (prog == ARG_SVQC) \
-                                               case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
-                                       #endif \
-                                       #endif
-                               NOTIF_ARGUMENT_LIST
-                               #undef ARG_CASE
-                               default: { backtrace(sprintf("Local_Notification_sprintf: Hit unknown token in selected string! '%s'\n", selected)); break; }
-                       }
+                       #define ARG_CASE(prog,selected,result) \
+                               #ifdef CSQC \
+                               #if (prog == ARG_BOTH) || (prog == ARG_CSQC) \
+                                       case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
+                               #endif \
+                               #else \
+                               #if (prog == ARG_BOTH) || (prog == ARG_SVQC) \
+                                       case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
+                               #endif \
+                               #endif
+                       NOTIF_ARGUMENT_LIST
+                       #undef ARG_CASE
+                       default: { backtrace(sprintf("Local_Notification_sprintf: Hit unknown token in selected string! '%s'\n", selected)); break; }
                }
-               return sprintf(input, arg_slot[0], arg_slot[1], arg_slot[2], arg_slot[3], arg_slot[4], arg_slot[5], arg_slot[6]);
        }
-       
-       return "";
+       return sprintf(input, arg_slot[0], arg_slot[1], arg_slot[2], arg_slot[3], arg_slot[4], arg_slot[5], arg_slot[6]);
 }
 
 #ifdef CSQC
@@ -122,20 +117,17 @@ void Local_Notification_HUD_Notify_Push(string icon, string hudargs, string s1,
        string selected, remaining = hudargs;
        float sel_num = 0;
        arg_slot[0] = ""; arg_slot[1] = "";
-       if(remaining != "")
+       for(;(remaining != "");)
        {
-               for(;remaining;)
+               selected = car(remaining); remaining = cdr(remaining);
+               if(sel_num == 2) { backtrace("Local_Notification_HUD_Notify_Push: Hit maximum arguments!\n"); break; }
+               switch(strtolower(selected))
                {
-                       selected = car(remaining); remaining = cdr(remaining);
-                       if(sel_num == 2) { backtrace("Local_Notification_HUD_Notify_Push: Hit maximum arguments!\n"); break; }
-                       switch(strtolower(selected))
-                       {
-                               #define ARG_CASE(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; }
-                               ARG_CASE("s1", s1)
-                               ARG_CASE("s2", s2)
-                               #undef ARG_CASE
-                               default: { backtrace(sprintf("Local_Notification_HUD_Notify_Push: Hit unknown token in selected string! '%s'\n", selected)); break; }
-                       }
+                       #define ARG_CASE(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; }
+                       ARG_CASE("s1", s1)
+                       ARG_CASE("s2", s2)
+                       #undef ARG_CASE
+                       default: { backtrace(sprintf("Local_Notification_HUD_Notify_Push: Hit unknown token in selected string! '%s'\n", selected)); break; }
                }
        }
        HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
index 65513be92d03327e9b35a47872d39dbc7bac8726..62d7db214129fb9f2aaea3cee8081ea976632e59 100644 (file)
@@ -580,7 +580,8 @@ void Dump_Notifications(float fh, float alsoprint);
 #define NOTIF_FIRST 1
 #define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
 
-var float notif_error = FALSE;
+var float notif_error = FALSE; // an error has occurred in this specific notification
+var float notif_global_error = FALSE; // an error has occurred in the notification system
 
 float NOTIF_INFO_COUNT;
 float NOTIF_CENTER_COUNT;
@@ -666,6 +667,7 @@ string Process_Notif_Args(float is_hudargs, string args, string notiftype, strin
 #define ADD_AUTOCVAR(name) var float autocvar_notification_##name = TRUE;
 
 #define CREATE_NOTIF_ENTITY(type,name,infoname,centername,strnum,flnum,args,hudargs,icon,cpid,durcnt,normal,gentle,check_newline,subcalls) \
+       notif_error = FALSE; \
        entity notif = spawn(); \
        msg_##type##_notifs[name - 1] = notif; \
        notif.classname = "msg_#type#_notification"; \
@@ -703,7 +705,13 @@ string Process_Notif_Args(float is_hudargs, string args, string notiftype, strin
                } \
                else if(normal != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, normal, strtoupper(#type), #name, "NORMAL"))); } \
                if(notif.nent_string == "") { print(sprintf("^1EMPTY NOTIFICATION: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \
-       #endif
+       #endif \
+       if(notif_error) \
+       { \
+               notif.nent_enabled = FALSE; \
+               notif_global_error = TRUE; \
+       }
+       
 
 #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \
        ADD_AUTOCVAR(name) \