]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications.qh
More work on entity notifications
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qh
index 03436c4dd849a8fab86f68d0c547b65f7c7fbff4..a67f9af151535479f5be8d6cfc5b1aaa2a5dfbf9 100644 (file)
@@ -124,15 +124,6 @@ void Read_Notification(float is_new);
 #define NOTIF_ANY 5
 #define NOTIF_ANY_EXCEPT 6
 
-.float nent_broadcast;
-.entity nent_client;
-.float nent_net_type;
-.float nent_net_name;
-.float nent_stringcount;
-.float nent_floatcount; 
-.string nent_strings[4];
-.float nent_floats[4];
-
 #define IFSTR(num) ((num < stringcount) ? ...(num, string) : NO_STR_ARG)
 #define IFFL(num) ((((stringcount-1) + num) < count) ? ...(((stringcount-1) + num), float) : NO_FL_ARG)
 
@@ -290,6 +281,7 @@ void Dump_Notifications(float fh, float alsoprint);
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_WAKI_DEATH,         2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 got caught in the blast when ^BG%s^K1%s\n"), "") \
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_RAPT_CANNON,        2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 couldn't resist ^BG%s^K1 purple blobs%s\n"), "") \
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_RAPT_BOMB,          2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 was cluster bombed by ^BG%s^K1%s\n"), "") \
+       MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_RAPT_FRAGMENT,      2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 was cluster bombed by ^BG%s^K1%s\n"), "") \
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_RAPT_DEATH,         2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 got caught in the blast when ^BG%s^K1%s\n"), "") \
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_BUMB_GUN,           2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 foobar by ^BG%s^K1%s\n"), "") \
        MSG_INFO_NOTIF(INFO_DEATH_MURDER_VH_BUMB_RAY,           2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),                      "notify_death",                 _("^BG%s^K1 foobar by ^BG%s^K1%s\n"), "") \
@@ -616,29 +608,69 @@ void Dump_Notifications(float fh, float alsoprint);
 #define ADD_AUTOCVAR(name) var float autocvar_notification_##name = TRUE;
 #define CHECK_AUTOCVAR(name) if(autocvar_notification_##name)
 
-#define CHECK_NOTIFICATION_1(net_type,net_name,check_newline,normal,gentle) \
-       if((normal == "") || ((normal == "") && (gentle == ""))) { print(strcat("^1EMPTY NOTIFICATION: ^7net_type = ", net_type, ", net_name = ", VAR_TO_TEXT(net_name), ".\n")); } \
-       #if check_newline \
-               else \
-               { \
-                       if not(substring(normal, (strlen(normal) - 1), 1) == "\n") { print(strcat("^1MISSING/BROKEN NEW LINE AT END OF NOTIFICATION: ^7net_type = ", net_type, ", net_name = ", VAR_TO_TEXT(net_name), ", NORMAL string.\n")); } \
-                       if(gentle != "") { if not(substring(gentle, (strlen(gentle) - 1), 1) == "\n") { print(strcat("^1MISSING/BROKEN NEW LINE AT END OF NOTIFICATION: ^7net_type = ", net_type, ", net_name = ", VAR_TO_TEXT(net_name), ", GENTLE string.\n")); } } \
-               } \
-       #endif
-
-#define CHECK_NOTIFICATION_2(net_type,net_name,infoname,centername) \
-       #if infoname == NO_MSG \
-               #if centername == NO_MSG \
-                       #warning PAIRED NOTIFICATION WITH NO SUBCALLS: ##net_type - ##net_name \
-               #endif \
-       #endif
-       
 float NOTIF_INFO_COUNT;
 float NOTIF_CENTER_COUNT;
 float NOTIF_WEAPON_COUNT;
 float NOTIF_DEATH_COUNT;
 float NOTIF_CPID_COUNT;
 
+entity msg_info_notifs[NOTIF_MAX];
+entity msg_center_notifs[NOTIF_MAX];
+entity msg_weapon_notifs[NOTIF_MAX];
+entity msg_death_notifs[NOTIF_MAX];
+
+.float nent_broadcast;
+.entity nent_client;
+.float nent_net_type;
+.float nent_net_name;
+.string nent_strings[4];
+.float nent_floats[4];
+
+.string nent_name;
+.float nent_infoname;
+.float nent_centername;
+.float nent_stringcount;
+.float nent_floatcount; 
+.string nent_args;
+.string nent_hudargs;
+.string nent_icon;
+.float nent_cpid;
+.string nent_durcnt;
+.string nent_normal;
+.string nent_gentle;
+
+//     notif.nent_args = strzone(args); \
+//     notif.nent_hudargs = strzone(hudargs); \
+// if(durcnt != "") { notif.nent_durcnt = durcnt; } \
+
+#define CREATE_NOTIF_ENTITY(type,name,infoname,centername,strnum,flnum,args,hudargs,icon,cpid,durcnt,normal,gentle,check_newline,subcalls) \
+       entity notif = spawn(); \
+       msg_##type##_notifs[name - 1] = notif; \
+       notif.classname = "msg_##type##_notification"; \
+       notif.nent_name = strzone(#name); \
+       #if subcalls \
+               #if (infoname == NO_MSG) && (centername == NO_MSG) \
+                       print(sprintf("^1NOTIFICATION WITH NO SUBCALLS: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); \
+               #else \
+                       if(infoname) { notif.nent_infoname = infoname; } \
+                       if(centername) { notif.nent_centername = centername; } \
+               #endif \
+       #else \
+               notif.nent_stringcount = strnum; \
+               notif.nent_floatcount = flnum; \
+               if(icon != "") { notif.nent_icon = strzone(icon); } \
+               if(normal != "") { notif.nent_normal = strzone(normal); } \
+               else { print(sprintf("^1EMPTY NOTIFICATION: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); } \
+               if(gentle != "") { notif.nent_gentle = strzone(gentle); } \
+               #if check_newline \
+                       if(normal != "") { if not(substring(normal, (strlen(normal) - 1), 1) == "\n") { print(sprintf("^1MISSING/BROKEN NEW LINE AT END OF NOTIFICATION: ^7net_type = MSG_%s, net_name = %s, NORMAL string.\n", strtoupper(#type), #name)); } } \
+                       if(gentle != "") { if not(substring(gentle, (strlen(gentle) - 1), 1) == "\n") { print(sprintf("^1MISSING/BROKEN NEW LINE AT END OF NOTIFICATION: ^7net_type = MSG_%s, net_name = %s, GENTLE string.\n", strtoupper(#type), #name)); } } \
+               #else \
+                       if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \
+               #endif \
+       #endif
+
+
 #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \
        ADD_AUTOCVAR(name) \
        float name; \
@@ -646,7 +678,9 @@ float NOTIF_CPID_COUNT;
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_INFO_COUNT, "notifications") \
-               CHECK_NOTIFICATION_1("MSG_INFO", name, 1, normal, gentle) \
+               CREATE_NOTIF_ENTITY(info, name, NO_MSG, NO_MSG, \
+                       strnum, flnum, args, hudargs, icon, NO_MSG, NO_MSG, \
+                       normal, gentle, 1, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -659,7 +693,9 @@ float NOTIF_CPID_COUNT;
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CENTER_COUNT) \
                SET_FIELD_COUNT(cpid, NOTIF_FIRST, NOTIF_CPID_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CENTER_COUNT, "notifications") \
-               CHECK_NOTIFICATION_1("MSG_CENTER", name, 0, normal, gentle) \
+               CREATE_NOTIF_ENTITY(center, name, NO_MSG, NO_MSG, \
+                       strnum, flnum, args, "", "", cpid, durcnt, \
+                       normal, gentle, 0, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -670,7 +706,9 @@ float NOTIF_CPID_COUNT;
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_WEAPON_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_WEAPON_COUNT, "notifications") \
-               CHECK_NOTIFICATION_2("MSG_WEAPON", name, infoname, centername) \
+               CREATE_NOTIF_ENTITY(weapon, name, infoname, centername, \
+                       NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -681,7 +719,9 @@ float NOTIF_CPID_COUNT;
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_DEATH_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_DEATH_COUNT, "notifications") \
-               CHECK_NOTIFICATION_2("MSG_DEATH", name, infoname, centername) \
+               CREATE_NOTIF_ENTITY(death, name, infoname, centername, \
+                       NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)