Commit 9d8065bf authored by terencehill's avatar terencehill

Remove nent_cvarname field, get the cvar name from nent_name

parent dbd2c0bd
Pipeline #5696680 passed with stage
in 13 minutes and 6 seconds
......@@ -88,14 +88,14 @@
*/
#define MULTITEAM_ANNCE2(prefix, default, sound, channel, volume, position) \
MSG_ANNCE_NOTIF_TEAM(1, prefix##_RED, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_1)), channel, volume, position) \
MSG_ANNCE_NOTIF_TEAM(2, prefix##_BLUE, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_2)), channel, volume, position)
MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_1)), channel, volume, position) \
MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_2)), channel, volume, position)
#define MULTITEAM_ANNCE3(prefix, default, sound, channel, volume, position) \
MULTITEAM_ANNCE2(prefix, default, sound, channel, volume, position) \
MSG_ANNCE_NOTIF_TEAM(3, prefix##_YELLOW, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_3)), channel, volume, position)
MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_3)), channel, volume, position)
#define MULTITEAM_ANNCE4(prefix, default, sound, channel, volume, position) \
MULTITEAM_ANNCE3(prefix, default, sound, channel, volume, position) \
MSG_ANNCE_NOTIF_TEAM(4, prefix##_PINK, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_4)), channel, volume, position)
MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, default, sprintf(sound, strtolower(STATIC_NAME_TEAM_4)), channel, volume, position)
#define MULTITEAM_ANNCE(prefix, teams, default, sound, channel, volume, position) \
NOTIF_ADD_AUTOCVAR(ANNCE_##prefix, default) \
MULTITEAM_ANNCE##teams(prefix, default, sound, channel, volume, position)
......@@ -207,14 +207,14 @@
MSG_ANNCE_NOTIF(VOTE_FAIL, 2, "votefail", CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
#define MULTITEAM_INFO2(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
MSG_INFO_NOTIF_TEAM(1, prefix##_RED, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_1)), TCR(normal, type, 1), TCR(gentle, type, 1)) \
MSG_INFO_NOTIF_TEAM(2, prefix##_BLUE, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_2)), TCR(normal, type, 2), TCR(gentle, type, 2))
MSG_INFO_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_1)), TCR(normal, type, 1), TCR(gentle, type, 1)) \
MSG_INFO_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_2)), TCR(normal, type, 2), TCR(gentle, type, 2))
#define MULTITEAM_INFO3(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
MULTITEAM_INFO2(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
MSG_INFO_NOTIF_TEAM(3, prefix##_YELLOW, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_3)), TCR(normal, type, 3), TCR(gentle, type, 3))
MSG_INFO_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_3)), TCR(normal, type, 3), TCR(gentle, type, 3))
#define MULTITEAM_INFO4(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
MULTITEAM_INFO3(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
MSG_INFO_NOTIF_TEAM(4, prefix##_PINK, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_4)), TCR(normal, type, 4), TCR(gentle, type, 4))
MSG_INFO_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, default, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_4)), TCR(normal, type, 4), TCR(gentle, type, 4))
#define MULTITEAM_INFO(prefix, teams, default, strnum, flnum, args, hudargs, icon, normal, gentle, type) \
NOTIF_ADD_AUTOCVAR(INFO_##prefix, default) \
MULTITEAM_INFO##teams(prefix, default, strnum, flnum, args, hudargs, icon, normal, gentle, type)
......@@ -495,14 +495,14 @@
MSG_INFO_NOTIF(WEAPON_VORTEX_MURDER, 1, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "weaponnex", _("^BG%s%s^K1 has been vaporized by ^BG%s^K1's Vortex%s%s"), "")
#define MULTITEAM_CENTER2(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
MSG_CENTER_NOTIF_TEAM(1, prefix##_RED, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 1), TCR(gentle, type, 1)) \
MSG_CENTER_NOTIF_TEAM(2, prefix##_BLUE, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 2), TCR(gentle, type, 2))
MSG_CENTER_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 1), TCR(gentle, type, 1)) \
MSG_CENTER_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 2), TCR(gentle, type, 2))
#define MULTITEAM_CENTER3(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
MULTITEAM_CENTER2(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
MSG_CENTER_NOTIF_TEAM(3, prefix##_YELLOW, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 3), TCR(gentle, type, 3))
MSG_CENTER_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 3), TCR(gentle, type, 3))
#define MULTITEAM_CENTER4(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
MULTITEAM_CENTER3(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
MSG_CENTER_NOTIF_TEAM(4, prefix##_PINK, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 4), TCR(gentle, type, 4))
MSG_CENTER_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, default, strnum, flnum, args, cpid, durcnt, TCR(normal, type, 4), TCR(gentle, type, 4))
#define MULTITEAM_CENTER(prefix, teams, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type) \
NOTIF_ADD_AUTOCVAR(CENTER_##prefix, default) \
MULTITEAM_CENTER##teams(prefix, default, strnum, flnum, args, cpid, durcnt, normal, gentle, type)
......@@ -935,14 +935,14 @@
MSG_MULTI_NOTIF(WEAPON_VORTEX_MURDER, 1, NULL, INFO_WEAPON_VORTEX_MURDER, NULL)
#define MULTITEAM_CHOICE2(prefix, default, challow, chtype, optiona, optionb) \
MSG_CHOICE_NOTIF_TEAM(1, prefix##_RED, prefix, default, challow, chtype, optiona##_RED, optionb##_RED) \
MSG_CHOICE_NOTIF_TEAM(2, prefix##_BLUE, prefix, default, challow, chtype, optiona##_BLUE, optionb##_BLUE)
MSG_CHOICE_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, default, challow, chtype, optiona##_RED, optionb##_RED) \
MSG_CHOICE_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, default, challow, chtype, optiona##_BLUE, optionb##_BLUE)
#define MULTITEAM_CHOICE3(prefix, default, challow, chtype, optiona, optionb) \
MULTITEAM_CHOICE2(prefix, default, challow, chtype, optiona, optionb) \
MSG_CHOICE_NOTIF_TEAM(3, prefix##_YELLOW, prefix, default, challow, chtype, optiona##_YELLOW, optionb##_YELLOW)
MSG_CHOICE_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, default, challow, chtype, optiona##_YELLOW, optionb##_YELLOW)
#define MULTITEAM_CHOICE4(prefix, default, challow, chtype, optiona, optionb) \
MULTITEAM_CHOICE3(prefix, default, challow, chtype, optiona, optionb) \
MSG_CHOICE_NOTIF_TEAM(4, prefix##_PINK, prefix, default, challow, chtype, optiona##_PINK, optionb##_PINK)
MSG_CHOICE_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, default, challow, chtype, optiona##_PINK, optionb##_PINK)
#define MULTITEAM_CHOICE(prefix, teams, default, challow, chtype, optiona, optionb) \
NOTIF_ADD_AUTOCVAR(CHOICE_##prefix, default) \
NOTIF_ADD_AUTOCVAR(CHOICE_##prefix##_ALLOWED, challow) \
......
......@@ -148,7 +148,6 @@ bool Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cli
void Destroy_Notification_Entity(entity notif)
{
if (notif.nent_name != "") strunzone(notif.nent_name);
if (notif.nent_cvarname != "") strunzone(notif.nent_cvarname);
if (notif.nent_snd != "") strunzone(notif.nent_snd);
if (notif.nent_args != "") strunzone(notif.nent_args);
if (notif.nent_hudargs != "") strunzone(notif.nent_hudargs);
......@@ -400,7 +399,6 @@ void Create_Notification_Entity(entity notif,
float var_cvar,
MSG typeId,
string namestring,
string cvarnamestring,
int teamnum)
{
// =====================
......@@ -410,8 +408,6 @@ void Create_Notification_Entity(entity notif,
notif.nent_enabled = (var_cvar >= 1);
notif.nent_type = typeId;
notif.nent_name = strzone(namestring);
if(namestring != cvarnamestring)
notif.nent_cvarname = strzone(cvarnamestring);
notif.nent_teamnum = teamnum;
// Other pre-notif-setup requisites
......@@ -767,14 +763,13 @@ void Create_Notification_Entity_Choice(entity notif,
#ifdef SVQC
void Notification_GetCvars(entity this)
{
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == 1), {
string cvarname = (it.nent_cvarname ? it.nent_cvarname : it.nent_name);
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
GetCvars_handleFloat(
this,
get_cvars_s,
get_cvars_f,
msg_choice_choices[it.nent_choice_idx],
sprintf("notification_%s", cvarname)
sprintf("notification_%s", Get_Notif_CvarName(it))
);
});
}
......@@ -789,21 +784,19 @@ void Dump_Notifications(int fh, bool alsoprint)
} MACRO_END
#define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN { \
string cvarname = (e.nent_cvarname ? e.nent_cvarname : e.nent_name); \
string notif_msg = sprintf( \
"seta notification_%s \"%d\" \"%s\"\n", \
cvarname, e.nent_default, description \
Get_Notif_CvarName(e), e.nent_default, description \
); \
NOTIF_WRITE(notif_msg); \
} MACRO_END
#define NOTIF_WRITE_ENTITY_CHOICE(e, descriptiona, descriptionb) MACRO_BEGIN { \
string cvarname = (e.nent_cvarname ? e.nent_cvarname : e.nent_name); \
string notif_msg = sprintf( \
"seta notification_%s \"%d\" \"%s\"\n" \
"seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
cvarname, e.nent_default, descriptiona, \
cvarname, e.nent_challow_def, descriptionb \
Get_Notif_CvarName(e), e.nent_default, descriptiona, \
Get_Notif_CvarName(e), e.nent_challow_def, descriptionb \
); \
NOTIF_WRITE(notif_msg); \
} MACRO_END
......@@ -840,7 +833,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_ANNCE_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_ANNCE, { ++NOTIF_ANNCE_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == 1), {
FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
);
......@@ -848,7 +841,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_INFO_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_INFO, { ++NOTIF_INFO_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == 1), {
FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = print to console, "
"2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
......@@ -857,7 +850,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_CENTER_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_CENTER, { ++NOTIF_CENTER_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == 1), {
FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = centerprint"
);
......@@ -865,7 +858,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_MULTI_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_MULTI, { ++NOTIF_MULTI_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == 1), {
FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"Enable this multiple notification"
);
......@@ -873,7 +866,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_CHOICE_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_CHOICE, { ++NOTIF_CHOICE_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == 1), {
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY_CHOICE(it,
"Choice for this notification 0 = off, 1 = default message, 2 = verbose message",
"Allow choice for this notification 0 = off, 1 = only in warmup mode, 2 = always"
......@@ -1376,8 +1369,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
{
entity found_choice = notif.nent_optiona;
if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) {
string cvarname = (notif.nent_cvarname ? notif.nent_cvarname : notif.nent_name);
switch (cvar(sprintf("notification_%s", cvarname)))
switch (cvar(sprintf("notification_%s", Get_Notif_CvarName(notif))))
{
case 1: break;
case 2: found_choice = notif.nent_optionb; break;
......
......@@ -110,7 +110,6 @@ void Create_Notification_Entity(entity notif,
float var_cvar,
MSG typeId,
string namestring,
string cvarnamestring,
int teamnum);
void Create_Notification_Entity_Annce(entity notif,
float var_cvar,
......@@ -630,7 +629,6 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
.bool nent_enabled;
.MSG nent_type;
.string nent_name;
.string nent_cvarname;
.int nent_stringcount;
.int nent_floatcount;
.bool nent_teamnum;
......@@ -693,6 +691,13 @@ STATIC_INIT_LATE(Notif_Choices) {
}
}
string Get_Notif_CvarName(Notification notif)
{
if(!notif.nent_teamnum)
return notif.nent_name;
return substring(notif.nent_name, 0, -strlen(Static_Team_ColorName(notif.nent_teamnum)) - 2);
}
Notification Get_Notif_Ent(MSG net_type, int net_name)
{
Notification it = _Notifications_from(net_name, NULL);
......@@ -716,7 +721,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, default, sound, channel, volume, position) \
REGISTER(Notifications, name, m_id, new_pure(msg_annce_notification)) { \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), teamnum); \
Create_Notification_Entity_Annce(this, ACVNN(cvarname), strtoupper(#name), \
channel, /* channel */ \
sound, /* snd */ \
......@@ -733,7 +738,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MSG_INFO_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_INFO, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_INFO, strtoupper(#name), teamnum); \
Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
args, /* args */ \
hudargs, /* hudargs */ \
......@@ -750,7 +755,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MULTIICON_INFO_(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
NOTIF_ADD_AUTOCVAR(name, default) \
REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \
Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name), #name, 0); \
Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name), 0); \
Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
args, /* args */ \
hudargs, /* hudargs */ \
......@@ -771,7 +776,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MSG_CENTER_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
REGISTER(Notifications, name, m_id, new_pure(msg_center_notification)) { \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), teamnum); \
Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
args, /* args */ \
"", /* hudargs */ \
......@@ -785,7 +790,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MSG_MULTI_NOTIF(name, default, anncename, infoname, centername) \
NOTIF_ADD_AUTOCVAR(name, default) \
REGISTER(Notifications, name, m_id, new_pure(msg_multi_notification)) { \
Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name), #name, 0); \
Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name), 0); \
Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \
anncename, /* anncename */ \
infoname, /* infoname */ \
......@@ -803,7 +808,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
#define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \
REGISTER(Notifications, name, m_id, new_pure(msg_choice_notification)) { \
this.nent_choice_idx = nent_choice_count++; \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), teamnum); \
Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \
challow, /* challow_def */ \
autocvar_notification_##cvarname##_ALLOWED, /* challow_var */ \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment