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