1 #ifndef NOTIFICATIONS_H
2 #define NOTIFICATIONS_H
4 #include <common/command/all.qh>
6 #include "constants.qh"
10 // ================================================
11 // Unified notification system, written by Samual
12 // Last updated: March, 2013
13 // ================================================
15 // main types/groups of notifications
16 const int MSG_ANNCE = 1; // "Global" AND "personal" announcer messages
17 const int MSG_INFO = 2; // "Global" information messages
18 const int MSG_CENTER = 3; // "Personal" centerprint messages
19 const int MSG_CENTER_CPID = 4; // Kill centerprint message
20 const int MSG_MULTI = 5; // Subcall MSG_INFO and/or MSG_CENTER notifications
21 const int MSG_CHOICE = 6; // Choose which subcall wrapper to activate
23 // negative confirmations
24 const int NO_MSG = -12345; // allows various things to know when no information is added
25 const int NOTIF_ABORT = -1234; // allows Send_Notification to safely abort sending
27 #define EIGHT_VARS_TO_VARARGS_VARLIST \
29 VARITEM(2, 0, XPD(s1, s2)) \
30 VARITEM(3, 0, XPD(s1, s2, s3)) \
31 VARITEM(4, 0, XPD(s1, s2, s3, s4)) \
33 VARITEM(1, 1, XPD(s1, f1)) \
34 VARITEM(2, 1, XPD(s1, s2, f1)) \
35 VARITEM(3, 1, XPD(s1, s2, s3, f1)) \
36 VARITEM(4, 1, XPD(s1, s2, s3, s4, f1)) \
37 VARITEM(0, 2, XPD(f1, f2)) \
38 VARITEM(1, 2, XPD(s1, f1, f2)) \
39 VARITEM(2, 2, XPD(s1, s2, f1, f2)) \
40 VARITEM(3, 2, XPD(s1, s2, s3, f1, f2)) \
41 VARITEM(4, 2, XPD(s1, s2, s3, s4, f1, f2)) \
42 VARITEM(0, 3, XPD(f1, f2, f3)) \
43 VARITEM(1, 3, XPD(s1, f1, f2, f3)) \
44 VARITEM(2, 3, XPD(s1, s2, f1, f2, f3)) \
45 VARITEM(3, 3, XPD(s1, s2, s3, f1, f2, f3)) \
46 VARITEM(4, 3, XPD(s1, s2, s3, s4, f1, f2, f3)) \
47 VARITEM(0, 4, XPD(f1, f2, f3, f4)) \
48 VARITEM(1, 4, XPD(s1, f1, f2, f3, f4)) \
49 VARITEM(2, 4, XPD(s1, s2, f1, f2, f3, f4)) \
50 VARITEM(3, 4, XPD(s1, s2, s3, f1, f2, f3, f4)) \
51 VARITEM(4, 4, XPD(s1, s2, s3, s4, f1, f2, f3, f4))
53 void Destroy_All_Notifications();
54 void Create_Notification_Entity(entity notif,
60 void Create_Notification_Entity_Annce(entity notif,
69 void Create_Notification_Entity_InfoCenter(entity notif,
74 /* MSG_INFO & MSG_CENTER */
83 void Create_Notification_Entity_Multi(entity notif,
91 void Create_Notification_Entity_Choice(entity notif,
101 void Dump_Notifications(float fh, float alsoprint);
104 GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt")
108 case CMD_REQUEST_COMMAND:
111 float fh, alsoprint = false;
112 string filename = argv(1);
116 filename = "notifications_dump.cfg";
119 else if(filename == "-")
121 filename = "notifications_dump.cfg";
124 fh = fopen(filename, FILE_WRITE);
128 Dump_Notifications(fh, alsoprint);
129 LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.\n", filename);
134 LOG_INFOF("^1Error: ^7Could not open file '%s'!\n", filename);
137 LOG_INFO(_("Notification dump command only works with cl_cmd and sv_cmd.\n"));
143 case CMD_REQUEST_USAGE:
145 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]"));
146 LOG_INFO(" Where 'filename' is the file to write (default is notifications_dump.cfg),\n");
147 LOG_INFO(" if supplied with '-' output to console as well as default,\n");
148 LOG_INFO(" if left blank, it will only write to default.\n");
154 #ifdef NOTIFICATIONS_DEBUG
155 void Debug_Notification(string input);
158 void Local_Notification(int net_type, int net_name, ...count);
159 void Local_Notification_WOVA(
160 float net_type, float net_name,
161 float stringcount, float floatcount,
162 string s1, string s2, string s3, string s4,
163 float f1, float f2, float f3, float f4);
165 #ifdef CSQC // CLIENT ONLY
166 string prev_soundfile;
167 float prev_soundtime;
170 #ifdef SVQC // SERVER ONLY
173 CASE(NOTIF, ONE_ONLY)
175 CASE(NOTIF, TEAM_EXCEPT)
177 CASE(NOTIF, ALL_EXCEPT)
180 void Kill_Notification(
181 NOTIF broadcast, entity client,
182 float net_type, float net_name);
183 void Send_Notification(
184 NOTIF broadcast, entity client,
185 float net_type, float net_name,
187 void Send_Notification_WOVA(
188 NOTIF broadcast, entity client,
189 float net_type, float net_name,
190 float stringcount, float floatcount,
191 string s1, string s2, string s3, string s4,
192 float f1, float f2, float f3, float f4);
193 void Send_Notification_WOCOVA(
194 NOTIF broadcast, entity client,
195 float net_type, float net_name,
196 string s1, string s2, string s3, string s4,
197 float f1, float f2, float f3, float f4);
200 // ===========================
201 // Special CVAR Declarations
202 // ===========================
204 // MAKE SURE THIS IS ALWAYS SYNCHRONIZED WITH THE DUMP
205 // NOTIFICATIONS FUNCTION IN THE .QC FILE!
207 #define NOTIF_ADD_AUTOCVAR(name,default) float autocvar_notification_##name = default;
209 float autocvar_notification_show_location = false;
210 string autocvar_notification_show_location_string = ""; //_(" at the %s");
211 float autocvar_notification_show_sprees = true;
212 float autocvar_notification_show_sprees_info = 3; // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker
213 float autocvar_notification_show_sprees_info_newline = true;
214 float autocvar_notification_show_sprees_info_specialonly = true;
215 float autocvar_notification_errors_are_fatal = true;
216 float autocvar_notification_lifetime_runtime = 0.5;
217 float autocvar_notification_lifetime_mapload = 10;
218 float autocvar_notification_debug = false;
222 void Notification_GetCvars();
223 float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes
225 float autocvar_notification_item_centerprinttime = 1.5;
227 // 0 = no, 1 = yes, 2 = forced on for all MSG_INFO notifs
228 // DISABLED IN CODE, BUT ENABLED IN CONFIG FOR COMPATIBILITY WITH OLD CLIENTS
229 float autocvar_notification_allow_chatboxprint = 0;
231 float autocvar_notification_show_sprees_center = true;
232 float autocvar_notification_show_sprees_center_specialonly = true;
236 // ============================
237 // Notification Argument List
238 // ============================
240 These arguments get replaced with the Local_Notification_sprintf
241 and other such functions found in notifications.qc to supply data
242 from networked notifications to their usage in sprintf... It
243 allows for more dynamic data to be inferred by the local
244 notification parser, so that the server does not have to network
245 anything too crazy on a per-client/per-situation basis.
247 Pay attention to the CSQC/SVQC relations, some of these are redefined
248 in slightly different ways for different programs, this is because the
249 server does a more conservative approach to the notifs than the client.
251 All arguments are swapped into strings, so be sure that your
252 sprintf usage matches with proper %s placement.
254 Argument descriptions:
255 s1-s4: string arguments to be literally swapped into sprintf
256 s2loc: s2 string of locations of deaths or other events
257 s3loc: s3 string of locations of deaths or other events
258 f1-f4: float arguments expanded into strings to be swapped into sprintf
259 f1p2dec: f1 float to string with 2 decimal places
260 f2p2dec: f2 float to string with 2 decimal places
261 f2primsec: f2 float primary or secondary selection for weapons
262 f3primsec: f3 float primary or secondary selection for weapons
263 f1secs: count_seconds of f1
264 f1points: point or points depending on f1
265 f1ord: count_ordinal of f1
266 f1time: process_time of f1
267 f1race_time: mmssss of f1
268 f2race_time: mmssss of f2
269 race_col: color of race time/position (i.e. good or bad)
270 race_diff: show time difference between f2 and f3
271 missing_teams: show which teams still need players
272 pass_key: find the keybind for "passing" or "dropping" in CTF game mode
273 frag_ping: show the ping of a player
274 frag_stats: show health/armor/ping of a player
275 frag_pos: show score status and position in the match of a player
276 spree_cen: centerprint notif for kill spree/how many kills they have
277 spree_inf: info notif for kill spree/how many kills they have
278 spree_end: placed at the end of murder messages to show ending of sprees
279 spree_lost: placed at the end of suicide messages to show losing of sprees
280 item_wepname: return full name of a weapon from weaponid
281 item_wepammo: ammo display for weapon from string
282 item_centime: amount of time to display weapon message in centerprint
283 item_buffname: return full name of a buff from buffid
284 death_team: show the full name of the team a player is switching from
285 minigame1_name: return human readable name of a minigame from its id(s1)
286 minigame1_d: return descriptor name of a minigame from its id(s1)
289 const float NOTIF_MAX_ARGS = 7;
290 const float NOTIF_MAX_HUDARGS = 2;
291 const float NOTIF_MAX_DURCNT = 2;
293 string arg_slot[NOTIF_MAX_ARGS];
295 const float ARG_CS_SV_HA = 1; // enabled on CSQC, SVQC, and Hudargs
296 const float ARG_CS_SV_DC = 2; // enabled on CSQC, SVQC, and durcnt centerprint
297 const float ARG_CS_SV = 3; // enabled on CSQC and SVQC
298 const float ARG_CS = 4; // unique result to CSQC
299 const float ARG_SV = 5; // unique result to SVQC
300 const float ARG_DC = 6; // unique result to durcnt/centerprint
302 // todo possible idea.... declare how many floats/strings each arg needs, and then dynamically increment the input
303 // this way, we don't need to have duplicates like i.e. s2loc and s3loc?
305 string BUFF_NAME(int i);
307 #define NOTIF_ARGUMENT_LIST \
308 ARG_CASE(ARG_CS_SV_HA, "s1", s1) \
309 ARG_CASE(ARG_CS_SV_HA, "s2", s2) \
310 ARG_CASE(ARG_CS_SV_HA, "s3", s3) \
311 ARG_CASE(ARG_CS_SV_HA, "s4", s4) \
312 ARG_CASE(ARG_CS_SV, "s2loc", ((autocvar_notification_show_location && (s2 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s2) : "")) \
313 ARG_CASE(ARG_CS_SV, "s3loc", ((autocvar_notification_show_location && (s3 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s3) : "")) \
314 ARG_CASE(ARG_CS_SV_DC, "f1", ftos(f1)) \
315 ARG_CASE(ARG_CS_SV_DC, "f2", ftos(f2)) \
316 ARG_CASE(ARG_CS_SV, "f3", ftos(f3)) \
317 ARG_CASE(ARG_CS_SV, "f4", ftos(f4)) \
318 ARG_CASE(ARG_CS_SV, "f1p2dec", ftos_decimals(f1/100, 2)) \
319 ARG_CASE(ARG_CS_SV, "f2p2dec", ftos_decimals(f2/100, 2)) \
320 ARG_CASE(ARG_CS, "f2primsec", (f2 ? _("secondary") : _("primary"))) \
321 ARG_CASE(ARG_CS, "f3primsec", (f3 ? _("secondary") : _("primary"))) \
322 ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \
323 ARG_CASE(ARG_CS, "f1points", (f1 == 1 ? _("point") : _("points"))) \
324 ARG_CASE(ARG_CS_SV, "f1ord", count_ordinal(f1)) \
325 ARG_CASE(ARG_CS, "f1time", process_time(2, f1)) \
326 ARG_CASE(ARG_CS_SV_HA, "f1race_time", mmssss(f1)) \
327 ARG_CASE(ARG_CS_SV_HA, "f2race_time", mmssss(f2)) \
328 ARG_CASE(ARG_CS_SV_HA, "f3race_time", mmssss(f3)) \
329 ARG_CASE(ARG_CS_SV, "race_col", CCR(((f1 == 1) ? "^F1" : "^F2"))) \
330 ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \
331 ARG_CASE(ARG_CS, "missing_teams", notif_arg_missing_teams(f1)) \
332 ARG_CASE(ARG_CS, "pass_key", ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \
333 ARG_CASE(ARG_CS, "frag_ping", notif_arg_frag_ping(true, f2)) \
334 ARG_CASE(ARG_CS, "frag_stats", notif_arg_frag_stats(f2, f3, f4)) \
335 /*ARG_CASE(ARG_CS, "frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \
336 ARG_CASE(ARG_CS, "spree_cen", (autocvar_notification_show_sprees ? notif_arg_spree_cen(f1) : "")) \
337 ARG_CASE(ARG_CS_SV, "spree_inf", (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \
338 ARG_CASE(ARG_CS_SV, "spree_end", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \
339 ARG_CASE(ARG_CS_SV, "spree_lost", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
340 ARG_CASE(ARG_CS_SV, "item_wepname", Weapons_from(f1).m_name) \
341 ARG_CASE(ARG_CS_SV, "item_buffname", BUFF_NAME(f1)) \
342 ARG_CASE(ARG_CS_SV, "f3buffname", BUFF_NAME(f3)) \
343 ARG_CASE(ARG_CS_SV, "item_wepammo", (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \
344 ARG_CASE(ARG_DC, "item_centime", ftos(autocvar_notification_item_centerprinttime)) \
345 ARG_CASE(ARG_SV, "death_team", Team_ColoredFullName(f1)) \
346 ARG_CASE(ARG_CS, "death_team", Team_ColoredFullName(f1 - 1)) \
347 ARG_CASE(ARG_CS_SV_HA, "minigame1_name",find(world,netname,s1).descriptor.message) \
348 ARG_CASE(ARG_CS_SV_HA, "minigame1_d", find(world,netname,s1).descriptor.netname)
350 #define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN { \
351 if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \
353 #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
355 #define KILL_SPREE_LIST \
356 SPREE_ITEM(3, 03, _("TRIPLE FRAG! "), _("%s^K1 made a TRIPLE FRAG! %s^BG"), _("%s^K1 made a TRIPLE SCORE! %s^BG")) \
357 SPREE_ITEM(5, 05, _("RAGE! "), _("%s^K1 unlocked RAGE! %s^BG"), _("%s^K1 made FIVE SCORES IN A ROW! %s^BG")) \
358 SPREE_ITEM(10, 10, _("MASSACRE! "), _("%s^K1 started a MASSACRE! %s^BG"), _("%s^K1 made TEN SCORES IN A ROW! %s^BG")) \
359 SPREE_ITEM(15, 15, _("MAYHEM! "), _("%s^K1 executed MAYHEM! %s^BG"), _("%s^K1 made FIFTEEN SCORES IN A ROW! %s^BG")) \
360 SPREE_ITEM(20, 20, _("BERSERKER! "), _("%s^K1 is a BERSERKER! %s^BG"), _("%s^K1 made TWENTY SCORES IN A ROW! %s^BG")) \
361 SPREE_ITEM(25, 25, _("CARNAGE! "), _("%s^K1 inflicts CARNAGE! %s^BG"), _("%s^K1 made TWENTY FIVE SCORES IN A ROW! %s^BG")) \
362 SPREE_ITEM(30, 30, _("ARMAGEDDON! "), _("%s^K1 unleashes ARMAGEDDON! %s^BG"), _("%s^K1 made THIRTY SCORES IN A ROW! %s^BG"))
365 string notif_arg_frag_ping(float newline, float fping)
368 return sprintf(CCR(_("%s(^F1Bot^BG)")), (newline ? "\n" : " "));
370 return sprintf(CCR(_("%s(Ping ^F1%d^BG)")), (newline ? "\n" : " "), fping);
373 string notif_arg_frag_stats(float fhealth, float farmor, float fping)
376 return sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), fhealth, farmor, notif_arg_frag_ping(false, fping));
378 return sprintf(CCR(_("\n(^F4Dead^BG)%s")), notif_arg_frag_ping(false, fping));
381 string notif_arg_missing_teams(float f1)
383 return sprintf("%s%s%s%s",
385 sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_1), ((f1 & (2 + 4 + 8)) ? ", " : ""))
390 sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_2), ((f1 & (4 + 8)) ? ", " : ""))
395 sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_3), ((f1 & 8) ? ", " : ""))
400 Team_ColoredFullName(NUM_TEAM_4)
407 string notif_arg_spree_cen(float spree)
409 // 0 = off, 1 = target (but only for first victim) and attacker
410 if(autocvar_notification_show_sprees_center)
414 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
415 case counta: { return normal_or_gentle(center, sprintf(_("%d score spree! "), spree)); }
422 if (!autocvar_notification_show_sprees_center_specialonly)
427 _("%d frag spree! "),
428 _("%d score spree! ")
432 else { return ""; } // don't show spree information if it isn't an achievement
438 else if(spree == -1) // first blood
440 return normal_or_gentle(_("First blood! "), _("First score! "));
442 else if(spree == -2) // first victim
444 return normal_or_gentle(_("First victim! "), _("First casualty! "));
451 string notif_arg_spree_inf(float type, string input, string player, float spree)
455 case 1: // attacker kill spree
457 // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker
458 // this conditional (& 2) is true for 2 and 3
459 if(autocvar_notification_show_sprees_info & 2)
462 string spree_newline =
463 ( autocvar_notification_show_sprees_info_newline ?
464 ((substring(input, 0, 1) == "\{3}") ? "\n\{3}" : "\n") : "" );
466 string spree_newline =
467 (autocvar_notification_show_sprees_info_newline ? "\n" : "");
472 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
473 case counta: { return sprintf(CCR(normal_or_gentle(normal, gentle)), player, spree_newline); }
480 if (!autocvar_notification_show_sprees_info_specialonly)
484 CCR(normal_or_gentle(
485 _("%s^K1 has %d frags in a row! %s^BG"),
486 _("%s^K1 made %d scores in a row! %s^BG")
493 else { return ""; } // don't show spree information if it isn't an achievement
499 else if(spree == -1) // firstblood
503 CCR(normal_or_gentle(
504 _("%s^K1 drew first blood! %s^BG"),
505 _("%s^K1 got the first score! %s^BG")
515 case -1: // kill spree ended
517 if((spree > 1) && (autocvar_notification_show_sprees_info & 1))
520 sprintf(normal_or_gentle(
521 _(", ending their %d frag spree"),
522 _(", ending their %d score spree")
530 case -2: // kill spree lost
532 if((spree > 1) && (autocvar_notification_show_sprees_info & 1))
535 sprintf(normal_or_gentle(
536 _(", losing their %d frag spree"),
537 _(", losing their %d score spree")
549 // ====================================
550 // Initialization/Create Declarations
551 // ====================================
572 , CPID_MISSING_PLAYERS
573 , CPID_INSTAGIB_FINDAMMO
580 , CPID_RACE_FINISHLAP
584 , CPID_VEHICLES_OTHER
588 // notification counts
589 const float NOTIF_FIRST = 1;
590 float NOTIF_ANNCE_COUNT;
591 float NOTIF_INFO_COUNT;
592 float NOTIF_CENTER_COUNT;
593 float NOTIF_MULTI_COUNT;
594 float NOTIF_CHOICE_COUNT;
596 // notification limits -- INCREASE AS NECESSARY
597 const float NOTIF_ANNCE_MAX = 400;
598 const float NOTIF_INFO_MAX = 450;
599 const float NOTIF_CENTER_MAX = 350;
600 const float NOTIF_MULTI_MAX = 300;
601 const float NOTIF_CHOICE_MAX = 50;
603 // notification entities
604 entity msg_annce_notifs[NOTIF_ANNCE_MAX];
605 entity msg_info_notifs[NOTIF_INFO_MAX];
606 entity msg_center_notifs[NOTIF_CENTER_MAX];
607 entity msg_multi_notifs[NOTIF_MULTI_MAX];
608 entity msg_choice_notifs[NOTIF_CHOICE_MAX];
610 // common notification entity values
616 .int nent_stringcount;
617 .int nent_floatcount;
619 // MSG_ANNCE entity values
623 .float nent_position;
625 // MSG_INFO and MSG_CENTER entity values
626 .string nent_args; // used by both
627 .string nent_hudargs; // used by info
628 .string nent_icon; // used by info
629 .float nent_cpid; // used by center
630 .string nent_durcnt; // used by center
631 .string nent_string; // used by both
633 // MSG_MULTI entity values
634 .entity nent_msgannce;
635 .entity nent_msginfo;
636 .entity nent_msgcenter;
638 // MSG_CHOICE entity values
639 .float nent_challow_def;
640 .float nent_challow_var;
641 .entity nent_optiona;
642 .entity nent_optionb;
644 // networked notification entity values
646 .NOTIF nent_broadcast;
649 .float nent_net_type;
650 .float nent_net_name;
651 .string nent_strings[4];
652 .float nent_floats[4];
654 // other notification properties
655 .float msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices
657 #define ACVNN(name) autocvar_notification_##name
659 // initialization error detection
661 float notif_global_error;
663 #define MSG_ANNCE_NOTIF(name, default, sound, channel, volume, position) \
664 MSG_ANNCE_NOTIF_(ANNCE_##name, default, sound, channel, volume, position)
665 #define MSG_ANNCE_NOTIF_(name, default, sound, channel, volume, position) \
666 NOTIF_ADD_AUTOCVAR(name, default) \
668 void RegisterNotification_##name() \
670 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_ANNCE_COUNT) \
671 CHECK_MAX_COUNT(name, NOTIF_ANNCE_MAX, NOTIF_ANNCE_COUNT, "MSG_ANNCE") \
672 entity this = msg_annce_notifs[name - 1] = new_pure(msg_annce_notification); \
673 Create_Notification_Entity (this, default, ACVNN(name), MSG_ANNCE, name, strtoupper(#name)); \
674 Create_Notification_Entity_Annce(this, ACVNN(name), strtoupper(#name), \
675 channel, /* channel */ \
678 position); /* position */ \
680 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
682 #define MSG_INFO_NOTIF(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
683 MSG_INFO_NOTIF_(INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle)
684 #define MSG_INFO_NOTIF_(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
685 NOTIF_ADD_AUTOCVAR(name, default) \
687 void RegisterNotification_##name() \
689 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \
690 CHECK_MAX_COUNT(name, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \
691 entity this = msg_info_notifs[name - 1] = new_pure(msg_info_notification); \
692 Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name, strtoupper(#name)); \
693 Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
695 hudargs, /* hudargs */ \
699 normal, /* normal */ \
700 gentle); /* gentle */ \
702 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
704 .string nent_iconargs;
705 #define MULTIICON_INFO(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
706 MULTIICON_INFO_(INFO_##name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle)
707 #define MULTIICON_INFO_(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
708 NOTIF_ADD_AUTOCVAR(name, default) \
710 void RegisterNotification_##name() \
712 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \
713 CHECK_MAX_COUNT(name, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \
714 entity this = msg_info_notifs[name - 1] = new_pure(msg_info_notification); \
715 Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name, strtoupper(#name)); \
716 Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
718 hudargs, /* hudargs */ \
722 normal, /* normal */ \
723 gentle); /* gentle */ \
724 msg_info_notifs[name - 1].nent_iconargs = iconargs; \
726 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
728 #define MSG_CENTER_NOTIF(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
729 MSG_CENTER_NOTIF_(CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
730 #define MSG_CENTER_NOTIF_(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
731 NOTIF_ADD_AUTOCVAR(name, default) \
733 void RegisterNotification_##name() \
735 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CENTER_COUNT) \
736 CHECK_MAX_COUNT(name, NOTIF_CENTER_MAX, NOTIF_CENTER_COUNT, "MSG_CENTER") \
737 entity this = msg_center_notifs[name - 1] = new_pure(msg_center_notification); \
738 Create_Notification_Entity (this, default, ACVNN(name), MSG_CENTER, name, strtoupper(#name)); \
739 Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
744 durcnt, /* durcnt */ \
745 normal, /* normal */ \
746 gentle); /* gentle */ \
748 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
750 #define MSG_MULTI_NOTIF(name, default, anncename, infoname, centername) \
751 NOTIF_ADD_AUTOCVAR(name, default) \
753 void RegisterNotification_##name() \
755 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_MULTI_COUNT) \
756 CHECK_MAX_COUNT(name, NOTIF_MULTI_MAX, NOTIF_MULTI_COUNT, "MSG_MULTI") \
757 entity this = msg_multi_notifs[name - 1] = new_pure(msg_multi_notification); \
758 Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, name, strtoupper(#name)); \
759 Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \
760 anncename, /* anncename */ \
761 infoname, /* infoname */ \
762 centername); /* centername */ \
764 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
766 #define MSG_CHOICE_NOTIF(name, default, challow, chtype, optiona, optionb) \
767 MSG_CHOICE_NOTIF_(CHOICE_##name, default, challow, chtype, optiona, optionb)
768 #define MSG_CHOICE_NOTIF_(name, default, challow, chtype, optiona, optionb) \
769 NOTIF_ADD_AUTOCVAR(name, default) \
770 NOTIF_ADD_AUTOCVAR(name##_ALLOWED, challow) \
772 void RegisterNotification_##name() \
774 SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CHOICE_COUNT) \
775 CHECK_MAX_COUNT(name, NOTIF_CHOICE_MAX, NOTIF_CHOICE_COUNT, "MSG_CHOICE") \
776 entity this = msg_choice_notifs[name - 1] = new_pure(msg_choice_notification); \
777 Create_Notification_Entity (this, default, ACVNN(name), MSG_CHOICE, name, strtoupper(#name)); \
778 Create_Notification_Entity_Choice(this, ACVNN(name), strtoupper(#name), \
779 challow, /* challow_def */ \
780 autocvar_notification_##name##_ALLOWED, /* challow_var */ \
781 chtype, /* chtype */ \
782 optiona, /* optiona */ \
783 optionb); /* optionb */ \
785 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
787 void RegisterNotifications_First()
789 notif_global_error = false;
792 void RegisterNotifications_Done()
794 if(notif_global_error)
796 // shit happened... stop the loading of the program now if this is unacceptable
797 if(autocvar_notification_errors_are_fatal)
798 LOG_FATAL("Notification initialization failed! Read above and fix the errors!\n");
800 LOG_SEVERE("Notification initialization failed! Read above and fix the errors!\n");
804 // NOW we actually activate the declarations
805 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_First)
806 #include "notifications.inc"
807 ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_Done)
809 STATIC_INIT(RegisterNotifications) { CALL_ACCUMULATED_FUNCTION(RegisterNotifications); }