#define XPND3(a,b,c) a, b, c
#define XPND2(a,b) a, b
-// accumulate functions for declarations
-#define NOTIF_FIRST 1
-#define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
-float NOTIF_INFO_COUNT;
-float NOTIF_NOTIFY_COUNT;
-float NOTIF_CENTER_COUNT;
-float NOTIF_WEAPON_COUNT;
-float NOTIF_CPID_COUNT;
+// allow sending of notifications to also pass through to spectators (specifically for centerprints)
+#ifdef SVQC
+#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname
+#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement)
+#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0
+#endif
-#define CHECK_MAX_NOTIFICATIONS(count) if(count == NOTIF_MAX) { error("Maximum notifications hit!\n"); }
+#define HANDLE_CPID(cpid) ((min(NOTIF_MAX, cpid) == NO_CPID) ? FALSE : cpid)
-#define MSG_INFO_NOTIF(name,args,normal,gentle) \
- float name; \
- void DecNotif_##name() { \
- if(!name) { \
- name = (NOTIF_FIRST + NOTIF_INFO_COUNT); \
- ++NOTIF_INFO_COUNT; } \
- CHECK_MAX_NOTIFICATIONS(NOTIF_INFO_COUNT) } \
- ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+// select between the normal or the gentle message string based on client (or server) settings
+string normal_or_gentle(string normal, string gentle)
+{
+ #ifdef CSQC
+ if(autocvar_cl_gentle || autocvar_cl_gentle_messages)
+ #else
+ if(autocvar_sv_gentle)
+ #endif
+ return ((gentle != "") ? gentle : normal);
+ else
+ return normal;
+}
-#define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
- float name; \
- void DecNotif_##name() { \
- if(!name) { \
- name = (NOTIF_FIRST + NOTIF_NOTIFY_COUNT); \
- ++NOTIF_NOTIFY_COUNT; } \
- CHECK_MAX_NOTIFICATIONS(NOTIF_NOTIFY_COUNT) } \
- ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+// color code replace, place inside of sprintf and parse the string
+string CCR(string input)
+{
+ input = strreplace("^F1", "^3", input);
+ input = strreplace("^F2", "^2", input);
+ input = strreplace("^BG", "^7", input);
-#define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
- float name; \
- float cpid; \
- void DecNotif_##name() { \
- if(!name) { \
- name = (NOTIF_FIRST + NOTIF_CENTER_COUNT); \
- ++NOTIF_CENTER_COUNT; } \
- if(!cpid) { \
- cpid = (NOTIF_FIRST + NOTIF_CPID_COUNT); \
- ++NOTIF_CPID_COUNT; } \
- CHECK_MAX_NOTIFICATIONS(NOTIF_CENTER_COUNT) } \
- ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+ input = strreplace("^N", "^7", input); // "none"-- reset to white
-#define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
- float name; \
- void DecNotif_##name() { \
- if(!name) { \
- name = (NOTIF_FIRST + NOTIF_WEAPON_COUNT); \
- ++NOTIF_WEAPON_COUNT; } \
- CHECK_MAX_NOTIFICATIONS(NOTIF_WEAPON_COUNT) } \
- ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+ return input;
+}
// ====================================
// ====================================
/*
List of all notifications (including identifiers and display information)
- Format: name, number, args, icon/CPID, normal, gentle
+ Format: name, args, *icon/CPID, *durcnt, normal, gentle
+ Asterisked fields are not present in all notification types.
Specifications:
Name of notification
- ID number of notification
Arguments for sprintf(string, args), if no args needed then use ""
- Icon/CPID:
+ *Icon/CPID:
MSG_NOTIFY: STRING: icon string name for the hud notify panel, "" if no icon is used
MSG_CENTER: FLOAT: centerprint ID number (CPID_*), NO_CPID if no CPID is needed
+ *Duration/Countdown:
+ MSG_CENTER: XPND2(FLOAT, FLOAT): extra arguments for centerprint messages
Normal message (string for sprintf when gentle messages are NOT enabled)
Gentle message (string for sprintf when gentle messages ARE enabled)
^F2 = next highest priority, "secondary"
^BG = normal/less important priority, "tertiary"
- Guidlines:
- ALWAYS start the string with a color, preferably background
- ALWAYS end messages with a new line
- NEVER re-declare an event twice
- ARIRE unir frk jvgu lbhe bja zbgure (gvc sbe zvxrrhfn)
+ Guidlines (please try and follow these):
+ ALWAYS start the string with a color, preferably background.
+ ALWAYS end messages with a new line.
+ ALWAYS properly use tab spacing to even out the notifications.
+ NEVER re-declare an event twice.
+ NEVER add or remove fields from the format, it SHOULD already work.
+ ARIRE unir frk jvgu lbhe bja zbgure. (gvc sbe zvxrrhfn) -- Don't pay attention to this ^_^
+ Be clean and simple with your notification naming, nothing too long.
+ Keep the notifications in alphabetical order.
*/
#define MSG_INFO_NOTIFICATIONS \
MSG_INFO_NOTIF(DEATH_MARBLES_LOST, XPND3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
#undef MSG_NOTIFY_NOTIF
#define MSG_CENTER_NOTIFICATIONS \
- MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_SHIELDED, "", CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_FREE, "", CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS, XPND2(s1, s2, s3), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s passed the ^F1%s^BG to %s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_SENT, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BGYou passed the ^F1%s^BG to %s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_RECEIVED, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BGYou received the ^F1%s^BG from %s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_EVENT_RETURN, s1, CPID_CTF_LOWPRIO, XPND2(0, 0), _("^BGYou returned the ^F1%s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_EVENT_CAPTURE, s1, NO_CPID, XPND2(0, 0), _("^BGYou captured the ^F1%s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_SHIELDED, "", CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_FREE, "", CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS, XPND2(s1, s2, s3), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s passed the ^F1%s^BG to %s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_SENT, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BGYou passed the ^F1%s^BG to %s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_RECEIVED, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BGYou received the ^F1%s^BG from %s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_EVENT_RETURN, s1, CPID_CTF_LOWPRIO, XPND2(0, 0), _("^BGYou returned the ^F1%s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_EVENT_CAPTURE, s1, NO_CPID, XPND2(0, 0), _("^BGYou captured the ^F1%s"), "") \
#undef MSG_CENTER_NOTIF
#define MSG_WEAPON_NOTIFICATIONS \
MSG_WEAPON_NOTIF(DEATH_MARBLES_LOST3, XPND3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
#undef MSG_WEAPON_NOTIF
-// NOW we actually activate the declarations
-MSG_INFO_NOTIFICATIONS
-MSG_NOTIFY_NOTIFICATIONS
-MSG_CENTER_NOTIFICATIONS
-MSG_WEAPON_NOTIFICATIONS
-
-// ======================
-// Supporting Functions
-// ======================
+// ====================================
+// Initialization/Create Declarations
+// ====================================
-#ifdef SVQC
-#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname
-#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement)
-#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0
-#endif
+#define NOTIF_FIRST 1
+#define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
+float NOTIF_INFO_COUNT;
+float NOTIF_NOTIFY_COUNT;
+float NOTIF_CENTER_COUNT;
+float NOTIF_WEAPON_COUNT;
+float NOTIF_CPID_COUNT;
-#define HANDLE_CPID(cpid) ((min(NOTIF_MAX, cpid) == NO_CPID) ? FALSE : cpid)
+#define CHECK_FIELD_AND_COUNT(field,count) if(!field) { field = (NOTIF_FIRST + count); ++count; }
+#define CHECK_MAX_NOTIFICATIONS(count) if(count == NOTIF_MAX) { error("Maximum notifications hit!\n"); }
+
+#define MSG_INFO_NOTIF(name,args,normal,gentle) \
+ float name; \
+ void DecNotif_##name() \
+ { \
+ CHECK_FIELD_AND_COUNT(name, NOTIF_INFO_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(NOTIF_INFO_COUNT) \
+ } \
+ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
-string normal_or_gentle(string normal, string gentle)
-{
- #ifdef CSQC
- if(autocvar_cl_gentle || autocvar_cl_gentle_messages)
- #else
- if(autocvar_sv_gentle)
- #endif
- return ((gentle != "") ? gentle : normal);
- else
- return normal;
-}
+#define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
+ float name; \
+ void DecNotif_##name() \
+ { \
+ CHECK_FIELD_AND_COUNT(name, NOTIF_NOTIFY_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(NOTIF_NOTIFY_COUNT) \
+ } \
+ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
-string CCR(string input) // color code replace, place inside of sprintf and parse the string
-{
- input = strreplace("^F1", "^3", input);
- input = strreplace("^F2", "^2", input);
- input = strreplace("^BG", "^7", input);
+#define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
+ float name; \
+ float cpid; \
+ void DecNotif_##name() \
+ { \
+ CHECK_FIELD_AND_COUNT(name, NOTIF_CENTER_COUNT) \
+ CHECK_FIELD_AND_COUNT(cpid, NOTIF_CPID_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(NOTIF_CENTER_COUNT) \
+ } \
+ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
- input = strreplace("^N", "^7", input); // "none"-- reset to white
+#define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
+ float name; \
+ void DecNotif_##name() \
+ { \
+ CHECK_FIELD_AND_COUNT(name, NOTIF_WEAPON_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(NOTIF_WEAPON_COUNT) \
+ } \
+ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
- return input;
-}
+// NOW we actually activate the declarations
+MSG_INFO_NOTIFICATIONS
+MSG_NOTIFY_NOTIFICATIONS
+MSG_CENTER_NOTIFICATIONS
+MSG_WEAPON_NOTIFICATIONS
// ===============================
// Frontend Notification Pushing
// ===============================
-
-// =========================
-// Notification Networking
-// =========================
-
#ifdef CSQC
-void Read_Notification()
+void Local_Notification(float net_type, float net_name, string s1, string s2, string s3)
{
- float net_type = ReadByte();
- float net_name = ReadCoord(); // byte only has 256 selections, we need more than that
- string s1 = ReadString();
- string s2 = ReadString();
- string s3 = ReadString();
-
switch(net_type)
{
case MSG_INFO:
}
}
#endif
+
+
+// =========================
+// Notification Networking
+// =========================
+
#ifdef SVQC
void Send_Notification(float net_type, entity client, float net_name, string s1, string s2, string s3)
{