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); }
108 if not(teamplay) { checkargs = sprintf("%sTeamplay not active!", checkargs); }
109 else if not(client.team) { checkargs = sprintf("%sNo team provided!", checkargs); }
113 case NOTIF_TEAM_EXCEPT:
115 if not(teamplay) { checkargs = sprintf("%sTeamplay not active!", checkargs); }
116 else if(IS_NOT_A_CLIENT(client)) { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
120 default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
125 float Notification_ShouldSend(float broadcast, entity to_client, entity other_client)
129 case NOTIF_ONE: // send to one client and their spectator
132 (to_client == other_client)
137 (to_client.enemy == other_client)
142 case NOTIF_ONE_ONLY: // send ONLY to one client
144 if(to_client == other_client) { return TRUE; }
147 case NOTIF_TEAM: // send only to X team and their spectators
150 (to_client.team == other_client.team)
155 (to_client.enemy.team == other_client.team)
160 case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators
163 (to_client != other_client)
166 (to_client.team == other_client.team)
172 (to_client.enemy != other_client)
174 (to_client.enemy.team == other_client.team)
181 case NOTIF_ALL: // send to everyone
185 case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators
188 (to_client != other_client)
193 (to_client.enemy == other_client)
204 // ===============================
205 // Initialization Core Functions
206 // ===============================
208 // used by restartnotifs command to initialize notifications
209 void Destroy_Notification_Entity(entity notif)
211 if(notif.nent_name != "") { strunzone(notif.nent_name); }
212 if(notif.nent_snd != "") { strunzone(notif.nent_snd); }
213 if(notif.nent_args != "") { strunzone(notif.nent_args); }
214 if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
215 if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
216 if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
217 if(notif.nent_string != "") { strunzone(notif.nent_string); }
221 void Destroy_All_Notifications(void)
226 #define DESTROY_LOOP(type,count) \
227 for(i = 1; i <= count; ++i) \
229 notif = Get_Notif_Ent(type, i); \
230 if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
231 Destroy_Notification_Entity(notif); \
234 // kill all networked notifications and centerprints
236 Kill_Notification(NOTIF_ALL, world, 0, 0);
238 reset_centerprint_messages();
241 // kill all real notification entities
242 DESTROY_LOOP(MSG_ANNCE, NOTIF_ANNCE_COUNT)
243 DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
244 DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
245 DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
246 DESTROY_LOOP(MSG_CHOICE, NOTIF_CHOICE_COUNT)
250 string Process_Notif_Line(
259 if(typeid == MSG_INFO)
261 if((chat && autocvar_notification_allow_chatboxprint)
262 || (autocvar_notification_allow_chatboxprint == 2))
264 // pass 1: add ETX char at beginning of line
265 input = strcat("\{3}", input);
267 // pass 2: add ETX char at end of each new line (so that
268 // messages with multiple lines are put through chatbox too)
269 input = strreplace("\n", "\n\{3}", input);
271 // pass 3: strip trailing ETX char
272 if(substring(input, (strlen(input) - 1), 1) == "\{3}")
273 { input = substring(input, 0, (strlen(input) - 1)); }
278 // done to both MSG_INFO and MSG_CENTER
279 if(substring(input, (strlen(input) - 1), 1) == "\n")
283 "^1TRAILING NEW LINE AT END OF NOTIFICATION: ",
284 "^7net_type = %s, net_name = %s, string = %s.\n"
291 input = substring(input, 1, (strlen(input) - 1));
297 string Process_Notif_Args(
303 string selected, remaining = args;
306 for(;(remaining != "");)
308 selected = car(remaining); remaining = cdr(remaining);
312 case 1: // normal args
314 if(sel_num == NOTIF_MAX_ARGS)
318 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
319 "^7net_type = %s, net_name = %s, max args = %d.\n"
329 switch(strtolower(selected))
331 #define ARG_CASE(prog,selected,result) \
332 #if (prog != ARG_DC) \
333 case selected: { ++sel_num; break; } \
341 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
342 "^7net_type = %s, net_name = %s, args arg = '%s'.\n"
356 if(sel_num == NOTIF_MAX_HUDARGS)
360 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
361 "^7net_type = %s, net_name = %s, max hudargs = %d.\n"
371 switch(strtolower(selected))
373 #define ARG_CASE(prog,selected,result) \
374 #if (prog == ARG_CS_SV_HA) \
375 case selected: { ++sel_num; break; } \
383 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
384 "^7net_type = %s, net_name = %s, hudargs arg = '%s'.\n"
398 if(sel_num == NOTIF_MAX_DURCNT)
402 "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
403 "^7net_type = %s, net_name = %s, max durcnt = %d.\n"
413 switch(strtolower(selected))
415 #define ARG_CASE(prog,selected,result) \
416 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
417 case selected: { ++sel_num; break; } \
423 if(ftos(stof(selected)) != "") { ++sel_num; }
428 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
429 "^7net_type = %s, net_name = %s, durcnt arg = '%s'.\n"
447 void Create_Notification_Entity(
460 /* MSG_INFO & MSG_CENTER */
479 // =====================
480 // Global Entity Setup
481 // =====================
482 entity notif = spawn();
487 msg_annce_notifs[nameid - 1] = notif;
488 notif.classname = "msg_annce_notification";
493 msg_info_notifs[nameid - 1] = notif;
494 notif.classname = "msg_info_notification";
499 msg_center_notifs[nameid - 1] = notif;
500 notif.classname = "msg_center_notification";
505 msg_multi_notifs[nameid - 1] = notif;
506 notif.classname = "msg_multi_notification";
511 msg_choice_notifs[nameid - 1] = notif;
512 notif.classname = "msg_choice_notification";
520 "^1NOTIFICATION WITH IMPROPER TYPE: ",
521 "^7net_type = %d, net_name = %s.\n"
526 return; // It's not possible to recover from this one
529 notif.nent_default = var_default;
530 notif.nent_enabled = (1 <= var_cvar);
531 notif.nent_type = typeid;
532 notif.nent_id = nameid;
533 notif.nent_name = strzone(namestring);
535 string typestring = Get_Notif_TypeName(typeid);
537 // Other pre-notif-setup requisites
540 // ====================
541 // Notification Setup
542 // ====================
547 // Set MSG_ANNCE information and handle precaching
549 if not(GENTLE && (var_cvar == 1))
553 if(notif.nent_enabled)
555 precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd));
556 notif.nent_channel = channel;
557 notif.nent_snd = strzone(snd);
558 notif.nent_vol = vol;
559 notif.nent_position = position;
566 "^1NOTIFICATION WITH NO SOUND: ",
567 "^7net_type = %s, net_name = %s.\n"
575 else { notif.nent_enabled = FALSE; }
577 notif.nent_enabled = FALSE;
586 // Set MSG_INFO and MSG_CENTER string/float counts
587 notif.nent_stringcount = strnum;
588 notif.nent_floatcount = flnum;
590 // Only initialize arguments if we're either a client or on a dedicated server
592 float should_process_args = server_is_dedicated;
594 float should_process_args = TRUE;
597 if(should_process_args)
599 // ========================
600 // Process Main Arguments
601 // ========================
606 notif.nent_args = strzone(
607 Process_Notif_Args(1, args, typestring, namestring));
609 else if((hudargs == "") && (durcnt ==""))
613 "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ",
614 "^7net_type = %s, net_name = %s, strnum = %d, flnum = %d\n"
626 notif.nent_args = strzone(
627 Process_Notif_Args(1, args, typestring, namestring));
631 // =======================================
632 // Process HUD and Centerprint Arguments
633 // Only processed on CSQC, as these
634 // args are only for HUD features.
635 // =======================================
639 notif.nent_hudargs = strzone(
640 Process_Notif_Args(2, hudargs, typestring, namestring));
642 if(icon != "") { notif.nent_icon = strzone(icon); }
647 "^1NOTIFICATION HAS HUDARGS BUT NO ICON: ",
648 "^7net_type = %s, net_name = %s.\n"
660 "^1NOTIFICATION HAS ICON BUT NO HUDARGS: ",
661 "^7net_type = %s, net_name = %s.\n"
671 notif.nent_durcnt = strzone(
672 Process_Notif_Args(3, durcnt, typestring, namestring));
674 if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
679 "^1NOTIFICATION HAS DURCNT BUT NO CPID: ",
680 "^7net_type = %s, net_name = %s.\n"
688 else if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
692 // ======================
693 // Process Notif String
694 // ======================
695 #define SET_NOTIF_STRING(string,stringname) \
696 notif.nent_string = strzone(CCR( \
697 Process_Notif_Line( \
709 if(gentle != "") { SET_NOTIF_STRING(gentle, "GENTLE") }
710 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
712 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
714 #undef SET_NOTIF_STRING
716 // Check to make sure a string was chosen
717 if(notif.nent_string == "")
721 "^1EMPTY NOTIFICATION: ",
722 "^7net_type = %s, net_name = %s.\n"
736 // Set MSG_MULTI string/float counts
737 if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG))
741 "^1NOTIFICATION WITH NO SUBCALLS: ",
742 "^7net_type = %s, net_name = %s.\n"
751 // announcements don't actually need any arguments, so lets not even count them.
752 if(anncename != NO_MSG) { notif.nent_msgannce = msg_annce_notifs[anncename - 1]; }
754 float infoname_stringcount = 0, infoname_floatcount = 0;
755 float centername_stringcount = 0, centername_floatcount = 0;
757 if(infoname != NO_MSG)
759 notif.nent_msginfo = msg_info_notifs[infoname - 1];
760 infoname_stringcount = notif.nent_msginfo.nent_stringcount;
761 infoname_floatcount = notif.nent_msginfo.nent_floatcount;
764 if(centername != NO_MSG)
766 notif.nent_msgcenter = msg_center_notifs[centername - 1];
767 centername_stringcount = notif.nent_msgcenter.nent_stringcount;
768 centername_floatcount = notif.nent_msgcenter.nent_floatcount;
771 // set the requirements of THIS notification to the totals of its subcalls
772 notif.nent_stringcount = max(infoname_stringcount, centername_stringcount);
773 notif.nent_floatcount = max(infoname_floatcount, centername_floatcount);
781 if((chtype == NO_MSG) || (optiona == NO_MSG) || (optionb == NO_MSG))
785 "^1NOTIFICATION IS MISSING CHOICE PARAMS: ",
786 "^7net_type = %s, net_name = %s.\n"
799 notif.nent_optiona = msg_annce_notifs[optiona - 1];
800 notif.nent_optionb = msg_annce_notifs[optionb - 1];
805 notif.nent_optiona = msg_info_notifs[optiona - 1];
806 notif.nent_optionb = msg_info_notifs[optionb - 1];
811 notif.nent_optiona = msg_center_notifs[optiona - 1];
812 notif.nent_optionb = msg_center_notifs[optionb - 1];
817 notif.nent_optiona = msg_multi_notifs[optiona - 1];
818 notif.nent_optionb = msg_multi_notifs[optionb - 1];
821 case MSG_CHOICE: // should we REALLY allow nested options?...
823 notif.nent_optiona = msg_choice_notifs[optiona - 1];
824 notif.nent_optionb = msg_choice_notifs[optionb - 1];
832 "^1NOTIFICATION WITH IMPROPER TYPE: ",
833 "^7net_type = %d, net_name = %s.\n"
842 notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed
843 notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed
844 notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount);
845 notif.nent_floatcount = max(notif.nent_optiona.nent_floatcount, notif.nent_optionb.nent_floatcount);
847 #ifdef NOTIFICATIONS_DEBUG
848 Debug_Notification(sprintf(
849 "Create_Notification_Entity(...): MSG_CHOICE: %s\n"
850 "^ optiona: %s %s : %d %d\n"
851 "^ optionb: %s %s : %d %d\n",
853 Get_Notif_TypeName(notif.nent_optiona.nent_type),
854 notif.nent_optiona.nent_name,
855 notif.nent_optiona.nent_stringcount,
856 notif.nent_optiona.nent_floatcount,
857 Get_Notif_TypeName(notif.nent_optiona.nent_type),
858 notif.nent_optiona.nent_name,
859 notif.nent_optiona.nent_stringcount,
860 notif.nent_optiona.nent_floatcount
867 default: print("DAFUQ?\n"); notif_error = TRUE; break;
870 // now check to see if any errors happened
873 notif.nent_enabled = FALSE; // disable the notification so it can't cause trouble
874 notif_global_error = TRUE; // throw the red flag that an error happened on init
883 // used by MSG_CHOICE to build list of choices
885 void Notification_GetCvars(void)
888 for(i = 0; i <= NOTIF_CHOICE_COUNT; ++i)
890 GetCvars_handleFloat(
893 msg_choice_choices[i],
894 sprintf("notification_%s", msg_choice_notifs[i].nent_name)
898 GetCvars_handleFloat(get_cvars_s, get_cvars_f, FRAG_VERBOSE, "notification_frag_verbose");
902 // used to output notifications.cfg file
903 void Dump_Notifications(float fh, float alsoprint)
905 #define NOTIF_WRITE(a) { \
907 if(alsoprint) { print(a); } }
908 #define NOTIF_WRITE_ENTITY(description) { \
911 "seta notification_%s \"%d\" \"%s\"\n", \
912 e.nent_name, e.nent_default, description \
914 NOTIF_WRITE(notif_msg) }
915 #define NOTIF_WRITE_ENTITY_CHOICE(descriptiona,descriptionb) { \
918 "seta notification_%s \"%d\" \"%s\"\n" \
919 "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
920 e.nent_name, e.nent_default, descriptiona, \
921 e.nent_name, e.nent_challow_def, descriptionb \
923 NOTIF_WRITE(notif_msg) }
924 #define NOTIF_WRITE_HARDCODED(cvar,default,description) { \
927 "seta notification_%s \"%s\" \"%s\"\n", \
928 cvar, default, description \
930 NOTIF_WRITE(notif_msg) }
936 // Note: This warning only applies to the notifications.cfg file that is output...
938 // You ARE supposed to manually edit this function to add i.e. hard coded
939 // notification variables for mutators or game modes or such and then
940 // regenerate the notifications.cfg file from the new code.
942 NOTIF_WRITE("// ********************************************** //\n");
943 NOTIF_WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
944 NOTIF_WRITE("// ** ** //\n");
945 NOTIF_WRITE("// ** This file is automatically generated ** //\n");
946 NOTIF_WRITE("// ** by code with the command 'dumpnotifs'. ** //\n");
947 NOTIF_WRITE("// ** ** //\n");
948 NOTIF_WRITE("// ** If you add a new notification, please ** //\n");
949 NOTIF_WRITE("// ** regenerate this file with that command ** //\n");
950 NOTIF_WRITE("// ** making sure that the output matches ** //\n");
951 NOTIF_WRITE("// ** with the lists and defaults in code. ** //\n");
952 NOTIF_WRITE("// ** ** //\n");
953 NOTIF_WRITE("// ********************************************** //\n");
955 // These notifications will also append their string as a comment...
956 // This is not necessary, and does not matter if they vary between config versions,
957 // it is just a semi-helpful tool for those who want to manually change their user settings.
959 NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
960 for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
962 e = Get_Notif_Ent(MSG_ANNCE, i);
963 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
966 "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
970 NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
971 for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
973 e = Get_Notif_Ent(MSG_INFO, i);
974 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
977 "Notification control cvar: 0 = off, 1 = print to console, "
978 "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
982 NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
983 for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
985 e = Get_Notif_Ent(MSG_CENTER, i);
986 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
989 "Notification control cvar: 0 = off, 1 = centerprint"
993 NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
994 for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
996 e = Get_Notif_Ent(MSG_MULTI, i);
997 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1000 "Notification control cvar: 0 = off, 1 = trigger subcalls"
1004 NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
1005 for(i = 1; i <= NOTIF_CHOICE_COUNT; ++i)
1007 e = Get_Notif_Ent(MSG_CHOICE, i);
1008 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1010 NOTIF_WRITE_ENTITY_CHOICE(
1011 "Notification control cvar: 0 = off, 1 = trigger option A subcall, 2 = trigger option B subcall",
1012 "Notification control cvar: 0 = off, 1 = allowed in warmup mode, 2 = always allowed"
1016 // edit these to match whichever cvars are used for specific notification options
1017 NOTIF_WRITE("\n// HARD CODED notification variables:\n");
1019 NOTIF_WRITE_HARDCODED(
1020 "allow_chatboxprint", "1",
1021 "Allow notifications to be printed to chat box by setting notification cvar to 2 "
1022 "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
1025 NOTIF_WRITE_HARDCODED(
1026 "ctf_capture_verbose", "0",
1027 "Show extra information when someone captures a flag"
1030 NOTIF_WRITE_HARDCODED(
1031 "ctf_pickup_enemy_verbose", "0",
1032 "Show extra information if an enemy picks up a flag"
1035 NOTIF_WRITE_HARDCODED(
1036 "ctf_pickup_team_verbose", "0",
1037 "Show extra information if a team mate picks up a flag"
1040 NOTIF_WRITE_HARDCODED(
1042 "Print extra debug information on all notification function calls "
1043 "(Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... "
1044 "0 = disabled, 1 = dprint, 2 = print"
1047 NOTIF_WRITE_HARDCODED(
1048 "errors_are_fatal", "1",
1049 "If a notification fails upon initialization, cause a Host_Error to stop the program"
1052 NOTIF_WRITE_HARDCODED(
1053 "item_centerprinttime", "1.5",
1054 "How long to show item information centerprint messages (like 'You got the Electro' or such)"
1057 NOTIF_WRITE_HARDCODED(
1058 "lifetime_mapload", "10",
1059 "Amount of time that notification entities last immediately at mapload (in seconds) "
1060 "to help prevent notifications from being lost on early init (like gamestart countdown)"
1063 NOTIF_WRITE_HARDCODED(
1064 "lifetime_runtime", "0.5",
1065 "Amount of time that notification entities last on the server during runtime (In seconds)"
1068 NOTIF_WRITE_HARDCODED(
1069 "server_allows_location", "1",
1070 "Server side cvar for allowing death messages to show location information too"
1073 NOTIF_WRITE_HARDCODED(
1074 "show_location", "0",
1075 "Append location information to MSG_INFO death/kill messages"
1078 NOTIF_WRITE_HARDCODED(
1079 "show_location_string", "",
1080 "Replacement string piped into sprintf, "
1081 "so you can do different messages like this: ' at the %s' or ' (near %s)'"
1084 NOTIF_WRITE_HARDCODED(
1086 "Print information about sprees in death/kill messages"
1089 NOTIF_WRITE_HARDCODED(
1090 "show_sprees_center", "1",
1091 "Show spree information in MSG_CENTER messages... "
1092 "0 = off, 1 = target (but only for first victim) and attacker"
1095 NOTIF_WRITE_HARDCODED(
1096 "show_sprees_center_specialonly", "1",
1097 "Don't show spree information in MSG_CENTER messages if it isn't an achievement"
1100 NOTIF_WRITE_HARDCODED(
1101 "show_sprees_info", "3",
1102 "Show spree information in MSG_INFO messages... "
1103 "0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker"
1106 NOTIF_WRITE_HARDCODED(
1107 "show_sprees_info_newline", "1",
1108 "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
1111 NOTIF_WRITE_HARDCODED(
1112 "show_sprees_info_specialonly", "1",
1113 "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
1116 NOTIF_WRITE(sprintf(
1118 "\n// Notification counts (total = %d): ",
1119 "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
1124 NOTIF_CENTER_COUNT +
1136 #undef NOTIF_WRITE_HARDCODED
1137 #undef NOTIF_WRITE_ENTITY
1142 // ===============================
1143 // Frontend Notification Pushing
1144 // ===============================
1146 #ifdef NOTIFICATIONS_DEBUG
1147 void Debug_Notification(string input)
1149 switch(autocvar_notification_debug)
1151 case 1: { dprint(input); break; }
1152 case 2: { print(input); break; }
1157 string Local_Notification_sprintf(
1158 string input, string args,
1159 string s1, string s2, string s3, string s4,
1160 float f1, float f2, float f3, float f4)
1162 #ifdef NOTIFICATIONS_DEBUG
1163 Debug_Notification(sprintf(
1164 "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
1165 MakeConsoleSafe(input),
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)
1174 for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
1178 for(sel_num = 0;(args != "");)
1180 selected = car(args); args = cdr(args);
1181 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1182 switch(strtolower(selected))
1184 #define ARG_CASE(prog,selected,result) \
1186 #if (prog != ARG_SV) && (prog != ARG_DC) \
1187 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1190 #if (prog != ARG_CS) && (prog != ARG_DC) \
1191 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1196 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1200 strcat(input, "\n"),
1212 void Local_Notification_sound(
1213 float soundchannel, string soundfile,
1214 float soundvolume, float soundposition)
1216 if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
1218 #ifdef NOTIFICATIONS_DEBUG
1219 Debug_Notification(sprintf(
1220 "Local_Notification_sound(world, %f, '%s', %f, %f);\n",
1223 "announcer/%s/%s.wav",
1224 autocvar_cl_announcer,
1236 "announcer/%s/%s.wav",
1237 autocvar_cl_announcer,
1244 if(prev_soundfile) { strunzone(prev_soundfile); }
1245 prev_soundfile = strzone(soundfile);
1246 prev_soundtime = time;
1250 #ifdef NOTIFICATIONS_DEBUG
1251 Debug_Notification(sprintf(
1253 "Local_Notification_sound(world, %f, '%s', %f, %f) ",
1254 "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
1258 "announcer/%s/%s.wav",
1259 autocvar_cl_announcer,
1265 (time - prev_soundtime),
1266 autocvar_cl_announcer_antispam
1272 void Local_Notification_HUD_Notify_Push(
1273 string icon, string hudargs,
1274 string s1, string s2, string s3, string s4)
1278 arg_slot[0] = ""; arg_slot[1] = "";
1280 for(sel_num = 0;(hudargs != "");)
1282 selected = car(hudargs); hudargs = cdr(hudargs);
1283 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1284 switch(strtolower(selected))
1286 #define ARG_CASE(prog,selected,result) \
1287 #if (prog == ARG_CS_SV_HA) \
1288 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1292 default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1295 #ifdef NOTIFICATIONS_DEBUG
1296 Debug_Notification(sprintf(
1297 "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s);\n",
1300 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1301 MakeConsoleSafe(sprintf("'%s^7', '%s^7'", stof(arg_slot[0]), stof(arg_slot[1])))
1304 HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
1307 void Local_Notification_centerprint_generic(
1308 string input, string durcnt,
1309 float cpid, float f1, float f2)
1313 arg_slot[0] = ""; arg_slot[1] = "";
1315 for(sel_num = 0;(durcnt != "");)
1317 selected = car(durcnt); durcnt = cdr(durcnt);
1318 NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic")
1319 switch(strtolower(selected))
1321 #define ARG_CASE(prog,selected,result) \
1322 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
1323 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1329 if(ftos(stof(selected)) != "") { arg_slot[sel_num] = selected; ++sel_num; }
1330 else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") }
1335 #ifdef NOTIFICATIONS_DEBUG
1336 Debug_Notification(sprintf(
1337 "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n",
1338 MakeConsoleSafe(input),
1341 stof(arg_slot[0]), stof(arg_slot[1])
1344 centerprint_generic(cpid, input, stof(arg_slot[0]), stof(arg_slot[1]));
1348 void Local_Notification(float net_type, float net_name, ...count)
1350 // check supplied type and name for errors
1351 string checkargs = Notification_CheckArgs_TypeName(net_type, net_name);
1352 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs)); return; }
1354 entity notif = Get_Notif_Ent(net_type, net_name);
1355 if not(notif) { backtrace("Local_Notification: Could not find notification entity!\n"); return; }
1356 if not(notif.nent_enabled)
1358 #ifdef NOTIFICATIONS_DEBUG
1359 Debug_Notification(sprintf(
1360 "Local_Notification(%s, %s): Entity was disabled...\n",
1361 Get_Notif_TypeName(net_type),
1368 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1372 "Not enough arguments for Local_Notification(%s, %s, ...)! ",
1373 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1374 "Check the definition and function call for accuracy...?\n"
1376 Get_Notif_TypeName(net_type), notif.nent_name,
1377 notif.nent_stringcount, notif.nent_floatcount, count
1381 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1385 "Too many arguments for Local_Notification(%s, %s, ...)! ",
1386 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1387 "Check the definition and function call for accuracy...?\n"
1389 Get_Notif_TypeName(net_type), notif.nent_name,
1390 notif.nent_stringcount, notif.nent_floatcount, count
1395 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1396 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1397 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1398 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1399 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1400 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1401 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1402 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1404 #ifdef NOTIFICATIONS_DEBUG
1405 Debug_Notification(sprintf(
1406 "Local_Notification(%s, %s, %s, %s);\n",
1407 Get_Notif_TypeName(net_type),
1409 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1410 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1419 Local_Notification_sound(
1426 backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
1434 Local_Notification_sprintf(
1441 if(notif.nent_icon != "")
1443 Local_Notification_HUD_Notify_Push(
1455 Local_Notification_centerprint_generic(
1456 Local_Notification_sprintf(
1470 if(notif.nent_msginfo)
1471 if(notif.nent_msginfo.nent_enabled)
1473 Local_Notification_WOVA(
1475 notif.nent_msginfo.nent_id,
1476 notif.nent_msginfo.nent_stringcount,
1477 notif.nent_msginfo.nent_floatcount,
1482 if(notif.nent_msgannce)
1483 if(notif.nent_msgannce.nent_enabled)
1485 Local_Notification_WOVA(
1487 notif.nent_msgannce.nent_id,
1492 if(notif.nent_msgcenter)
1493 if(notif.nent_msgcenter.nent_enabled)
1495 Local_Notification_WOVA(
1497 notif.nent_msgcenter.nent_id,
1498 notif.nent_msgcenter.nent_stringcount,
1499 notif.nent_msgcenter.nent_floatcount,
1509 entity found_choice;
1511 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2)))
1513 switch(cvar_string(sprintf("notification_%s", notif.nent_name)))
1515 case 1: found_choice = notif.nent_optiona; break;
1516 case 2: found_choice = notif.nent_optionb; break;
1517 default: return; // not enabled anyway
1520 else { found_choice = notif.nent_optiona; }
1522 Local_Notification_WOVA(
1523 found_choice.nent_type,
1524 found_choice.nent_id,
1525 found_choice.nent_stringcount,
1526 found_choice.nent_floatcount,
1533 // WOVA = Without Variable Arguments
1534 void Local_Notification_WOVA(
1535 float net_type, float net_name,
1536 float stringcount, float floatcount,
1537 string s1, string s2, string s3, string s4,
1538 float f1, float f2, float f3, float f4)
1540 #define VARITEM(stringc,floatc,args) \
1541 if((stringcount == stringc) && (floatcount == floatc)) \
1542 { Local_Notification(net_type, net_name, args); return; }
1543 EIGHT_VARS_TO_VARARGS_VARLIST
1545 Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
1549 // =========================
1550 // Notification Networking
1551 // =========================
1554 void Read_Notification(float is_new)
1556 float net_type = ReadByte();
1557 float net_name = ReadShort();
1561 if(net_type == MSG_CENTER_CPID)
1563 #ifdef NOTIFICATIONS_DEBUG
1564 Debug_Notification(sprintf(
1565 "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n",
1568 Get_Notif_TypeName(net_type),
1575 if(net_name == 0) { reset_centerprint_messages(); }
1576 else if(net_name != NO_CPID)
1578 // in this case, net_name IS the cpid we want to kill
1579 centerprint_generic(net_name, "", 0, 0);
1584 "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n",
1593 notif = Get_Notif_Ent(net_type, net_name);
1594 if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; }
1596 #ifdef NOTIFICATIONS_DEBUG
1597 Debug_Notification(sprintf(
1598 "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n",
1601 Get_Notif_TypeName(net_type),
1606 string s1 = ((0 < notif.nent_stringcount) ? ReadString() : "");
1607 string s2 = ((1 < notif.nent_stringcount) ? ReadString() : "");
1608 string s3 = ((2 < notif.nent_stringcount) ? ReadString() : "");
1609 string s4 = ((3 < notif.nent_stringcount) ? ReadString() : "");
1610 float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0);
1611 float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0);
1612 float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0);
1613 float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0);
1617 Local_Notification_WOVA(
1619 notif.nent_stringcount,
1620 notif.nent_floatcount,
1629 void Net_Notification_Remove()
1631 if not(self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
1633 #ifdef NOTIFICATIONS_DEBUG
1634 Debug_Notification(sprintf(
1635 "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
1637 ((self.nent_net_name == -1) ? "Killed" : "Removed"),
1638 Get_Notif_TypeName(self.nent_net_type),
1639 self.owner.nent_name
1644 for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
1648 float Net_Write_Notification(entity client, float sf)
1650 if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client))
1653 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
1654 WriteByte(MSG_ENTITY, self.nent_net_type);
1655 WriteShort(MSG_ENTITY, self.nent_net_name);
1656 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); }
1657 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
1660 else { return FALSE; }
1663 void Kill_Notification(
1664 float broadcast, entity client,
1665 float net_type, float net_name)
1667 string checkargs = Notification_CheckArgs(broadcast, client, 1, 1);
1668 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; }
1670 #ifdef NOTIFICATIONS_DEBUG
1671 Debug_Notification(sprintf(
1672 "Kill_Notification(%s, '%s', %s, %d);\n",
1673 Get_Notif_BroadcastName(broadcast),
1675 (net_type ? Get_Notif_TypeName(net_type) : "0"),
1680 entity notif, net_notif;
1681 float killed_cpid = NO_CPID;
1687 killed_cpid = 0; // kill ALL centerprints
1695 entity notif = Get_Notif_Ent(net_type, net_name);
1696 if not(notif) { backtrace("Kill_Notification: Could not find notification entity!\n"); return; }
1699 killed_cpid = notif.nent_cpid;
1701 killed_cpid = NO_CPID;
1705 killed_cpid = 0; // kill ALL centerprints
1710 case MSG_CENTER_CPID:
1712 killed_cpid = net_name;
1717 if(killed_cpid != NO_CPID)
1719 net_notif = spawn();
1720 net_notif.classname = "net_kill_notification";
1721 net_notif.nent_broadcast = broadcast;
1722 net_notif.nent_client = client;
1723 net_notif.nent_net_type = MSG_CENTER_CPID;
1724 net_notif.nent_net_name = killed_cpid;
1725 Net_LinkEntity(net_notif, FALSE, autocvar_notification_lifetime_runtime, Net_Write_Notification);
1728 for(notif = world; (notif = find(notif, classname, "net_notification"));)
1732 if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER))
1734 if(notif.owner.nent_cpid == killed_cpid)
1736 notif.nent_net_name = -1;
1737 notif.nextthink = time;
1739 else { continue; } // we ARE looking for a specific CPID, don't kill everything else too
1741 else if(notif.nent_net_type == net_type)
1745 if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; }
1746 else { continue; } // we ARE looking for a certain net_name, don't kill everything else too
1748 else { notif.nent_net_name = -1; notif.nextthink = time; }
1750 else { continue; } // we ARE looking for a certain net_type, don't kill everything else too
1752 else { notif.nent_net_name = -1; notif.nextthink = time; }
1756 void Send_Notification(
1757 float broadcast, entity client,
1758 float net_type, float net_name,
1761 // check supplied broadcast, target, type, and name for errors
1762 string checkargs = Notification_CheckArgs(broadcast, client, net_type, net_name);
1765 #ifdef NOTIFICATIONS_DEBUG
1766 Debug_Notification(sprintf(
1767 "Send_Notification(%s, '%s', %s, %d, ...);\n",
1768 Get_Notif_BroadcastName(broadcast),
1770 Get_Notif_TypeName(net_type),
1771 Get_Notif_Ent(net_type, net_name).nent_name
1774 backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs));
1778 // retreive counts for the arguments of this notification
1779 entity notif = Get_Notif_Ent(net_type, net_name);
1782 #ifdef NOTIFICATIONS_DEBUG
1783 Debug_Notification(sprintf(
1784 "Send_Notification(%s, '%s', %s, %d, ...);\n",
1785 Get_Notif_BroadcastName(broadcast),
1787 Get_Notif_TypeName(net_type),
1791 backtrace("Send_Notification: Could not find notification entity!\n");
1795 string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1796 string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1797 string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1798 string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1799 float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1800 float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1801 float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1802 float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1804 #ifdef NOTIFICATIONS_DEBUG
1805 Debug_Notification(sprintf(
1806 "Send_Notification(%s, '%s', %s, %s, %s, %s);\n",
1807 Get_Notif_BroadcastName(broadcast),
1809 Get_Notif_TypeName(net_type),
1811 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1812 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1816 if((notif.nent_stringcount + notif.nent_floatcount) > count)
1820 "Not enough arguments for Send_Notification(%s, '%s', %s, %s, ...)! ",
1821 "stringcount(%d) + floatcount(%d) > count(%d)\n",
1822 "Check the definition and function call for accuracy...?\n"
1824 Get_Notif_BroadcastName(broadcast),
1826 Get_Notif_TypeName(net_type), notif.nent_name,
1827 notif.nent_stringcount, notif.nent_floatcount, count
1831 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1835 "Too many arguments for Send_Notification(%s, '%s', %s, %s, ...)! ",
1836 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1837 "Check the definition and function call for accuracy...?\n"
1839 Get_Notif_BroadcastName(broadcast),
1841 Get_Notif_TypeName(net_type), notif.nent_name,
1842 notif.nent_stringcount, notif.nent_floatcount, count
1851 broadcast == NOTIF_ALL
1853 broadcast == NOTIF_ALL_EXCEPT
1857 net_type == MSG_ANNCE
1859 net_type == MSG_CENTER
1863 Local_Notification_WOVA(
1865 notif.nent_stringcount,
1866 notif.nent_floatcount,
1871 if(net_type == MSG_CHOICE)
1873 // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast)
1874 // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option...
1875 // It's slow, but it's better than the alternatives:
1876 // 1. Constantly networking all info and letting client decide
1877 // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
1878 entity found_choice;
1880 #define RECURSE_FROM_CHOICE(ent,action) \
1881 if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \
1883 switch(ent.msg_choice_choices[net_name]) \
1885 case 1: found_choice = notif.nent_optiona; break; \
1886 case 2: found_choice = notif.nent_optionb; break; \
1890 else { found_choice = notif.nent_optiona; } \
1891 Send_Notification_WOVA( \
1894 found_choice.nent_type, \
1895 found_choice.nent_id, \
1896 found_choice.nent_stringcount, \
1897 found_choice.nent_floatcount, \
1903 case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method
1905 if(IS_REAL_CLIENT(client))
1906 { RECURSE_FROM_CHOICE(client, return) }
1912 FOR_EACH_REALCLIENT(to)
1913 { if(Notification_ShouldSend(broadcast, to, client))
1914 { RECURSE_FROM_CHOICE(to, continue) } }
1921 entity net_notif = spawn();
1922 net_notif.owner = notif;
1923 net_notif.classname = "net_notification";
1924 net_notif.nent_broadcast = broadcast;
1925 net_notif.nent_client = client;
1926 net_notif.nent_net_type = net_type;
1927 net_notif.nent_net_name = net_name;
1928 net_notif.nent_stringcount = notif.nent_stringcount;
1929 net_notif.nent_floatcount = notif.nent_floatcount;
1932 for(i = 0; i < net_notif.nent_stringcount; ++i)
1933 { net_notif.nent_strings[i] = strzone(...(i, string)); }
1934 for(i = 0; i < net_notif.nent_floatcount; ++i)
1935 { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); }
1937 net_notif.think = Net_Notification_Remove;
1938 net_notif.nextthink =
1939 ((time > autocvar_notification_lifetime_mapload)
1941 (time + autocvar_notification_lifetime_runtime)
1943 autocvar_notification_lifetime_mapload
1946 Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification);
1950 // WOVA = Without Variable Arguments
1951 void Send_Notification_WOVA(
1952 float broadcast, entity client,
1953 float net_type, float net_name,
1954 float stringcount, float floatcount,
1955 string s1, string s2, string s3, string s4,
1956 float f1, float f2, float f3, float f4)
1958 #ifdef NOTIFICATIONS_DEBUG
1959 entity notif = Get_Notif_Ent(net_type, net_name);
1960 Debug_Notification(sprintf(
1961 "Send_Notification_WOVA(%s, '%s', %s, %s, %d, %d, %s, %s);\n",
1962 Get_Notif_BroadcastName(broadcast),
1964 Get_Notif_TypeName(net_type),
1968 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1969 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1973 #define VARITEM(stringc,floatc,args) \
1974 if((stringcount == stringc) && (floatcount == floatc)) \
1975 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
1976 EIGHT_VARS_TO_VARARGS_VARLIST
1978 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
1981 // WOCOVA = Without Counts Or Variable Arguments
1982 void Send_Notification_WOCOVA(
1983 float broadcast, entity client,
1984 float net_type, float net_name,
1985 string s1, string s2, string s3, string s4,
1986 float f1, float f2, float f3, float f4)
1988 entity notif = Get_Notif_Ent(net_type, net_name);
1990 #ifdef NOTIFICATIONS_DEBUG
1991 Debug_Notification(sprintf(
1992 "Send_Notification_WOCOVA(%s, '%s', %s, %s, %s, %s);\n",
1993 Get_Notif_BroadcastName(broadcast),
1995 Get_Notif_TypeName(net_type),
1997 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1998 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
2002 #define VARITEM(stringc,floatc,args) \
2003 if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
2004 { Send_Notification(broadcast, client, net_type, net_name, args); return; }
2005 EIGHT_VARS_TO_VARARGS_VARLIST
2007 Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
2009 #endif // ifdef SVQC