// ================================================
#ifndef MENUQC
+string arg_slot[8];
+string Fill_Notif_Args(string args, string input,
+ string s1, string s2, string s3, string s4,
+ float f1, float f2, float f3, float f4)
+{
+ dprint(sprintf("Fill_Notif_Args('%s', '%s', %s, %s, %s, %s, %d, %d, %d, %d);\n",
+ args, input, s1, s2, s3, s4, f1, f2, f3, f4));
+
+ string selected, remaining = args;
+ float sel_num = 0;
+
+ #ifdef CSQC
+ string tmp_s;
+ #endif
+
+ if((remaining != "") && (input != ""))
+ {
+ for(;remaining;)
+ {
+ selected = car(remaining); remaining = cdr(remaining);
+
+ switch(strtolower(selected))
+ {
+ #define ADD_ARG_CASE(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; }
+
+ ADD_ARG_CASE("s1", s1)
+ ADD_ARG_CASE("s2", s2)
+ ADD_ARG_CASE("s3", s3)
+ ADD_ARG_CASE("s4", s4)
+ ADD_ARG_CASE("f1", ftos(f1))
+ ADD_ARG_CASE("f2", ftos(f2))
+ ADD_ARG_CASE("f3", ftos(f3))
+ ADD_ARG_CASE("f4", ftos(f4))
+
+ #ifdef CSQC // CSQC replacements
+ ADD_ARG_CASE("pass_key", ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : ""))
+ ADD_ARG_CASE("frag_ping", ((f2 != BOT_PING) ? sprintf(CCR(_("\n(Ping ^2%d^BG)")), f2) : ""))
+ ADD_ARG_CASE("frag_stats", sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), f1, f2, ((f3 != BOT_PING) ? sprintf(CCR(_(" (Ping ^2%d^BG)")), f3) : "")))
+ //ADD_ARG_CASE("frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))
+ ADD_ARG_CASE("spree_cen", (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
+ ADD_ARG_CASE("spree_inf", (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
+ ADD_ARG_CASE("spree_end", ((f1 >= 3) ? sprintf(normal_or_gentle(_(", ending their %d frag spree"), _(", ending their %d score spree")), f1) : ""))
+ ADD_ARG_CASE("spree_lost", ((f1 >= 3) ? sprintf(normal_or_gentle(_(", losing their %d frag spree"), _(", losing their %d score spree")), f1) : ""))
+ ADD_ARG_CASE("death_team", Team_ColoredFullName(f1 - 1))
+ ADD_ARG_CASE("weapon_name", ftos(f1)) // weaponorder[f1].netname
+
+ #else // SVQC replacements
+ ADD_ARG_CASE("spree_inf", (((f1 == 3) || (f1 == 5) || (f1 == 10) || (f1 == 15) || (f1 == 20) || (f1 == 25) || (f1 == 30)) ? sprintf(normal_or_gentle(_("%d frag spree! "), _("%d score spree! ")), f1) : ""))
+ ADD_ARG_CASE("spree_end", ((f1 >= 3) ? sprintf(normal_or_gentle(_(", ending their %d frag spree"), _(", ending their %d score spree")), f1) : ""))
+ ADD_ARG_CASE("spree_lost", ((f1 >= 3) ? sprintf(normal_or_gentle(_(", losing their %d frag spree"), _(", losing their %d score spree")), f1) : ""))
+ ADD_ARG_CASE("death_team", Team_ColoredFullName(f1))
+ ADD_ARG_CASE("weapon_name", ftos(f1)) // weaponorder[f1].netname
+ #endif
+
+ #undef ADD_ARG_CASE
+ default: { print("Hit unknown token in selected string! '", selected, "'\n"); break; }
+ }
+ if(sel_num == 7) { print("Hit maximum arguments!\n"); break; }
+ }
+
+ return sprintf(CCR(input), arg_slot[0], arg_slot[1], arg_slot[2], arg_slot[3], arg_slot[4], arg_slot[5], arg_slot[6], arg_slot[7]);
+ }
+
+ return "";
+}
+
// get the actual name of a notification and return it as a string
string Get_Field_Value(float field, float net_type, float net_name)
{
#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)
#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) && (centername == NO_MSG) \
- print(strcat("^1NOTIFICATION WITH NO SUBCALLS: ^7net_type = ", #net_type, ", net_name = ", #net_name, ".\n")); \
- #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;
+.float nent_stringcount;
+.float nent_floatcount;
+.string nent_strings[4];
+.float nent_floats[4];
+
+.string nent_name;
+.string nent_args;
+.string nent_hudargs;
+.string nent_icon;
+.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; } \
+
+#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; \
{ \
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, TRUE, FALSE) \
} \
ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
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, FALSE, FALSE) \
} \
ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
{ \
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, \
+ "", "", FALSE, TRUE) \
} \
ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
{ \
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, \
+ "", "", FALSE, TRUE) \
} \
ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)