]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/notifications.qc
Implement a way to send notifications to chatbox in notification system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qc
1 // ================================================
2 //  Unified notification system, written by Samual
3 //  Last updated: February, 2013
4 // ================================================
5
6 entity Get_Notif_Ent(float net_type, float net_name)
7 {
8         switch(net_type)
9         {
10                 case MSG_INFO: return msg_info_notifs[net_name - 1];
11                 case MSG_CENTER: return msg_center_notifs[net_name - 1];
12                 case MSG_WEAPON: return msg_weapon_notifs[net_name - 1];
13                 case MSG_DEATH: return msg_death_notifs[net_name - 1];
14         }
15         backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name));
16         return world;
17 }
18
19
20 // ===============================
21 //  Frontend Notification Pushing
22 // ===============================
23
24 void Dump_Notifications(float fh, float alsoprint)
25 {
26         #define NOTIF_WRITE(a) { \
27                 fputs(fh, a); \
28                 if(alsoprint) { print(a); } }
29         #define NOTIF_WRITE_SETA(name,default,text) { \
30                 notif_msg = \
31                         sprintf( \
32                                 "seta notification_%s %d \"notif string: %s^7\"\n", \
33                                 name, default, strreplace("\{3}", "", strreplace("\n", "\\n", text)) \
34                         ); \
35                 NOTIF_WRITE(notif_msg) }
36
37         string notif_msg;
38         float i;
39         entity e;
40
41         // Note: This warning only applies to the notifications.cfg file that is output...
42
43         // You ARE supposed to manually edit this function to add i.e. hard coded
44         // notification variables for mutators or game modes or such and then
45         // regenerate the notifications.cfg file from the new code.
46
47         NOTIF_WRITE("// ********************************************** //\n");
48         NOTIF_WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n");
49         NOTIF_WRITE("// **                                          ** //\n");
50         NOTIF_WRITE("// **  This file is automatically generated    ** //\n");
51         NOTIF_WRITE("// **  by code with the command 'dumpnotifs'.  ** //\n");
52         NOTIF_WRITE("// **                                          ** //\n");
53         NOTIF_WRITE("// **  If you add a new notification, please   ** //\n");
54         NOTIF_WRITE("// **  regenerate this file with that command  ** //\n");
55         NOTIF_WRITE("// **  making sure that the output matches     ** //\n");
56         NOTIF_WRITE("// **  with the lists and defaults in code.    ** //\n");
57         NOTIF_WRITE("// **                                          ** //\n");
58         NOTIF_WRITE("// ********************************************** //\n");
59
60         NOTIF_WRITE("\n// Version number to identify mismatches between code and config file...\n");
61         NOTIF_WRITE("// Increment NOTIF_VERSION in common/notifications.qh with any\n");
62         NOTIF_WRITE("// new notifications or other changes to notif cvars/this config.\n");
63         
64         NOTIF_WRITE(sprintf("set notification_version %d\n", NOTIF_VERSION));
65
66         // These notifications will also append their string as a comment...
67         // This is not necessary, and does not matter if they vary between config versions,
68         // it is just a semi-helpful tool for those who want to manually change their user settings.
69
70         NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
71         for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
72         {
73                 e = Get_Notif_Ent(MSG_INFO, i);
74                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
75                 NOTIF_WRITE_SETA(e.nent_name, e.nent_default, e.nent_string);
76         }
77
78         NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
79         for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
80         {
81                 e = Get_Notif_Ent(MSG_CENTER, i);
82                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
83                 NOTIF_WRITE_SETA(e.nent_name, e.nent_default, e.nent_string);
84         }
85
86         NOTIF_WRITE(sprintf("\n// MSG_WEAPON notifications (count = %d):\n", NOTIF_WEAPON_COUNT));
87         for(i = 1; i <= NOTIF_WEAPON_COUNT; ++i)
88         {
89                 e = Get_Notif_Ent(MSG_WEAPON, i);
90                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
91                 NOTIF_WRITE_SETA(e.nent_name, e.nent_default, sprintf("infoname: %s, centername: %s",
92                         e.nent_msginfo.nent_name, e.nent_msgcenter.nent_name));
93         }
94
95         NOTIF_WRITE(sprintf("\n// MSG_DEATH notifications (count = %d):\n", NOTIF_DEATH_COUNT));
96         for(i = 1; i <= NOTIF_DEATH_COUNT; ++i)
97         {
98                 e = Get_Notif_Ent(MSG_DEATH, i);
99                 if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
100                 NOTIF_WRITE_SETA(e.nent_name, e.nent_default, sprintf("infoname: %s, centername: %s",
101                         e.nent_msginfo.nent_name, e.nent_msgcenter.nent_name));
102         }
103
104         // edit these to match whichever cvars are used for specific notification options
105         NOTIF_WRITE("\n// HARD CODED notification variables:\n");
106         NOTIF_WRITE("seta notification_allow_chatboxprint 1 \"Allow notifications to be printed to chat box by setting notification cvar to 2 (You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)\"\n");
107         NOTIF_WRITE("seta notification_show_sprees 1 \"Print information about sprees in death/kill messages\"\n");
108         NOTIF_WRITE("seta notification_version_mismatch_client_error 0 \"Cause a notif error on client if the version in notifications.cfg mismatches the code\"\n");
109         NOTIF_WRITE("seta notification_version_mismatch_server_error 1 \"Cause a notif error on server if the version in notifications.cfg mismatches the code\"\n");
110         NOTIF_WRITE("seta notification_errors_are_fatal 1 \"If a notification fails upon initialization, cause a Host_Error to stop the program\"\n");
111         NOTIF_WRITE("seta notification_ctf_pickup_team_verbose 1 \"Show extra information if a team mate picks up a flag\"\n");
112         NOTIF_WRITE("seta notification_ctf_pickup_enemy_verbose 1 \"Show extra information if an enemy picks up a flag\"\n");
113         NOTIF_WRITE("seta notification_ctf_capture_verbose 1 \"Show extra information when someone captures a flag\"\n");
114         NOTIF_WRITE("seta notification_frag_verbose 1 \"Show extra information when you frag someone (or when you are fragged\"\n");
115
116         NOTIF_WRITE(sprintf("\n// Notification counts (total = %d): MSG_INFO = %d, MSG_CENTER = %d, MSG_WEAPON = %d, MSG_DEATH = %d\n",
117                 (NOTIF_INFO_COUNT + NOTIF_CENTER_COUNT + NOTIF_WEAPON_COUNT + NOTIF_DEATH_COUNT), 
118                 NOTIF_INFO_COUNT, NOTIF_CENTER_COUNT, NOTIF_WEAPON_COUNT, NOTIF_DEATH_COUNT));
119         
120         return;
121         #undef NOTIF_WRITE_SETA
122         #undef NOTIF_WRITE
123 }
124
125 #ifdef SVQC
126 void Notification_GetCvars()
127 {
128         GetCvars_handleFloat(get_cvars_s, get_cvars_f, FRAG_VERBOSE, "notification_frag_verbose");
129 }
130 #endif
131
132 string Local_Notification_sprintf(string input, string args, 
133         string s1, string s2, string s3, string s4,
134         float f1, float f2, float f3, float f4)
135 {
136         #ifdef NOTIFICATIONS_DEBUG
137         dprint(
138                 sprintf("Local_Notification_sprintf('%s^7', '%s', %s, %s);\n",
139                         strreplace("\n", "\\n", input),
140                         args,
141                         sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4),
142                         sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
143                 )
144         );
145         #endif
146         
147         string selected;
148         float sel_num;
149         for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; }
150
151         #ifdef CSQC
152         string tmp_s;
153         #endif
154
155         for(sel_num = 0;(args != "");)
156         {
157                 selected = car(args); args = cdr(args);
158                 NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
159                 switch(strtolower(selected))
160                 {
161                         #define ARG_CASE(prog,selected,result) \
162                                 #ifdef CSQC \
163                                         #if (prog == ARG_DOUBLE) || (prog == ARG_TRIPLE) || (prog == ARG_CSQC) \
164                                                 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
165                                         #endif \
166                                 #else \
167                                         #if (prog == ARG_DOUBLE) || (prog == ARG_TRIPLE) || (prog == ARG_SVQC) \
168                                                 case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
169                                         #endif \
170                                 #endif
171                         NOTIF_ARGUMENT_LIST
172                         #undef ARG_CASE
173                         NOTIF_HIT_UNKNOWN(NOTIF_MAX_ARGS, "Local_Notification_sprintf")
174                 }
175         }
176         return sprintf(input, arg_slot[0], arg_slot[1], arg_slot[2], arg_slot[3], arg_slot[4], arg_slot[5], arg_slot[6]);
177 }
178
179 #ifdef CSQC
180 void Local_Notification_HUD_Notify_Push(string icon, string hudargs, string s1, string s2, string s3, string s4)
181 {
182         string selected;
183         float sel_num;
184         arg_slot[0] = ""; arg_slot[1] = "";
185
186         for(sel_num = 0;(hudargs != "");)
187         {
188                 selected = car(hudargs); hudargs = cdr(hudargs);
189                 NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
190                 switch(strtolower(selected))
191                 {
192                         #define ARG_CASE(prog,selected,result) \
193                                 #if (prog == ARG_TRIPLE) \
194                                         case selected: { arg_slot[sel_num] = result; ++sel_num; break; } \
195                                 #endif
196                         NOTIF_ARGUMENT_LIST
197                         #undef ARG_CASE
198                         NOTIF_HIT_UNKNOWN(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push")
199                 }
200         }
201         HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
202 }
203 #endif
204
205 void Local_Notification(float net_type, float net_name, ...count)
206 {
207         // check supplied type and name for errors
208         string checkargs = "";
209         #define CHECKARG_TYPENAME(type) case MSG_##type##: \
210                 { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
211                 { checkargs = sprintf("Improper name: %d!", net_name); } break; }
212         switch(net_type)
213         {
214                 CHECKARG_TYPENAME(INFO)
215                 CHECKARG_TYPENAME(CENTER)
216                 CHECKARG_TYPENAME(WEAPON)
217                 CHECKARG_TYPENAME(DEATH)
218                 default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; }
219         }
220         #undef CHECKARG_TYPENAME
221         if(checkargs != "") { backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs)); return; }
222
223         entity notif = Get_Notif_Ent(net_type, net_name);
224         if not(notif) { backtrace("Local_Notification: Could not find notification entity!\n"); return; }
225         if not(notif.nent_enabled) { print("Local_Notification: Entity was disabled...\n"); return; }
226
227         if((notif.nent_stringcount + notif.nent_floatcount) > count)
228         {
229                 backtrace(sprintf(
230                         strcat(
231                                 "Not enough arguments for Local_Notification! ",
232                                 "stringcount(%d) + floatcount(%d) > count(%d)\n", 
233                                 "Check the definition and function call for accuracy...?\n"
234                         ),
235                         notif.nent_stringcount, notif.nent_floatcount, count));
236                 return;
237         }
238         else if((notif.nent_stringcount + notif.nent_floatcount) < count)
239         {
240                 backtrace(sprintf(
241                         strcat(
242                                 "Too many arguments for Local_Notification! ",
243                                 "stringcount(%d) + floatcount(%d) < count(%d)\n",
244                                 "Check the definition and function call for accuracy...?\n"
245                         ),
246                         notif.nent_stringcount, notif.nent_floatcount, count));
247                 return;
248         }
249
250         string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : "");
251         string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : "");
252         string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : "");
253         string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : "");
254         float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0);
255         float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0);
256         float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0);
257         float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0);
258
259         #ifdef NOTIFICATIONS_DEBUG
260         dprint(
261                 sprintf("Local_Notification(%d, %s, %s, %s);\n",
262                         net_type,
263                         notif.nent_name,
264                         sprintf("'%s^7', '%s^7', '%s^7', '%s^7'", s1, s2, s3, s4),
265                         sprintf("%d, %d, %d, %d", f1, f2, f3, f4)
266                 )
267         );
268         #endif
269         
270         switch(net_type)
271         {
272                 case MSG_INFO:
273                 {
274                         print(
275                                 Local_Notification_sprintf(
276                                         notif.nent_string,
277                                         notif.nent_args, 
278                                         s1, s2, s3, s4,
279                                         f1, f2, f3, f4)
280                         );
281                         #ifdef CSQC 
282                         if(notif.nent_icon != "")
283                         {
284                                 Local_Notification_HUD_Notify_Push(
285                                         notif.nent_icon,
286                                         notif.nent_hudargs,
287                                         s1, s2, s3, s4);
288                         } 
289                         #endif 
290                         break;
291                 }
292                 
293                 #ifdef CSQC
294                 case MSG_CENTER:
295                 {
296                         centerprint_generic(
297                                 notif.nent_cpid,
298                                 Local_Notification_sprintf(
299                                         notif.nent_string,
300                                         notif.nent_args, 
301                                         s1, s2, s3, s4,
302                                         f1, f2, f3, f4),
303                                 0, 0);
304                         break;
305                 }
306                 #endif
307                 
308                 case MSG_WEAPON:
309                 case MSG_DEATH:
310                 {
311                         if(notif.nent_msginfo)
312                         if(notif.nent_msginfo.nent_enabled)
313                         {
314                                 Local_Notification_WOVA(
315                                         MSG_INFO,
316                                         notif.nent_msginfo.nent_id, 
317                                         notif.nent_msginfo.nent_stringcount, 
318                                         notif.nent_msginfo.nent_floatcount, 
319                                         s1, s2, s3, s4,
320                                         f1, f2, f3, f4);
321                         }
322                         #ifdef CSQC
323                         if(notif.nent_msgcenter)
324                         if(notif.nent_msgcenter.nent_enabled)
325                         {
326                                 Local_Notification_WOVA(
327                                         MSG_CENTER,
328                                         notif.nent_msgcenter.nent_id, 
329                                         notif.nent_msgcenter.nent_stringcount, 
330                                         notif.nent_msgcenter.nent_floatcount, 
331                                         s1, s2, s3, s4,
332                                         f1, f2, f3, f4); 
333                         }
334                         #endif
335                         break;
336                 }
337         }
338 }
339
340 // WOVA = Without Variable Arguments 
341 void Local_Notification_WOVA(float net_type, float net_name,
342         float stringcount, float floatcount,
343         string s1, string s2, string s3, string s4,
344         float f1, float f2, float f3, float f4)
345 {
346         #define VARITEM(stringc,floatc,args) \
347                 if((stringcount == stringc) && (floatcount == floatc)) \
348                         { Local_Notification(net_type, net_name, args); return; }
349         EIGHT_VARS_TO_VARARGS_VARLIST
350         #undef VARITEM
351         Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
352 }
353
354
355 // =========================
356 //  Notification Networking
357 // =========================
358
359 #ifdef CSQC
360 void Read_Notification(float is_new)
361 {
362         float net_type = ReadByte();
363         float net_name = ReadShort();
364
365         entity notif = Get_Notif_Ent(net_type, net_name);
366         if not(notif) { print("Read_Notification: Could not find notification entity!\n"); return; }
367
368         string s1 = ((0 < notif.nent_stringcount) ? ReadString() : "");
369         string s2 = ((1 < notif.nent_stringcount) ? ReadString() : "");
370         string s3 = ((2 < notif.nent_stringcount) ? ReadString() : "");
371         string s4 = ((3 < notif.nent_stringcount) ? ReadString() : "");
372         float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0);
373         float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0);
374         float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0);
375         float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0);
376
377         #ifdef NOTIFICATIONS_DEBUG
378         dprint(sprintf("Read_Notification(%d) at %f: net_name = %s.\n", is_new, time, notif.nent_name));
379         #endif
380         
381         if(is_new)
382         {
383                 Local_Notification_WOVA(
384                         net_type, net_name,
385                         notif.nent_stringcount,
386                         notif.nent_floatcount,
387                         s1, s2, s3, s4,
388                         f1, f2, f3, f4);
389         }
390 }
391 #endif
392
393 #ifdef SVQC
394 void Net_Notification_Remove()
395 {
396         float i;
397         for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
398         remove(self);
399 }
400
401 float Net_Write_Notification(entity client, float sf)
402 {
403         float i, send = FALSE;
404         
405         switch(self.nent_broadcast)
406         {
407                 case NOTIF_ONE: // send to one client and their spectator
408                 {
409                         if(
410                                 (client == self.nent_client)
411                                 ||
412                                 (
413                                         (client.classname == STR_SPECTATOR)
414                                         &&
415                                         (client.enemy == self.nent_client)
416                                 )
417                         ) { send = TRUE; }
418                         break;
419                 }
420                 case NOTIF_ONE_ONLY: // send ONLY to one client
421                 {
422                         if(client == self.nent_client) { send = TRUE; }
423                         break;
424                 }
425                 case NOTIF_TEAM: // send only to X team and their spectators
426                 {
427                         if(
428                                 (client.team == self.nent_client.team)
429                                 ||
430                                 (
431                                         (client.classname == STR_SPECTATOR)
432                                         &&
433                                         (client.enemy.team == self.nent_client.team)
434                                 )
435                         ) { send = TRUE; }
436                         break;
437                 }
438                 case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators
439                 {
440                         if(
441                                 (client != self.nent_client)
442                                 &&
443                                 (
444                                         (client.team == self.nent_client.team)
445                                         ||
446                                         (
447                                                 (client.classname == STR_SPECTATOR)
448                                                 &&
449                                                 (
450                                                         (client.enemy != self.nent_client)
451                                                         &&
452                                                         (client.enemy.team == self.nent_client.team)
453                                                 )
454                                         )
455                                 )
456                         ) { send = TRUE; }
457                         break;
458                 }
459                 case NOTIF_ANY: // send to everyone
460                 {
461                         send = TRUE;
462                         break;
463                 }
464                 case NOTIF_ANY_EXCEPT: // send to everyone except X person and their spectators
465                 {
466                         if(
467                                 (client != self.nent_client)
468                                 &&
469                                 !(
470                                         (client.classname == STR_SPECTATOR)
471                                         &&
472                                         (client.enemy == self.nent_client)
473                                 )
474                         ) { send = TRUE; }
475                         break;
476                 }
477                 default: { send = FALSE; break; }
478         }
479
480         if(send)
481         {               
482                 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
483                 WriteByte(MSG_ENTITY, self.nent_net_type);
484                 WriteShort(MSG_ENTITY, self.nent_net_name);
485                 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } 
486                 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
487         }
488
489         return send; 
490 }
491
492 void Send_Notification(float broadcast, entity client,
493         float net_type, float net_name, ...count)
494 {
495         // check supplied broadcast, target, type, and name for errors
496         string checkargs = "";
497         #define CHECKARG_TYPENAME(type) case MSG_##type##: \
498                 { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
499                 { checkargs = sprintf("Improper name: %d!", net_name); } break; }
500         switch(net_type)
501         {
502                 CHECKARG_TYPENAME(INFO)
503                 CHECKARG_TYPENAME(CENTER)
504                 CHECKARG_TYPENAME(WEAPON)
505                 CHECKARG_TYPENAME(DEATH)
506                 default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; }
507         }
508         #undef CHECKARG_TYPENAME
509         if(checkargs != "") { checkargs = strcat(checkargs, " "); }
510         switch(broadcast)
511         {
512                 case NOTIF_ONE:
513                 case NOTIF_ONE_ONLY:
514                 {
515                         if(IS_NOT_A_CLIENT(client))
516                                 { checkargs = sprintf("%sNo client provided!", checkargs); }
517                         break;
518                 }
519                 
520                 case NOTIF_ANY_EXCEPT:
521                 {
522                         if(IS_NOT_A_CLIENT(client))
523                                 { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
524                         break;
525                 }
526                 
527                 case NOTIF_ANY:
528                 {
529                         if(client)
530                                 { checkargs = sprintf("%sEntity provided when world was required!", checkargs); }
531                         break;
532                 }
533                 
534                 case NOTIF_TEAM:
535                 case NOTIF_TEAM_EXCEPT:
536                 {
537                         if not(teamplay) { checkargs = sprintf("%sTeamplay not active!", checkargs); }
538                         else if(IS_NOT_A_CLIENT(client))
539                         {
540                                 if(broadcast == NOTIF_TEAM) { checkargs = sprintf("%sNo client provided!", checkargs); }
541                                 else { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
542                         }
543                         break;
544                 }
545                 
546                 default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
547         }
548         if(checkargs != "") { backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs)); return; }
549
550         // retreive counts for the arguments of this notification
551         entity notif = Get_Notif_Ent(net_type, net_name);
552         if not(notif) { backtrace("Send_Notification: Could not find notification entity!\n"); return; }
553
554         if((notif.nent_stringcount + notif.nent_floatcount) > count)
555         {
556                 backtrace(sprintf(
557                         strcat(
558                                 "Not enough arguments for Send_Notification! ",
559                                 "stringcount(%d) + floatcount(%d) > count(%d)\n", 
560                                 "Check the definition and function call for accuracy...?\n"
561                         ),
562                         notif.nent_stringcount, notif.nent_floatcount, count));
563                 return;
564         }
565         else if((notif.nent_stringcount + notif.nent_floatcount) < count)
566         {
567                 backtrace(sprintf(
568                         strcat(
569                                 "Too many arguments for Send_Notification! ",
570                                 "stringcount(%d) + floatcount(%d) < count(%d)\n",
571                                 "Check the definition and function call for accuracy...?\n"
572                         ),
573                         notif.nent_stringcount, notif.nent_floatcount, count));
574                 return;
575         }
576         
577         #ifdef NOTIFICATIONS_DEBUG
578         dprint(
579                 sprintf("Send_Notification(%d, %d, %s, stringcount: %d, floatcount: %d, varargs: %d);\n",
580                         broadcast,
581                         net_type,
582                         notif.nent_name,
583                         notif.nent_stringcount,
584                         notif.nent_floatcount,
585                         count
586                 )
587         );
588         #endif
589
590         entity net_notif = spawn();
591         net_notif.nent_broadcast = broadcast;
592         net_notif.nent_client = client;
593         net_notif.nent_net_type = net_type;
594         net_notif.nent_net_name = net_name;
595         net_notif.nent_stringcount = notif.nent_stringcount;
596         net_notif.nent_floatcount = notif.nent_floatcount;
597         
598         float i;
599         for(i = 0; i < net_notif.nent_stringcount; ++i) { net_notif.nent_strings[i] = strzone(...(i, string)); }
600         for(i = 0; i < net_notif.nent_floatcount; ++i) { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); }
601         
602         net_notif.think = Net_Notification_Remove;
603         net_notif.nextthink = (time + 0.5); 
604
605         Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification);
606
607         if((!server_is_local) && (broadcast == NOTIF_ANY || broadcast == NOTIF_ANY_EXCEPT) && (net_type != MSG_CENTER))
608         {
609                 Local_Notification_WOVA(
610                         net_type, net_name,
611                         notif.nent_stringcount,
612                         notif.nent_floatcount,
613                         IFSTR(0), IFSTR(1), IFSTR(2), IFSTR(3),
614                         IFFL(0), IFFL(1), IFFL(2), IFFL(3));
615         }
616 }
617
618 // WOVA = Without Variable Arguments 
619 void Send_Notification_WOVA(float broadcast, entity client,
620         float net_type, float net_name,
621         string s1, string s2, string s3, string s4,
622         float f1, float f2, float f3, float f4)
623 {
624         entity notif = Get_Notif_Ent(net_type, net_name);
625         #define VARITEM(stringc,floatc,args) \
626                 if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \
627                         { Send_Notification(broadcast, client, net_type, net_name, args); return; }
628         EIGHT_VARS_TO_VARARGS_VARLIST
629         #undef VARITEM
630         Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
631 }
632
633
634 // =============================
635 //  LEGACY NOTIFICATION SYSTEMS
636 // =============================
637
638 void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num)
639 {
640         if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT))
641         {
642                 msg_entity = e;
643                 WRITESPECTATABLE_MSG_ONE({
644                         WriteByte(MSG_ONE, SVC_TEMPENTITY);
645                         WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC);
646                         WriteByte(MSG_ONE, id);
647                         WriteString(MSG_ONE, s);
648                         if (id != 0 && s != "")
649                         {
650                                 WriteByte(MSG_ONE, duration);
651                                 WriteByte(MSG_ONE, countdown_num);
652                         }
653                 });
654         }
655 }
656 #endif // ifdef SVQC