From: Samual Lenks Date: Mon, 18 Feb 2013 22:40:53 +0000 (-0500) Subject: Disable a notification if it has errors X-Git-Tag: xonotic-v0.7.0~62^2~23^2~200 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cf2427a72e39ddf51efcd6c9905041e1d8fb2231;p=xonotic%2Fxonotic-data.pk3dir.git Disable a notification if it has errors --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index d5f1ffa88..3caccb5f8 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -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]); diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 65513be92..62d7db214 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -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) \