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