4 #include <client/announcer.qh>
7 #include <common/constants.qh>
8 #include <common/net_linked.qh>
9 #include <common/teams.qh>
10 #include <server/command/getreplies.qh>
11 #include <server/mutators/_mod.qh>
12 #include <server/world.qh>
15 // ================================================
16 // Unified notification system, written by Samual
17 // Last updated: August, 2013
18 // ================================================
21 string Notification_CheckArgs(
22 NOTIF broadcast, entity client)
24 // check supplied broadcast and target for errors
30 if (IS_NOT_A_CLIENT(client)) {
31 return "No client provided!";
36 case NOTIF_ALL_EXCEPT:
38 if (IS_NOT_A_CLIENT(client)) {
39 return "Exception can't be a non-client!";
48 return "Entity provided when NULL was required!";
57 return "Teamplay not active!";
58 } else if (!client.team) {
59 // checkargs = sprintf("%sNo team provided!", checkargs);
64 case NOTIF_TEAM_EXCEPT:
65 case NOTIF_TEAM_ONLY_EXCEPT:
68 return "Teamplay not active!";
69 } else if (IS_NOT_A_CLIENT(client)) {
70 return "Exception can't be a non-client!";
77 return sprintf("Improper broadcast: %d!", broadcast);
83 bool Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_client)
85 if(!IS_REAL_CLIENT(to_client))
92 (to_client == other_client)
94 (IS_SPEC(to_client) && (to_client.enemy == other_client))
97 return (to_client == other_client);
100 (to_client.team == other_client.team)
105 (to_client.enemy.team == other_client.team)
108 case NOTIF_TEAM_EXCEPT:
110 (to_client != other_client)
113 (to_client.team == other_client.team)
119 (to_client.enemy != other_client)
121 (to_client.enemy.team == other_client.team)
126 case NOTIF_TEAM_ONLY:
128 (to_client.team == other_client.team)
130 case NOTIF_TEAM_ONLY_EXCEPT:
132 (to_client != other_client)
134 (to_client.team == other_client.team)
138 (IS_SPEC(to_client) || IS_OBSERVER(to_client))
142 case NOTIF_ALL_EXCEPT:
144 (to_client != other_client)
149 (to_client.enemy == other_client)
159 // ===============================
160 // Initialization Core Functions
161 // ===============================
163 // used by restartnotifs command to initialize notifications
164 void Destroy_Notification_Entity(entity notif)
166 if (notif.nent_name != "") strunzone(notif.nent_name);
167 if (notif.nent_snd != "") strunzone(notif.nent_snd);
168 if (notif.nent_args != "") strunzone(notif.nent_args);
169 if (notif.nent_hudargs != "") strunzone(notif.nent_hudargs);
170 if (notif.nent_icon != "") strunzone(notif.nent_icon);
171 if (notif.nent_durcnt != "") strunzone(notif.nent_durcnt);
172 if (notif.nent_string != "") strunzone(notif.nent_string);
176 void Destroy_All_Notifications()
178 // kill all networked notifications and centerprints
180 Kill_Notification(NOTIF_ALL, NULL, MSG_Null, CPID_Null);
182 centerprint_KillAll();
185 // kill all real notification entities
186 FOREACH(Notifications, true, { Destroy_Notification_Entity(it); });
189 string Process_Notif_Line(
198 if(typeId == MSG_INFO)
200 if((chat && autocvar_notification_allow_chatboxprint)
201 || (autocvar_notification_allow_chatboxprint == 2))
203 // pass 1: add ETX char at beginning of line
204 input = strcat("\{3}", input);
206 // pass 2: add ETX char at end of each new line (so that
207 // messages with multiple lines are put through chatbox too)
208 input = strreplace("\n", "\n\{3}", input);
210 // pass 3: strip trailing ETX char
211 if(substring(input, (strlen(input) - 1), 1) == "\{3}")
212 { input = substring(input, 0, (strlen(input) - 1)); }
217 // done to both MSG_INFO and MSG_CENTER
218 if(substring(input, (strlen(input) - 1), 1) == "\n")
222 "^1TRAILING NEW LINE AT END OF NOTIFICATION: "
223 "^7net_type = %s, net_name = %s, string = %s."
230 input = substring(input, 1, (strlen(input) - 1));
236 string Process_Notif_Args(
242 string selected, remaining = args;
245 for (;(remaining != "");)
247 selected = car(remaining); remaining = cdr(remaining);
251 case 1: // normal args
253 if(sel_num == NOTIF_MAX_ARGS)
257 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
258 "^7net_type = %s, net_name = %s, max args = %d."
268 switch(strtolower(selected))
270 #define ARG_CASE_ARG_CS_SV_HA(selected,result) case selected: ++sel_num; break;
271 #define ARG_CASE_ARG_CS_SV_DC(selected,result) case selected: ++sel_num; break;
272 #define ARG_CASE_ARG_CS_SV(selected,result) case selected: ++sel_num; break;
273 #define ARG_CASE_ARG_CS(selected,result) case selected: ++sel_num; break;
274 #define ARG_CASE_ARG_SV(selected,result) case selected: ++sel_num; break;
275 #define ARG_CASE_ARG_DC(selected,result)
276 #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result)
279 #undef ARG_CASE_ARG_DC
280 #undef ARG_CASE_ARG_SV
281 #undef ARG_CASE_ARG_CS
282 #undef ARG_CASE_ARG_CS_SV
283 #undef ARG_CASE_ARG_CS_SV_DC
284 #undef ARG_CASE_ARG_CS_SV_HA
289 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
290 "^7net_type = %s, net_name = %s, args arg = '%s'."
304 if(sel_num == NOTIF_MAX_HUDARGS)
308 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
309 "^7net_type = %s, net_name = %s, max hudargs = %d."
319 switch(strtolower(selected))
321 #define ARG_CASE_ARG_CS_SV_HA(selected,result) case selected: ++sel_num; break;
322 #define ARG_CASE_ARG_CS_SV_DC(selected,result)
323 #define ARG_CASE_ARG_CS_SV(selected,result)
324 #define ARG_CASE_ARG_CS(selected,result)
325 #define ARG_CASE_ARG_SV(selected,result)
326 #define ARG_CASE_ARG_DC(selected,result)
327 #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result)
330 #undef ARG_CASE_ARG_DC
331 #undef ARG_CASE_ARG_SV
332 #undef ARG_CASE_ARG_CS
333 #undef ARG_CASE_ARG_CS_SV
334 #undef ARG_CASE_ARG_CS_SV_DC
335 #undef ARG_CASE_ARG_CS_SV_HA
340 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
341 "^7net_type = %s, net_name = %s, hudargs arg = '%s'."
355 if(sel_num == NOTIF_MAX_DURCNT)
359 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
360 "^7net_type = %s, net_name = %s, max durcnt = %d."
370 switch(strtolower(selected))
372 #define ARG_CASE_ARG_CS_SV_HA(selected,result)
373 #define ARG_CASE_ARG_CS_SV_DC(selected,result) case selected: ++sel_num; break;
374 #define ARG_CASE_ARG_CS_SV(selected,result)
375 #define ARG_CASE_ARG_CS(selected,result)
376 #define ARG_CASE_ARG_SV(selected,result)
377 #define ARG_CASE_ARG_DC(selected,result) case selected: ++sel_num; break;
378 #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result)
381 #undef ARG_CASE_ARG_DC
382 #undef ARG_CASE_ARG_SV
383 #undef ARG_CASE_ARG_CS
384 #undef ARG_CASE_ARG_CS_SV
385 #undef ARG_CASE_ARG_CS_SV_DC
386 #undef ARG_CASE_ARG_CS_SV_HA
389 if(ftos(stof(selected)) != "") { ++sel_num; }
394 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
395 "^7net_type = %s, net_name = %s, durcnt arg = '%s'."
413 void Create_Notification_Entity(entity notif,
420 // =====================
421 // Global Entity Setup
422 // =====================
423 notif.nent_default = var_default;
424 notif.nent_enabled = (var_cvar >= 1);
425 notif.nent_type = typeId;
426 notif.nent_name = strzone(namestring);
427 notif.nent_teamnum = teamnum;
429 // Other pre-notif-setup requisites
444 "^1NOTIFICATION WITH IMPROPER TYPE: "
445 "^7net_type = %d, net_name = %s."
454 // now check to see if any errors happened
457 notif.nent_enabled = false; // disable the notification so it can't cause trouble
458 notif_global_error = true; // throw the red flag that an error happened on init
462 #define AnnouncerFilename(snd) sprintf("announcer/%s/%s.wav", AnnouncerOption(), snd)
464 void Create_Notification_Entity_Annce(entity notif,
474 // Set MSG_ANNCE information and handle precaching
476 MSG typeId = MSG_ANNCE;
477 if (!(GENTLE && (var_cvar == 1)))
481 if(notif.nent_enabled)
483 precache_sound(AnnouncerFilename(snd));
484 notif.nent_channel = channel;
485 notif.nent_snd = strzone(snd);
486 notif.nent_vol = vol;
487 notif.nent_position = position;
488 notif.nent_queuetime = queuetime;
493 string typestring = Get_Notif_TypeName(typeId);
496 "^1NOTIFICATION WITH NO SOUND: "
497 "^7net_type = %s, net_name = %s."
505 else { notif.nent_enabled = false; }
507 notif.nent_enabled = false;
512 void Create_Notification_Entity_InfoCenter(entity notif,
517 /* MSG_INFO & MSG_CENTER */
526 MSG typeId = notif.nent_type;
527 // Set MSG_INFO and MSG_CENTER string/float counts
528 notif.nent_stringcount = strnum;
529 notif.nent_floatcount = flnum;
531 // Only initialize arguments if we're either a client or on a dedicated server
533 float should_process_args = server_is_dedicated;
535 float should_process_args = true;
537 string typestring = Get_Notif_TypeName(typeId);
538 if(should_process_args)
540 // ========================
541 // Process Main Arguments
542 // ========================
547 notif.nent_args = strzone(
548 Process_Notif_Args(1, args, typestring, namestring));
550 else if((hudargs == "") && (durcnt ==""))
554 "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: "
555 "^7net_type = %s, net_name = %s, strnum = %d, flnum = %d"
567 notif.nent_args = strzone(
568 Process_Notif_Args(1, args, typestring, namestring));
572 // =======================================
573 // Process HUD and Centerprint Arguments
574 // Only processed on CSQC, as these
575 // args are only for HUD features.
576 // =======================================
580 notif.nent_hudargs = strzone(
581 Process_Notif_Args(2, hudargs, typestring, namestring));
583 if(icon != "") { notif.nent_icon = strzone(icon); }
588 "^1NOTIFICATION HAS HUDARGS BUT NO ICON: "
589 "^7net_type = %s, net_name = %s."
601 "^1NOTIFICATION HAS ICON BUT NO HUDARGS: "
602 "^7net_type = %s, net_name = %s.\n"
612 notif.nent_durcnt = strzone(Process_Notif_Args(3, durcnt, typestring, namestring));
614 if (cpid == CPID_Null && durcnt != "0 0")
618 "Notification has durcnt but no cpid: "
619 "net_type = %s, net_name = %s."
627 notif.nent_cpid = cpid;
631 // ======================
632 // Process Notif String
633 // ======================
634 #define SET_NOTIF_STRING(string,stringname) MACRO_BEGIN \
635 notif.nent_string = strzone(CCR( \
636 Process_Notif_Line( \
649 if(gentle != "") { SET_NOTIF_STRING(gentle, "GENTLE"); }
650 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL"); }
652 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL"); }
653 #undef SET_NOTIF_STRING
655 // Check to make sure a string was chosen
656 if(notif.nent_string == "")
660 "^1EMPTY NOTIFICATION: "
661 "^7net_type = %s, net_name = %s."
671 void Create_Notification_Entity_Multi(entity notif,
675 Notification anncename,
676 Notification infoname,
677 Notification centername)
679 MSG typeId = MSG_MULTI;
680 // Set MSG_MULTI string/float counts
681 if (!anncename && !infoname && !centername)
683 string typestring = Get_Notif_TypeName(typeId);
686 "^1NOTIFICATION WITH NO SUBCALLS: "
687 "^7net_type = %s, net_name = %s."
696 // announcements don't actually need any arguments, so lets not even count them.
697 if (anncename) { notif.nent_msgannce = anncename; }
699 float infoname_stringcount = 0, infoname_floatcount = 0;
700 float centername_stringcount = 0, centername_floatcount = 0;
704 notif.nent_msginfo = infoname;
705 infoname_stringcount = notif.nent_msginfo.nent_stringcount;
706 infoname_floatcount = notif.nent_msginfo.nent_floatcount;
711 notif.nent_msgcenter = centername;
712 centername_stringcount = notif.nent_msgcenter.nent_stringcount;
713 centername_floatcount = notif.nent_msgcenter.nent_floatcount;
716 // set the requirements of THIS notification to the totals of its subcalls
717 notif.nent_stringcount = max(infoname_stringcount, centername_stringcount);
718 notif.nent_floatcount = max(infoname_floatcount, centername_floatcount);
722 void Create_Notification_Entity_Choice(entity notif,
729 Notification optiona,
730 Notification optionb)
732 MSG typeId = MSG_CHOICE;
733 if (chtype == MSG_Null || !optiona || !optionb)
735 string typestring = Get_Notif_TypeName(typeId);
738 "^1NOTIFICATION IS MISSING CHOICE PARAMS: "
739 "^7net_type = %s, net_name = %s."
748 notif.nent_optiona = optiona;
749 notif.nent_optionb = optionb;
750 notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed
751 notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed
752 notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount);
753 notif.nent_floatcount = max(notif.nent_optiona.nent_floatcount, notif.nent_optionb.nent_floatcount);
755 /*#ifdef NOTIFICATIONS_DEBUG
756 Debug_Notification(sprintf(
757 "Create_Notification_Entity(...): MSG_CHOICE: %s\n%s\n%s\n",
760 "^ optiona: %s %s : %d %d",
761 Get_Notif_TypeName(notif.nent_optiona.nent_type),
762 notif.nent_optiona.nent_name,
763 notif.nent_optiona.nent_stringcount,
764 notif.nent_optiona.nent_floatcount
767 "^ optionb: %s %s : %d %d",
768 Get_Notif_TypeName(notif.nent_optionb.nent_type),
769 notif.nent_optionb.nent_name,
770 notif.nent_optionb.nent_stringcount,
771 notif.nent_optionb.nent_floatcount
778 void Create_Notification_Entity_Medal(entity notif,
783 Notification anncename)
785 notif.nent_floatcount = 1;
786 if (icon != "") { notif.nent_icon = strzone(icon); }
787 if (anncename) { notif.nent_msgannce = anncename; }
794 // used by MSG_CHOICE to build list of choices
796 void Notification_GetCvars(entity this, entity store)
798 FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
799 GetCvars_handleFloat(
804 msg_choice_choices[it.nent_choice_idx],
805 sprintf("notification_%s", Get_Notif_CvarName(it))
811 /** used to output notifications.cfg file */
812 void Dump_Notifications(int fh, bool alsoprint)
814 #define NOTIF_WRITE(str) write_String_To_File(fh, str, alsoprint)
816 #define NOTIF_WRITE_ENTITY(e, description) \
817 NOTIF_WRITE(sprintf( \
818 "seta notification_%s \"%d\" \"%s\"\n", \
819 Get_Notif_CvarName(e), e.nent_default, description \
822 #define NOTIF_WRITE_ENTITY_CHOICE(e, descriptiona, descriptionb) \
823 NOTIF_WRITE(sprintf( \
824 "seta notification_%s \"%d\" \"%s\"\n" \
825 "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
826 Get_Notif_CvarName(e), e.nent_default, descriptiona, \
827 Get_Notif_CvarName(e), e.nent_challow_def, descriptionb \
830 #define NOTIF_WRITE_HARDCODED(cvar, default, description) \
831 NOTIF_WRITE("seta notification_" cvar " \"" default "\" \"" description "\"\n")
833 // Note: This warning only applies to the notifications.cfg file that is output...
834 // You ARE supposed to manually edit this function to add i.e. hard coded
835 // notification variables for mutators or game modes or such and then
836 // regenerate the notifications.cfg file from the new code.
839 "// ********************************************** //\n"
840 "// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n"
842 "// ** This file is automatically generated ** //\n"
843 "// ** by code with the command 'dumpnotifs'. ** //\n"
845 "// ** If you add a new notification, please ** //\n"
846 "// ** regenerate this file with that command ** //\n"
847 "// ** making sure that the output matches ** //\n"
848 "// ** with the lists and defaults in code. ** //\n"
850 "// ********************************************** //\n");
852 // These notifications will also append their string as a comment...
853 // This is not necessary, and does not matter if they vary between config versions,
854 // it is just a semi-helpful tool for those who want to manually change their user settings.
856 int NOTIF_ANNCE_COUNT = 0;
857 int NOTIF_INFO_COUNT = 0;
858 int NOTIF_CENTER_COUNT = 0;
859 int NOTIF_MULTI_COUNT = 0;
860 int NOTIF_CHOICE_COUNT = 0;
861 int NOTIF_MEDAL_COUNT = 0;
862 FOREACH(Notifications, true, {
863 switch (it.nent_type)
865 case MSG_ANNCE: ++NOTIF_ANNCE_COUNT; break;
866 case MSG_INFO: ++NOTIF_INFO_COUNT; break;
867 case MSG_CENTER: ++NOTIF_CENTER_COUNT; break;
868 case MSG_MULTI: ++NOTIF_MULTI_COUNT; break;
869 case MSG_CHOICE: ++NOTIF_CHOICE_COUNT; break;
870 case MSG_MEDAL: ++NOTIF_MEDAL_COUNT; break;
874 NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications:\n"));
875 FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
876 NOTIF_WRITE_ENTITY(it,
877 "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
881 NOTIF_WRITE(sprintf("\n// MSG_INFO notifications:\n"));
882 FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
883 NOTIF_WRITE_ENTITY(it,
884 "0 = off, 1 = print to console, "
885 "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
889 NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications:\n"));
890 FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
891 NOTIF_WRITE_ENTITY(it,
892 "0 = off, 1 = centerprint"
896 NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications:\n"));
897 FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
898 NOTIF_WRITE_ENTITY(it,
899 "Enable this multiple notification"
903 NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications:\n"));
904 FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
905 NOTIF_WRITE_ENTITY_CHOICE(it,
906 "Choice for this notification 0 = off, 1 = default message, 2 = verbose message",
907 "Allow choice for this notification 0 = off, 1 = only in warmup mode, 2 = always"
911 NOTIF_WRITE(sprintf("\n// MSG_MEDAL notifications (count = %d):\n", NOTIF_MEDAL_COUNT));
912 FOREACH(Notifications, it.nent_type == MSG_MEDAL && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
913 NOTIF_WRITE_ENTITY(it,
914 "Enable this multiple notification"
918 // edit these to match whichever cvars are used for specific notification options
919 NOTIF_WRITE("\n// HARD CODED notification variables:\n");
921 NOTIF_WRITE_HARDCODED(
922 "allow_chatboxprint", "1",
923 "Allow INFO notifications to be printed to chat box "
925 "1 = allow only if allowed by individual notification_INFO* cvars, "
926 "2 = force all INFO notifications to be printed to the chatbox"
929 NOTIF_WRITE_HARDCODED(
931 "Print extra debug information on all notification function calls "
932 "(Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... "
933 "0 = disabled, 1 = dprint, 2 = print"
936 NOTIF_WRITE_HARDCODED(
937 "errors_are_fatal", "1",
938 "If a notification fails upon initialization, cause a Host_Error to stop the program"
941 NOTIF_WRITE_HARDCODED(
942 "item_centerprinttime", "1.5",
943 "How long to show item information centerprint messages (like 'You got the Electro' or such)"
946 NOTIF_WRITE_HARDCODED(
947 "lifetime_mapload", "10",
948 "Amount of time that notification entities last immediately at mapload (in seconds) "
949 "to help prevent notifications from being lost on early init (like gamestart countdown)"
952 NOTIF_WRITE_HARDCODED(
953 "lifetime_runtime", "0.5",
954 "Amount of time that notification entities last on the server during runtime (In seconds)"
957 NOTIF_WRITE_HARDCODED(
958 "server_allows_location", "1",
959 "Server side cvar for allowing death messages to show location information too"
962 NOTIF_WRITE_HARDCODED(
963 "show_location", "0",
964 "Append location information to MSG_INFO death/kill messages"
967 NOTIF_WRITE_HARDCODED(
968 "show_location_string", "",
969 "Replacement string piped into sprintf, "
970 "so you can do different messages like this: ' at the %s' or ' (near %s)'"
973 NOTIF_WRITE_HARDCODED(
975 "Print information about sprees in death/kill messages"
978 NOTIF_WRITE_HARDCODED(
979 "show_sprees_center", "1",
980 "Show spree information in MSG_CENTER messages... "
981 "0 = off, 1 = target (but only for first victim) and attacker"
984 NOTIF_WRITE_HARDCODED(
985 "show_sprees_center_specialonly", "1",
986 "Don't show spree information in MSG_CENTER messages if it isn't an achievement"
989 NOTIF_WRITE_HARDCODED(
990 "show_sprees_info", "3",
991 "Show spree information in MSG_INFO messages... "
992 "0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker"
995 NOTIF_WRITE_HARDCODED(
996 "show_sprees_info_newline", "1",
997 "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
1000 NOTIF_WRITE_HARDCODED(
1001 "show_sprees_info_specialonly", "1",
1002 "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
1005 LOG_INFOF("Notification counts (total = %d): "
1006 "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n",
1010 NOTIF_CENTER_COUNT +
1012 NOTIF_CHOICE_COUNT +
1022 #undef NOTIF_WRITE_HARDCODED
1023 #undef NOTIF_WRITE_ENTITY
1028 // ===============================
1029 // Frontend Notification Pushing
1030 // ===============================
1032 string Local_Notification_sprintf(
1033 string input, string args,
1034 string s1, string s2, string s3, string s4,
1035 int f1, float f2, float f3, float f4)
1037 #ifdef NOTIFICATIONS_DEBUG
1038 Debug_Notification(sprintf(
1039 "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
1040 MakeConsoleSafe(input),
1042 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1043 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1047 for (int sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
1049 for (int sel_num = 0; (args != ""); )
1051 string selected = car(args); args = cdr(args);
1052 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf");
1053 string tmp_s; // used by NOTIF_ARGUMENT_LIST
1054 switch (strtolower(selected))
1056 #define ARG_CASE_ARG_CS_SV_HA(selected, result) case selected: arg_slot[sel_num++] = result; break;
1057 #define ARG_CASE_ARG_CS_SV_DC(selected, result) case selected: arg_slot[sel_num++] = result; break;
1058 #define ARG_CASE_ARG_CS_SV(selected, result) case selected: arg_slot[sel_num++] = result; break;
1060 #define ARG_CASE_ARG_CS(selected, result) case selected: arg_slot[sel_num++] = result; break;
1061 #define ARG_CASE_ARG_SV(selected, result)
1063 #define ARG_CASE_ARG_CS(selected, result)
1064 #define ARG_CASE_ARG_SV(selected, result) case selected: arg_slot[sel_num++] = result; break;
1066 #define ARG_CASE_ARG_DC(selected, result)
1067 #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected, result)
1070 #undef ARG_CASE_ARG_DC
1071 #undef ARG_CASE_ARG_SV
1072 #undef ARG_CASE_ARG_CS
1073 #undef ARG_CASE_ARG_CS_SV
1074 #undef ARG_CASE_ARG_CS_SV_DC
1075 #undef ARG_CASE_ARG_CS_SV_HA
1076 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1080 strcat(input, "\n"),
1092 void Local_Notification_sound(int soundchannel, string soundfile, float soundvolume, float soundposition)
1094 if ((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
1096 #ifdef NOTIFICATIONS_DEBUG
1097 Debug_Notification(sprintf(
1098 "Local_Notification_sound(%f, '%s', %f, %f);\n",
1100 AnnouncerFilename(soundfile),
1106 _sound(NULL, soundchannel, AnnouncerFilename(soundfile), soundvolume, soundposition);
1108 strcpy(prev_soundfile, soundfile);
1109 prev_soundtime = time;
1113 #ifdef NOTIFICATIONS_DEBUG
1114 Debug_Notification(sprintf(
1116 "Local_Notification_sound(%f, '%s', %f, %f) "
1117 "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
1120 AnnouncerFilename(soundfile),
1124 (time - prev_soundtime),
1125 autocvar_cl_announcer_antispam
1131 void Local_Notification_HUD_Notify_Push(
1132 string icon, string hudargs,
1133 string s1, string s2, string s3, string s4,
1134 float f1, float f2, float f3, float f4)
1136 arg_slot[0] = ""; arg_slot[1] = "";
1138 for (int sel_num = 0; (hudargs != ""); )
1140 string selected = car(hudargs); hudargs = cdr(hudargs);
1141 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push");
1142 switch (strtolower(selected))
1144 #define ARG_CASE_ARG_CS_SV_HA(selected, result) case selected: arg_slot[sel_num++] = result; break;
1145 #define ARG_CASE_ARG_CS_SV_DC(selected, result)
1146 #define ARG_CASE_ARG_CS_SV(selected, result)
1147 #define ARG_CASE_ARG_CS(selected, result)
1148 #define ARG_CASE_ARG_SV(selected, result)
1149 #define ARG_CASE_ARG_DC(selected, result)
1150 #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected, result)
1153 #undef ARG_CASE_ARG_DC
1154 #undef ARG_CASE_ARG_SV
1155 #undef ARG_CASE_ARG_CS
1156 #undef ARG_CASE_ARG_CS_SV
1157 #undef ARG_CASE_ARG_CS_SV_DC
1158 #undef ARG_CASE_ARG_CS_SV_HA
1159 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1162 #ifdef NOTIFICATIONS_DEBUG
1163 Debug_Notification(sprintf(
1164 "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s, %s);\n",
1167 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1168 sprintf("%d, %d, %d, %d", f1, f2, f3, f4),
1169 MakeConsoleSafe(sprintf("'%s^7', '%s^7'", stof(arg_slot[0]), stof(arg_slot[1])))
1172 HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
1175 void Local_Notification_centerprint_Add(
1176 string input, string durcnt,
1177 CPID cpid, float f1, float f2)
1179 arg_slot[0] = ""; arg_slot[1] = "";
1181 for (int sel_num = 0; (durcnt != ""); )
1183 string selected = car(durcnt); durcnt = cdr(durcnt);
1184 NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_Add");
1185 switch (strtolower(selected))
1187 #define ARG_CASE_ARG_CS_SV_HA(selected, result)
1188 #define ARG_CASE_ARG_CS_SV_DC(selected, result) case selected: arg_slot[sel_num++] = result; break;
1189 #define ARG_CASE_ARG_CS_SV(selected, result)
1190 #define ARG_CASE_ARG_CS(selected, result)
1191 #define ARG_CASE_ARG_SV(selected, result)
1192 #define ARG_CASE_ARG_DC(selected, result) case selected: arg_slot[sel_num++] = result; break;
1193 #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected,result)
1196 #undef ARG_CASE_ARG_DC
1197 #undef ARG_CASE_ARG_SV
1198 #undef ARG_CASE_ARG_CS
1199 #undef ARG_CASE_ARG_CS_SV
1200 #undef ARG_CASE_ARG_CS_SV_DC
1201 #undef ARG_CASE_ARG_CS_SV_HA
1204 if (/* wtf */ ftos(stof(selected)) != "") { arg_slot[sel_num++] = selected; }
1205 else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_Add") }
1210 #ifdef NOTIFICATIONS_DEBUG
1211 Debug_Notification(sprintf(
1212 "Local_Notification_centerprint_Add('%s^7', '%s', %d, %d, %d, %d);\n",
1213 MakeConsoleSafe(input),
1220 centerprint_Add(ORDINAL(cpid), input, stof(arg_slot[0]), stof(arg_slot[1]));
1223 void Local_Notification_Queue_Run(MSG net_type, entity notif, float f1)
1229 Local_Notification_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
1235 centerprint_Medal(notif.nent_icon, f1);
1236 if(notif.nent_msgannce)
1237 Local_Notification_sound(
1238 notif.nent_msgannce.nent_channel,
1239 notif.nent_msgannce.nent_snd,
1240 notif.nent_msgannce.nent_vol,
1241 notif.nent_msgannce.nent_position);
1247 void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time, float f1)
1249 //LOG_INFOF("Comparison %d > %d", time, notif_queue_next_time);
1250 if(queue_time == -1 || time > notif_queue_next_time) {
1251 //LOG_INFOF("Running NOW!");
1252 Local_Notification_Queue_Run(net_type, notif, f1);
1253 notif_queue_next_time = time + queue_time;
1255 //LOG_INFOF("Queueing: %d %d", notif_queue_length, notif_queue_next_time);
1256 if(notif_queue_length >= NOTIF_QUEUE_MAX) return;
1258 notif_queue_type[notif_queue_length] = net_type;
1259 notif_queue_entity[notif_queue_length] = notif;
1260 notif_queue_time[notif_queue_length] = notif_queue_next_time;
1261 notif_queue_f1[notif_queue_length] = f1;
1263 notif_queue_next_time += queue_time;
1264 ++notif_queue_length;
1268 void Local_Notification_Queue_Process()
1270 if(!notif_queue_length)
1275 if(notif_queue_time[0] <= time) {
1276 //LOG_INFOF("Process running: %d <= %d", notif_queue_time[0], time);
1277 Local_Notification_Queue_Run(notif_queue_type[0], notif_queue_entity[0], notif_queue_f1[0]);
1279 // Shift queue to the left
1280 for (j = 0; j < notif_queue_length - 1; j++) {
1281 notif_queue_type[j] = notif_queue_type[j+1];
1282 notif_queue_entity[j] = notif_queue_entity[j+1];
1283 notif_queue_time[j] = notif_queue_time[j+1];
1284 notif_queue_f1[j] = notif_queue_f1[j+1];
1287 --notif_queue_length;
1293 void Local_Notification(MSG net_type, Notification net_name, ...count)
1295 // retreive entity of this notification
1296 entity notif = net_name;
1299 #ifdef NOTIFICATIONS_DEBUG
1300 Debug_Notification(sprintf(
1301 "Local_Notification(%s, NULL, ...);\n",
1302 Get_Notif_TypeName(net_type)
1305 LOG_WARNF("Incorrect usage of Local_Notification: %s", "Null notification");
1309 // check if the notification is enabled
1310 if (!notif.nent_enabled)
1312 #ifdef NOTIFICATIONS_DEBUG
1313 Debug_Notification(sprintf(
1314 "Local_Notification(%s, %s, ...): Entity was disabled...\n",
1315 Get_Notif_TypeName(net_type),
1322 string s1 = CCR((notif.nent_stringcount > 0) ? ...(0, string) : "");
1323 string s2 = CCR((notif.nent_stringcount > 1) ? ...(1, string) : "");
1324 string s3 = CCR((notif.nent_stringcount > 2) ? ...(2, string) : "");
1325 string s4 = CCR((notif.nent_stringcount > 3) ? ...(3, string) : "");
1326 float f1 = ((notif.nent_floatcount > 0) ? ...((notif.nent_stringcount + 0), float) : 0);
1327 float f2 = ((notif.nent_floatcount > 1) ? ...((notif.nent_stringcount + 1), float) : 0);
1328 float f3 = ((notif.nent_floatcount > 2) ? ...((notif.nent_stringcount + 2), float) : 0);
1329 float f4 = ((notif.nent_floatcount > 3) ? ...((notif.nent_stringcount + 3), float) : 0);
1331 #ifdef NOTIFICATIONS_DEBUG
1332 Debug_Notification(sprintf(
1333 "Local_Notification(%s, %s, %s, %s);\n",
1334 Get_Notif_TypeName(net_type),
1336 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1337 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1341 if ((notif.nent_stringcount + notif.nent_floatcount) != count)
1345 "Arguments mismatch for Local_Notification(%s, %s, ...)! "
1346 "stringcount(%d) + floatcount(%d) != count(%d)\n"
1347 "Check the definition and function call for accuracy...?\n"
1349 Get_Notif_TypeName(net_type),
1351 notif.nent_stringcount,
1352 notif.nent_floatcount,
1363 //Local_Notification_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
1364 Local_Notification_Queue_Add(
1367 notif.nent_queuetime,
1370 backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
1378 Local_Notification_sprintf(
1385 if (notif.nent_icon != "")
1387 if (notif.nent_iconargs != "")
1389 string s = Local_Notification_sprintf(
1390 notif.nent_icon,notif.nent_iconargs,
1391 s1, s2, s3, s4, f1, f2, f3, f4);
1392 // remove the trailing newline
1393 notif.nent_icon = strzone(substring(s, 0, -1));
1395 Local_Notification_HUD_Notify_Push(
1408 Local_Notification_centerprint_Add(
1409 Local_Notification_sprintf(
1423 if (notif.nent_msginfo && notif.nent_msginfo.nent_enabled)
1425 Local_Notification_WOVA(
1428 notif.nent_msginfo.nent_stringcount,
1429 notif.nent_msginfo.nent_floatcount,
1434 if (notif.nent_msgannce && notif.nent_msgannce.nent_enabled)
1436 Local_Notification_WOVA(
1438 notif.nent_msgannce,
1443 if (notif.nent_msgcenter && notif.nent_msgcenter.nent_enabled)
1445 Local_Notification_WOVA(
1447 notif.nent_msgcenter,
1448 notif.nent_msgcenter.nent_stringcount,
1449 notif.nent_msgcenter.nent_floatcount,
1459 entity found_choice = notif.nent_optiona;
1460 if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) {
1461 switch (cvar(sprintf("notification_%s", Get_Notif_CvarName(notif))))
1464 case 2: found_choice = notif.nent_optionb; break;
1465 default: return; // not enabled anyway
1469 Local_Notification_WOVA(
1470 found_choice.nent_type,
1472 found_choice.nent_stringcount,
1473 found_choice.nent_floatcount,
1482 Local_Notification_Queue_Add(
1485 (notif.nent_msgannce ? MSG_MEDAL_TIME : 0),
1493 // WOVA = Without Variable Arguments
1494 void Local_Notification_WOVA(
1495 MSG net_type, Notification net_name,
1496 float stringcount, float floatcount,
1497 string s1, string s2, string s3, string s4,
1498 float f1, float f2, float f3, float f4)
1500 #define VARITEM(stringc, floatc, args) \
1501 if ((stringcount == stringc) && (floatcount == floatc)) \
1502 { Local_Notification(net_type, net_name, args); return; }
1503 EIGHT_VARS_TO_VARARGS_VARLIST
1505 Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
1509 // =========================
1510 // Notification Networking
1511 // =========================
1513 /** networked as a linked entity to give newly connecting clients some notification context */
1514 REGISTER_NET_LINKED(ENT_CLIENT_NOTIFICATION)
1517 NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new)
1520 MSG net_type = ENUMCAST(MSG, ReadByte());
1521 int net_name = ReadShort();
1524 if (net_type == MSG_CENTER_KILL)
1526 if (!is_new) return;
1528 #ifdef NOTIFICATIONS_DEBUG
1529 Debug_Notification(sprintf(
1530 "Read_Notification(%d) at %f: net_type = %s, cpid = %d\n",
1533 Get_Notif_TypeName(net_type),
1537 int _net_name = net_name;
1538 CPID net_name = ENUMCAST(CPID, _net_name);
1539 if (net_name == CPID_Null) {
1540 centerprint_KillAll();
1542 centerprint_Kill(ORDINAL(net_name));// kill group
1547 Notification notif = Get_Notif_Ent(net_type, net_name);
1549 #ifdef NOTIFICATIONS_DEBUG
1550 Debug_Notification(sprintf(
1551 "Read_Notification(%d) at %f: net_type = %s, net_name = %s (%d)\n",
1554 Get_Notif_TypeName(net_type),
1555 notif.registered_id,
1561 backtrace("Read_Notification: Could not find notification entity!\n");
1565 string s1 = ((notif.nent_stringcount > 0) ? ReadString() : "");
1566 string s2 = ((notif.nent_stringcount > 1) ? ReadString() : "");
1567 string s3 = ((notif.nent_stringcount > 2) ? ReadString() : "");
1568 string s4 = ((notif.nent_stringcount > 3) ? ReadString() : "");
1569 float f1 = ((notif.nent_floatcount > 0) ? ReadLong() : 0);
1570 float f2 = ((notif.nent_floatcount > 1) ? ReadLong() : 0);
1571 float f3 = ((notif.nent_floatcount > 2) ? ReadLong() : 0);
1572 float f4 = ((notif.nent_floatcount > 3) ? ReadLong() : 0);
1574 if (!is_new) return;
1575 Local_Notification_WOVA(
1577 notif.nent_stringcount,
1578 notif.nent_floatcount,
1585 void Net_Notification_Remove(entity this)
1587 #ifdef NOTIFICATIONS_DEBUG
1588 Debug_Notification(sprintf(
1589 "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
1591 ((this.nent_net_name == -1) ? "Killed" : "Removed"),
1592 Get_Notif_TypeName(this.nent_net_type),
1593 this.owner.nent_name
1596 for (int i = 0; i < this.nent_stringcount; ++i) { strfree(this.nent_strings[i]); }
1600 bool Net_Write_Notification(entity this, entity client, int sf)
1602 if (!Notification_ShouldSend(this.nent_broadcast, client, this.nent_client)) return false;
1603 WriteHeader(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
1604 WriteByte(MSG_ENTITY, ORDINAL(this.nent_net_type));
1605 WriteShort(MSG_ENTITY, this.nent_net_name);
1606 for (int i = 0; i < this.nent_stringcount; ++i) { WriteString(MSG_ENTITY, this.nent_strings[i]); }
1607 for (int i = 0; i < this.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, this.nent_floats[i]); }
1611 void Kill_Notification(
1612 NOTIF broadcast, entity client,
1613 /** message group, MSG_Null for all */
1615 /** cpid group, CPID_Null for all */
1618 #ifdef NOTIFICATIONS_DEBUG
1619 Debug_Notification(sprintf(
1620 "Kill_Notification(%s, '%s', %s, %d);\n",
1621 Get_Notif_BroadcastName(broadcast),
1623 (net_type ? Get_Notif_TypeName(net_type) : "0"),
1628 string checkargs = Notification_CheckArgs(broadcast, client);
1629 if (checkargs != "") { LOG_WARNF("Incorrect usage of Kill_Notification: %s", checkargs); return; }
1631 entity net_notif = new_pure(net_kill_notification);
1632 net_notif.nent_broadcast = broadcast;
1633 net_notif.nent_client = client;
1634 net_notif.nent_net_type = MSG_CENTER_KILL;
1635 net_notif.nent_net_name = ORDINAL(net_cpid);
1636 Net_LinkEntity(net_notif, false, autocvar_notification_lifetime_runtime, Net_Write_Notification);
1638 IL_EACH(g_notifications,
1639 (it.owner.nent_type == net_type || net_type == MSG_Null) && (it.owner.nent_cpid == net_cpid || net_cpid == CPID_Null),
1641 it.nent_net_name = -1;
1642 it.nextthink = time;
1647 void Send_Notification(
1648 NOTIF broadcast, entity client,
1649 MSG net_type, Notification net_name,
1652 if (broadcast == NOTIF_ONE_ONLY && !IS_REAL_CLIENT(client)) return;
1653 entity notif = net_name;
1654 string parms = sprintf("%s, '%s', %s, %s",
1655 Get_Notif_BroadcastName(broadcast),
1657 Get_Notif_TypeName(net_type),
1658 net_name.registered_id
1660 #ifdef NOTIFICATIONS_DEBUG
1661 Debug_Notification(sprintf("Send_Notification(%s, ...%d);\n", parms, count));
1666 LOG_WARN("Send_Notification: Could not find notification entity!");
1670 // check supplied broadcast, target, type, and name for errors
1671 string checkargs = Notification_CheckArgs(broadcast, client);
1672 if (!net_name) { checkargs = sprintf("No notification provided! %s", checkargs); }
1673 if (checkargs != "")
1675 LOG_WARNF("Incorrect usage of Send_Notification: %s", checkargs);
1679 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1680 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1681 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1682 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1683 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1684 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1685 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1686 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1688 #ifdef NOTIFICATIONS_DEBUG
1689 Debug_Notification(sprintf(
1690 "Send_Notification(%s, %s, %s);\n",
1692 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1693 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1697 if ((notif.nent_stringcount + notif.nent_floatcount) != count)
1700 "Argument mismatch for Send_Notification(%s, ...)! "
1701 "stringcount(%d) + floatcount(%d) != count(%d)\n"
1702 "Check the definition and function call for accuracy...?\n",
1704 notif.nent_stringcount,
1705 notif.nent_floatcount,
1711 if (server_is_dedicated
1712 && (broadcast == NOTIF_ALL || broadcast == NOTIF_ALL_EXCEPT)
1713 && !(net_type == MSG_ANNCE || net_type == MSG_CENTER)
1716 Local_Notification_WOVA(
1718 notif.nent_stringcount,
1719 notif.nent_floatcount,
1724 if (net_type == MSG_CHOICE)
1726 // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast)
1727 // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option...
1728 // It's slow, but it's better than the alternatives:
1729 // 1. Constantly networking all info and letting client decide
1730 // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
1731 entity found_choice;
1733 #define RECURSE_FROM_CHOICE(ent,action) MACRO_BEGIN \
1734 if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) { \
1735 switch (CS_CVAR(ent).msg_choice_choices[net_name.nent_choice_idx]) \
1737 case 1: found_choice = notif.nent_optiona; break; \
1738 case 2: found_choice = notif.nent_optionb; break; \
1742 found_choice = notif.nent_optiona; \
1744 Send_Notification_WOVA( \
1747 found_choice.nent_type, \
1749 found_choice.nent_stringcount, \
1750 found_choice.nent_floatcount, \
1757 case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method
1759 if (IS_REAL_CLIENT(client)) {
1760 RECURSE_FROM_CHOICE(client, return);
1766 FOREACH_CLIENT(Notification_ShouldSend(broadcast, it, client), {
1767 RECURSE_FROM_CHOICE(it, continue);
1775 entity net_notif = new_pure(net_notification);
1776 IL_PUSH(g_notifications, net_notif);
1777 net_notif.owner = notif;
1778 net_notif.nent_broadcast = broadcast;
1779 net_notif.nent_client = client;
1780 net_notif.nent_net_type = net_type;
1781 net_notif.nent_net_name = notif.m_id;
1782 net_notif.nent_stringcount = notif.nent_stringcount;
1783 net_notif.nent_floatcount = notif.nent_floatcount;
1785 for (int i = 0; i < net_notif.nent_stringcount; ++i) {
1786 net_notif.nent_strings[i] = strzone(...(i, string));
1788 for (int i = 0; i < net_notif.nent_floatcount; ++i) {
1789 net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float);
1792 setthink(net_notif, Net_Notification_Remove);
1793 net_notif.nextthink = (time > autocvar_notification_lifetime_mapload)
1794 ? (time + autocvar_notification_lifetime_runtime)
1795 : autocvar_notification_lifetime_mapload;
1797 Net_LinkEntity(net_notif, false, 0, Net_Write_Notification);
1801 // WOVA = Without Variable Arguments
1802 void Send_Notification_WOVA(
1803 NOTIF broadcast, entity client,
1804 MSG net_type, Notification net_name,
1805 float stringcount, float floatcount,
1806 string s1, string s2, string s3, string s4,
1807 float f1, float f2, float f3, float f4)
1809 #ifdef NOTIFICATIONS_DEBUG
1810 entity notif = net_name;
1811 Debug_Notification(sprintf(
1812 "Send_Notification_WOVA(%s, %d, %d, %s, %s);\n",
1815 Get_Notif_BroadcastName(broadcast),
1817 Get_Notif_TypeName(net_type),
1822 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1823 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1827 #define VARITEM(stringc, floatc, args) \
1828 if ((stringcount == stringc) && (floatcount == floatc)) \
1829 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
1830 EIGHT_VARS_TO_VARARGS_VARLIST
1832 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
1835 // WOCOVA = Without Counts Or Variable Arguments
1836 void Send_Notification_WOCOVA(
1837 NOTIF broadcast, entity client,
1838 MSG net_type, Notification net_name,
1839 string s1, string s2, string s3, string s4,
1840 float f1, float f2, float f3, float f4)
1842 entity notif = net_name;
1844 #ifdef NOTIFICATIONS_DEBUG
1845 Debug_Notification(sprintf(
1846 "Send_Notification_WOCOVA(%s, %s, %s);\n",
1849 Get_Notif_BroadcastName(broadcast),
1851 Get_Notif_TypeName(net_type),
1854 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1855 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1859 #define VARITEM(stringc, floatc, args) \
1860 if ((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
1861 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
1862 EIGHT_VARS_TO_VARARGS_VARLIST
1864 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
1866 #endif // ifdef SVQC