]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/notifications.qc
Cleanup Fill_Notif_Args a bit (and other stuff too)
[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 #ifndef MENUQC
7 string arg_slot[7];
8 entity Get_Notif_Ent(float net_type, float net_name)
9 {
10         switch(net_type)
11         {
12                 case MSG_INFO: return msg_info_notifs[net_name - 1];
13                 case MSG_CENTER: return msg_center_notifs[net_name - 1];
14                 case MSG_WEAPON: return msg_weapon_notifs[net_name - 1];
15                 case MSG_DEATH: return msg_death_notifs[net_name - 1];
16         }
17         backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name));
18         return world;
19 }
20
21 string Get_Notif_Name(float net_type, float net_name)
22 {
23         entity e = Get_Notif_Ent(net_type, net_name);
24         if(e) { return e.nent_name; }
25         backtrace(sprintf("Get_Notif_Name(%d, %d): Could not find entity!\n", net_type, net_name));
26         return "";
27 }
28
29 float Get_Notif_Infval(float net_type, float net_name)
30 {
31         entity e = Get_Notif_Ent(net_type, net_name);
32         if(e) { return e.nent_infoname; }
33         backtrace(sprintf("Get_Notif_Infval(%d, %d): Could not find entity!\n", net_type, net_name));
34         return NO_MSG;
35 }
36
37 float Get_Notif_Cenval(float net_type, float net_name)
38 {
39         entity e = Get_Notif_Ent(net_type, net_name);
40         if(e) { return e.nent_centername; }
41         backtrace(sprintf("Get_Notif_Cenval(%d, %d): Could not find entity!\n", net_type, net_name));
42         return NO_MSG;
43 }
44
45 float Get_Notif_Strnum(float net_type, float net_name)
46 {
47         entity e = Get_Notif_Ent(net_type, net_name);
48         if(e) { return e.nent_stringcount; }
49         backtrace(sprintf("Get_Notif_Strnum(%d, %d): Could not find entity!\n", net_type, net_name));
50         return NO_MSG;
51 }
52
53 float Get_Notif_Flnum(float net_type, float net_name)
54 {
55         entity e = Get_Notif_Ent(net_type, net_name);
56         if(e) { return e.nent_floatcount; }
57         backtrace(sprintf("Get_Notif_Flnum(%d, %d): Could not find entity!\n", net_type, net_name));
58         return NO_MSG;
59 }
60 #endif // ifndef MENUQC
61
62
63 // ===============================
64 //  Frontend Notification Pushing
65 // ===============================
66
67 void Dump_Notifications(float fh, float alsoprint)
68 {
69         float MSG_INFO_NOTIFS = 0, MSG_CENTER_NOTIFS = 0, MSG_WEAPON_NOTIFS = 0, MSG_DEATH_NOTIFS = 0;
70
71         #define NOTIF_WRITE(type,name,text) { \
72                 ++##type##_NOTIFS; \
73                 notif_msg = sprintf("seta %s 1 // %s - %s\n", name, #type, strreplace("\n", "\\n", text)); \
74                 fputs(fh, notif_msg); \
75                 if(alsoprint) { print(strreplace("^", "^^", notif_msg)); } }
76
77         #ifndef MENUQC
78         string notif_msg;
79         float i;
80         entity e;
81
82         for(i = 0; i < NOTIF_INFO_COUNT; ++i) {
83                 e = Get_Notif_Ent(MSG_INFO, i);
84                 NOTIF_WRITE(MSG_INFO, e.nent_name, e.nent_string); }
85                 
86         for(i = 0; i < NOTIF_CENTER_COUNT; ++i) {
87                 e = Get_Notif_Ent(MSG_CENTER, i);
88                 NOTIF_WRITE(MSG_CENTER, e.nent_name, e.nent_string); }
89         
90         for(i = 0; i < NOTIF_WEAPON_COUNT; ++i) {
91                 e = Get_Notif_Ent(MSG_WEAPON, i);
92                 NOTIF_WRITE(MSG_WEAPON, e.nent_name, sprintf("infoname: %s, centername: %s",
93                         Get_Notif_Name(MSG_INFO, Get_Notif_Infval(MSG_WEAPON, i)),
94                         Get_Notif_Name(MSG_CENTER, Get_Notif_Cenval(MSG_WEAPON, i)) ) ); }
95                 
96         for(i = 0; i < NOTIF_DEATH_COUNT; ++i) {
97                 e = Get_Notif_Ent(MSG_DEATH, i);
98                 NOTIF_WRITE(MSG_DEATH, e.nent_name, sprintf("infoname: %s, centername: %s",
99                         Get_Notif_Name(MSG_INFO, Get_Notif_Infval(MSG_DEATH, i)),
100                         Get_Notif_Name(MSG_CENTER, Get_Notif_Cenval(MSG_DEATH, i)) ) ); }
101                 
102         #endif
103
104         print(sprintf("Notification counts: MSG_INFO = %d, MSG_CENTER = %d, MSG_WEAPON = %d, MSG_DEATH = %d\n",
105                 MSG_INFO_NOTIFS, MSG_CENTER_NOTIFS, MSG_WEAPON_NOTIFS, MSG_DEATH_NOTIFS));
106         
107         return;
108         #undef NOTIF_WRITE
109 }
110
111 #ifndef MENUQC
112 #ifdef CSQC
113 void HUD_Notify_Push(string icon, string attacker, string victim)
114 {
115         if(icon != "")
116         {
117                 --kn_index;
118                 if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; }
119                 killnotify_times[kn_index] = time;
120
121                 // icon
122                 if(killnotify_icon[kn_index]) { strunzone(killnotify_icon[kn_index]); }
123                 killnotify_icon[kn_index] = strzone(icon);
124
125                 // attacker
126                 if(killnotify_attackers[kn_index]) { strunzone(killnotify_attackers[kn_index]); }
127                 killnotify_attackers[kn_index] = strzone(attacker);
128
129                 // victim
130                 if(killnotify_victims[kn_index]) { strunzone(killnotify_victims[kn_index]); }
131                 killnotify_victims[kn_index] = strzone(victim);
132         }
133 }
134 #endif // ifdef CSQC
135
136
137 string Local_Notification_sprintf(string input, string args, 
138         string s1, string s2, string s3, string s4,
139         float f1, float f2, float f3, float f4)
140 {
141         #ifdef NOTIFICATIONS_DEBUG
142         dprint(
143                 sprintf("Local_Notification_sprintf('%s', '%s', %s, %s);\n",
144                 input, args,
145                 sprintf("%s, %s, %s, %s", s1, s2, s3, s4),
146                 sprintf("%d, %d, %d, %d", f1, f2, f3, f4)));
147         #endif
148         
149         string selected, remaining = args;
150         float sel_num = 0;
151
152         #ifdef CSQC
153         string tmp_s;
154         #endif
155         
156         if((remaining != "") && (input != ""))
157         {
158                 for(;remaining;)
159                 {
160                         selected = car(remaining); remaining = cdr(remaining);
161
162                         switch(strtolower(selected))
163                         {
164                                 #define ADD_ARG_CASE(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; }
165                                 
166                                 ADD_ARG_CASE("s1", s1)
167                                 ADD_ARG_CASE("s2", s2)
168                                 ADD_ARG_CASE("s3", s3)
169                                 ADD_ARG_CASE("s4", s4)
170                                 ADD_ARG_CASE("f1", ftos(f1))
171                                 ADD_ARG_CASE("f2", ftos(f2))
172                                 ADD_ARG_CASE("f3", ftos(f3))
173                                 ADD_ARG_CASE("f4", ftos(f4))
174
175                                 #ifdef CSQC // CSQC replacements
176                                 ADD_ARG_CASE("pass_key",                ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : ""))
177                                 ADD_ARG_CASE("frag_ping",               ((f2 != BOT_PING) ? sprintf(CCR(_("\n(Ping ^2%d^BG)")), f2) : ""))
178                                 ADD_ARG_CASE("frag_stats",              sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), f1, f2, ((f3 != BOT_PING) ? sprintf(CCR(_(" (Ping ^2%d^BG)")), f3) : "")))
179                                 //ADD_ARG_CASE("frag_pos",              ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))
180                                 ADD_ARG_CASE("spree_cen",               (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
181                                 ADD_ARG_CASE("spree_inf",               (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
182                                 ADD_ARG_CASE("spree_end",               ((f1 >= 3) ? sprintf(normal_or_gentle(_(", ending their %d frag spree"), _(", ending their %d score spree")), f1) : ""))
183                                 ADD_ARG_CASE("spree_lost",              ((f1 >= 3) ? sprintf(normal_or_gentle(_(", losing their %d frag spree"), _(", losing their %d score spree")), f1) : ""))
184                                 ADD_ARG_CASE("death_team",              Team_ColoredFullName(f1 - 1))
185                                 ADD_ARG_CASE("weapon_name",     ftos(f1)) // weaponorder[f1].netname
186
187                                 #else // SVQC replacements
188                                 ADD_ARG_CASE("spree_inf",               (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
189                                 ADD_ARG_CASE("spree_end",               ((f1 >= 3) ? sprintf(normal_or_gentle(_(", ending their %d frag spree"), _(", ending their %d score spree")), f1) : ""))
190                                 ADD_ARG_CASE("spree_lost",              ((f1 >= 3) ? sprintf(normal_or_gentle(_(", losing their %d frag spree"), _(", losing their %d score spree")), f1) : ""))
191                                 ADD_ARG_CASE("death_team",              Team_ColoredFullName(f1))
192                                 ADD_ARG_CASE("weapon_name",             ftos(f1)) // weaponorder[f1].netname
193                                 #endif
194
195                                 #undef ADD_ARG_CASE
196                                 default: { backtrace(sprintf("Hit unknown token in selected string! '%s'\n", selected)); break; }
197                         }
198                         if(sel_num == 6) { backtrace("Hit maximum arguments!\n"); break; }
199                 }
200
201                 return sprintf(input, arg_slot[0], arg_slot[1], arg_slot[2], arg_slot[3], arg_slot[4], arg_slot[5], arg_slot[6]);
202         }
203
204         return "";
205 }
206
207 void Local_Notification(float net_type, float net_name, ...count)
208 {
209         // check supplied type and name for errors
210         #ifdef NOTIFICATIONS_DEBUG
211         {
212                 #define CHECKARG_TYPENAME(type) case MSG_##type##: \
213                         { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
214                         { checkargs = sprintf("Improper name: %d!", net_name); } break; }
215                         
216                 string checkargs = "";
217                 switch(net_type)
218                 {
219                         CHECKARG_TYPENAME(INFO)
220                         CHECKARG_TYPENAME(CENTER)
221                         CHECKARG_TYPENAME(WEAPON)
222                         CHECKARG_TYPENAME(DEATH)
223                         
224                         default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; }
225                 }
226                 #undef CHECKARG_TYPENAME
227
228                 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs)); return; }
229         }
230         #endif
231
232         entity notif = Get_Notif_Ent(net_type, net_name);
233         if not(notif) { backtrace("Local_Notification: Could not find notification entity! (This wasn't caught by usage check?...)\n"); return; }
234         if not(notif.nent_enabled) { print("entity notification was disabled...\n"); return; }
235
236         string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : NO_STR_ARG);
237         string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : NO_STR_ARG);
238         string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : NO_STR_ARG);
239         string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : NO_STR_ARG);
240         float f1 = ((notif.nent_stringcount < count) ? ...(notif.nent_stringcount, float) : NO_FL_ARG);
241         float f2 = (((notif.nent_stringcount + 1) < count) ? ...((notif.nent_stringcount + 1), float) : NO_FL_ARG);
242         float f3 = (((notif.nent_stringcount + 2) < count) ? ...((notif.nent_stringcount + 2), float) : NO_FL_ARG);
243         float f4 = (((notif.nent_stringcount + 3) < count) ? ...((notif.nent_stringcount + 3), float) : NO_FL_ARG);
244
245         #ifdef NOTIFICATIONS_DEBUG
246         {
247                 dprint(sprintf("Local_Notification(%d, %s, %s, %s, %s, %s, %d, %d, %d, %d);\n",
248                         net_type, notif.nent_name,
249                         s1, s2, s3, s4, f1, f2, f3, f4));
250
251                 if((notif.nent_stringcount + notif.nent_floatcount) > count)
252                         { backtrace(sprintf(strcat("Not enough arguments for Send_Notification! stringcount(%d) + floatcount(%d) > count(%d)\n", 
253                         "Check the notification definition and function call for accuracy...?\n"), notif.nent_stringcount, notif.nent_floatcount, count)); return; }
254                 else if((notif.nent_stringcount + notif.nent_floatcount) < count)
255                         { backtrace(sprintf(strcat("Too many arguments for Send_Notification! stringcount(%d) + floatcount(%d) < count(%d)\n",
256                         "Check the notification definition and function call for accuracy...?\n"), notif.nent_stringcount, notif.nent_floatcount, count)); return; }
257         }
258         #endif
259         
260         switch(net_type)
261         {
262                 case MSG_INFO:
263                 {
264                         print(Local_Notification_sprintf(notif.nent_string, notif.nent_args, 
265                                 s1, s2, s3, s4, f1, f2, f3, f4));
266                                 
267                         #ifdef CSQC 
268                         if(notif.nent_icon != "") { HUD_Notify_Push(notif.nent_icon, s1, s2); } 
269                         #endif 
270                         break;
271                 }
272                 
273                 #ifdef CSQC
274                 case MSG_CENTER:
275                 {
276                         centerprint_generic(notif.nent_cpid,
277                                 Local_Notification_sprintf(notif.nent_string, notif.nent_args, 
278                                 s1, s2, s3, s4, f1, f2, f3, f4), 0, 0);
279                         break;
280                 }
281                 #endif
282                 
283                 case MSG_WEAPON:
284                 case MSG_DEATH:
285                 {
286                         if(notif.nent_infoname)
287                         if(msg_info_notifs[notif.nent_infoname - 1].nent_enabled)
288                         {
289                                 Local_Notification_Without_VarArgs(MSG_INFO, notif.nent_infoname, 
290                                         Get_Notif_Strnum(MSG_INFO, notif.nent_infoname), 
291                                         Get_Notif_Flnum(MSG_INFO, notif.nent_infoname), 
292                                         s1, s2, s3, s4, f1, f2, f3, f4);
293                         }
294                         #ifdef CSQC \
295                         if(notif.nent_centername)
296                         if(msg_center_notifs[notif.nent_centername - 1].nent_enabled)
297                         {
298                                 Local_Notification_Without_VarArgs(MSG_CENTER, notif.nent_centername, 
299                                         Get_Notif_Strnum(MSG_CENTER, notif.nent_centername), 
300                                         Get_Notif_Flnum(MSG_CENTER, notif.nent_centername), 
301                                         s1, s2, s3, s4, f1, f2, f3, f4); 
302                         }
303                         #endif \
304                         break;
305                 }
306         }
307 }
308
309 void Local_Notification_Without_VarArgs(float net_type, float net_name,
310         float stringcount, float floatcount,
311         string s1, string s2, string s3, string s4,
312         float f1, float f2, float f3, float f4)
313 {
314         #define VARITEM(stringc,floatc,args) if((stringcount == stringc) && (floatcount == floatc)) { Local_Notification(net_type, net_name, args); return; }
315         EIGHT_VARS_TO_VARARGS_VARLIST
316         #undef VARITEM
317
318         Local_Notification(net_type, net_name); // some notifications don't have any arguments at all
319 }
320
321
322 // =========================
323 //  Notification Networking
324 // =========================
325
326 #ifdef CSQC
327 void Read_Notification(float is_new)
328 {
329         float net_type = ReadByte();
330         float net_name = ReadShort();
331
332         float stringcount = Get_Notif_Strnum(net_type, net_name);
333         float floatcount = Get_Notif_Flnum(net_type, net_name);
334
335         string s1 = ((stringcount >= 1) ? ReadString() : NO_STR_ARG);
336         string s2 = ((stringcount >= 2) ? ReadString() : NO_STR_ARG);
337         string s3 = ((stringcount >= 3) ? ReadString() : NO_STR_ARG);
338         string s4 = ((stringcount == 4) ? ReadString() : NO_STR_ARG);
339         float f1 = ((floatcount >= 1) ? ReadLong() : NO_FL_ARG);
340         float f2 = ((floatcount >= 2) ? ReadLong() : NO_FL_ARG);
341         float f3 = ((floatcount >= 3) ? ReadLong() : NO_FL_ARG);
342         float f4 = ((floatcount == 4) ? ReadLong() : NO_FL_ARG);
343
344         #ifdef NOTIFICATIONS_DEBUG
345         dprint(sprintf("Read_Notification(%d) at %f: net_name = %s.\n", is_new, time, Get_Notif_Name(net_type, net_name)));
346         #endif
347         
348         if(is_new) { Local_Notification_Without_VarArgs(net_type, net_name, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); }
349 }
350 #endif
351
352 #ifdef SVQC
353 void Notification_Remove()
354 {
355         float i;
356         for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } }
357         remove(self);
358 }
359
360 float Write_Notification(entity client, float sf)
361 {
362         float i, send = FALSE;
363         
364         switch(self.nent_broadcast)
365         {
366                 case NOTIF_ONE: { if((client == self.nent_client) || (client.classname == STR_SPECTATOR && client.enemy == self.nent_client)) { send = TRUE; } break; }
367                 case NOTIF_ONE_ONLY: { if(client == self.nent_client) { send = TRUE; } break; }
368                 case NOTIF_TEAM: { if((client.team == self.nent_client.team) || (client.classname == STR_SPECTATOR && client.enemy.team == self.nent_client.team)) { send = TRUE; } break; }
369                 case NOTIF_TEAM_EXCEPT: { if(((client != self.nent_client) && (client.team == self.nent_client.team) && !(client.classname == STR_SPECTATOR && client.enemy == self.nent_client))) { send = TRUE; } break; }
370                 case NOTIF_ANY: { send = TRUE; break; }
371                 case NOTIF_ANY_EXCEPT: { if((client != self.nent_client) && !(client.classname == STR_SPECTATOR && client.enemy == self.nent_client)) { send = TRUE; } break; }
372                 default: { send = FALSE; break; }
373         }
374
375         if(send)
376         {               
377                 WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
378                 WriteByte(MSG_ENTITY, self.nent_net_type);
379                 WriteShort(MSG_ENTITY, self.nent_net_name);
380                 for(i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } 
381                 for(i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); }
382         }
383
384         return send; 
385 }
386
387 void Send_Notification(float broadcast, entity client,
388         float net_type, float net_name, ...count)
389 {
390         // check supplied broadcast, target, type, and name for errors
391         #ifdef NOTIFICATIONS_DEBUG
392         {
393                 #define CHECKARG_TYPENAME(type) case MSG_##type##: \
394                         { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
395                         { checkargs = sprintf("Improper name: %d!", net_name); } break; }
396                         
397                 string checkargs = "";
398                 switch(net_type)
399                 {
400                         CHECKARG_TYPENAME(INFO)
401                         CHECKARG_TYPENAME(CENTER)
402                         CHECKARG_TYPENAME(WEAPON)
403                         CHECKARG_TYPENAME(DEATH)
404                         
405                         default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; }
406                 }
407                 #undef CHECKARG_TYPENAME
408                 
409                 if(checkargs != "") { checkargs = strcat(checkargs, " "); }
410                 switch(broadcast)
411                 {
412                         case NOTIF_ONE:
413                         case NOTIF_ONE_ONLY: { if(clienttype(client) == CLIENTTYPE_NOTACLIENT) { checkargs = sprintf("%sNo client provided!", checkargs); } break; }
414                         case NOTIF_ANY_EXCEPT: { if(clienttype(client) == CLIENTTYPE_NOTACLIENT) { checkargs = sprintf("%sException can't be a non-client!", checkargs); } break; }
415                         case NOTIF_ANY: { if(client) { checkargs = sprintf("%sEntity provided when world was required!", checkargs); } break; }
416                         
417                         case NOTIF_TEAM:
418                         case NOTIF_TEAM_EXCEPT:
419                         {
420                                 if not(teamplay) { checkargs = sprintf("%sTeamplay not active!", checkargs); }
421                                 else if(clienttype(client) == CLIENTTYPE_NOTACLIENT)
422                                 {
423                                         if(broadcast == NOTIF_TEAM) { checkargs = sprintf("%sNo client provided!", checkargs); }
424                                         else { checkargs = sprintf("%sException can't be a non-client!", checkargs); }
425                                 }
426                                 break;
427                         }
428                         
429                         default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; }
430                 }
431                 
432                 if(checkargs != "") { backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs)); return; }
433         }
434         #endif
435
436         // retreive counts for the arguments of this notification
437         float stringcount = Get_Notif_Strnum(net_type, net_name);
438         float floatcount = Get_Notif_Flnum(net_type, net_name);
439
440         #ifdef NOTIFICATIONS_DEBUG
441         {
442                 dprint(sprintf("Send_Notification(%d, %d, %s, stringcount: %d, floatcount: %d, varargs: %d);\n",
443                         broadcast, net_type, Get_Notif_Name(net_type, net_name), stringcount, floatcount, count));
444
445                 if((stringcount + floatcount) > count)
446                         { backtrace(sprintf(strcat("Not enough arguments for Send_Notification! stringcount(%d) + floatcount(%d) > count(%d)\n", 
447                         "Check the notification definition and function call for accuracy...?\n"), stringcount, floatcount, count)); return; }
448                 else if((stringcount + floatcount) < count)
449                         { backtrace(sprintf(strcat("Too many arguments for Send_Notification! stringcount(%d) + floatcount(%d) < count(%d)\n",
450                         "Check the notification definition and function call for accuracy...?\n"), stringcount, floatcount, count)); return; }
451         }
452         #endif
453
454         entity notif = spawn();
455         notif.nent_broadcast = broadcast;
456         notif.nent_client = client;
457         notif.nent_net_type = net_type;
458         notif.nent_net_name = net_name;
459         notif.nent_stringcount = stringcount;
460         notif.nent_floatcount = floatcount;
461         
462         float i;
463         
464         for(i = 0; i < stringcount; ++i) { notif.nent_strings[i] = strzone(...(i, string)); }
465         for(i = 0; i < floatcount; ++i) { notif.nent_floats[i] = ...((stringcount + i), float); }
466         
467         notif.think = Notification_Remove;
468         notif.nextthink = (time + 0.5); 
469
470         Net_LinkEntity(notif, FALSE, 0, Write_Notification);
471
472         if((!server_is_local) && (broadcast == NOTIF_ANY || broadcast == NOTIF_ANY_EXCEPT) && (net_type != MSG_CENTER))
473                 { Local_Notification_Without_VarArgs(net_type, net_name, stringcount, floatcount,
474                         IFSTR(0), IFSTR(1), IFSTR(2), IFSTR(3), IFFL(0), IFFL(1), IFFL(2), IFFL(3)); }
475 }
476
477 void Send_Notification_Without_VarArgs(float broadcast, entity client,
478         float net_type, float net_name,
479         float stringcount, float floatcount,
480         string s1, string s2, string s3, string s4,
481         float f1, float f2, float f3, float f4)
482 {               
483         #define VARITEM(stringc,floatc,args) if((stringcount == stringc) && (floatcount == floatc)) { Send_Notification(broadcast, client, net_type, net_name, args); return; }
484         EIGHT_VARS_TO_VARARGS_VARLIST
485         #undef VARITEM
486
487         Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
488 }
489
490 void Send_Notification_Legacy_Wrapper(float broadcast, entity client,
491         float net_type, float net_name,
492         string s1, string s2,
493         float f1, float f2, float f3)
494 {
495         float stringcount = Get_Notif_Strnum(net_type, net_name);
496         float floatcount = Get_Notif_Flnum(net_type, net_name);
497         Send_Notification_Without_VarArgs(broadcast, client, net_type, net_name, stringcount, floatcount, s1, s2, NO_STR_ARG, NO_STR_ARG, f1, f2, f3, NO_FL_ARG);
498 }
499
500
501 // =============================
502 //  LEGACY NOTIFICATION SYSTEMS
503 // =============================
504
505 void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num)
506 {
507         if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT))
508         {
509                 msg_entity = e;
510                 WRITESPECTATABLE_MSG_ONE({
511                         WriteByte(MSG_ONE, SVC_TEMPENTITY);
512                         WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC);
513                         WriteByte(MSG_ONE, id);
514                         WriteString(MSG_ONE, s);
515                         if (id != 0 && s != "")
516                         {
517                                 WriteByte(MSG_ONE, duration);
518                                 WriteByte(MSG_ONE, countdown_num);
519                         }
520                 });
521         }
522 }
523 void Send_CSQC_Centerprint_Generic_Expire(entity e, float id)
524 {
525         Send_CSQC_Centerprint_Generic(e, id, "", 1, 0);
526 }
527 #endif // ifdef SVQC
528 #endif // ifndef MENUQC