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