1 // ================================================
2 // Unified notification system, written by Samual
3 // Last updated: August, 2013
4 // ================================================
6 string Get_Notif_TypeName(float net_type)
10 case MSG_ANNCE: return "MSG_ANNCE";
11 case MSG_INFO: return "MSG_INFO";
12 case MSG_CENTER: return "MSG_CENTER";
13 case MSG_CENTER_CPID: return "MSG_CENTER_CPID";
14 case MSG_MULTI: return "MSG_MULTI";
15 case MSG_CHOICE: return "MSG_CHOICE";
17 backtrace(sprintf("Get_Notif_TypeName(%d): Improper net type!\n", net_type));
21 entity Get_Notif_Ent(float net_type, float net_name)
25 case MSG_ANNCE: return msg_annce_notifs[net_name - 1];
26 case MSG_INFO: return msg_info_notifs[net_name - 1];
27 case MSG_CENTER: return msg_center_notifs[net_name - 1];
28 case MSG_MULTI: return msg_multi_notifs[net_name - 1];
29 case MSG_CHOICE: return msg_choice_notifs[net_name - 1];
31 backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name));
36 #ifdef NOTIFICATIONS_DEBUG
37 string Get_Notif_BroadcastName(float broadcast)
41 case NOTIF_ONE: return "NOTIF_ONE";
42 case NOTIF_ONE_ONLY: return "NOTIF_ONE_ONLY";
43 case NOTIF_ALL_EXCEPT: return "NOTIF_ALL_EXCEPT";
44 case NOTIF_ALL: return "NOTIF_ALL";
45 case NOTIF_TEAM: return "NOTIF_TEAM";
46 case NOTIF_TEAM_EXCEPT: return "NOTIF_TEAM_EXCEPT";
48 backtrace(sprintf("Get_Notif_BroadcastName(%d): Improper broadcast!\n", broadcast));
54 string Notification_CheckArgs_TypeName(float net_type, float net_name)
56 // check supplied type and name for errors
57 string checkargs = "";
58 #define CHECKARG_TYPENAME(type) case MSG_##type##: \
59 { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
60 { checkargs = sprintf("Improper name: %d!", net_name); } break; }
63 CHECKARG_TYPENAME(ANNCE)
64 CHECKARG_TYPENAME(INFO)
65 CHECKARG_TYPENAME(CENTER)
66 CHECKARG_TYPENAME(MULTI)
67 CHECKARG_TYPENAME(CHOICE)
68 default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; }
70 #undef CHECKARG_TYPENAME
75 string Notification_CheckArgs(
76 float broadcast, entity client,
77 float net_type, float net_name)
79 // check supplied broadcast, target, type, and name for errors
80 string checkargs = Notification_CheckArgs_TypeName(net_type, net_name);
81 if(checkargs != "") { checkargs = strcat(checkargs, " "); }
87 if(IS_NOT_A_CLIENT(client))
88 { checkargs = sprintf("%sNo client provided!", checkargs); }
92 case NOTIF_ALL_EXCEPT:
94 if(IS_NOT_A_CLIENT(client))
95 { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
102 { checkargs = sprintf("%sEntity provided when world was required!", checkargs); }
109 { checkargs = sprintf("%sTeamplay not active!", checkargs); }
110 //else if not(client.team) { checkargs = sprintf("%sNo team provided!", checkargs); }
114 case NOTIF_TEAM_EXCEPT:
117 { checkargs = sprintf("%sTeamplay not active!", checkargs); }
118 else if(IS_NOT_A_CLIENT(client))
119 { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
123 default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
128 float Notification_ShouldSend(float broadcast, entity to_client, entity other_client)
132 case NOTIF_ONE: // send to one client and their spectator
135 (to_client == other_client)
140 (to_client.enemy == other_client)
145 case NOTIF_ONE_ONLY: // send ONLY to one client
147 if(to_client == other_client) { return TRUE; }
150 case NOTIF_TEAM: // send only to X team and their spectators
153 (to_client.team == other_client.team)
158 (to_client.enemy.team == other_client.team)
163 case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators
166 (to_client != other_client)
169 (to_client.team == other_client.team)
175 (to_client.enemy != other_client)
177 (to_client.enemy.team == other_client.team)
184 case NOTIF_ALL: // send to everyone
188 case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators
191 (to_client != other_client)
196 (to_client.enemy == other_client)
207 // ===============================
208 // Initialization Core Functions
209 // ===============================
211 // used by restartnotifs command to initialize notifications
212 void Destroy_Notification_Entity(entity notif)
214 if(notif.nent_name != "") { strunzone(notif.nent_name); }
215 if(notif.nent_snd != "") { strunzone(notif.nent_snd); }
216 if(notif.nent_args != "") { strunzone(notif.nent_args); }
217 if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
218 if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
219 if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
220 if(notif.nent_string != "") { strunzone(notif.nent_string); }
224 void Destroy_All_Notifications(void)
229 #define DESTROY_LOOP(type,count) \
230 for(i = 1; i <= count; ++i) \
232 notif = Get_Notif_Ent(type, i); \
233 if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
234 Destroy_Notification_Entity(notif); \
237 // kill all networked notifications and centerprints
239 Kill_Notification(NOTIF_ALL, world, 0, 0);
241 reset_centerprint_messages();
244 // kill all real notification entities
245 DESTROY_LOOP(MSG_ANNCE, NOTIF_ANNCE_COUNT)
246 DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
247 DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
248 DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
249 DESTROY_LOOP(MSG_CHOICE, NOTIF_CHOICE_COUNT)
253 string Process_Notif_Line(
262 if(typeid == MSG_INFO)
264 if((chat && autocvar_notification_allow_chatboxprint)
265 || (autocvar_notification_allow_chatboxprint == 2))
267 // pass 1: add ETX char at beginning of line
268 input = strcat("\{3}", input);
270 // pass 2: add ETX char at end of each new line (so that
271 // messages with multiple lines are put through chatbox too)
272 input = strreplace("\n", "\n\{3}", input);
274 // pass 3: strip trailing ETX char
275 if(substring(input, (strlen(input) - 1), 1) == "\{3}")
276 { input = substring(input, 0, (strlen(input) - 1)); }
281 // done to both MSG_INFO and MSG_CENTER
282 if(substring(input, (strlen(input) - 1), 1) == "\n")
286 "^1TRAILING NEW LINE AT END OF NOTIFICATION: ",
287 "^7net_type = %s, net_name = %s, string = %s.\n"
294 input = substring(input, 1, (strlen(input) - 1));
300 string Process_Notif_Args(
306 string selected, remaining = args;
309 for(;(remaining != "");)
311 selected = car(remaining); remaining = cdr(remaining);
315 case 1: // normal args
317 if(sel_num == NOTIF_MAX_ARGS)
321 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
322 "^7net_type = %s, net_name = %s, max args = %d.\n"
332 switch(strtolower(selected))
334 #define ARG_CASE(prog,selected,result) \
335 #if (prog != ARG_DC) \
336 case selected: { ++sel_num; break; } \
344 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
345 "^7net_type = %s, net_name = %s, args arg = '%s'.\n"
359 if(sel_num == NOTIF_MAX_HUDARGS)
363 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
364 "^7net_type = %s, net_name = %s, max hudargs = %d.\n"
374 switch(strtolower(selected))
376 #define ARG_CASE(prog,selected,result) \
377 #if (prog == ARG_CS_SV_HA) \
378 case selected: { ++sel_num; break; } \
386 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
387 "^7net_type = %s, net_name = %s, hudargs arg = '%s'.\n"
401 if(sel_num == NOTIF_MAX_DURCNT)
405 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
406 "^7net_type = %s, net_name = %s, max durcnt = %d.\n"
416 switch(strtolower(selected))
418 #define ARG_CASE(prog,selected,result) \
419 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
420 case selected: { ++sel_num; break; } \
426 if(ftos(stof(selected)) != "") { ++sel_num; }
431 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
432 "^7net_type = %s, net_name = %s, durcnt arg = '%s'.\n"
450 void Create_Notification_Entity(
463 /* MSG_INFO & MSG_CENTER */
482 // =====================
483 // Global Entity Setup
484 // =====================
485 entity notif = spawn();
490 msg_annce_notifs[nameid - 1] = notif;
491 notif.classname = "msg_annce_notification";
496 msg_info_notifs[nameid - 1] = notif;
497 notif.classname = "msg_info_notification";
502 msg_center_notifs[nameid - 1] = notif;
503 notif.classname = "msg_center_notification";
508 msg_multi_notifs[nameid - 1] = notif;
509 notif.classname = "msg_multi_notification";
514 msg_choice_notifs[nameid - 1] = notif;
515 notif.classname = "msg_choice_notification";
523 "^1NOTIFICATION WITH IMPROPER TYPE: ",
524 "^7net_type = %d, net_name = %s.\n"
529 return; // It's not possible to recover from this one
532 notif.nent_default = var_default;
533 notif.nent_enabled = (1 <= var_cvar);
534 notif.nent_type = typeid;
535 notif.nent_id = nameid;
536 notif.nent_name = strzone(namestring);
538 string typestring = Get_Notif_TypeName(typeid);
540 // Other pre-notif-setup requisites
543 // ====================
544 // Notification Setup
545 // ====================
550 // Set MSG_ANNCE information and handle precaching
552 if not(GENTLE && (var_cvar == 1))
556 if(notif.nent_enabled)
558 precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd));
559 notif.nent_channel = channel;
560 notif.nent_snd = strzone(snd);
561 notif.nent_vol = vol;
562 notif.nent_position = position;
569 "^1NOTIFICATION WITH NO SOUND: ",
570 "^7net_type = %s, net_name = %s.\n"
578 else { notif.nent_enabled = FALSE; }
580 notif.nent_enabled = FALSE;
589 // Set MSG_INFO and MSG_CENTER string/float counts
590 notif.nent_stringcount = strnum;
591 notif.nent_floatcount = flnum;
593 // Only initialize arguments if we're either a client or on a dedicated server
595 float should_process_args = server_is_dedicated;
597 float should_process_args = TRUE;
600 if(should_process_args)
602 // ========================
603 // Process Main Arguments
604 // ========================
609 notif.nent_args = strzone(
610 Process_Notif_Args(1, args, typestring, namestring));
612 else if((hudargs == "") && (durcnt ==""))
616 "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ",
617 "^7net_type = %s, net_name = %s, strnum = %d, flnum = %d\n"
629 notif.nent_args = strzone(
630 Process_Notif_Args(1, args, typestring, namestring));
634 // =======================================
635 // Process HUD and Centerprint Arguments
636 // Only processed on CSQC, as these
637 // args are only for HUD features.
638 // =======================================
642 notif.nent_hudargs = strzone(
643 Process_Notif_Args(2, hudargs, typestring, namestring));
645 if(icon != "") { notif.nent_icon = strzone(icon); }
650 "^1NOTIFICATION HAS HUDARGS BUT NO ICON: ",
651 "^7net_type = %s, net_name = %s.\n"
663 "^1NOTIFICATION HAS ICON BUT NO HUDARGS: ",
664 "^7net_type = %s, net_name = %s.\n"
674 notif.nent_durcnt = strzone(
675 Process_Notif_Args(3, durcnt, typestring, namestring));
677 if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
682 "^1NOTIFICATION HAS DURCNT BUT NO CPID: ",
683 "^7net_type = %s, net_name = %s.\n"
691 else if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
695 // ======================
696 // Process Notif String
697 // ======================
698 #define SET_NOTIF_STRING(string,stringname) \
699 notif.nent_string = strzone(CCR( \
700 Process_Notif_Line( \
712 if(gentle != "") { SET_NOTIF_STRING(gentle, "GENTLE") }
713 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
715 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
717 #undef SET_NOTIF_STRING
719 // Check to make sure a string was chosen
720 if(notif.nent_string == "")
724 "^1EMPTY NOTIFICATION: ",
725 "^7net_type = %s, net_name = %s.\n"
739 // Set MSG_MULTI string/float counts
740 if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG))
744 "^1NOTIFICATION WITH NO SUBCALLS: ",
745 "^7net_type = %s, net_name = %s.\n"
754 // announcements don't actually need any arguments, so lets not even count them.
755 if(anncename != NO_MSG) { notif.nent_msgannce = msg_annce_notifs[anncename - 1]; }
757 float infoname_stringcount = 0, infoname_floatcount = 0;
758 float centername_stringcount = 0, centername_floatcount = 0;
760 if(infoname != NO_MSG)
762 notif.nent_msginfo = msg_info_notifs[infoname - 1];
763 infoname_stringcount = notif.nent_msginfo.nent_stringcount;
764 infoname_floatcount = notif.nent_msginfo.nent_floatcount;
767 if(centername != NO_MSG)
769 notif.nent_msgcenter = msg_center_notifs[centername - 1];
770 centername_stringcount = notif.nent_msgcenter.nent_stringcount;
771 centername_floatcount = notif.nent_msgcenter.nent_floatcount;
774 // set the requirements of THIS notification to the totals of its subcalls
775 notif.nent_stringcount = max(infoname_stringcount, centername_stringcount);
776 notif.nent_floatcount = max(infoname_floatcount, centername_floatcount);
784 if((chtype == NO_MSG) || (optiona == NO_MSG) || (optionb == NO_MSG))
788 "^1NOTIFICATION IS MISSING CHOICE PARAMS: ",
789 "^7net_type = %s, net_name = %s.\n"
802 notif.nent_optiona = msg_annce_notifs[optiona - 1];
803 notif.nent_optionb = msg_annce_notifs[optionb - 1];
808 notif.nent_optiona = msg_info_notifs[optiona - 1];
809 notif.nent_optionb = msg_info_notifs[optionb - 1];
814 notif.nent_optiona = msg_center_notifs[optiona - 1];
815 notif.nent_optionb = msg_center_notifs[optionb - 1];
820 notif.nent_optiona = msg_multi_notifs[optiona - 1];
821 notif.nent_optionb = msg_multi_notifs[optionb - 1];
824 case MSG_CHOICE: // should we REALLY allow nested options?...
826 notif.nent_optiona = msg_choice_notifs[optiona - 1];
827 notif.nent_optionb = msg_choice_notifs[optionb - 1];
835 "^1NOTIFICATION WITH IMPROPER TYPE: ",
836 "^7net_type = %d, net_name = %s.\n"
845 notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed
846 notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed
847 notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount);
848 notif.nent_floatcount = max(notif.nent_optiona.nent_floatcount, notif.nent_optionb.nent_floatcount);
850 /*#ifdef NOTIFICATIONS_DEBUG
851 Debug_Notification(sprintf(
852 "Create_Notification_Entity(...): MSG_CHOICE: %s\n%s\n%s\n",
855 "^ optiona: %s %s : %d %d",
856 Get_Notif_TypeName(notif.nent_optiona.nent_type),
857 notif.nent_optiona.nent_name,
858 notif.nent_optiona.nent_stringcount,
859 notif.nent_optiona.nent_floatcount
862 "^ optionb: %s %s : %d %d",
863 Get_Notif_TypeName(notif.nent_optionb.nent_type),
864 notif.nent_optionb.nent_name,
865 notif.nent_optionb.nent_stringcount,
866 notif.nent_optionb.nent_floatcount
878 "^1NOTIFICATION WITH IMPROPER TYPE: ",
879 "^7net_type = %d, net_name = %s.\n"
889 // now check to see if any errors happened
892 notif.nent_enabled = FALSE; // disable the notification so it can't cause trouble
893 notif_global_error = TRUE; // throw the red flag that an error happened on init
902 // used by MSG_CHOICE to build list of choices
904 void Notification_GetCvars(void)
907 for(i = 0; i <= NOTIF_CHOICE_COUNT; ++i)
909 GetCvars_handleFloat(
912 msg_choice_choices[i],
913 sprintf("notification_%s", msg_choice_notifs[i].nent_name)
919 // used to output notifications.cfg file
920 void Dump_Notifications(float fh, float alsoprint)
922 #define NOTIF_WRITE(a) { \
924 if(alsoprint) { print(a); } }
925 #define NOTIF_WRITE_ENTITY(description) { \
928 "seta notification_%s \"%d\" \"%s\"\n", \
929 e.nent_name, e.nent_default, description \
931 NOTIF_WRITE(notif_msg) }
932 #define NOTIF_WRITE_ENTITY_CHOICE(descriptiona,descriptionb) { \
935 "seta notification_%s \"%d\" \"%s\"\n" \
936 "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
937 e.nent_name, e.nent_default, descriptiona, \
938 e.nent_name, e.nent_challow_def, descriptionb \
940 NOTIF_WRITE(notif_msg) }
941 #define NOTIF_WRITE_HARDCODED(cvar,default,description) { \
944 "seta notification_%s \"%s\" \"%s\"\n", \
945 cvar, default, description \
947 NOTIF_WRITE(notif_msg) }
953 // Note: This warning only applies to the notifications.cfg file that is output...
955 // You ARE supposed to manually edit this function to add i.e. hard coded
956 // notification variables for mutators or game modes or such and then
957 // regenerate the notifications.cfg file from the new code.
959 NOTIF_WRITE("// ********************************************** //\n");
960 NOTIF_WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
961 NOTIF_WRITE("// ** ** //\n");
962 NOTIF_WRITE("// ** This file is automatically generated ** //\n");
963 NOTIF_WRITE("// ** by code with the command 'dumpnotifs'. ** //\n");
964 NOTIF_WRITE("// ** ** //\n");
965 NOTIF_WRITE("// ** If you add a new notification, please ** //\n");
966 NOTIF_WRITE("// ** regenerate this file with that command ** //\n");
967 NOTIF_WRITE("// ** making sure that the output matches ** //\n");
968 NOTIF_WRITE("// ** with the lists and defaults in code. ** //\n");
969 NOTIF_WRITE("// ** ** //\n");
970 NOTIF_WRITE("// ********************************************** //\n");
972 // These notifications will also append their string as a comment...
973 // This is not necessary, and does not matter if they vary between config versions,
974 // it is just a semi-helpful tool for those who want to manually change their user settings.
976 NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
977 for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
979 e = Get_Notif_Ent(MSG_ANNCE, i);
980 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
983 "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
987 NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
988 for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
990 e = Get_Notif_Ent(MSG_INFO, i);
991 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
994 "Notification control cvar: 0 = off, 1 = print to console, "
995 "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
999 NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
1000 for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
1002 e = Get_Notif_Ent(MSG_CENTER, i);
1003 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1006 "Notification control cvar: 0 = off, 1 = centerprint"
1010 NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
1011 for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
1013 e = Get_Notif_Ent(MSG_MULTI, i);
1014 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1017 "Notification control cvar: 0 = off, 1 = trigger subcalls"
1021 NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
1022 for(i = 1; i <= NOTIF_CHOICE_COUNT; ++i)
1024 e = Get_Notif_Ent(MSG_CHOICE, i);
1025 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1027 NOTIF_WRITE_ENTITY_CHOICE(
1028 "Notification control cvar: 0 = off, 1 = trigger option A subcall, 2 = trigger option B subcall",
1029 "Notification control cvar: 0 = off, 1 = allowed in warmup mode, 2 = always allowed"
1033 // edit these to match whichever cvars are used for specific notification options
1034 NOTIF_WRITE("\n// HARD CODED notification variables:\n");
1036 NOTIF_WRITE_HARDCODED(
1037 "allow_chatboxprint", "1",
1038 "Allow notifications to be printed to chat box by setting notification cvar to 2 "
1039 "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
1042 NOTIF_WRITE_HARDCODED(
1044 "Print extra debug information on all notification function calls "
1045 "(Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... "
1046 "0 = disabled, 1 = dprint, 2 = print"
1049 NOTIF_WRITE_HARDCODED(
1050 "errors_are_fatal", "1",
1051 "If a notification fails upon initialization, cause a Host_Error to stop the program"
1054 NOTIF_WRITE_HARDCODED(
1055 "item_centerprinttime", "1.5",
1056 "How long to show item information centerprint messages (like 'You got the Electro' or such)"
1059 NOTIF_WRITE_HARDCODED(
1060 "lifetime_mapload", "10",
1061 "Amount of time that notification entities last immediately at mapload (in seconds) "
1062 "to help prevent notifications from being lost on early init (like gamestart countdown)"
1065 NOTIF_WRITE_HARDCODED(
1066 "lifetime_runtime", "0.5",
1067 "Amount of time that notification entities last on the server during runtime (In seconds)"
1070 NOTIF_WRITE_HARDCODED(
1071 "server_allows_location", "1",
1072 "Server side cvar for allowing death messages to show location information too"
1075 NOTIF_WRITE_HARDCODED(
1076 "show_location", "0",
1077 "Append location information to MSG_INFO death/kill messages"
1080 NOTIF_WRITE_HARDCODED(
1081 "show_location_string", "",
1082 "Replacement string piped into sprintf, "
1083 "so you can do different messages like this: ' at the %s' or ' (near %s)'"
1086 NOTIF_WRITE_HARDCODED(
1088 "Print information about sprees in death/kill messages"
1091 NOTIF_WRITE_HARDCODED(
1092 "show_sprees_center", "1",
1093 "Show spree information in MSG_CENTER messages... "
1094 "0 = off, 1 = target (but only for first victim) and attacker"
1097 NOTIF_WRITE_HARDCODED(
1098 "show_sprees_center_specialonly", "1",
1099 "Don't show spree information in MSG_CENTER messages if it isn't an achievement"
1102 NOTIF_WRITE_HARDCODED(
1103 "show_sprees_info", "3",
1104 "Show spree information in MSG_INFO messages... "
1105 "0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker"
1108 NOTIF_WRITE_HARDCODED(
1109 "show_sprees_info_newline", "1",
1110 "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
1113 NOTIF_WRITE_HARDCODED(
1114 "show_sprees_info_specialonly", "1",
1115 "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
1118 NOTIF_WRITE(sprintf(
1120 "\n// Notification counts (total = %d): ",
1121 "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
1126 NOTIF_CENTER_COUNT +
1138 #undef NOTIF_WRITE_HARDCODED
1139 #undef NOTIF_WRITE_ENTITY
1144 // ===============================
1145 // Frontend Notification Pushing
1146 // ===============================
1148 #ifdef NOTIFICATIONS_DEBUG
1149 void Debug_Notification(string input)
1151 switch(autocvar_notification_debug)
1153 case 1: { dprint(input); break; }
1154 case 2: { print(input); break; }
1159 string Local_Notification_sprintf(
1160 string input, string args,
1161 string s1, string s2, string s3, string s4,
1162 float f1, float f2, float f3, float f4)
1164 #ifdef NOTIFICATIONS_DEBUG
1165 Debug_Notification(sprintf(
1166 "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
1167 MakeConsoleSafe(input),
1169 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1170 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1176 for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
1180 for(sel_num = 0;(args != "");)
1182 selected = car(args); args = cdr(args);
1183 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1184 switch(strtolower(selected))
1186 #define ARG_CASE(prog,selected,result) \
1188 #if (prog != ARG_SV) && (prog != ARG_DC) \
1189 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1192 #if (prog != ARG_CS) && (prog != ARG_DC) \
1193 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1198 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1202 strcat(input, "\n"),
1214 void Local_Notification_sound(
1215 float soundchannel, string soundfile,
1216 float soundvolume, float soundposition)
1218 if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
1220 #ifdef NOTIFICATIONS_DEBUG
1221 Debug_Notification(sprintf(
1222 "Local_Notification_sound(world, %f, '%s', %f, %f);\n",
1225 "announcer/%s/%s.wav",
1226 autocvar_cl_announcer,
1238 "announcer/%s/%s.wav",
1239 autocvar_cl_announcer,
1246 if(prev_soundfile) { strunzone(prev_soundfile); }
1247 prev_soundfile = strzone(soundfile);
1248 prev_soundtime = time;
1252 #ifdef NOTIFICATIONS_DEBUG
1253 Debug_Notification(sprintf(
1255 "Local_Notification_sound(world, %f, '%s', %f, %f) ",
1256 "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
1260 "announcer/%s/%s.wav",
1261 autocvar_cl_announcer,
1267 (time - prev_soundtime),
1268 autocvar_cl_announcer_antispam
1274 void Local_Notification_HUD_Notify_Push(
1275 string icon, string hudargs,
1276 string s1, string s2, string s3, string s4)
1280 arg_slot[0] = ""; arg_slot[1] = "";
1282 for(sel_num = 0;(hudargs != "");)
1284 selected = car(hudargs); hudargs = cdr(hudargs);
1285 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1286 switch(strtolower(selected))
1288 #define ARG_CASE(prog,selected,result) \
1289 #if (prog == ARG_CS_SV_HA) \
1290 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1294 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1297 #ifdef NOTIFICATIONS_DEBUG
1298 Debug_Notification(sprintf(
1299 "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s);\n",
1302 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1303 MakeConsoleSafe(sprintf("'%s^7', '%s^7'", stof(arg_slot[0]), stof(arg_slot[1])))
1306 HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
1309 void Local_Notification_centerprint_generic(
1310 string input, string durcnt,
1311 float cpid, float f1, float f2)
1315 arg_slot[0] = ""; arg_slot[1] = "";
1317 for(sel_num = 0;(durcnt != "");)
1319 selected = car(durcnt); durcnt = cdr(durcnt);
1320 NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic")
1321 switch(strtolower(selected))
1323 #define ARG_CASE(prog,selected,result) \
1324 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
1325 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1331 if(ftos(stof(selected)) != "") { arg_slot[sel_num] = selected; ++sel_num; }
1332 else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") }
1337 #ifdef NOTIFICATIONS_DEBUG
1338 Debug_Notification(sprintf(
1339 "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n",
1340 MakeConsoleSafe(input),
1347 centerprint_generic(cpid, input, stof(arg_slot[0]), stof(arg_slot[1]));
1351 void Local_Notification(float net_type, float net_name, ...count)
1353 // check if this should be aborted
1354 if(net_name == NOTIF_ABORT)
1356 #ifdef NOTIFICATIONS_DEBUG
1357 Debug_Notification(sprintf(
1358 "Local_Notification(%s, %s, ...);\n",
1359 Get_Notif_TypeName(net_type),
1366 // check supplied type and name for errors
1367 string checkargs = Notification_CheckArgs_TypeName(net_type, net_name);
1370 #ifdef NOTIFICATIONS_DEBUG
1371 Debug_Notification(sprintf(
1372 "Local_Notification(%s, %d, ...);\n",
1373 Get_Notif_TypeName(net_type),
1374 Get_Notif_Ent(net_type, net_name).nent_name
1377 backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs));
1381 // retreive entity of this notification
1382 entity notif = Get_Notif_Ent(net_type, net_name);
1385 #ifdef NOTIFICATIONS_DEBUG
1386 Debug_Notification(sprintf(
1387 "Local_Notification(%s, %d, ...);\n",
1388 Get_Notif_TypeName(net_type),
1392 backtrace("Local_Notification: Could not find notification entity!\n");
1396 // check if the notification is enabled
1397 if not(notif.nent_enabled)
1399 #ifdef NOTIFICATIONS_DEBUG
1400 Debug_Notification(sprintf(
1401 "Local_Notification(%s, %s, ...): Entity was disabled...\n",
1402 Get_Notif_TypeName(net_type),
1409 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1410 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1411 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1412 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1413 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1414 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1415 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1416 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1418 #ifdef NOTIFICATIONS_DEBUG
1419 Debug_Notification(sprintf(
1420 "Local_Notification(%s, %s, %s, %s);\n",
1421 Get_Notif_TypeName(net_type),
1423 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1424 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1428 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1432 "Not enough arguments for Local_Notification(%s, %s, ...)! ",
1433 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1434 "Check the definition and function call for accuracy...?\n"
1436 Get_Notif_TypeName(net_type),
1438 notif.nent_stringcount,
1439 notif.nent_floatcount,
1444 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1448 "Too many arguments for Local_Notification(%s, %s, ...)! ",
1449 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1450 "Check the definition and function call for accuracy...?\n"
1452 Get_Notif_TypeName(net_type),
1454 notif.nent_stringcount,
1455 notif.nent_floatcount,
1466 Local_Notification_sound(
1473 backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
1481 Local_Notification_sprintf(
1488 if(notif.nent_icon != "")
1490 Local_Notification_HUD_Notify_Push(
1502 Local_Notification_centerprint_generic(
1503 Local_Notification_sprintf(
1517 if(notif.nent_msginfo)
1518 if(notif.nent_msginfo.nent_enabled)
1520 Local_Notification_WOVA(
1522 notif.nent_msginfo.nent_id,
1523 notif.nent_msginfo.nent_stringcount,
1524 notif.nent_msginfo.nent_floatcount,
1529 if(notif.nent_msgannce)
1530 if(notif.nent_msgannce.nent_enabled)
1532 Local_Notification_WOVA(
1534 notif.nent_msgannce.nent_id,
1539 if(notif.nent_msgcenter)
1540 if(notif.nent_msgcenter.nent_enabled)
1542 Local_Notification_WOVA(
1544 notif.nent_msgcenter.nent_id,
1545 notif.nent_msgcenter.nent_stringcount,
1546 notif.nent_msgcenter.nent_floatcount,
1556 entity found_choice;
1558 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2)))
1560 switch(cvar_string(sprintf("notification_%s", notif.nent_name)))
1562 case 1: found_choice = notif.nent_optiona; break;
1563 case 2: found_choice = notif.nent_optionb; break;
1564 default: return; // not enabled anyway
1567 else { found_choice = notif.nent_optiona; }
1569 Local_Notification_WOVA(
1570 found_choice.nent_type,
1571 found_choice.nent_id,
1572 found_choice.nent_stringcount,
1573 found_choice.nent_floatcount,
1580 // WOVA = Without Variable Arguments
1581 void Local_Notification_WOVA(
1582 float net_type, float net_name,
1583 float stringcount, float floatcount,
1584 string s1, string s2, string s3, string s4,
1585 float f1, float f2, float f3, float f4)
1587 #define VARITEM(stringc,floatc,args) \
1588 if((stringcount == stringc) && (floatcount == floatc)) \
1589 { Local_Notification(net_type, net_name, args); return; }
1590 EIGHT_VARS_TO_VARARGS_VARLIST
1592 Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
1596 // =========================
1597 // Notification Networking
1598 // =========================
1601 void Read_Notification(float is_new)
1603 float net_type = ReadByte();
1604 float net_name = ReadShort();
1608 if(net_type == MSG_CENTER_CPID)
1610 #ifdef NOTIFICATIONS_DEBUG
1611 Debug_Notification(sprintf(
1612 "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n",
1615 Get_Notif_TypeName(net_type),
1622 if(net_name == 0) { reset_centerprint_messages(); }
1623 else if(net_name != NO_CPID)
1625 // in this case, net_name IS the cpid we want to kill
1626 centerprint_generic(net_name, "", 0, 0);
1631 "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n",
1640 notif = Get_Notif_Ent(net_type, net_name);
1641 if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; }
1643 #ifdef NOTIFICATIONS_DEBUG
1644 Debug_Notification(sprintf(
1645 "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n",
1648 Get_Notif_TypeName(net_type),
1653 string s1 = ((0 < notif.nent_stringcount) ? ReadString() : "");
1654 string s2 = ((1 < notif.nent_stringcount) ? ReadString() : "");
1655 string s3 = ((2 < notif.nent_stringcount) ? ReadString() : "");
1656 string s4 = ((3 < notif.nent_stringcount) ? ReadString() : "");
1657 float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0);
1658 float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0);
1659 float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0);
1660 float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0);
1664 Local_Notification_WOVA(
1666 notif.nent_stringcount,
1667 notif.nent_floatcount,
1676 void Net_Notification_Remove()
1678 if not(self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
1680 #ifdef NOTIFICATIONS_DEBUG
1681 Debug_Notification(sprintf(
1682 "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
1684 ((self.nent_net_name == -1) ? "Killed" : "Removed"),
1685 Get_Notif_TypeName(self.nent_net_type),
1686 self.owner.nent_name
1691 for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
1695 float Net_Write_Notification(entity client, float sf)
1697 if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client))
1700 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
1701 WriteByte(MSG_ENTITY, self.nent_net_type);
1702 WriteShort(MSG_ENTITY, self.nent_net_name);
1703 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); }
1704 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
1707 else { return FALSE; }
1710 void Kill_Notification(
1711 float broadcast, entity client,
1712 float net_type, float net_name)
1714 #ifdef NOTIFICATIONS_DEBUG
1715 Debug_Notification(sprintf(
1716 "Kill_Notification(%s, '%s', %s, %d);\n",
1717 Get_Notif_BroadcastName(broadcast),
1719 (net_type ? Get_Notif_TypeName(net_type) : "0"),
1724 string checkargs = Notification_CheckArgs(broadcast, client, 1, 1);
1725 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; }
1727 entity notif, net_notif;
1728 float killed_cpid = NO_CPID;
1734 killed_cpid = 0; // kill ALL centerprints
1742 entity notif = Get_Notif_Ent(net_type, net_name);
1743 if not(notif) { backtrace("Kill_Notification: Could not find notification entity!\n"); return; }
1746 killed_cpid = notif.nent_cpid;
1748 killed_cpid = NO_CPID;
1752 killed_cpid = 0; // kill ALL centerprints
1757 case MSG_CENTER_CPID:
1759 killed_cpid = net_name;
1764 if(killed_cpid != NO_CPID)
1766 net_notif = spawn();
1767 net_notif.classname = "net_kill_notification";
1768 net_notif.nent_broadcast = broadcast;
1769 net_notif.nent_client = client;
1770 net_notif.nent_net_type = MSG_CENTER_CPID;
1771 net_notif.nent_net_name = killed_cpid;
1772 Net_LinkEntity(net_notif, FALSE, autocvar_notification_lifetime_runtime, Net_Write_Notification);
1775 for(notif = world; (notif = find(notif, classname, "net_notification"));)
1779 if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER))
1781 if(notif.owner.nent_cpid == killed_cpid)
1783 notif.nent_net_name = -1;
1784 notif.nextthink = time;
1786 else { continue; } // we ARE looking for a specific CPID, don't kill everything else too
1788 else if(notif.nent_net_type == net_type)
1792 if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; }
1793 else { continue; } // we ARE looking for a certain net_name, don't kill everything else too
1795 else { notif.nent_net_name = -1; notif.nextthink = time; }
1797 else { continue; } // we ARE looking for a certain net_type, don't kill everything else too
1799 else { notif.nent_net_name = -1; notif.nextthink = time; }
1803 void Send_Notification(
1804 float broadcast, entity client,
1805 float net_type, float net_name,
1808 // check if this should be aborted
1809 if(net_name == NOTIF_ABORT)
1811 #ifdef NOTIFICATIONS_DEBUG
1812 Debug_Notification(sprintf(
1813 "Send_Notification(%s, '%s', %s, %s, ...);\n",
1814 Get_Notif_BroadcastName(broadcast),
1816 Get_Notif_TypeName(net_type),
1823 // check supplied broadcast, target, type, and name for errors
1824 string checkargs = Notification_CheckArgs(broadcast, client, net_type, net_name);
1827 #ifdef NOTIFICATIONS_DEBUG
1828 Debug_Notification(sprintf(
1829 "Send_Notification(%s, '%s', %s, %s, ...);\n",
1830 Get_Notif_BroadcastName(broadcast),
1832 Get_Notif_TypeName(net_type),
1833 Get_Notif_Ent(net_type, net_name).nent_name
1836 backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs));
1840 // retreive entity of this notification
1841 entity notif = Get_Notif_Ent(net_type, net_name);
1844 #ifdef NOTIFICATIONS_DEBUG
1845 Debug_Notification(sprintf(
1846 "Send_Notification(%s, '%s', %s, %d, ...);\n",
1847 Get_Notif_BroadcastName(broadcast),
1849 Get_Notif_TypeName(net_type),
1853 backtrace("Send_Notification: Could not find notification entity!\n");
1857 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1858 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1859 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1860 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1861 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1862 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1863 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1864 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1866 #ifdef NOTIFICATIONS_DEBUG
1867 Debug_Notification(sprintf(
1868 "Send_Notification(%s, %s, %s);\n",
1871 Get_Notif_BroadcastName(broadcast),
1873 Get_Notif_TypeName(net_type),
1876 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1877 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1881 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1885 "Not enough arguments for Send_Notification(%s, ...)! ",
1886 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1887 "Check the definition and function call for accuracy...?\n"
1891 Get_Notif_BroadcastName(broadcast),
1893 Get_Notif_TypeName(net_type),
1896 notif.nent_stringcount,
1897 notif.nent_floatcount,
1902 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1906 "Too many arguments for Send_Notification(%s, ...)! ",
1907 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1908 "Check the definition and function call for accuracy...?\n"
1912 Get_Notif_BroadcastName(broadcast),
1914 Get_Notif_TypeName(net_type),
1917 notif.nent_stringcount,
1918 notif.nent_floatcount,
1928 broadcast == NOTIF_ALL
1930 broadcast == NOTIF_ALL_EXCEPT
1934 net_type == MSG_ANNCE
1936 net_type == MSG_CENTER
1940 Local_Notification_WOVA(
1942 notif.nent_stringcount,
1943 notif.nent_floatcount,
1948 if(net_type == MSG_CHOICE)
1950 // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast)
1951 // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option...
1952 // It's slow, but it's better than the alternatives:
1953 // 1. Constantly networking all info and letting client decide
1954 // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
1955 entity found_choice;
1957 #define RECURSE_FROM_CHOICE(ent,action) \
1958 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \
1960 switch(ent.msg_choice_choices[net_name]) \
1962 case 1: found_choice = notif.nent_optiona; break; \
1963 case 2: found_choice = notif.nent_optionb; break; \
1967 else { found_choice = notif.nent_optiona; } \
1968 Send_Notification_WOVA( \
1971 found_choice.nent_type, \
1972 found_choice.nent_id, \
1973 found_choice.nent_stringcount, \
1974 found_choice.nent_floatcount, \
1980 case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method
1982 if(IS_REAL_CLIENT(client))
1983 { RECURSE_FROM_CHOICE(client, return) }
1989 FOR_EACH_REALCLIENT(to)
1990 { if(Notification_ShouldSend(broadcast, to, client))
1991 { RECURSE_FROM_CHOICE(to, continue) } }
1998 entity net_notif = spawn();
1999 net_notif.owner = notif;
2000 net_notif.classname = "net_notification";
2001 net_notif.nent_broadcast = broadcast;
2002 net_notif.nent_client = client;
2003 net_notif.nent_net_type = net_type;
2004 net_notif.nent_net_name = net_name;
2005 net_notif.nent_stringcount = notif.nent_stringcount;
2006 net_notif.nent_floatcount = notif.nent_floatcount;
2009 for(i = 0; i < net_notif.nent_stringcount; ++i)
2010 { net_notif.nent_strings[i] = strzone(...(i, string)); }
2011 for(i = 0; i < net_notif.nent_floatcount; ++i)
2012 { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); }
2014 net_notif.think = Net_Notification_Remove;
2015 net_notif.nextthink =
2016 ((time > autocvar_notification_lifetime_mapload)
2018 (time + autocvar_notification_lifetime_runtime)
2020 autocvar_notification_lifetime_mapload
2023 Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification);
2027 // WOVA = Without Variable Arguments
2028 void Send_Notification_WOVA(
2029 float broadcast, entity client,
2030 float net_type, float net_name,
2031 float stringcount, float floatcount,
2032 string s1, string s2, string s3, string s4,
2033 float f1, float f2, float f3, float f4)
2035 #ifdef NOTIFICATIONS_DEBUG
2036 entity notif = Get_Notif_Ent(net_type, net_name);
2037 Debug_Notification(sprintf(
2038 "Send_Notification_WOVA(%s, %d, %d, %s, %s);\n",
2041 Get_Notif_BroadcastName(broadcast),
2043 Get_Notif_TypeName(net_type),
2048 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
2049 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
2053 #define VARITEM(stringc,floatc,args) \
2054 if((stringcount == stringc) && (floatcount == floatc)) \
2055 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
2056 EIGHT_VARS_TO_VARARGS_VARLIST
2058 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
2061 // WOCOVA = Without Counts Or Variable Arguments
2062 void Send_Notification_WOCOVA(
2063 float broadcast, entity client,
2064 float net_type, float net_name,
2065 string s1, string s2, string s3, string s4,
2066 float f1, float f2, float f3, float f4)
2068 entity notif = Get_Notif_Ent(net_type, net_name);
2070 #ifdef NOTIFICATIONS_DEBUG
2071 Debug_Notification(sprintf(
2072 "Send_Notification_WOCOVA(%s, %s, %s);\n",
2075 Get_Notif_BroadcastName(broadcast),
2077 Get_Notif_TypeName(net_type),
2080 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
2081 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
2085 #define VARITEM(stringc,floatc,args) \
2086 if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
2087 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
2088 EIGHT_VARS_TO_VARARGS_VARLIST
2090 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
2092 #endif // ifdef SVQC