92cecf25c48d68c9ce96550561225ad4541425ba
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qc
1 // ================================================
2 //  Unified notification system, written by Samual
3 //  Last updated: August, 2013
4 // ================================================
5
6 string Get_Notif_TypeName(float net_type)
7 {
8         switch(net_type)
9         {
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";
16         }
17         backtrace(sprintf("Get_Notif_TypeName(%d): Improper net type!\n", net_type));
18         return "";
19 }
20
21 entity Get_Notif_Ent(float net_type, float net_name)
22 {
23         switch(net_type)
24         {
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];
30         }
31         backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name));
32         return world;
33 }
34
35 #ifdef SVQC
36 #ifdef NOTIFICATIONS_DEBUG
37 string Get_Notif_BroadcastName(float broadcast)
38 {
39         switch(broadcast)
40         {
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";
47         }
48         backtrace(sprintf("Get_Notif_BroadcastName(%d): Improper broadcast!\n", broadcast));
49         return "";
50 }
51 #endif
52 #endif
53
54 string Notification_CheckArgs_TypeName(float net_type, float net_name)
55 {
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; }
61         switch(net_type)
62         {
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; }
69         }
70         #undef CHECKARG_TYPENAME
71         return checkargs;
72 }
73
74 #ifdef SVQC
75 string Notification_CheckArgs(
76         float broadcast, entity client,
77         float net_type, float net_name)
78 {
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, " "); }
82         switch(broadcast)
83         {
84                 case NOTIF_ONE:
85                 case NOTIF_ONE_ONLY:
86                 {
87                         if(IS_NOT_A_CLIENT(client))
88                                 { checkargs = sprintf("%sNo client provided!", checkargs); }
89                         break;
90                 }
91                 
92                 case NOTIF_ALL_EXCEPT:
93                 {
94                         if(IS_NOT_A_CLIENT(client))
95                                 { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
96                         break;
97                 }
98                 
99                 case NOTIF_ALL:
100                 {
101                         if(client)
102                                 { checkargs = sprintf("%sEntity provided when world was required!", checkargs); }
103                         break;
104                 }
105                 
106                 case NOTIF_TEAM:
107                 {
108                         if not(teamplay)
109                                 { checkargs = sprintf("%sTeamplay not active!", checkargs); }
110                         //else if not(client.team) { checkargs = sprintf("%sNo team provided!", checkargs); }
111                         break;
112                 }
113                 
114                 case NOTIF_TEAM_EXCEPT:
115                 {
116                         if not(teamplay)
117                                 { checkargs = sprintf("%sTeamplay not active!", checkargs); }
118                         else if(IS_NOT_A_CLIENT(client))
119                                 { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
120                         break;
121                 }
122                 
123                 default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
124         }
125         return checkargs;
126 }
127
128 float Notification_ShouldSend(float broadcast, entity to_client, entity other_client)
129 {
130         switch(broadcast)
131         {
132                 case NOTIF_ONE: // send to one client and their spectator
133                 {
134                         if(
135                                 (to_client == other_client)
136                                 ||
137                                 (
138                                         IS_SPEC(to_client)
139                                         &&
140                                         (to_client.enemy == other_client)
141                                 )
142                         ) { return TRUE; }
143                         break;
144                 }
145                 case NOTIF_ONE_ONLY: // send ONLY to one client
146                 {
147                         if(to_client == other_client) { return TRUE; }
148                         break;
149                 }
150                 case NOTIF_TEAM: // send only to X team and their spectators
151                 {
152                         if(
153                                 (to_client.team == other_client.team)
154                                 ||
155                                 (
156                                         IS_SPEC(to_client)
157                                         &&
158                                         (to_client.enemy.team == other_client.team)
159                                 )
160                         ) { return TRUE; }
161                         break;
162                 }
163                 case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators
164                 {
165                         if(
166                                 (to_client != other_client)
167                                 &&
168                                 (
169                                         (to_client.team == other_client.team)
170                                         ||
171                                         (
172                                                 IS_SPEC(to_client)
173                                                 &&
174                                                 (
175                                                         (to_client.enemy != other_client)
176                                                         &&
177                                                         (to_client.enemy.team == other_client.team)
178                                                 )
179                                         )
180                                 )
181                         ) { return TRUE; }
182                         break;
183                 }
184                 case NOTIF_ALL: // send to everyone
185                 {
186                         return TRUE;
187                 }
188                 case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators
189                 {
190                         if(
191                                 (to_client != other_client)
192                                 &&
193                                 !(
194                                         IS_SPEC(to_client)
195                                         &&
196                                         (to_client.enemy == other_client)
197                                 )
198                         ) { return TRUE; }
199                         break;
200                 }
201         }
202         return FALSE;
203 }
204
205 #endif
206
207 // ===============================
208 //  Initialization Core Functions
209 // ===============================
210
211 // used by restartnotifs command to initialize notifications
212 void Destroy_Notification_Entity(entity notif)
213 {
214         if(notif.nent_name != "") { strunzone(notif.nent_name); }
215         if(notif.nent_snd != "") { strunzone(notif.nent_snd); }
216         if(notif.nent_args != "") { strunzone(notif.nent_args); }
217         if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
218         if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
219         if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
220         if(notif.nent_string != "") { strunzone(notif.nent_string); }
221         remove(notif);
222 }
223
224 void Destroy_All_Notifications(void)
225 {
226         entity notif;
227         float i;
228         
229         #define DESTROY_LOOP(type,count) \
230                 for(i = 1; i <= count; ++i) \
231                 { \
232                         notif = Get_Notif_Ent(type, i); \
233                         if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
234                         Destroy_Notification_Entity(notif); \
235                 }
236
237         // kill all networked notifications and centerprints
238         #ifdef SVQC
239         Kill_Notification(NOTIF_ALL, world, 0, 0);
240         #else
241         reset_centerprint_messages();
242         #endif
243
244         // kill all real notification entities
245         DESTROY_LOOP(MSG_ANNCE, NOTIF_ANNCE_COUNT)
246         DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
247         DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
248         DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
249         DESTROY_LOOP(MSG_CHOICE, NOTIF_CHOICE_COUNT)
250         #undef DESTROY_LOOP
251 }
252
253 string Process_Notif_Line(
254         float typeid,
255         float chat,
256         string input,
257         string notiftype,
258         string notifname,
259         string stringtype)
260 {
261         #ifdef CSQC
262         if(typeid == MSG_INFO)
263         {
264                 if((chat && autocvar_notification_allow_chatboxprint)
265                         || (autocvar_notification_allow_chatboxprint == 2))
266                 {
267                         // pass 1: add ETX char at beginning of line
268                         input = strcat("\{3}", input);
269
270                         // pass 2: add ETX char at end of each new line (so that
271                         // messages with multiple lines are put through chatbox too)
272                         input = strreplace("\n", "\n\{3}", input);
273
274                         // pass 3: strip trailing ETX char
275                         if(substring(input, (strlen(input) - 1), 1) == "\{3}")
276                                 { input = substring(input, 0, (strlen(input) - 1)); }
277                 }
278         }
279         #endif
280
281         // done to both MSG_INFO and MSG_CENTER
282         if(substring(input, (strlen(input) - 1), 1) == "\n")
283         {
284                 print(sprintf(
285                         strcat(
286                                 "^1TRAILING NEW LINE AT END OF NOTIFICATION: ",
287                                 "^7net_type = %s, net_name = %s, string = %s.\n"
288                         ),
289                         notiftype,
290                         notifname,
291                         stringtype
292                 ));
293                 notif_error = TRUE;
294                 input = substring(input, 1, (strlen(input) - 1));
295         }
296
297         return input;
298 }
299
300 string Process_Notif_Args(
301         float arg_type,
302         string args,
303         string notiftype,
304         string notifname)
305 {
306         string selected, remaining = args;
307         float sel_num = 0;
308
309         for(;(remaining != "");)
310         {
311                 selected = car(remaining); remaining = cdr(remaining);
312
313                 switch(arg_type)
314                 {
315                         case 1: // normal args
316                         {
317                                 if(sel_num == NOTIF_MAX_ARGS)
318                                 {
319                                         print(sprintf(
320                                                 strcat(
321                                                         "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
322                                                         "^7net_type = %s, net_name = %s, max args = %d.\n"
323                                                 ),
324                                                 notiftype,
325                                                 notifname,
326                                                 NOTIF_MAX_ARGS
327                                         ));
328                                         notif_error = TRUE;
329                                         break;
330                                 }
331
332                                 switch(strtolower(selected))
333                                 {
334                                         #define ARG_CASE(prog,selected,result) \
335                                                 #if (prog != ARG_DC) \
336                                                         case selected: { ++sel_num; break; } \
337                                                 #endif
338                                         NOTIF_ARGUMENT_LIST
339                                         #undef ARG_CASE
340                                         default:
341                                         {
342                                                 print(sprintf(
343                                                         strcat(
344                                                                 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
345                                                                 "^7net_type = %s, net_name = %s, args arg = '%s'.\n"
346                                                         ),
347                                                         notiftype,
348                                                         notifname,
349                                                         selected
350                                                 ));
351                                                 notif_error = TRUE;
352                                                 break;
353                                         }
354                                 }
355                                 break;
356                         }
357                         case 2: // hudargs
358                         {
359                                 if(sel_num == NOTIF_MAX_HUDARGS)
360                                 {
361                                         print(sprintf(
362                                                 strcat(
363                                                         "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
364                                                         "^7net_type = %s, net_name = %s, max hudargs = %d.\n"
365                                                 ),
366                                                 notiftype,
367                                                 notifname,
368                                                 NOTIF_MAX_HUDARGS
369                                         ));
370                                         notif_error = TRUE;
371                                         break;
372                                 }
373
374                                 switch(strtolower(selected))
375                                 {
376                                         #define ARG_CASE(prog,selected,result) \
377                                                 #if (prog == ARG_CS_SV_HA) \
378                                                         case selected: { ++sel_num; break; } \
379                                                 #endif
380                                         NOTIF_ARGUMENT_LIST
381                                         #undef ARG_CASE
382                                         default:
383                                         {
384                                                 print(sprintf(
385                                                         strcat(
386                                                                 "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
387                                                                 "^7net_type = %s, net_name = %s, hudargs arg = '%s'.\n"
388                                                         ),
389                                                         notiftype,
390                                                         notifname,
391                                                         selected
392                                                 ));
393                                                 notif_error = TRUE;
394                                                 break;
395                                         }
396                                 }
397                                 break;
398                         }
399                         case 3: // durcnt 
400                         {
401                                 if(sel_num == NOTIF_MAX_DURCNT)
402                                 {
403                                         print(sprintf(
404                                                 strcat(
405                                                         "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
406                                                         "^7net_type = %s, net_name = %s, max durcnt = %d.\n"
407                                                 ),
408                                                 notiftype,
409                                                 notifname,
410                                                 NOTIF_MAX_DURCNT
411                                         ));
412                                         notif_error = TRUE;
413                                         break;
414                                 }
415
416                                 switch(strtolower(selected))
417                                 {
418                                         #define ARG_CASE(prog,selected,result) \
419                                                 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
420                                                         case selected: { ++sel_num; break; } \
421                                                 #endif
422                                         NOTIF_ARGUMENT_LIST
423                                         #undef ARG_CASE
424                                         default:
425                                         {
426                                                 if(ftos(stof(selected)) != "") { ++sel_num; }
427                                                 else
428                                                 {
429                                                         print(sprintf(
430                                                                 strcat(
431                                                                         "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
432                                                                         "^7net_type = %s, net_name = %s, durcnt arg = '%s'.\n"
433                                                                 ),
434                                                                 notiftype,
435                                                                 notifname,
436                                                                 selected
437                                                         ));
438                                                         notif_error = TRUE;
439                                                 }
440                                                 break;
441                                         }
442                                 }
443                                 break;
444                         }
445                 }
446         }
447         return args;
448 }
449
450 void Create_Notification_Entity(
451         float var_default,
452         float var_cvar,
453         float typeid,
454         float nameid,
455         string namestring,
456         float strnum,
457         float flnum,
458         /* MSG_ANNCE */
459         float channel, 
460         string snd,
461         float vol,
462         float position,
463         /* MSG_INFO & MSG_CENTER */
464         string args,
465         string hudargs,
466         string icon,
467         float cpid,
468         string durcnt,
469         string normal,
470         string gentle,
471         /* MSG_MULTI */
472         float anncename,
473         float infoname,
474         float centername,
475         /* MSG_CHOICE */
476         float challow_def,
477         float challow_var,
478         float chtype,
479         float optiona,
480         float optionb)
481 {
482         // =====================
483         //  Global Entity Setup
484         // =====================
485         entity notif = spawn();
486         switch(typeid)
487         {
488                 case MSG_ANNCE:
489                 {
490                         msg_annce_notifs[nameid - 1] = notif;
491                         notif.classname = "msg_annce_notification";
492                         break;
493                 }
494                 case MSG_INFO:
495                 {
496                         msg_info_notifs[nameid - 1] = notif;
497                         notif.classname = "msg_info_notification";
498                         break;
499                 }
500                 case MSG_CENTER:
501                 {
502                         msg_center_notifs[nameid - 1] = notif;
503                         notif.classname = "msg_center_notification";
504                         break;
505                 }
506                 case MSG_MULTI:
507                 {
508                         msg_multi_notifs[nameid - 1] = notif;
509                         notif.classname = "msg_multi_notification";
510                         break;
511                 }
512                 case MSG_CHOICE:
513                 {
514                         msg_choice_notifs[nameid - 1] = notif;
515                         notif.classname = "msg_choice_notification";
516                         break;
517                 }
518
519                 default:
520                 {
521                         error(sprintf(
522                                 strcat(
523                                         "^1NOTIFICATION WITH IMPROPER TYPE: ",
524                                         "^7net_type = %d, net_name = %s.\n"
525                                 ),
526                                 typeid,
527                                 namestring
528                         ));
529                         return; // It's not possible to recover from this one
530                 }
531         }
532         notif.nent_default = var_default;
533         notif.nent_enabled = (1 <= var_cvar);
534         notif.nent_type = typeid;
535         notif.nent_id = nameid;
536         notif.nent_name = strzone(namestring);
537         
538         string typestring = Get_Notif_TypeName(typeid);
539
540         // Other pre-notif-setup requisites
541         notif_error = FALSE;
542
543         // ====================
544         //  Notification Setup
545         // ====================
546         switch(typeid)
547         {
548                 case MSG_ANNCE:
549                 {
550                         // Set MSG_ANNCE information and handle precaching
551                         #ifdef CSQC
552                         if not(GENTLE && (var_cvar == 1))
553                         {
554                                 if(snd != "")
555                                 {
556                                         if(notif.nent_enabled)
557                                         {
558                                                 precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd));
559                                                 notif.nent_channel = channel;
560                                                 notif.nent_snd = strzone(snd);
561                                                 notif.nent_vol = vol;
562                                                 notif.nent_position = position;
563                                         }
564                                 }
565                                 else
566                                 {
567                                         print(sprintf(
568                                                 strcat(
569                                                         "^1NOTIFICATION WITH NO SOUND: ",
570                                                         "^7net_type = %s, net_name = %s.\n"
571                                                 ),
572                                                 typestring,
573                                                 namestring
574                                         ));
575                                         notif_error = TRUE;
576                                 }
577                         }
578                         else { notif.nent_enabled = FALSE; }
579                         #else
580                         notif.nent_enabled = FALSE;
581                         #endif
582
583                         break;
584                 }
585                 
586                 case MSG_INFO:
587                 case MSG_CENTER:
588                 {
589                         // Set MSG_INFO and MSG_CENTER string/float counts
590                         notif.nent_stringcount = strnum;
591                         notif.nent_floatcount = flnum;
592
593                         // Only initialize arguments if we're either a client or on a dedicated server
594                         #ifdef SVQC
595                         float should_process_args = server_is_dedicated;
596                         #else
597                         float should_process_args = TRUE;
598                         #endif
599
600                         if(should_process_args)
601                         {
602                                 // ========================
603                                 //  Process Main Arguments
604                                 // ========================
605                                 if(strnum + flnum)
606                                 {
607                                         if(args != "")
608                                         {
609                                                 notif.nent_args = strzone(
610                                                         Process_Notif_Args(1, args, typestring, namestring));
611                                         }
612                                         else if((hudargs == "") && (durcnt ==""))
613                                         {
614                                                 print(sprintf(
615                                                         strcat(
616                                                                 "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ",
617                                                                 "^7net_type = %s, net_name = %s, strnum = %d, flnum = %d\n"
618                                                         ),
619                                                         typestring,
620                                                         namestring,
621                                                         strnum,
622                                                         flnum
623                                                 ));
624                                                 notif_error = TRUE;
625                                         }
626                                 }
627                                 else if(args != "")
628                                 {
629                                         notif.nent_args = strzone(
630                                                 Process_Notif_Args(1, args, typestring, namestring));
631                                 }
632
633
634                                 // =======================================
635                                 //  Process HUD and Centerprint Arguments
636                                 //    Only processed on CSQC, as these
637                                 //    args are only for HUD features.
638                                 // =======================================
639                                 #ifdef CSQC
640                                 if(hudargs != "")
641                                 {
642                                         notif.nent_hudargs = strzone(
643                                                 Process_Notif_Args(2, hudargs, typestring, namestring));
644                                                 
645                                         if(icon != "") { notif.nent_icon = strzone(icon); }
646                                         else
647                                         {
648                                                 print(sprintf(
649                                                         strcat(
650                                                                 "^1NOTIFICATION HAS HUDARGS BUT NO ICON: ",
651                                                                 "^7net_type = %s, net_name = %s.\n"
652                                                         ),
653                                                         typestring,
654                                                         namestring
655                                                 ));
656                                                 notif_error = TRUE;
657                                         }
658                                 }
659                                 else if(icon != "")
660                                 {
661                                         print(sprintf(
662                                                 strcat(
663                                                         "^1NOTIFICATION HAS ICON BUT NO HUDARGS: ",
664                                                         "^7net_type = %s, net_name = %s.\n"
665                                                 ),
666                                                 typestring,
667                                                 namestring
668                                         ));
669                                         notif_error = TRUE;
670                                 }
671
672                                 if(durcnt != "")
673                                 {
674                                         notif.nent_durcnt = strzone(
675                                                 Process_Notif_Args(3, durcnt, typestring, namestring));
676                                                 
677                                         if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
678                                         else
679                                         {
680                                                 print(sprintf(
681                                                         strcat(
682                                                                 "^1NOTIFICATION HAS DURCNT BUT NO CPID: ",
683                                                                 "^7net_type = %s, net_name = %s.\n"
684                                                         ),
685                                                         typestring,
686                                                         namestring
687                                                 ));
688                                                 notif_error = TRUE;
689                                         }
690                                 } 
691                                 else if(cpid != NO_MSG) { notif.nent_cpid = cpid; }
692                                 #endif
693
694
695                                 // ======================
696                                 //  Process Notif String
697                                 // ======================
698                                 #define SET_NOTIF_STRING(string,stringname) \
699                                         notif.nent_string = strzone(CCR( \
700                                                 Process_Notif_Line( \
701                                                         typeid, \
702                                                         (var_cvar > 1), \
703                                                         string, \
704                                                         typestring, \
705                                                         namestring, \
706                                                         stringname \
707                                                 )) \
708                                         );
709
710                                 if(GENTLE)
711                                 {
712                                         if(gentle != "") { SET_NOTIF_STRING(gentle, "GENTLE") }
713                                         else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
714                                 }
715                                 else if(normal != "") { SET_NOTIF_STRING(normal, "NORMAL") }
716                                 
717                                 #undef SET_NOTIF_STRING
718
719                                 // Check to make sure a string was chosen
720                                 if(notif.nent_string == "")
721                                 {
722                                         print(sprintf(
723                                                 strcat(
724                                                         "^1EMPTY NOTIFICATION: ",
725                                                         "^7net_type = %s, net_name = %s.\n"
726                                                 ),
727                                                 typestring,
728                                                 namestring
729                                         ));
730                                         notif_error = TRUE;
731                                 }
732                         }
733
734                         break;
735                 }
736
737                 case MSG_MULTI:
738                 {
739                         // Set MSG_MULTI string/float counts
740                         if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG))
741                         {
742                                 print(sprintf(
743                                         strcat(
744                                                 "^1NOTIFICATION WITH NO SUBCALLS: ",
745                                                 "^7net_type = %s, net_name = %s.\n"
746                                         ),
747                                         typestring,
748                                         namestring
749                                 ));
750                                 notif_error = TRUE;
751                         }
752                         else
753                         {
754                                 // announcements don't actually need any arguments, so lets not even count them.
755                                 if(anncename != NO_MSG) { notif.nent_msgannce = msg_annce_notifs[anncename - 1]; }
756                                 
757                                 float infoname_stringcount = 0, infoname_floatcount = 0;
758                                 float centername_stringcount = 0, centername_floatcount = 0;
759                                 
760                                 if(infoname != NO_MSG)
761                                 {
762                                         notif.nent_msginfo = msg_info_notifs[infoname - 1];
763                                         infoname_stringcount = notif.nent_msginfo.nent_stringcount;
764                                         infoname_floatcount = notif.nent_msginfo.nent_floatcount;
765                                 }
766                                 
767                                 if(centername != NO_MSG)
768                                 {
769                                         notif.nent_msgcenter = msg_center_notifs[centername - 1];
770                                         centername_stringcount = notif.nent_msgcenter.nent_stringcount;
771                                         centername_floatcount = notif.nent_msgcenter.nent_floatcount;
772                                 }
773                                 
774                                 // set the requirements of THIS notification to the totals of its subcalls
775                                 notif.nent_stringcount = max(infoname_stringcount, centername_stringcount);
776                                 notif.nent_floatcount = max(infoname_floatcount, centername_floatcount);
777                         }
778                         
779                         break;
780                 }
781
782                 case MSG_CHOICE:
783                 {
784                         if((chtype == NO_MSG) || (optiona == NO_MSG) || (optionb == NO_MSG))
785                         {
786                                 print(sprintf(
787                                         strcat(
788                                                 "^1NOTIFICATION IS MISSING CHOICE PARAMS: ",
789                                                 "^7net_type = %s, net_name = %s.\n"
790                                         ),
791                                         typestring,
792                                         namestring
793                                 ));
794                                 notif_error = TRUE;
795                         }
796                         else
797                         {
798                                 switch(chtype)
799                                 {
800                                         case MSG_ANNCE:
801                                         {
802                                                 notif.nent_optiona = msg_annce_notifs[optiona - 1];
803                                                 notif.nent_optionb = msg_annce_notifs[optionb - 1];
804                                                 break;
805                                         }
806                                         case MSG_INFO:
807                                         {
808                                                 notif.nent_optiona = msg_info_notifs[optiona - 1];
809                                                 notif.nent_optionb = msg_info_notifs[optionb - 1];
810                                                 break;
811                                         }
812                                         case MSG_CENTER:
813                                         {
814                                                 notif.nent_optiona = msg_center_notifs[optiona - 1];
815                                                 notif.nent_optionb = msg_center_notifs[optionb - 1];
816                                                 break;
817                                         }
818                                         case MSG_MULTI:
819                                         {
820                                                 notif.nent_optiona = msg_multi_notifs[optiona - 1];
821                                                 notif.nent_optionb = msg_multi_notifs[optionb - 1];
822                                                 break;
823                                         }
824                                         case MSG_CHOICE: // should we REALLY allow nested options?... 
825                                         {
826                                                 notif.nent_optiona = msg_choice_notifs[optiona - 1];
827                                                 notif.nent_optionb = msg_choice_notifs[optionb - 1];
828                                                 break;
829                                         }
830
831                                         default:
832                                         {
833                                                 print(sprintf(
834                                                         strcat(
835                                                                 "^1NOTIFICATION WITH IMPROPER TYPE: ",
836                                                                 "^7net_type = %d, net_name = %s.\n"
837                                                         ),
838                                                         typeid,
839                                                         namestring
840                                                 ));
841                                                 notif_error = TRUE;
842                                                 break;
843                                         }
844                                 }
845                                 notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed
846                                 notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed
847                                 notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount);
848                                 notif.nent_floatcount = max(notif.nent_optiona.nent_floatcount, notif.nent_optionb.nent_floatcount);
849                                 
850                                 /*#ifdef NOTIFICATIONS_DEBUG
851                                 Debug_Notification(sprintf(
852                                         "Create_Notification_Entity(...): MSG_CHOICE: %s\n%s\n%s\n",
853                                         notif.nent_name,
854                                         sprintf(
855                                                 "^ optiona: %s %s : %d %d",
856                                                 Get_Notif_TypeName(notif.nent_optiona.nent_type),
857                                                 notif.nent_optiona.nent_name,
858                                                 notif.nent_optiona.nent_stringcount,
859                                                 notif.nent_optiona.nent_floatcount
860                                         ),
861                                         sprintf(
862                                                 "^ optionb: %s %s : %d %d",
863                                                 Get_Notif_TypeName(notif.nent_optionb.nent_type),
864                                                 notif.nent_optionb.nent_name,
865                                                 notif.nent_optionb.nent_stringcount,
866                                                 notif.nent_optionb.nent_floatcount
867                                         )
868                                 ));
869                                 #endif*/
870                         }
871                         break;
872                 }
873                 
874                 default:
875                 {
876                         print(sprintf(
877                                 strcat(
878                                         "^1NOTIFICATION WITH IMPROPER TYPE: ",
879                                         "^7net_type = %d, net_name = %s.\n"
880                                 ),
881                                 typeid,
882                                 namestring
883                         ));
884                         notif_error = TRUE;
885                         break;
886                 }
887         }
888
889         // now check to see if any errors happened 
890         if(notif_error)
891         {
892                 notif.nent_enabled = FALSE; // disable the notification so it can't cause trouble
893                 notif_global_error = TRUE; // throw the red flag that an error happened on init
894         }
895 }
896
897
898 // ===============
899 //  Cvar Handling
900 // ===============
901
902 // used by MSG_CHOICE to build list of choices
903 #ifdef SVQC
904 void Notification_GetCvars(void)
905 {
906         float i;
907         for(i = 0; i <= NOTIF_CHOICE_COUNT; ++i)
908         {
909                 GetCvars_handleFloat(
910                         get_cvars_s,
911                         get_cvars_f,
912                         msg_choice_choices[i],
913                         sprintf("notification_%s", msg_choice_notifs[i].nent_name)
914                 );
915         }
916
917         GetCvars_handleFloat(get_cvars_s, get_cvars_f, FRAG_VERBOSE, "notification_frag_verbose");
918 }
919 #endif
920
921 // used to output notifications.cfg file
922 void Dump_Notifications(float fh, float alsoprint)
923 {
924         #define NOTIF_WRITE(a) { \
925                 fputs(fh, a); \
926                 if(alsoprint) { print(a); } }
927         #define NOTIF_WRITE_ENTITY(description) { \
928                 notif_msg = \
929                         sprintf( \
930                                 "seta notification_%s \"%d\" \"%s\"\n", \
931                                 e.nent_name, e.nent_default, description \
932                         ); \
933                 NOTIF_WRITE(notif_msg) }
934         #define NOTIF_WRITE_ENTITY_CHOICE(descriptiona,descriptionb) { \
935                 notif_msg = \
936                         sprintf( \
937                                 "seta notification_%s \"%d\" \"%s\"\n" \
938                                 "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
939                                 e.nent_name, e.nent_default, descriptiona, \
940                                 e.nent_name, e.nent_challow_def, descriptionb \
941                         ); \
942                 NOTIF_WRITE(notif_msg) }
943         #define NOTIF_WRITE_HARDCODED(cvar,default,description) { \
944                 notif_msg = \
945                         sprintf( \
946                                 "seta notification_%s \"%s\" \"%s\"\n", \
947                                 cvar, default, description \
948                         ); \
949                 NOTIF_WRITE(notif_msg) }
950
951         string notif_msg;
952         float i;
953         entity e;
954
955         // Note: This warning only applies to the notifications.cfg file that is output...
956
957         // You ARE supposed to manually edit this function to add i.e. hard coded
958         // notification variables for mutators or game modes or such and then
959         // regenerate the notifications.cfg file from the new code.
960
961         NOTIF_WRITE("// ********************************************** //\n");
962         NOTIF_WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
963         NOTIF_WRITE("// **                                          ** //\n");
964         NOTIF_WRITE("// **  This file is automatically generated    ** //\n");
965         NOTIF_WRITE("// **  by code with the command 'dumpnotifs'.  ** //\n");
966         NOTIF_WRITE("// **                                          ** //\n");
967         NOTIF_WRITE("// **  If you add a new notification, please   ** //\n");
968         NOTIF_WRITE("// **  regenerate this file with that command  ** //\n");
969         NOTIF_WRITE("// **  making sure that the output matches     ** //\n");
970         NOTIF_WRITE("// **  with the lists and defaults in code.    ** //\n");
971         NOTIF_WRITE("// **                                          ** //\n");
972         NOTIF_WRITE("// ********************************************** //\n");
973
974         // These notifications will also append their string as a comment...
975         // This is not necessary, and does not matter if they vary between config versions,
976         // it is just a semi-helpful tool for those who want to manually change their user settings.
977
978         NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
979         for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
980         {
981                 e = Get_Notif_Ent(MSG_ANNCE, i);
982                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
983                 
984                 NOTIF_WRITE_ENTITY(
985                         "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
986                 );
987         }
988
989         NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
990         for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
991         {
992                 e = Get_Notif_Ent(MSG_INFO, i);
993                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
994                 
995                 NOTIF_WRITE_ENTITY(
996                         "Notification control cvar: 0 = off, 1 = print to console, "
997                         "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
998                 );
999         }
1000
1001         NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
1002         for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
1003         {
1004                 e = Get_Notif_Ent(MSG_CENTER, i);
1005                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1006                 
1007                 NOTIF_WRITE_ENTITY(
1008                         "Notification control cvar: 0 = off, 1 = centerprint"
1009                 );
1010         }
1011
1012         NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
1013         for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
1014         {
1015                 e = Get_Notif_Ent(MSG_MULTI, i);
1016                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1017                 
1018                 NOTIF_WRITE_ENTITY(
1019                         "Notification control cvar: 0 = off, 1 = trigger subcalls"
1020                 );
1021         }
1022
1023         NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
1024         for(i = 1; i <= NOTIF_CHOICE_COUNT; ++i)
1025         {
1026                 e = Get_Notif_Ent(MSG_CHOICE, i);
1027                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
1028                 
1029                 NOTIF_WRITE_ENTITY_CHOICE(
1030                         "Notification control cvar: 0 = off, 1 = trigger option A subcall, 2 = trigger option B subcall",
1031                         "Notification control cvar: 0 = off, 1 = allowed in warmup mode, 2 = always allowed"
1032                 );
1033         }
1034
1035         // edit these to match whichever cvars are used for specific notification options
1036         NOTIF_WRITE("\n// HARD CODED notification variables:\n");
1037         
1038         NOTIF_WRITE_HARDCODED(
1039                 "allow_chatboxprint", "1",
1040                 "Allow notifications to be printed to chat box by setting notification cvar to 2 "
1041                 "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
1042         );
1043         
1044         NOTIF_WRITE_HARDCODED(
1045                 "debug", "0",
1046                 "Print extra debug information on all notification function calls "
1047                 "(Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... "
1048                 "0 = disabled, 1 = dprint, 2 = print"
1049         );
1050         
1051         NOTIF_WRITE_HARDCODED(
1052                 "errors_are_fatal", "1",
1053                 "If a notification fails upon initialization, cause a Host_Error to stop the program"
1054         );
1055         
1056         NOTIF_WRITE_HARDCODED(
1057                 "item_centerprinttime", "1.5",
1058                 "How long to show item information centerprint messages (like 'You got the Electro' or such)"
1059         );
1060         
1061         NOTIF_WRITE_HARDCODED(
1062                 "lifetime_mapload", "10",
1063                 "Amount of time that notification entities last immediately at mapload (in seconds) "
1064                 "to help prevent notifications from being lost on early init (like gamestart countdown)"
1065         );
1066         
1067         NOTIF_WRITE_HARDCODED(
1068                 "lifetime_runtime", "0.5",
1069                 "Amount of time that notification entities last on the server during runtime (In seconds)"
1070         );
1071         
1072         NOTIF_WRITE_HARDCODED(
1073                 "server_allows_location", "1",
1074                 "Server side cvar for allowing death messages to show location information too"
1075         );
1076         
1077         NOTIF_WRITE_HARDCODED(
1078                 "show_location", "0",
1079                 "Append location information to MSG_INFO death/kill messages"
1080         );
1081         
1082         NOTIF_WRITE_HARDCODED(
1083                 "show_location_string", "",
1084                 "Replacement string piped into sprintf, "
1085                 "so you can do different messages like this: ' at the %s' or ' (near %s)'"
1086         );
1087         
1088         NOTIF_WRITE_HARDCODED(
1089                 "show_sprees", "1",
1090                 "Print information about sprees in death/kill messages"
1091         );
1092         
1093         NOTIF_WRITE_HARDCODED(
1094                 "show_sprees_center", "1",
1095                 "Show spree information in MSG_CENTER messages... "
1096                 "0 = off, 1 = target (but only for first victim) and attacker"
1097         );
1098         
1099         NOTIF_WRITE_HARDCODED(
1100                 "show_sprees_center_specialonly", "1",
1101                 "Don't show spree information in MSG_CENTER messages if it isn't an achievement"
1102         );
1103         
1104         NOTIF_WRITE_HARDCODED(
1105                 "show_sprees_info", "3",
1106                 "Show spree information in MSG_INFO messages... "
1107                 "0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker"
1108         );
1109         
1110         NOTIF_WRITE_HARDCODED(
1111                 "show_sprees_info_newline", "1",
1112                 "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
1113         );
1114         
1115         NOTIF_WRITE_HARDCODED(
1116                 "show_sprees_info_specialonly", "1",
1117                 "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
1118         );
1119
1120         NOTIF_WRITE(sprintf(
1121                 strcat(
1122                         "\n// Notification counts (total = %d): ",
1123                         "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
1124                 ),
1125                 (
1126                         NOTIF_ANNCE_COUNT +
1127                         NOTIF_INFO_COUNT +
1128                         NOTIF_CENTER_COUNT +
1129                         NOTIF_MULTI_COUNT +
1130                         NOTIF_CHOICE_COUNT
1131                 ),
1132                 NOTIF_ANNCE_COUNT,
1133                 NOTIF_INFO_COUNT,
1134                 NOTIF_CENTER_COUNT,
1135                 NOTIF_MULTI_COUNT,
1136                 NOTIF_CHOICE_COUNT
1137         ));
1138         
1139         return;
1140         #undef NOTIF_WRITE_HARDCODED
1141         #undef NOTIF_WRITE_ENTITY
1142         #undef NOTIF_WRITE
1143 }
1144
1145
1146 // ===============================
1147 //  Frontend Notification Pushing
1148 // ===============================
1149
1150 #ifdef NOTIFICATIONS_DEBUG
1151 void Debug_Notification(string input)
1152 {
1153         switch(autocvar_notification_debug)
1154         {
1155                 case 1: { dprint(input); break; }
1156                 case 2: { print(input); break; }
1157         }
1158 }
1159 #endif
1160
1161 string Local_Notification_sprintf(
1162         string input, string args, 
1163         string s1, string s2, string s3, string s4,
1164         float f1, float f2, float f3, float f4)
1165 {
1166         #ifdef NOTIFICATIONS_DEBUG
1167         Debug_Notification(sprintf(
1168                 "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
1169                 MakeConsoleSafe(input),
1170                 args,
1171                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1172                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1173         ));
1174         #endif
1175         
1176         string selected;
1177         float sel_num;
1178         for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
1179
1180         string tmp_s;
1181
1182         for(sel_num = 0;(args != "");)
1183         {
1184                 selected = car(args); args = cdr(args);
1185                 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1186                 switch(strtolower(selected))
1187                 {
1188                         #define ARG_CASE(prog,selected,result) \
1189                                 #ifdef CSQC \
1190                                         #if (prog != ARG_SV) && (prog != ARG_DC) \
1191                                                 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1192                                         #endif \
1193                                 #else \
1194                                         #if (prog != ARG_CS) && (prog != ARG_DC) \
1195                                                 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1196                                         #endif \
1197                                 #endif
1198                         NOTIF_ARGUMENT_LIST
1199                         #undef ARG_CASE
1200                         default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
1201                 }
1202         }
1203         return sprintf(
1204                 strcat(input, "\n"),
1205                 arg_slot[0],
1206                 arg_slot[1],
1207                 arg_slot[2],
1208                 arg_slot[3],
1209                 arg_slot[4],
1210                 arg_slot[5],
1211                 arg_slot[6]
1212         );
1213 }
1214
1215 #ifdef CSQC
1216 void Local_Notification_sound(
1217         float soundchannel, string soundfile,
1218         float soundvolume, float soundposition)
1219 {
1220         if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
1221         {
1222                 #ifdef NOTIFICATIONS_DEBUG
1223                 Debug_Notification(sprintf(
1224                         "Local_Notification_sound(world, %f, '%s', %f, %f);\n",
1225                         soundchannel,
1226                         sprintf(
1227                                 "announcer/%s/%s.wav",
1228                                 autocvar_cl_announcer,
1229                                 soundfile
1230                         ),
1231                         soundvolume,
1232                         soundposition
1233                 ));
1234                 #endif
1235                 
1236                 sound(
1237                         world,
1238                         soundchannel,
1239                         sprintf(
1240                                 "announcer/%s/%s.wav",
1241                                 autocvar_cl_announcer,
1242                                 soundfile
1243                         ),
1244                         soundvolume,
1245                         soundposition
1246                 );
1247                 
1248                 if(prev_soundfile) { strunzone(prev_soundfile); }
1249                 prev_soundfile = strzone(soundfile);
1250                 prev_soundtime = time;
1251         }
1252         else
1253         {
1254                 #ifdef NOTIFICATIONS_DEBUG
1255                 Debug_Notification(sprintf(
1256                         strcat(
1257                                 "Local_Notification_sound(world, %f, '%s', %f, %f) ",
1258                                 "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
1259                          ),
1260                         soundchannel,
1261                         sprintf(
1262                                 "announcer/%s/%s.wav",
1263                                 autocvar_cl_announcer,
1264                                 soundfile
1265                         ),
1266                         soundvolume,
1267                         soundposition,
1268                         prev_soundfile,
1269                         (time - prev_soundtime),
1270                         autocvar_cl_announcer_antispam
1271                 ));
1272                 #endif
1273         }
1274 }
1275
1276 void Local_Notification_HUD_Notify_Push(
1277         string icon, string hudargs,
1278         string s1, string s2, string s3, string s4)
1279 {
1280         string selected;
1281         float sel_num;
1282         arg_slot[0] = ""; arg_slot[1] = "";
1283
1284         for(sel_num = 0;(hudargs != "");)
1285         {
1286                 selected = car(hudargs); hudargs = cdr(hudargs);
1287                 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1288                 switch(strtolower(selected))
1289                 {
1290                         #define ARG_CASE(prog,selected,result) \
1291                                 #if (prog == ARG_CS_SV_HA) \
1292                                         case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1293                                 #endif
1294                         NOTIF_ARGUMENT_LIST
1295                         #undef ARG_CASE
1296                         default: NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
1297                 }
1298         }
1299         #ifdef NOTIFICATIONS_DEBUG
1300         Debug_Notification(sprintf(
1301                 "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s);\n",
1302                 icon,
1303                 hudargs,
1304                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1305                 MakeConsoleSafe(sprintf("'%s^7', '%s^7'", stof(arg_slot[0]), stof(arg_slot[1])))
1306         ));
1307         #endif
1308         HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
1309 }
1310
1311 void Local_Notification_centerprint_generic(
1312         string input, string durcnt,
1313         float cpid, float f1, float f2)
1314 {
1315         string selected;
1316         float sel_num;
1317         arg_slot[0] = ""; arg_slot[1] = "";
1318
1319         for(sel_num = 0;(durcnt != "");)
1320         {
1321                 selected = car(durcnt); durcnt = cdr(durcnt);
1322                 NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic")
1323                 switch(strtolower(selected))
1324                 {
1325                         #define ARG_CASE(prog,selected,result) \
1326                                 #if (prog == ARG_CS_SV_DC) || (prog == ARG_DC) \
1327                                         case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
1328                                 #endif
1329                         NOTIF_ARGUMENT_LIST
1330                         #undef ARG_CASE
1331                         default:
1332                         {
1333                                 if(ftos(stof(selected)) != "") { arg_slot[sel_num] = selected; ++sel_num; }
1334                                 else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") }
1335                                 break;
1336                         }
1337                 }
1338         }
1339         #ifdef NOTIFICATIONS_DEBUG
1340         Debug_Notification(sprintf(
1341                 "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n",
1342                 MakeConsoleSafe(input),
1343                 durcnt,
1344                 f1, f2,
1345                 stof(arg_slot[0]),
1346                 stof(arg_slot[1])
1347         ));
1348         #endif
1349         centerprint_generic(cpid, input, stof(arg_slot[0]), stof(arg_slot[1]));
1350 }
1351 #endif
1352
1353 void Local_Notification(float net_type, float net_name, ...count)
1354 {
1355         // check if this should be aborted
1356         if(net_name == NOTIF_ABORT)
1357         {
1358                 #ifdef NOTIFICATIONS_DEBUG
1359                 Debug_Notification(sprintf(
1360                         "Local_Notification(%s, %s, ...);\n",
1361                         Get_Notif_TypeName(net_type),
1362                         "NOTIF_ABORT"
1363                 ));
1364                 #endif
1365                 return;
1366         }
1367         
1368         // check supplied type and name for errors
1369         string checkargs = Notification_CheckArgs_TypeName(net_type, net_name);
1370         if(checkargs != "")
1371         {
1372                 #ifdef NOTIFICATIONS_DEBUG
1373                 Debug_Notification(sprintf(
1374                         "Local_Notification(%s, %d, ...);\n",
1375                         Get_Notif_TypeName(net_type),
1376                         Get_Notif_Ent(net_type, net_name).nent_name
1377                 ));
1378                 #endif
1379                 backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs));
1380                 return;
1381         }
1382
1383         // retreive entity of this notification
1384         entity notif = Get_Notif_Ent(net_type, net_name);
1385         if not(notif)
1386         {
1387                 #ifdef NOTIFICATIONS_DEBUG
1388                 Debug_Notification(sprintf(
1389                         "Local_Notification(%s, %d, ...);\n",
1390                         Get_Notif_TypeName(net_type),
1391                         net_name
1392                 ));
1393                 #endif
1394                 backtrace("Local_Notification: Could not find notification entity!\n");
1395                 return;
1396         }
1397
1398         // check if the notification is enabled
1399         if not(notif.nent_enabled)
1400         {
1401                 #ifdef NOTIFICATIONS_DEBUG
1402                 Debug_Notification(sprintf(
1403                         "Local_Notification(%s, %s, ...): Entity was disabled...\n",
1404                         Get_Notif_TypeName(net_type),
1405                         notif.nent_name
1406                 ));
1407                 #endif
1408                 return;
1409         }
1410
1411         string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1412         string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1413         string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1414         string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1415         float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1416         float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1417         float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1418         float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1419
1420         #ifdef NOTIFICATIONS_DEBUG
1421         Debug_Notification(sprintf(
1422                 "Local_Notification(%s, %s, %s, %s);\n",
1423                 Get_Notif_TypeName(net_type),
1424                 notif.nent_name,
1425                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1426                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1427         ));
1428         #endif
1429         
1430         if((notif.nent_stringcount + notif.nent_floatcount) > count)
1431         {
1432                 backtrace(sprintf(
1433                         strcat(
1434                                 "Not enough arguments for Local_Notification(%s, %s, ...)! ",
1435                                 "stringcount(%d) + floatcount(%d) > count(%d)\n", 
1436                                 "Check the definition and function call for accuracy...?\n"
1437                         ),
1438                         Get_Notif_TypeName(net_type),
1439                         notif.nent_name,
1440                         notif.nent_stringcount,
1441                         notif.nent_floatcount,
1442                         count
1443                 ));
1444                 return;
1445         }
1446         else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1447         {
1448                 backtrace(sprintf(
1449                         strcat(
1450                                 "Too many arguments for Local_Notification(%s, %s, ...)! ",
1451                                 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1452                                 "Check the definition and function call for accuracy...?\n"
1453                         ),
1454                         Get_Notif_TypeName(net_type),
1455                         notif.nent_name,
1456                         notif.nent_stringcount,
1457                         notif.nent_floatcount,
1458                         count
1459                 ));
1460                 return;
1461         }
1462         
1463         switch(net_type)
1464         {
1465                 case MSG_ANNCE:
1466                 {
1467                         #ifdef CSQC
1468                         Local_Notification_sound(
1469                                 notif.nent_channel,
1470                                 notif.nent_snd,
1471                                 notif.nent_vol,
1472                                 notif.nent_position
1473                         );
1474                         #else
1475                         backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
1476                         #endif
1477                         break;
1478                 }
1479                 
1480                 case MSG_INFO:
1481                 {
1482                         print(
1483                                 Local_Notification_sprintf(
1484                                         notif.nent_string,
1485                                         notif.nent_args, 
1486                                         s1, s2, s3, s4,
1487                                         f1, f2, f3, f4)
1488                         );
1489                         #ifdef CSQC 
1490                         if(notif.nent_icon != "")
1491                         {
1492                                 Local_Notification_HUD_Notify_Push(
1493                                         notif.nent_icon,
1494                                         notif.nent_hudargs,
1495                                         s1, s2, s3, s4);
1496                         } 
1497                         #endif 
1498                         break;
1499                 }
1500                 
1501                 #ifdef CSQC
1502                 case MSG_CENTER:
1503                 {
1504                         Local_Notification_centerprint_generic(
1505                                 Local_Notification_sprintf(
1506                                         notif.nent_string,
1507                                         notif.nent_args, 
1508                                         s1, s2, s3, s4,
1509                                         f1, f2, f3, f4),
1510                                 notif.nent_durcnt,
1511                                 notif.nent_cpid,
1512                                 f1, f2);
1513                         break;
1514                 }
1515                 #endif
1516                 
1517                 case MSG_MULTI:
1518                 {
1519                         if(notif.nent_msginfo)
1520                         if(notif.nent_msginfo.nent_enabled)
1521                         {
1522                                 Local_Notification_WOVA(
1523                                         MSG_INFO,
1524                                         notif.nent_msginfo.nent_id, 
1525                                         notif.nent_msginfo.nent_stringcount, 
1526                                         notif.nent_msginfo.nent_floatcount, 
1527                                         s1, s2, s3, s4,
1528                                         f1, f2, f3, f4);
1529                         }
1530                         #ifdef CSQC
1531                         if(notif.nent_msgannce)
1532                         if(notif.nent_msgannce.nent_enabled)
1533                         {
1534                                 Local_Notification_WOVA(
1535                                         MSG_ANNCE,
1536                                         notif.nent_msgannce.nent_id, 
1537                                         0, 0, 
1538                                         "", "", "", "",
1539                                         0, 0, 0, 0);
1540                         }
1541                         if(notif.nent_msgcenter)
1542                         if(notif.nent_msgcenter.nent_enabled)
1543                         {
1544                                 Local_Notification_WOVA(
1545                                         MSG_CENTER,
1546                                         notif.nent_msgcenter.nent_id, 
1547                                         notif.nent_msgcenter.nent_stringcount, 
1548                                         notif.nent_msgcenter.nent_floatcount, 
1549                                         s1, s2, s3, s4,
1550                                         f1, f2, f3, f4); 
1551                         }
1552                         #endif
1553                         break;
1554                 }
1555
1556                 case MSG_CHOICE:
1557                 {
1558                         entity found_choice;
1559                         
1560                         if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2)))
1561                         {
1562                                 switch(cvar_string(sprintf("notification_%s", notif.nent_name)))
1563                                 {
1564                                         case 1: found_choice = notif.nent_optiona; break;
1565                                         case 2: found_choice = notif.nent_optionb; break;
1566                                         default: return; // not enabled anyway
1567                                 }
1568                         }
1569                         else { found_choice = notif.nent_optiona; }
1570                         
1571                         Local_Notification_WOVA(
1572                                 found_choice.nent_type,
1573                                 found_choice.nent_id, 
1574                                 found_choice.nent_stringcount, 
1575                                 found_choice.nent_floatcount, 
1576                                 s1, s2, s3, s4,
1577                                 f1, f2, f3, f4); 
1578                 }
1579         }
1580 }
1581
1582 // WOVA = Without Variable Arguments 
1583 void Local_Notification_WOVA(
1584         float net_type, float net_name,
1585         float stringcount, float floatcount,
1586         string s1, string s2, string s3, string s4,
1587         float f1, float f2, float f3, float f4)
1588 {
1589         #define VARITEM(stringc,floatc,args) \
1590                 if((stringcount == stringc) && (floatcount == floatc)) \
1591                         { Local_Notification(net_type, net_name, args); return; }
1592         EIGHT_VARS_TO_VARARGS_VARLIST
1593         #undef VARITEM
1594         Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
1595 }
1596
1597
1598 // =========================
1599 //  Notification Networking
1600 // =========================
1601
1602 #ifdef CSQC
1603 void Read_Notification(float is_new)
1604 {
1605         float net_type = ReadByte();
1606         float net_name = ReadShort();
1607
1608         entity notif;
1609
1610         if(net_type == MSG_CENTER_CPID)
1611         {
1612                 #ifdef NOTIFICATIONS_DEBUG
1613                 Debug_Notification(sprintf(
1614                         "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n",
1615                         is_new,
1616                         time,
1617                         Get_Notif_TypeName(net_type),
1618                         net_name
1619                 ));
1620                 #endif
1621                 
1622                 if(is_new)
1623                 {
1624                         if(net_name == 0) { reset_centerprint_messages(); }
1625                         else if(net_name != NO_CPID)
1626                         {
1627                                 // in this case, net_name IS the cpid we want to kill
1628                                 centerprint_generic(net_name, "", 0, 0);
1629                         }
1630                         else
1631                         {
1632                                 backtrace(sprintf(
1633                                         "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n",
1634                                         is_new,
1635                                         time
1636                                 ));
1637                         } 
1638                 }
1639         }
1640         else
1641         {
1642                 notif = Get_Notif_Ent(net_type, net_name);
1643                 if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; }
1644
1645                 #ifdef NOTIFICATIONS_DEBUG
1646                 Debug_Notification(sprintf(
1647                         "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n",
1648                         is_new,
1649                         time,
1650                         Get_Notif_TypeName(net_type),
1651                         notif.nent_name
1652                 ));
1653                 #endif
1654
1655                 string s1 = ((0 < notif.nent_stringcount) ? ReadString() : "");
1656                 string s2 = ((1 < notif.nent_stringcount) ? ReadString() : "");
1657                 string s3 = ((2 < notif.nent_stringcount) ? ReadString() : "");
1658                 string s4 = ((3 < notif.nent_stringcount) ? ReadString() : "");
1659                 float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0);
1660                 float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0);
1661                 float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0);
1662                 float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0);
1663         
1664                 if(is_new)
1665                 {
1666                         Local_Notification_WOVA(
1667                                 net_type, net_name,
1668                                 notif.nent_stringcount,
1669                                 notif.nent_floatcount,
1670                                 s1, s2, s3, s4,
1671                                 f1, f2, f3, f4);
1672                 }
1673         }
1674 }
1675 #endif
1676
1677 #ifdef SVQC
1678 void Net_Notification_Remove()
1679 {
1680         if not(self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
1681         
1682         #ifdef NOTIFICATIONS_DEBUG
1683         Debug_Notification(sprintf(
1684                 "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
1685                 time,
1686                 ((self.nent_net_name == -1) ? "Killed" : "Removed"),
1687                 Get_Notif_TypeName(self.nent_net_type),
1688                 self.owner.nent_name
1689         ));
1690         #endif
1691         
1692         float i;
1693         for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
1694         remove(self);
1695 }
1696
1697 float Net_Write_Notification(entity client, float sf)
1698 {
1699         if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client))
1700         {
1701                 float i;
1702                 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
1703                 WriteByte(MSG_ENTITY, self.nent_net_type);
1704                 WriteShort(MSG_ENTITY, self.nent_net_name);
1705                 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } 
1706                 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
1707                 return TRUE;
1708         }
1709         else { return FALSE; }
1710 }
1711
1712 void Kill_Notification(
1713         float broadcast, entity client,
1714         float net_type, float net_name)
1715 {
1716         #ifdef NOTIFICATIONS_DEBUG
1717         Debug_Notification(sprintf(
1718                 "Kill_Notification(%s, '%s', %s, %d);\n",
1719                 Get_Notif_BroadcastName(broadcast),
1720                 client.netname,
1721                 (net_type ? Get_Notif_TypeName(net_type) : "0"),
1722                 net_name
1723         ));
1724         #endif
1725         
1726         string checkargs = Notification_CheckArgs(broadcast, client, 1, 1);
1727         if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; }
1728
1729         entity notif, net_notif;
1730         float killed_cpid = NO_CPID;
1731         
1732         switch(net_type)
1733         {
1734                 case 0:
1735                 {
1736                         killed_cpid = 0; // kill ALL centerprints
1737                         break;
1738                 }
1739                 
1740                 case MSG_CENTER:
1741                 {
1742                         if(net_name)
1743                         {
1744                                 entity notif = Get_Notif_Ent(net_type, net_name);
1745                                 if not(notif) { backtrace("Kill_Notification: Could not find notification entity!\n"); return; }
1746                                 
1747                                 if(notif.nent_cpid)
1748                                         killed_cpid = notif.nent_cpid;
1749                                 else
1750                                         killed_cpid = NO_CPID;
1751                         }
1752                         else
1753                         {
1754                                 killed_cpid = 0; // kill ALL centerprints
1755                         }
1756                         break;
1757                 }
1758
1759                 case MSG_CENTER_CPID:
1760                 {
1761                         killed_cpid = net_name;
1762                         break;
1763                 }
1764         }
1765
1766         if(killed_cpid != NO_CPID)
1767         {
1768                 net_notif = spawn();
1769                 net_notif.classname = "net_kill_notification";
1770                 net_notif.nent_broadcast = broadcast;
1771                 net_notif.nent_client = client;
1772                 net_notif.nent_net_type = MSG_CENTER_CPID;
1773                 net_notif.nent_net_name = killed_cpid;
1774                 Net_LinkEntity(net_notif, FALSE, autocvar_notification_lifetime_runtime, Net_Write_Notification);
1775         }
1776
1777         for(notif = world; (notif = find(notif, classname, "net_notification"));)
1778         {
1779                 if(net_type)
1780                 {
1781                         if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER))
1782                         {
1783                                 if(notif.owner.nent_cpid == killed_cpid)
1784                                 {
1785                                         notif.nent_net_name = -1;
1786                                         notif.nextthink = time;
1787                                 }
1788                                 else { continue; } // we ARE looking for a specific CPID, don't kill everything else too
1789                         }
1790                         else if(notif.nent_net_type == net_type)
1791                         {
1792                                 if(net_name)
1793                                 {
1794                                         if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; }
1795                                         else { continue; } // we ARE looking for a certain net_name, don't kill everything else too
1796                                 }
1797                                 else { notif.nent_net_name = -1; notif.nextthink = time; }
1798                         }
1799                         else { continue; } // we ARE looking for a certain net_type, don't kill everything else too
1800                 }
1801                 else { notif.nent_net_name = -1; notif.nextthink = time; }
1802         }
1803 }
1804
1805 void Send_Notification(
1806         float broadcast, entity client,
1807         float net_type, float net_name,
1808         ...count)
1809 {
1810         // check if this should be aborted
1811         if(net_name == NOTIF_ABORT)
1812         {
1813                 #ifdef NOTIFICATIONS_DEBUG
1814                 Debug_Notification(sprintf(
1815                         "Send_Notification(%s, '%s', %s, %s, ...);\n",
1816                         Get_Notif_BroadcastName(broadcast),
1817                         client.classname,
1818                         Get_Notif_TypeName(net_type),
1819                         "NOTIF_ABORT"
1820                 ));
1821                 #endif
1822                 return;
1823         }
1824         
1825         // check supplied broadcast, target, type, and name for errors
1826         string checkargs = Notification_CheckArgs(broadcast, client, net_type, net_name);
1827         if(checkargs != "")
1828         {
1829                 #ifdef NOTIFICATIONS_DEBUG
1830                 Debug_Notification(sprintf(
1831                         "Send_Notification(%s, '%s', %s, %s, ...);\n",
1832                         Get_Notif_BroadcastName(broadcast),
1833                         client.classname,
1834                         Get_Notif_TypeName(net_type),
1835                         Get_Notif_Ent(net_type, net_name).nent_name
1836                 ));
1837                 #endif
1838                 backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs));
1839                 return;
1840         }
1841
1842         // retreive entity of this notification
1843         entity notif = Get_Notif_Ent(net_type, net_name);
1844         if not(notif)
1845         {
1846                 #ifdef NOTIFICATIONS_DEBUG
1847                 Debug_Notification(sprintf(
1848                         "Send_Notification(%s, '%s', %s, %d, ...);\n",
1849                         Get_Notif_BroadcastName(broadcast),
1850                         client.classname,
1851                         Get_Notif_TypeName(net_type),
1852                         net_name
1853                 ));
1854                 #endif
1855                 backtrace("Send_Notification: Could not find notification entity!\n");
1856                 return;
1857         }
1858
1859         string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
1860         string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
1861         string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
1862         string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
1863         float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
1864         float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
1865         float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
1866         float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
1867
1868         #ifdef NOTIFICATIONS_DEBUG
1869         Debug_Notification(sprintf(
1870                 "Send_Notification(%s, %s, %s);\n",
1871                 sprintf(
1872                         "%s, '%s', %s, %s",
1873                         Get_Notif_BroadcastName(broadcast),
1874                         client.classname,
1875                         Get_Notif_TypeName(net_type),
1876                         notif.nent_name
1877                 ),
1878                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
1879                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
1880         ));
1881         #endif
1882
1883         if((notif.nent_stringcount + notif.nent_floatcount) > count)
1884         {
1885                 backtrace(sprintf(
1886                         strcat(
1887                                 "Not enough arguments for Send_Notification(%s, ...)! ",
1888                                 "stringcount(%d) + floatcount(%d) > count(%d)\n", 
1889                                 "Check the definition and function call for accuracy...?\n"
1890                         ),
1891                         sprintf(
1892                                 "%s, '%s', %s, %s",
1893                                 Get_Notif_BroadcastName(broadcast),
1894                                 client.classname,
1895                                 Get_Notif_TypeName(net_type),
1896                                 notif.nent_name
1897                         ),
1898                         notif.nent_stringcount,
1899                         notif.nent_floatcount,
1900                         count
1901                 ));
1902                 return;
1903         }
1904         else if((notif.nent_stringcount + notif.nent_floatcount) < count)
1905         {
1906                 backtrace(sprintf(
1907                         strcat(
1908                                 "Too many arguments for Send_Notification(%s, ...)! ",
1909                                 "stringcount(%d) + floatcount(%d) < count(%d)\n",
1910                                 "Check the definition and function call for accuracy...?\n"
1911                         ),
1912                         sprintf(
1913                                 "%s, '%s', %s, %s",
1914                                 Get_Notif_BroadcastName(broadcast),
1915                                 client.classname,
1916                                 Get_Notif_TypeName(net_type),
1917                                 notif.nent_name
1918                         ),
1919                         notif.nent_stringcount,
1920                         notif.nent_floatcount,
1921                         count
1922                 ));
1923                 return;
1924         }
1925
1926         if(
1927                 server_is_dedicated
1928                 &&
1929                 (
1930                         broadcast == NOTIF_ALL
1931                         ||
1932                         broadcast == NOTIF_ALL_EXCEPT
1933                 )
1934                 &&
1935                 !(
1936                         net_type == MSG_ANNCE
1937                         ||
1938                         net_type == MSG_CENTER
1939                 )
1940         )
1941         {
1942                 Local_Notification_WOVA(
1943                         net_type, net_name,
1944                         notif.nent_stringcount,
1945                         notif.nent_floatcount,
1946                         s1, s2, s3, s4,
1947                         f1, f2, f3, f4);
1948         }
1949
1950         if(net_type == MSG_CHOICE)
1951         {
1952                 // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast)
1953                 // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option...
1954                 // It's slow, but it's better than the alternatives:
1955                 //   1. Constantly networking all info and letting client decide
1956                 //   2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose)
1957                 entity found_choice; 
1958
1959                 #define RECURSE_FROM_CHOICE(ent,action) \
1960                         if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \
1961                         { \
1962                                 switch(ent.msg_choice_choices[net_name]) \
1963                                 { \
1964                                         case 1: found_choice = notif.nent_optiona; break; \
1965                                         case 2: found_choice = notif.nent_optionb; break; \
1966                                         default: action; \
1967                                 } \
1968                         } \
1969                         else { found_choice = notif.nent_optiona; } \
1970                         Send_Notification_WOVA( \
1971                                 NOTIF_ONE_ONLY, \
1972                                 ent, \
1973                                 found_choice.nent_type, \
1974                                 found_choice.nent_id, \
1975                                 found_choice.nent_stringcount, \
1976                                 found_choice.nent_floatcount, \
1977                                 s1, s2, s3, s4, \
1978                                 f1, f2, f3, f4);
1979
1980                 switch(broadcast)
1981                 {
1982                         case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method
1983                         {
1984                                 if(IS_REAL_CLIENT(client))
1985                                         { RECURSE_FROM_CHOICE(client, return) }
1986                                 break;
1987                         }
1988                         default:
1989                         {
1990                                 entity to;
1991                                 FOR_EACH_REALCLIENT(to)
1992                                         { if(Notification_ShouldSend(broadcast, to, client))
1993                                                 { RECURSE_FROM_CHOICE(to, continue) } }
1994                                 break;
1995                         }
1996                 }
1997         }
1998         else
1999         {
2000                 entity net_notif = spawn();
2001                 net_notif.owner = notif;
2002                 net_notif.classname = "net_notification";
2003                 net_notif.nent_broadcast = broadcast;
2004                 net_notif.nent_client = client;
2005                 net_notif.nent_net_type = net_type;
2006                 net_notif.nent_net_name = net_name;
2007                 net_notif.nent_stringcount = notif.nent_stringcount;
2008                 net_notif.nent_floatcount = notif.nent_floatcount;
2009                 
2010                 float i;
2011                 for(i = 0; i < net_notif.nent_stringcount; ++i)
2012                         { net_notif.nent_strings[i] = strzone(...(i, string)); }
2013                 for(i = 0; i < net_notif.nent_floatcount; ++i)
2014                         { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); }
2015
2016                 net_notif.think = Net_Notification_Remove;
2017                 net_notif.nextthink =
2018                         ((time > autocvar_notification_lifetime_mapload)
2019                         ?
2020                                 (time + autocvar_notification_lifetime_runtime)
2021                                 :
2022                                 autocvar_notification_lifetime_mapload
2023                         ); 
2024
2025                 Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification);
2026         }
2027 }
2028
2029 // WOVA = Without Variable Arguments 
2030 void Send_Notification_WOVA(
2031         float broadcast, entity client,
2032         float net_type, float net_name,
2033         float stringcount, float floatcount,
2034         string s1, string s2, string s3, string s4,
2035         float f1, float f2, float f3, float f4)
2036 {
2037         #ifdef NOTIFICATIONS_DEBUG
2038         entity notif = Get_Notif_Ent(net_type, net_name);
2039         Debug_Notification(sprintf(
2040                 "Send_Notification_WOVA(%s, %d, %d, %s, %s);\n",
2041                 sprintf(
2042                         "%s, '%s', %s, %s",
2043                         Get_Notif_BroadcastName(broadcast),
2044                         client.classname,
2045                         Get_Notif_TypeName(net_type),
2046                         notif.nent_name
2047                 ),
2048                 stringcount,
2049                 floatcount,
2050                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
2051                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
2052         ));
2053         #endif
2054         
2055         #define VARITEM(stringc,floatc,args) \
2056                 if((stringcount == stringc) && (floatcount == floatc)) \
2057                         { Send_Notification(broadcast, client, net_type, net_name, args); return; }
2058         EIGHT_VARS_TO_VARARGS_VARLIST
2059         #undef VARITEM
2060         Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
2061 }
2062
2063 // WOCOVA = Without Counts Or Variable Arguments 
2064 void Send_Notification_WOCOVA(
2065         float broadcast, entity client,
2066         float net_type, float net_name,
2067         string s1, string s2, string s3, string s4,
2068         float f1, float f2, float f3, float f4)
2069 {
2070         entity notif = Get_Notif_Ent(net_type, net_name);
2071         
2072         #ifdef NOTIFICATIONS_DEBUG
2073         Debug_Notification(sprintf(
2074                 "Send_Notification_WOCOVA(%s, %s, %s);\n",
2075                 sprintf(
2076                         "%s, '%s', %s, %s",
2077                         Get_Notif_BroadcastName(broadcast),
2078                         client.classname,
2079                         Get_Notif_TypeName(net_type),
2080                         notif.nent_name
2081                 ),
2082                 MakeConsoleSafe(sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4)),
2083                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
2084         ));
2085         #endif
2086         
2087         #define VARITEM(stringc,floatc,args) \
2088                 if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
2089                         { Send_Notification(broadcast, client, net_type, net_name, args); return; }
2090         EIGHT_VARS_TO_VARARGS_VARLIST
2091         #undef VARITEM
2092         Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
2093 }
2094 #endif // ifdef SVQC