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