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