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