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