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