]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications.qh
Slight cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qh
index 6f7350ccca86f619f17f88309ade10682f70b9d5..23784363eecba0018e920c59a359658dbc8f97f6 100644 (file)
@@ -97,7 +97,13 @@ string got_commandkey;
                default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = ", VAR_TO_TEXT(net_type), ", net_name = ", ftos(net_name), ".\n")); returnv; } \
        }
 
-string Get_Field_Value(float field, float net_type, float net_name); // get the actual name of a notification and return it as a string
+entity Get_Notif_Ent(float net_type, float net_name);
+string Get_Notif_Name(float net_type, float net_name);
+float Get_Notif_Infval(float net_type, float net_name);
+float Get_Notif_Cenval(float net_type, float net_name);
+float Get_Notif_Strnum(float net_type, float net_name);
+float Get_Notif_Flnum(float net_type, float net_name);
+
 void Local_Notification(float net_type, float net_name, ...count);
 void Local_Notification_Without_VarArgs(float net_type, float net_name, float stringcount, float floatcount, string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4);
 
@@ -623,22 +629,22 @@ entity msg_death_notifs[NOTIF_MAX];
 .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];
 
 .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;
 
-.float nent_cpid;
-.float nent_durcnt;
-
 //     notif.nent_args = strzone(args); \
 //     notif.nent_hudargs = strzone(hudargs); \
 // if(durcnt != "") { notif.nent_durcnt = durcnt; } \
@@ -646,22 +652,33 @@ entity msg_death_notifs[NOTIF_MAX];
 #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.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; } \
+                       float infoname_stringcount = 0, infoname_floatcount = 0, centername_stringcount = 0, centername_floatcount = 0; \
+                       #if (infoname != NO_MSG) \
+                               notif.nent_infoname = infoname; \
+                               infoname_stringcount = msg_info_notifs[infoname - 1].nent_stringcount; \
+                               infoname_floatcount = msg_info_notifs[infoname - 1].nent_floatcount; \
+                       #endif \
+                       #if (centername != NO_MSG) \
+                               notif.nent_centername = centername; \
+                               centername_stringcount = msg_center_notifs[centername - 1].nent_stringcount; \
+                               centername_floatcount = msg_center_notifs[centername - 1].nent_floatcount; \
+                       #endif \
+                       notif.nent_stringcount = max(infoname_stringcount, centername_stringcount); \
+                       notif.nent_floatcount = max(infoname_floatcount, centername_floatcount); \
                #endif \
        #else \
                notif.nent_stringcount = strnum; \
                notif.nent_floatcount = flnum; \
                if(icon != "") { notif.nent_icon = strzone(icon); } \
-               if(normal != "") { notif.nent_normal = strzone(normal); } \
+               if(normal != "") { notif.nent_normal = strzone(CCR(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(gentle != "") { notif.nent_gentle = strzone(CCR(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)); } } \
@@ -670,7 +687,6 @@ entity msg_death_notifs[NOTIF_MAX];
                #endif \
        #endif
 
-
 #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \
        ADD_AUTOCVAR(name) \
        float name; \
@@ -680,7 +696,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_INFO_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(info, name, NO_MSG, NO_MSG, \
                        strnum, flnum, args, hudargs, icon, NO_MSG, NO_MSG, \
-                       normal, gentle, TRUE, FALSE) \
+                       normal, gentle, 1, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -695,7 +711,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CENTER_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(center, name, NO_MSG, NO_MSG, \
                        strnum, flnum, args, "", "", cpid, durcnt, \
-                       normal, gentle, FALSE, FALSE) \
+                       normal, gentle, 0, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -708,7 +724,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_WEAPON_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(weapon, name, infoname, centername, \
                        NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
-                       "", "", FALSE, TRUE) \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -721,7 +737,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_DEATH_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(death, name, infoname, centername, \
                        NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
-                       "", "", FALSE, TRUE) \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)