From 1d3a8c738e3566d144b76feb9bc3bd1798882c2b Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Wed, 21 Aug 2013 18:09:52 -0400 Subject: [PATCH] Alright, now initialization should work for MSG_CHOICE --- qcsrc/common/notifications.qc | 96 +++++++++++++++++++++++++++++++---- qcsrc/common/notifications.qh | 5 +- 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 580368d09..f941dbebc 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -458,35 +458,30 @@ void Create_Notification_Entity( { case MSG_ANNCE: { - typestring = "MSG_ANNCE"; msg_annce_notifs[nameid - 1] = notif; notif.classname = "msg_annce_notification"; break; } case MSG_INFO: { - typestring = "MSG_INFO"; msg_info_notifs[nameid - 1] = notif; notif.classname = "msg_info_notification"; break; } case MSG_CENTER: { - typestring = "MSG_CENTER"; msg_center_notifs[nameid - 1] = notif; notif.classname = "msg_center_notification"; break; } case MSG_MULTI: { - typestring = "MSG_MULTI"; msg_multi_notifs[nameid - 1] = notif; notif.classname = "msg_multi_notification"; break; } case MSG_CHOICE: { - typestring = "MSG_CHOICE"; msg_choice_notifs[nameid - 1] = notif; notif.classname = "msg_choice_notification"; break; @@ -507,9 +502,12 @@ void Create_Notification_Entity( } notif.nent_default = var_default; notif.nent_name = strzone(namestring); + notif.nent_type = typeid; notif.nent_id = nameid; notif.nent_enabled = (1 <= var_cvar); + typestring = Get_Notif_TypeName(typeid); + // Other pre-notif-setup requisites notif_error = FALSE; @@ -754,6 +752,68 @@ void Create_Notification_Entity( case MSG_CHOICE: { + if((chtype == NO_MSG) || (optiona == NO_MSG) || (optionb == NO_MSG)) + { + print(sprintf( + strcat( + "^1NOTIFICATION IS MISSING CHOICE PARAMS: ", + "^7net_type = %s, net_name = %s.\n" + ), + typestring, + namestring + )); + notif_error = TRUE; + } + else + { + switch(chtype) + { + case MSG_ANNCE: + { + notif.nent_optiona = msg_annce_notifs[optiona - 1]; + notif.nent_optionb = msg_annce_notifs[optionb - 1]; + break; + } + case MSG_INFO: + { + notif.nent_optiona = msg_info_notifs[optiona - 1]; + notif.nent_optionb = msg_info_notifs[optionb - 1]; + break; + } + case MSG_CENTER: + { + notif.nent_optiona = msg_center_notifs[optiona - 1]; + notif.nent_optionb = msg_center_notifs[optionb - 1]; + break; + } + case MSG_MULTI: + { + notif.nent_optiona = msg_multi_notifs[optiona - 1]; + notif.nent_optionb = msg_multi_notifs[optionb - 1]; + break; + } + case MSG_CHOICE: // should we REALLY allow nested options?... + { + notif.nent_optiona = msg_choice_notifs[optiona - 1]; + notif.nent_optionb = msg_choice_notifs[optionb - 1]; + break; + } + + default: + { + error(sprintf( + strcat( + "^1NOTIFICATION WITH IMPROPER TYPE: ", + "^7net_type = %d, net_name = %s.\n" + ), + typeid, + namestring + )); + notif_error = TRUE; + break; + } + } + } break; } @@ -1375,6 +1435,24 @@ void Local_Notification(float net_type, float net_name, ...count) #endif break; } + + case MSG_CHOICE: + { + entity found_choice; + switch(cvar_string(sprintf("notification_%s", notif.nent_name))) + { + case 1: found_choice = notif.nent_optiona; break; + case 2: found_choice = notif.nent_optionb; break; + default: return; // not enabled anyway + } + Local_Notification_WOVA( + found_choice.nent_type, + found_choice.nent_id, + found_choice.nent_stringcount, + found_choice.nent_floatcount, + s1, s2, s3, s4, + f1, f2, f3, f4); + } } } @@ -1697,15 +1775,15 @@ void Send_Notification( #define RECURSE_FROM_CHOICE(ent,action) \ switch(ent.msg_choice_choices[net_name]) \ { \ - case 1: found_choice = notif.nent_choicea; \ - case 2: found_choice = notif.nent_choiceb; \ + case 1: found_choice = notif.nent_optiona; break; \ + case 2: found_choice = notif.nent_optionb; break; \ default: action; \ } \ Send_Notification_WOVA( \ NOTIF_ONE_ONLY, \ ent, \ - found_choice.nent_net_type, \ - found_choice.nent_net_name, \ + found_choice.nent_type, \ + found_choice.nent_id, \ s1, s2, s3, s4, \ f1, f2, f3, f4); diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 7c271156c..02cd56880 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -1096,6 +1096,7 @@ float NOTIF_CPID_COUNT; // notification entity values .float nent_default; .string nent_name; +.float nent_type; .float nent_id; .float nent_enabled; .entity nent_msgannce; @@ -1113,8 +1114,8 @@ float NOTIF_CPID_COUNT; .float nent_cpid; .string nent_durcnt; .string nent_string; -.entity nent_choicea; -.entity nent_choiceb; +.entity nent_optiona; +.entity nent_optionb; // networked notification values .float nent_broadcast; -- 2.39.2