1 // ================================================
2 // Unified notification system, written by Samual
3 // Last updated: June, 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); }
107 case NOTIF_TEAM_EXCEPT:
109 if not(teamplay) { checkargs = sprintf("%sTeamplay not active!", checkargs); }
110 else if(IS_NOT_A_CLIENT(client))
112 if(broadcast == NOTIF_TEAM) { checkargs = sprintf("%sNo client provided!", checkargs); }
113 else { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
118 default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
123 float Notification_ShouldSend(float broadcast, entity to_client, entity other_client)
127 case NOTIF_ONE: // send to one client and their spectator
130 (to_client == other_client)
135 (to_client.enemy == other_client)
140 case NOTIF_ONE_ONLY: // send ONLY to one client
142 if(to_client == other_client) { return TRUE; }
145 case NOTIF_TEAM: // send only to X team and their spectators
148 (to_client.team == other_client.team)
153 (to_client.enemy.team == other_client.team)
158 case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators
161 (to_client != other_client)
164 (to_client.team == other_client.team)
170 (to_client.enemy != other_client)
172 (to_client.enemy.team == other_client.team)
179 case NOTIF_ALL: // send to everyone
183 case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators
186 (to_client != other_client)
191 (to_client.enemy == other_client)
202 // ===============================
203 // Initialization Core Functions
204 // ===============================
206 // used by restartnotifs command to initialize notifications
207 void Destroy_Notification_Entity(entity notif)
209 if(notif.nent_name != "") { strunzone(notif.nent_name); }
210 if(notif.nent_snd != "") { strunzone(notif.nent_snd); }
211 if(notif.nent_args != "") { strunzone(notif.nent_args); }
212 if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
213 if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
214 if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
215 if(notif.nent_string != "") { strunzone(notif.nent_string); }
219 void Destroy_All_Notifications(void)
224 #define DESTROY_LOOP(type,count) \
225 for(i = 1; i <= count; ++i) \
227 notif = Get_Notif_Ent(type, i); \
228 if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
229 Destroy_Notification_Entity(notif); \
232 // kill all networked notifications and centerprints
234 Kill_Notification(NOTIF_ALL, world, 0, 0);
236 reset_centerprint_messages();
239 // kill all real notification entities
240 DESTROY_LOOP(MSG_ANNCE, NOTIF_ANNCE_COUNT)
241 DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
242 DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
243 DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
244 DESTROY_LOOP(MSG_CHOICE, NOTIF_CHOICE_COUNT)
248 string Process_Notif_Line(
257 if(typeid == MSG_INFO)
259 if((chat && autocvar_notification_allow_chatboxprint)
260 || (autocvar_notification_allow_chatboxprint == 2))
262 // pass 1: add ETX char at beginning of line
263 input = strcat("\{3}", input);
265 // pass 2: add ETX char at end of each new line (so that
266 // messages with multiple lines are put through chatbox too)
267 input = strreplace("\n", "\n\{3}", input);
269 // pass 3: strip trailing ETX char
270 if(substring(input, (strlen(input) - 1), 1) == "\{3}")
271 { input = substring(input, 0, (strlen(input) - 1)); }
276 // done to both MSG_INFO and MSG_CENTER
277 if(substring(input, (strlen(input) - 1), 1) == "\n")
281 "^1TRAILING NEW LINE AT END OF NOTIFICATION: ",
282 "^7net_type = %s, net_name = %s, string = %s.\n"
289 input = substring(input, 1, (strlen(input) - 1));
295 string Process_Notif_Args(
301 string selected, remaining = args;
304 for(;(remaining != "");)
306 selected = car(remaining); remaining = cdr(remaining);
310 case 1: // normal args
312 if(sel_num == NOTIF_MAX_ARGS)
316 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
317 "^7net_type = %s, net_name = %s, max args = %d.\n"
327 switch(strtolower(selected))
329 #define ARG_CASE(prog,selected,result) \
330 #if (prog != ARG_DC) \
331 case selected: { ++sel_num; break; } \
339 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
340 "^7net_type = %s, net_name = %s, args arg = '%s'.\n"
354 if(sel_num == NOTIF_MAX_HUDARGS)
358 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
359 "^7net_type = %s, net_name = %s, max hudargs = %d.\n"
369 switch(strtolower(selected))
371 #define ARG_CASE(prog,selected,result) \
372 #if (prog == ARG_CS_SV_HA) \
373 case selected: { ++sel_num; break; } \
381 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
382 "^7net_type = %s, net_name = %s, hudargs arg = '%s'.\n"
396 if(sel_num == NOTIF_MAX_DURCNT)
400 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
401 "^7net_type = %s, net_name = %s, max durcnt = %d.\n"
411 switch(strtolower(selected))
413 #define ARG_CASE(prog,selected,result) \
414 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
415 case selected: { ++sel_num; break; } \
421 if(ftos(stof(selected)) != "") { ++sel_num; }
426 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
427 "^7net_type = %s, net_name = %s, durcnt arg = '%s'.\n"
445 void Create_Notification_Entity(
458 /* MSG_INFO & MSG_CENTER */
477 // =====================
478 // Global Entity Setup
479 // =====================
480 entity notif = spawn();
485 msg_annce_notifs[nameid - 1] = notif;
486 notif.classname = "msg_annce_notification";
491 msg_info_notifs[nameid - 1] = notif;
492 notif.classname = "msg_info_notification";
497 msg_center_notifs[nameid - 1] = notif;
498 notif.classname = "msg_center_notification";
503 msg_multi_notifs[nameid - 1] = notif;
504 notif.classname = "msg_multi_notification";
509 msg_choice_notifs[nameid - 1] = notif;
510 notif.classname = "msg_choice_notification";
518 "^1NOTIFICATION WITH IMPROPER TYPE: ",
519 "^7net_type = %d, net_name = %s.\n"
524 return; // It's not possible to recover from this one
527 notif.nent_default = var_default;
528 notif.nent_enabled = (1 <= var_cvar);
529 notif.nent_type = typeid;
530 notif.nent_id = nameid;
531 notif.nent_name = strzone(namestring);
533 string typestring = Get_Notif_TypeName(typeid);
535 // Other pre-notif-setup requisites
538 // ====================
539 // Notification Setup
540 // ====================
545 // Set MSG_ANNCE information and handle precaching
547 if not(GENTLE && (var_cvar == 1))
551 if(notif.nent_enabled)
553 precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd));
554 notif.nent_channel = channel;
555 notif.nent_snd = strzone(snd);
556 notif.nent_vol = vol;
557 notif.nent_position = position;
564 "^1NOTIFICATION WITH NO SOUND: ",
565 "^7net_type = %s, net_name = %s.\n"
573 else { notif.nent_enabled = FALSE; }
575 notif.nent_enabled = FALSE;
584 // Set MSG_INFO and MSG_CENTER string/float counts
585 notif.nent_stringcount = strnum;
586 notif.nent_floatcount = flnum;
588 // Only initialize arguments if we're either a client or on a dedicated server
590 float should_process_args = server_is_dedicated;
592 float should_process_args = TRUE;
595 if(should_process_args)
597 // ========================
598 // Process Main Arguments
599 // ========================
604 notif.nent_args = strzone(
605 Process_Notif_Args(1, args, typestring, namestring));
607 else if((hudargs == "") && (durcnt ==""))
611 "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ",
612 "^7net_type = %s, net_name = %s, strnum = %d, flnum = %d\n"
624 notif.nent_args = strzone(
625 Process_Notif_Args(1, args, typestring, namestring));
629 // =======================================
630 // Process HUD and Centerprint Arguments
631 // Only processed on CSQC, as these
632 // args are only for HUD features.
633 // =======================================
637 notif.nent_hudargs = strzone(
638 Process_Notif_Args(2, hudargs, typestring, namestring));
640 if(icon != "") { notif.nent_icon = strzone(icon); }
645 "^1NOTIFICATION HAS HUDARGS BUT NO ICON: ",
646 "^7net_type = %s, net_name = %s.\n"
658 "^1NOTIFICATION HAS ICON BUT NO HUDARGS: ",
659 "^7net_type = %s, net_name = %s.\n"
669 notif.nent_durcnt = strzone(
670 Process_Notif_Args(3, durcnt, typestring, namestring));
672 if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
677 "^1NOTIFICATION HAS DURCNT BUT NO CPID: ",
678 "^7net_type = %s, net_name = %s.\n"
686 else if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
690 // ======================
691 // Process Notif String
692 // ======================
693 #define SET_NOTIF_STRING(string,stringname) \
694 notif.nent_string = strzone(CCR( \
695 Process_Notif_Line( \
707 if(gentle != "") { SET_NOTIF_STRING(gentle, "GENTLE") }
708 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
710 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
712 #undef SET_NOTIF_STRING
714 // Check to make sure a string was chosen
715 if(notif.nent_string == "")
719 "^1EMPTY NOTIFICATION: ",
720 "^7net_type = %s, net_name = %s.\n"
734 // Set MSG_MULTI string/float counts
735 if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG))
739 "^1NOTIFICATION WITH NO SUBCALLS: ",
740 "^7net_type = %s, net_name = %s.\n"
749 // announcements don't actually need any arguments, so lets not even count them.
750 if(anncename != NO_MSG) { notif.nent_msgannce = msg_annce_notifs[anncename - 1]; }
752 float infoname_stringcount = 0, infoname_floatcount = 0;
753 float centername_stringcount = 0, centername_floatcount = 0;
755 if(infoname != NO_MSG)
757 notif.nent_msginfo = msg_info_notifs[infoname - 1];
758 infoname_stringcount = notif.nent_msginfo.nent_stringcount;
759 infoname_floatcount = notif.nent_msginfo.nent_floatcount;
762 if(centername != NO_MSG)
764 notif.nent_msgcenter = msg_center_notifs[centername - 1];
765 centername_stringcount = notif.nent_msgcenter.nent_stringcount;
766 centername_floatcount = notif.nent_msgcenter.nent_floatcount;
769 // set the requirements of THIS notification to the totals of its subcalls
770 notif.nent_stringcount = max(infoname_stringcount, centername_stringcount);
771 notif.nent_floatcount = max(infoname_floatcount, centername_floatcount);
779 if((chtype == NO_MSG) || (optiona == NO_MSG) || (optionb == NO_MSG))
783 "^1NOTIFICATION IS MISSING CHOICE PARAMS: ",
784 "^7net_type = %s, net_name = %s.\n"
797 notif.nent_optiona = msg_annce_notifs[optiona - 1];
798 notif.nent_optionb = msg_annce_notifs[optionb - 1];
803 notif.nent_optiona = msg_info_notifs[optiona - 1];
804 notif.nent_optionb = msg_info_notifs[optionb - 1];
809 notif.nent_optiona = msg_center_notifs[optiona - 1];
810 notif.nent_optionb = msg_center_notifs[optionb - 1];
815 notif.nent_optiona = msg_multi_notifs[optiona - 1];
816 notif.nent_optionb = msg_multi_notifs[optionb - 1];
819 case MSG_CHOICE: // should we REALLY allow nested options?...
821 notif.nent_optiona = msg_choice_notifs[optiona - 1];
822 notif.nent_optionb = msg_choice_notifs[optionb - 1];
830 "^1NOTIFICATION WITH IMPROPER TYPE: ",
831 "^7net_type = %d, net_name = %s.\n"
840 notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed
841 notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed
842 notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount);
843 notif.nent_floatcount = max(notif.nent_optiona.nent_floatcount, notif.nent_optionb.nent_floatcount);
845 #ifdef NOTIFICATIONS_DEBUG
846 Debug_Notification(sprintf(
847 "Create_Notification_Entity(...): MSG_CHOICE: %s\n"
848 "^ optiona: %s %s : %d %d\n"
849 "^ optionb: %s %s : %d %d\n",
851 Get_Notif_TypeName(notif.nent_optiona.nent_type),
852 notif.nent_optiona.nent_name,
853 notif.nent_optiona.nent_stringcount,
854 notif.nent_optiona.nent_floatcount,
855 Get_Notif_TypeName(notif.nent_optiona.nent_type),
856 notif.nent_optiona.nent_name,
857 notif.nent_optiona.nent_stringcount,
858 notif.nent_optiona.nent_floatcount
865 default: print("DAFUQ?\n"); notif_error = TRUE; break;
868 // now check to see if any errors happened
871 notif.nent_enabled = FALSE; // disable the notification so it can't cause trouble
872 notif_global_error = TRUE; // throw the red flag that an error happened on init
881 // used by MSG_CHOICE to build list of choices
883 void Notification_GetCvars(void)
886 for(i = 0; i <= NOTIF_CHOICE_COUNT; ++i)
888 GetCvars_handleFloat(
891 msg_choice_choices[i],
892 sprintf("notification_%s", msg_choice_notifs[i].nent_name)
896 GetCvars_handleFloat(get_cvars_s, get_cvars_f, FRAG_VERBOSE, "notification_frag_verbose");
900 // used to output notifications.cfg file
901 void Dump_Notifications(float fh, float alsoprint)
903 #define NOTIF_WRITE(a) { \
905 if(alsoprint) { print(a); } }
906 #define NOTIF_WRITE_ENTITY(description) { \
909 "seta notification_%s \"%d\" \"%s\"\n", \
910 e.nent_name, e.nent_default, description \
912 NOTIF_WRITE(notif_msg) }
913 #define NOTIF_WRITE_ENTITY_CHOICE(descriptiona,descriptionb) { \
916 "seta notification_%s \"%d\" \"%s\"\n" \
917 "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
918 e.nent_name, e.nent_default, descriptiona, \
919 e.nent_name, e.nent_challow_def, descriptionb \
921 NOTIF_WRITE(notif_msg) }
922 #define NOTIF_WRITE_HARDCODED(cvar,default,description) { \
925 "seta notification_%s \"%s\" \"%s\"\n", \
926 cvar, default, description \
928 NOTIF_WRITE(notif_msg) }
934 // Note: This warning only applies to the notifications.cfg file that is output...
936 // You ARE supposed to manually edit this function to add i.e. hard coded
937 // notification variables for mutators or game modes or such and then
938 // regenerate the notifications.cfg file from the new code.
940 NOTIF_WRITE("// ********************************************** //\n");
941 NOTIF_WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
942 NOTIF_WRITE("// ** ** //\n");
943 NOTIF_WRITE("// ** This file is automatically generated ** //\n");
944 NOTIF_WRITE("// ** by code with the command 'dumpnotifs'. ** //\n");
945 NOTIF_WRITE("// ** ** //\n");
946 NOTIF_WRITE("// ** If you add a new notification, please ** //\n");
947 NOTIF_WRITE("// ** regenerate this file with that command ** //\n");
948 NOTIF_WRITE("// ** making sure that the output matches ** //\n");
949 NOTIF_WRITE("// ** with the lists and defaults in code. ** //\n");
950 NOTIF_WRITE("// ** ** //\n");
951 NOTIF_WRITE("// ********************************************** //\n");
953 // These notifications will also append their string as a comment...
954 // This is not necessary, and does not matter if they vary between config versions,
955 // it is just a semi-helpful tool for those who want to manually change their user settings.
957 NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
958 for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
960 e = Get_Notif_Ent(MSG_ANNCE, i);
961 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
964 "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
968 NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
969 for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
971 e = Get_Notif_Ent(MSG_INFO, i);
972 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
975 "Notification control cvar: 0 = off, 1 = print to console, "
976 "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
980 NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
981 for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
983 e = Get_Notif_Ent(MSG_CENTER, i);
984 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
987 "Notification control cvar: 0 = off, 1 = centerprint"
991 NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
992 for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
994 e = Get_Notif_Ent(MSG_MULTI, i);
995 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
998 "Notification control cvar: 0 = off, 1 = trigger subcalls"
1002 NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
1003 for(i = 1; i <= NOTIF_CHOICE_COUNT; ++i)
1005 e = Get_Notif_Ent(MSG_CHOICE, i);
1006 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1008 NOTIF_WRITE_ENTITY_CHOICE(
1009 "Notification control cvar: 0 = off, 1 = trigger option A subcall, 2 = trigger option B subcall",
1010 "Notification control cvar: 0 = off, 1 = allowed in warmup mode, 2 = always allowed"
1014 // edit these to match whichever cvars are used for specific notification options
1015 NOTIF_WRITE("\n// HARD CODED notification variables:\n");
1017 NOTIF_WRITE_HARDCODED(
1018 "allow_chatboxprint", "1",
1019 "Allow notifications to be printed to chat box by setting notification cvar to 2 "
1020 "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
1023 NOTIF_WRITE_HARDCODED(
1024 "ctf_capture_verbose", "0",
1025 "Show extra information when someone captures a flag"
1028 NOTIF_WRITE_HARDCODED(
1029 "ctf_pickup_enemy_verbose", "0",
1030 "Show extra information if an enemy picks up a flag"
1033 NOTIF_WRITE_HARDCODED(
1034 "ctf_pickup_team_verbose", "0",
1035 "Show extra information if a team mate picks up a flag"
1038 NOTIF_WRITE_HARDCODED(
1040 "Print extra debug information on all notification function calls "
1041 "(Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... "
1042 "0 = disabled, 1 = dprint, 2 = print"
1045 NOTIF_WRITE_HARDCODED(
1046 "errors_are_fatal", "1",
1047 "If a notification fails upon initialization, cause a Host_Error to stop the program"
1050 NOTIF_WRITE_HARDCODED(
1051 "item_centerprinttime", "1.5",
1052 "How long to show item information centerprint messages (like 'You got the Electro' or such)"
1055 NOTIF_WRITE_HARDCODED(
1056 "lifetime_mapload", "10",
1057 "Amount of time that notification entities last immediately at mapload (in seconds) "
1058 "to help prevent notifications from being lost on early init (like gamestart countdown)"
1061 NOTIF_WRITE_HARDCODED(
1062 "lifetime_runtime", "0.5",
1063 "Amount of time that notification entities last on the server during runtime (In seconds)"
1066 NOTIF_WRITE_HARDCODED(
1067 "server_allows_location", "1",
1068 "Server side cvar for allowing death messages to show location information too"
1071 NOTIF_WRITE_HARDCODED(
1072 "show_location", "0",
1073 "Append location information to MSG_INFO death/kill messages"
1076 NOTIF_WRITE_HARDCODED(
1077 "show_location_string", "",
1078 "Replacement string piped into sprintf, "
1079 "so you can do different messages like this: ' at the %s' or ' (near %s)'"
1082 NOTIF_WRITE_HARDCODED(
1084 "Print information about sprees in death/kill messages"
1087 NOTIF_WRITE_HARDCODED(
1088 "show_sprees_center", "1",
1089 "Show spree information in MSG_CENTER messages... "
1090 "0 = off, 1 = target (but only for first victim) and attacker"
1093 NOTIF_WRITE_HARDCODED(
1094 "show_sprees_center_specialonly", "1",
1095 "Don't show spree information in MSG_CENTER messages if it isn't an achievement"
1098 NOTIF_WRITE_HARDCODED(
1099 "show_sprees_info", "3",
1100 "Show spree information in MSG_INFO messages... "
1101 "0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker"
1104 NOTIF_WRITE_HARDCODED(
1105 "show_sprees_info_newline", "1",
1106 "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
1109 NOTIF_WRITE_HARDCODED(
1110 "show_sprees_info_specialonly", "1",
1111 "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
1114 NOTIF_WRITE(sprintf(
1116 "\n// Notification counts (total = %d): ",
1117 "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
1122 NOTIF_CENTER_COUNT +
1134 #undef NOTIF_WRITE_HARDCODED
1135 #undef NOTIF_WRITE_ENTITY
1140 // ===============================
1141 // Frontend Notification Pushing
1142 // ===============================
1144 #ifdef NOTIFICATIONS_DEBUG
1145 void Debug_Notification(string input)
1147 switch(autocvar_notification_debug)
1149 case 1: { dprint(input); break; }
1150 case 2: { print(input); break; }
1155 string Local_Notification_sprintf(
1156 string input, string args,
1157 string s1, string s2, string s3, string s4,
1158 float f1, float f2, float f3, float f4)
1160 #ifdef NOTIFICATIONS_DEBUG
1161 Debug_Notification(sprintf(
1162 "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
1163 MakeConsoleSafe(input),
1165 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1166 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1172 for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
1176 for(sel_num = 0;(args != "");)
1178 selected = car(args); args = cdr(args);
1179 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1180 switch(strtolower(selected))
1182 #define ARG_CASE(prog,selected,result) \
1184 #if (prog != ARG_SV) && (prog != ARG_DC) \
1185 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1188 #if (prog != ARG_CS) && (prog != ARG_DC) \
1189 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1194 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1198 strcat(input, "\n"),
1210 void Local_Notification_sound(
1211 float soundchannel, string soundfile,
1212 float soundvolume, float soundposition)
1214 if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
1216 #ifdef NOTIFICATIONS_DEBUG
1217 Debug_Notification(sprintf(
1218 "Local_Notification_sound(world, %f, '%s', %f, %f);\n",
1221 "announcer/%s/%s.wav",
1222 autocvar_cl_announcer,
1234 "announcer/%s/%s.wav",
1235 autocvar_cl_announcer,
1242 if(prev_soundfile) { strunzone(prev_soundfile); }
1243 prev_soundfile = strzone(soundfile);
1244 prev_soundtime = time;
1248 #ifdef NOTIFICATIONS_DEBUG
1249 Debug_Notification(sprintf(
1251 "Local_Notification_sound(world, %f, '%s', %f, %f) ",
1252 "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
1256 "announcer/%s/%s.wav",
1257 autocvar_cl_announcer,
1263 (time - prev_soundtime),
1264 autocvar_cl_announcer_antispam
1270 void Local_Notification_HUD_Notify_Push(
1271 string icon, string hudargs,
1272 string s1, string s2, string s3, string s4)
1276 arg_slot[0] = ""; arg_slot[1] = "";
1278 for(sel_num = 0;(hudargs != "");)
1280 selected = car(hudargs); hudargs = cdr(hudargs);
1281 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1282 switch(strtolower(selected))
1284 #define ARG_CASE(prog,selected,result) \
1285 #if (prog == ARG_CS_SV_HA) \
1286 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1290 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1293 #ifdef NOTIFICATIONS_DEBUG
1294 Debug_Notification(sprintf(
1295 "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s);\n",
1298 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1299 MakeConsoleSafe(sprintf("'%s^7', '%s^7'", stof(arg_slot[0]), stof(arg_slot[1])))
1302 HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
1305 void Local_Notification_centerprint_generic(
1306 string input, string durcnt,
1307 float cpid, float f1, float f2)
1311 arg_slot[0] = ""; arg_slot[1] = "";
1313 for(sel_num = 0;(durcnt != "");)
1315 selected = car(durcnt); durcnt = cdr(durcnt);
1316 NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic")
1317 switch(strtolower(selected))
1319 #define ARG_CASE(prog,selected,result) \
1320 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
1321 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1327 if(ftos(stof(selected)) != "") { arg_slot[sel_num] = selected; ++sel_num; }
1328 else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") }
1333 #ifdef NOTIFICATIONS_DEBUG
1334 Debug_Notification(sprintf(
1335 "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n",
1336 MakeConsoleSafe(input),
1339 stof(arg_slot[0]), stof(arg_slot[1])
1342 centerprint_generic(cpid, input, stof(arg_slot[0]), stof(arg_slot[1]));
1346 void Local_Notification(float net_type, float net_name, ...count)
1348 // check supplied type and name for errors
1349 string checkargs = Notification_CheckArgs_TypeName(net_type, net_name);
1350 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs)); return; }
1352 entity notif = Get_Notif_Ent(net_type, net_name);
1353 if not(notif) { backtrace("Local_Notification: Could not find notification entity!\n"); return; }
1354 if not(notif.nent_enabled)
1356 #ifdef NOTIFICATIONS_DEBUG
1357 Debug_Notification(sprintf(
1358 "Local_Notification(%s, %s): Entity was disabled...\n",
1359 Get_Notif_TypeName(net_type),
1366 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1370 "Not enough arguments for Local_Notification(%s, %s, ...)! ",
1371 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1372 "Check the definition and function call for accuracy...?\n"
1374 Get_Notif_TypeName(net_type), notif.nent_name,
1375 notif.nent_stringcount, notif.nent_floatcount, count
1379 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1383 "Too many arguments for Local_Notification(%s, %s, ...)! ",
1384 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1385 "Check the definition and function call for accuracy...?\n"
1387 Get_Notif_TypeName(net_type), notif.nent_name,
1388 notif.nent_stringcount, notif.nent_floatcount, count
1393 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1394 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1395 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1396 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1397 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1398 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1399 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1400 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1402 #ifdef NOTIFICATIONS_DEBUG
1403 Debug_Notification(sprintf(
1404 "Local_Notification(%s, %s, %s, %s);\n",
1405 Get_Notif_TypeName(net_type),
1407 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1408 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1417 Local_Notification_sound(
1424 backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
1432 Local_Notification_sprintf(
1439 if(notif.nent_icon != "")
1441 Local_Notification_HUD_Notify_Push(
1453 Local_Notification_centerprint_generic(
1454 Local_Notification_sprintf(
1468 if(notif.nent_msginfo)
1469 if(notif.nent_msginfo.nent_enabled)
1471 Local_Notification_WOVA(
1473 notif.nent_msginfo.nent_id,
1474 notif.nent_msginfo.nent_stringcount,
1475 notif.nent_msginfo.nent_floatcount,
1480 if(notif.nent_msgannce)
1481 if(notif.nent_msgannce.nent_enabled)
1483 Local_Notification_WOVA(
1485 notif.nent_msgannce.nent_id,
1490 if(notif.nent_msgcenter)
1491 if(notif.nent_msgcenter.nent_enabled)
1493 Local_Notification_WOVA(
1495 notif.nent_msgcenter.nent_id,
1496 notif.nent_msgcenter.nent_stringcount,
1497 notif.nent_msgcenter.nent_floatcount,
1507 entity found_choice;
1509 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2)))
1511 switch(cvar_string(sprintf("notification_%s", notif.nent_name)))
1513 case 1: found_choice = notif.nent_optiona; break;
1514 case 2: found_choice = notif.nent_optionb; break;
1515 default: return; // not enabled anyway
1518 else { found_choice = notif.nent_optiona; }
1520 Local_Notification_WOVA(
1521 found_choice.nent_type,
1522 found_choice.nent_id,
1523 found_choice.nent_stringcount,
1524 found_choice.nent_floatcount,
1531 // WOVA = Without Variable Arguments
1532 void Local_Notification_WOVA(
1533 float net_type, float net_name,
1534 float stringcount, float floatcount,
1535 string s1, string s2, string s3, string s4,
1536 float f1, float f2, float f3, float f4)
1538 #define VARITEM(stringc,floatc,args) \
1539 if((stringcount == stringc) && (floatcount == floatc)) \
1540 { Local_Notification(net_type, net_name, args); return; }
1541 EIGHT_VARS_TO_VARARGS_VARLIST
1543 Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
1547 // =========================
1548 // Notification Networking
1549 // =========================
1552 void Read_Notification(float is_new)
1554 float net_type = ReadByte();
1555 float net_name = ReadShort();
1559 if(net_type == MSG_CENTER_CPID)
1561 #ifdef NOTIFICATIONS_DEBUG
1562 Debug_Notification(sprintf(
1563 "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n",
1566 Get_Notif_TypeName(net_type),
1573 if(net_name == 0) { reset_centerprint_messages(); }
1574 else if(net_name != NO_CPID)
1576 // in this case, net_name IS the cpid we want to kill
1577 centerprint_generic(net_name, "", 0, 0);
1582 "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n",
1591 notif = Get_Notif_Ent(net_type, net_name);
1592 if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; }
1594 #ifdef NOTIFICATIONS_DEBUG
1595 Debug_Notification(sprintf(
1596 "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n",
1599 Get_Notif_TypeName(net_type),
1604 string s1 = ((0 < notif.nent_stringcount) ? ReadString() : "");
1605 string s2 = ((1 < notif.nent_stringcount) ? ReadString() : "");
1606 string s3 = ((2 < notif.nent_stringcount) ? ReadString() : "");
1607 string s4 = ((3 < notif.nent_stringcount) ? ReadString() : "");
1608 float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0);
1609 float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0);
1610 float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0);
1611 float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0);
1615 Local_Notification_WOVA(
1617 notif.nent_stringcount,
1618 notif.nent_floatcount,
1627 void Net_Notification_Remove()
1629 if not(self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
1631 #ifdef NOTIFICATIONS_DEBUG
1632 Debug_Notification(sprintf(
1633 "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
1635 ((self.nent_net_name == -1) ? "Killed" : "Removed"),
1636 Get_Notif_TypeName(self.nent_net_type),
1637 self.owner.nent_name
1642 for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
1646 float Net_Write_Notification(entity client, float sf)
1648 if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client))
1651 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
1652 WriteByte(MSG_ENTITY, self.nent_net_type);
1653 WriteShort(MSG_ENTITY, self.nent_net_name);
1654 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); }
1655 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
1658 else { return FALSE; }
1661 void Kill_Notification(
1662 float broadcast, entity client,
1663 float net_type, float net_name)
1665 string checkargs = Notification_CheckArgs(broadcast, client, 1, 1);
1666 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; }
1668 #ifdef NOTIFICATIONS_DEBUG
1669 Debug_Notification(sprintf(
1670 "Kill_Notification(%s, '%s', %s, %d);\n",
1671 Get_Notif_BroadcastName(broadcast),
1673 (net_type ? Get_Notif_TypeName(net_type) : "0"),
1678 entity notif, net_notif;
1679 float killed_cpid = NO_CPID;
1685 killed_cpid = 0; // kill ALL centerprints
1693 entity notif = Get_Notif_Ent(net_type, net_name);
1694 if not(notif) { backtrace("Kill_Notification: Could not find notification entity!\n"); return; }
1697 killed_cpid = notif.nent_cpid;
1699 killed_cpid = NO_CPID;
1703 killed_cpid = 0; // kill ALL centerprints
1708 case MSG_CENTER_CPID:
1710 killed_cpid = net_name;
1715 if(killed_cpid != NO_CPID)
1717 net_notif = spawn();
1718 net_notif.classname = "net_kill_notification";
1719 net_notif.nent_broadcast = broadcast;
1720 net_notif.nent_client = client;
1721 net_notif.nent_net_type = MSG_CENTER_CPID;
1722 net_notif.nent_net_name = killed_cpid;
1723 Net_LinkEntity(net_notif, FALSE, autocvar_notification_lifetime_runtime, Net_Write_Notification);
1726 for(notif = world; (notif = find(notif, classname, "net_notification"));)
1730 if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER))
1732 if(notif.owner.nent_cpid == killed_cpid)
1734 notif.nent_net_name = -1;
1735 notif.nextthink = time;
1737 else { continue; } // we ARE looking for a specific CPID, don't kill everything else too
1739 else if(notif.nent_net_type == net_type)
1743 if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; }
1744 else { continue; } // we ARE looking for a certain net_name, don't kill everything else too
1746 else { notif.nent_net_name = -1; notif.nextthink = time; }
1748 else { continue; } // we ARE looking for a certain net_type, don't kill everything else too
1750 else { notif.nent_net_name = -1; notif.nextthink = time; }
1754 void Send_Notification(
1755 float broadcast, entity client,
1756 float net_type, float net_name,
1759 // check supplied broadcast, target, type, and name for errors
1760 string checkargs = Notification_CheckArgs(broadcast, client, net_type, net_name);
1761 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs)); return; }
1763 // retreive counts for the arguments of this notification
1764 entity notif = Get_Notif_Ent(net_type, net_name);
1765 if not(notif) { backtrace("Send_Notification: Could not find notification entity!\n"); return; }
1767 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1768 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1769 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1770 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1771 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1772 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1773 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1774 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1776 #ifdef NOTIFICATIONS_DEBUG
1777 Debug_Notification(sprintf(
1778 "Send_Notification(%s, %s, %s, %s, %s);\n",
1779 Get_Notif_BroadcastName(broadcast),
1780 Get_Notif_TypeName(net_type),
1782 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1783 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1787 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1791 "Not enough arguments for Send_Notification(%s, %s, %s, ...)! ",
1792 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1793 "Check the definition and function call for accuracy...?\n"
1795 Get_Notif_BroadcastName(broadcast),
1796 Get_Notif_TypeName(net_type), notif.nent_name,
1797 notif.nent_stringcount, notif.nent_floatcount, count
1801 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1805 "Too many arguments for Send_Notification(%s, %s, %s, ...)! ",
1806 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1807 "Check the definition and function call for accuracy...?\n"
1809 Get_Notif_BroadcastName(broadcast),
1810 Get_Notif_TypeName(net_type), notif.nent_name,
1811 notif.nent_stringcount, notif.nent_floatcount, count
1820 broadcast == NOTIF_ALL
1822 broadcast == NOTIF_ALL_EXCEPT
1826 net_type == MSG_ANNCE
1828 net_type == MSG_CENTER
1832 Local_Notification_WOVA(
1834 notif.nent_stringcount,
1835 notif.nent_floatcount,
1840 if(net_type == MSG_CHOICE)
1842 // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast)
1843 // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option...
1844 // It's slow, but it's better than the alternatives:
1845 // 1. Constantly networking all info and letting client decide
1846 // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
1847 entity found_choice;
1849 #define RECURSE_FROM_CHOICE(ent,action) \
1850 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \
1852 switch(ent.msg_choice_choices[net_name]) \
1854 case 1: found_choice = notif.nent_optiona; break; \
1855 case 2: found_choice = notif.nent_optionb; break; \
1859 else { found_choice = notif.nent_optiona; } \
1860 Send_Notification_WOVA( \
1863 found_choice.nent_type, \
1864 found_choice.nent_id, \
1865 found_choice.nent_stringcount, \
1866 found_choice.nent_floatcount, \
1872 case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method
1874 if(IS_REAL_CLIENT(client))
1875 { RECURSE_FROM_CHOICE(client, return) }
1881 FOR_EACH_REALCLIENT(to)
1882 { if(Notification_ShouldSend(broadcast, to, client))
1883 { RECURSE_FROM_CHOICE(to, continue) } }
1890 entity net_notif = spawn();
1891 net_notif.owner = notif;
1892 net_notif.classname = "net_notification";
1893 net_notif.nent_broadcast = broadcast;
1894 net_notif.nent_client = client;
1895 net_notif.nent_net_type = net_type;
1896 net_notif.nent_net_name = net_name;
1897 net_notif.nent_stringcount = notif.nent_stringcount;
1898 net_notif.nent_floatcount = notif.nent_floatcount;
1901 for(i = 0; i < net_notif.nent_stringcount; ++i)
1902 { net_notif.nent_strings[i] = strzone(...(i, string)); }
1903 for(i = 0; i < net_notif.nent_floatcount; ++i)
1904 { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); }
1906 net_notif.think = Net_Notification_Remove;
1907 net_notif.nextthink =
1908 ((time > autocvar_notification_lifetime_mapload)
1910 (time + autocvar_notification_lifetime_runtime)
1912 autocvar_notification_lifetime_mapload
1915 Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification);
1919 // WOVA = Without Variable Arguments
1920 void Send_Notification_WOVA(
1921 float broadcast, entity client,
1922 float net_type, float net_name,
1923 float stringcount, float floatcount,
1924 string s1, string s2, string s3, string s4,
1925 float f1, float f2, float f3, float f4)
1927 #ifdef NOTIFICATIONS_DEBUG
1928 entity notif = Get_Notif_Ent(net_type, net_name);
1929 Debug_Notification(sprintf(
1930 "Send_Notification_WOVA(%s, %s, %d, %d, %d, %s, %s);\n",
1931 Get_Notif_BroadcastName(broadcast),
1932 Get_Notif_TypeName(net_type),
1936 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1937 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1941 #define VARITEM(stringc,floatc,args) \
1942 if((stringcount == stringc) && (floatcount == floatc)) \
1943 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
1944 EIGHT_VARS_TO_VARARGS_VARLIST
1946 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
1949 // WOCOVA = Without Counts Or Variable Arguments
1950 void Send_Notification_WOCOVA(
1951 float broadcast, entity client,
1952 float net_type, float net_name,
1953 string s1, string s2, string s3, string s4,
1954 float f1, float f2, float f3, float f4)
1956 entity notif = Get_Notif_Ent(net_type, net_name);
1958 #ifdef NOTIFICATIONS_DEBUG
1959 Debug_Notification(sprintf(
1960 "Send_Notification_WOCOVA(%s, %s, %s, %s, %s);\n",
1961 Get_Notif_BroadcastName(broadcast),
1962 Get_Notif_TypeName(net_type),
1964 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1965 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1969 #define VARITEM(stringc,floatc,args) \
1970 if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
1971 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
1972 EIGHT_VARS_TO_VARARGS_VARLIST
1974 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
1976 #endif // ifdef SVQC