#endif
#define HANDLE_CPID(cpid) ((min(NOTIF_MAX, cpid) == NO_CPID) ? FALSE : cpid)
-#define CHECK_MATCH(a,b) if(min(NOTIF_MAX, a) == b)
+#define NOTIF_MATCH(a,b) if(min(NOTIF_MAX, a) == b)
#define VAR_TO_TEXT(var) #var
+#define CHECK_FIELD_AND_COUNT(field,count) if(!field) { field = (NOTIF_FIRST + count); ++count; }
+#define CHECK_MAX_NOTIFICATIONS(name,count) if(count == NOTIF_MAX) { error(strcat("Maximum notifications hit: ", VAR_TO_TEXT(name), ": ", ftos(count), ".\n"); }
+
// ====================================
// Notifications List and Information
float NOTIF_CENTER_COUNT;
float NOTIF_WEAPON_COUNT;
float NOTIF_CPID_COUNT;
-
-#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) \
+ CHECK_MAX_NOTIFICATIONS(name, NOTIF_INFO_COUNT) \
} \
ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
void DecNotif_##name() \
{ \
CHECK_FIELD_AND_COUNT(name, NOTIF_NOTIFY_COUNT) \
- CHECK_MAX_NOTIFICATIONS(NOTIF_NOTIFY_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(name, NOTIF_NOTIFY_COUNT) \
} \
ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
{ \
CHECK_FIELD_AND_COUNT(name, NOTIF_CENTER_COUNT) \
CHECK_FIELD_AND_COUNT(cpid, NOTIF_CPID_COUNT) \
- CHECK_MAX_NOTIFICATIONS(NOTIF_CENTER_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(name, NOTIF_CENTER_COUNT) \
} \
ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
void DecNotif_##name() \
{ \
CHECK_FIELD_AND_COUNT(name, NOTIF_WEAPON_COUNT) \
- CHECK_MAX_NOTIFICATIONS(NOTIF_WEAPON_COUNT) \
+ CHECK_MAX_NOTIFICATIONS(name, NOTIF_WEAPON_COUNT) \
} \
ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
case MSG_INFO:
{
#define MSG_INFO_NOTIF(name,args,normal,gentle) \
- { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+ { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
MSG_INFO_NOTIFICATIONS
break;
}
case MSG_NOTIFY:
{
#define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
- { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+ { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
MSG_NOTIFY_NOTIFICATIONS
break;
}
case MSG_CENTER:
{
#define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
- { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+ { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
MSG_CENTER_NOTIFICATIONS
break;
}
case MSG_WEAPON:
{
#define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
- { CHECK_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
+ { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
MSG_WEAPON_NOTIFICATIONS
break;
}
case MSG_INFO:
{
#define MSG_INFO_NOTIF(name,args,normal,gentle) \
- { CHECK_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
+ { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
MSG_INFO_NOTIFICATIONS
break;
case MSG_CENTER:
{
#define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
- { CHECK_MATCH(name, net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } }
+ { NOTIF_MATCH(name, net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } }
MSG_CENTER_NOTIFICATIONS
break;
case MSG_INFO:
{
#define MSG_INFO_NOTIF(name,args,normal,gentle) \
- { if(min(NOTIF_MAX, name) == net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
+ { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
MSG_INFO_NOTIFICATIONS
break;