From: Samual Lenks Date: Wed, 21 Aug 2013 18:55:25 +0000 (-0400) Subject: Most of the framework should now properly support MSG_CHOICE X-Git-Tag: xonotic-v0.8.0~341^2~30 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7d86ade6464587abe1ece66045169fd862d09eab;p=xonotic%2Fxonotic-data.pk3dir.git Most of the framework should now properly support MSG_CHOICE --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index d1dba4f3e..580368d09 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -160,7 +160,6 @@ float Notification_ShouldSend(float broadcast, entity to_client, entity other_cl case NOTIF_ALL: // send to everyone { return TRUE; - break; } case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators { @@ -175,8 +174,8 @@ float Notification_ShouldSend(float broadcast, entity to_client, entity other_cl ) { return TRUE; } break; } - default: { return FALSE; } } + return FALSE; } #endif @@ -1690,54 +1689,40 @@ void Send_Notification( { // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast) // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option... - // It's slow, but it's better than the alternatives + // It's slow, but it's better than the alternatives: + // 1. Constantly networking all info and letting client decide + // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose) entity found_choice; - + + #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; \ + default: action; \ + } \ + Send_Notification_WOVA( \ + NOTIF_ONE_ONLY, \ + ent, \ + found_choice.nent_net_type, \ + found_choice.nent_net_name, \ + s1, s2, s3, s4, \ + f1, f2, f3, f4); + switch(broadcast) { case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method { if(IS_REAL_CLIENT(client)) - { - switch(client.msg_choice_choices[net_name]) - { - case 1: found_choice = notif.nent_choicea; - case 2: found_choice = notif.nent_choiceb; - default: return; // nothing to do here, client disables this - } - Send_Notification_WOVA( - NOTIF_ONE_ONLY, - client, - found_choice.nent_net_type, - found_choice.nent_net_name, - s1, s2, s3, s4, - f1, f2, f3, f4); - } + { RECURSE_FROM_CHOICE(client, return) } break; } - default: { entity to; FOR_EACH_REALCLIENT(to) - { - if(Notification_ShouldSend(broadcast, to, client)) - { - switch(client.msg_choice_choices[net_name]) - { - case 1: found_choice = notif.nent_choicea; - case 2: found_choice = notif.nent_choiceb; - default: continue; // nothing to do here, client disables this - } - Send_Notification_WOVA( - NOTIF_ONE_ONLY, - to, - found_choice.nent_net_type, - found_choice.nent_net_name, - s1, s2, s3, s4, - f1, f2, f3, f4); - } - } + { if(Notification_ShouldSend(broadcast, to, client)) + { RECURSE_FROM_CHOICE(to, continue) } } break; } } diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 136e093a8..7c271156c 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -1065,18 +1065,25 @@ string notif_arg_spree_inf(float type, string input, string player, float spree) // ==================================== #define NOTIF_FIRST 1 -#define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION + +// notification limits +#define NOTIF_ANNCE_MAX 64 +#define NOTIF_INFO_MAX 512 +#define NOTIF_CENTER_MAX 512 +#define NOTIF_MULTI_MAX 256 +#define NOTIF_CHOICE_MAX 64 +#define NOTIF_CPID_MAX 128 // error detection float notif_error; float notif_global_error; // notification entities -entity msg_annce_notifs[NOTIF_MAX]; -entity msg_info_notifs[NOTIF_MAX]; -entity msg_center_notifs[NOTIF_MAX]; -entity msg_multi_notifs[NOTIF_MAX]; -entity msg_choice_notifs[NOTIF_MAX]; +entity msg_annce_notifs[NOTIF_ANNCE_MAX]; +entity msg_info_notifs[NOTIF_INFO_MAX]; +entity msg_center_notifs[NOTIF_CENTER_MAX]; +entity msg_multi_notifs[NOTIF_MULTI_MAX]; +entity msg_choice_notifs[NOTIF_CHOICE_MAX]; // notification counts float NOTIF_ANNCE_COUNT; @@ -1106,10 +1113,8 @@ float NOTIF_CPID_COUNT; .float nent_cpid; .string nent_durcnt; .string nent_string; - -.float nent_msgchtype; -.string nent_msgopa; -.string nent_msgopb; +.entity nent_choicea; +.entity nent_choiceb; // networked notification values .float nent_broadcast; @@ -1119,13 +1124,16 @@ float NOTIF_CPID_COUNT; .string nent_strings[4]; .float nent_floats[4]; +// other notification properties +.float msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices + #define MSG_ANNCE_NOTIF(default,name,channel,sound,volume,position) \ NOTIF_ADD_AUTOCVAR(name, default) \ float name; \ void RegisterNotification_##name() \ { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_ANNCE_COUNT) \ - CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_ANNCE_COUNT, "notifications") \ + CHECK_MAX_COUNT(name, NOTIF_ANNCE_MAX, NOTIF_ANNCE_COUNT, "MSG_ANNCE") \ Create_Notification_Entity( \ default, /* var_default */ \ autocvar_notification_##name, /* var_cvar */ \ @@ -1160,7 +1168,7 @@ float NOTIF_CPID_COUNT; void RegisterNotification_##name() \ { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \ - CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_INFO_COUNT, "notifications") \ + CHECK_MAX_COUNT(name, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \ Create_Notification_Entity( \ default, /* var_default */ \ autocvar_notification_##name, /* var_cvar */ \ @@ -1197,7 +1205,7 @@ float NOTIF_CPID_COUNT; { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CENTER_COUNT) \ SET_FIELD_COUNT(cpid, NOTIF_FIRST, NOTIF_CPID_COUNT) \ - CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CENTER_COUNT, "notifications") \ + CHECK_MAX_COUNT(name, NOTIF_CENTER_MAX, NOTIF_CENTER_COUNT, "MSG_CENTER") \ Create_Notification_Entity( \ default, /* var_default */ \ autocvar_notification_##name, /* var_cvar */ \ @@ -1232,7 +1240,7 @@ float NOTIF_CPID_COUNT; void RegisterNotification_##name() \ { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_MULTI_COUNT) \ - CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_MULTI_COUNT, "notifications") \ + CHECK_MAX_COUNT(name, NOTIF_MULTI_MAX, NOTIF_MULTI_COUNT, "MSG_MULTI") \ Create_Notification_Entity( \ default, /* var_default */ \ autocvar_notification_##name, /* var_cvar */ \ @@ -1267,7 +1275,7 @@ float NOTIF_CPID_COUNT; void RegisterNotification_##name() \ { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CHOICE_COUNT) \ - CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CHOICE_COUNT, "notifications") \ + CHECK_MAX_COUNT(name, NOTIF_CHOICE_MAX, NOTIF_CHOICE_COUNT, "MSG_CHOICE") \ Create_Notification_Entity( \ default, /* var_default */ \ autocvar_notification_##name, /* var_cvar */ \