Commit dbd2c0bd authored by terencehill's avatar terencehill

Handle notifications with team information with a single cvar instead of one...

Handle notifications with team information with a single cvar instead of one per team. Say goodbye to 156 cvars!
parent 4e7cb7b9
This diff is collapsed.
......@@ -553,7 +553,7 @@ void ons_ControlPoint_Icon_BuildThink(entity this)
if(IS_PLAYER(this.owner.ons_toucher))
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM), this.owner.message);
Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
......
This diff is collapsed.
......@@ -148,6 +148,7 @@ 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);
......@@ -398,7 +399,9 @@ void Create_Notification_Entity(entity notif,
float var_default,
float var_cvar,
MSG typeId,
string namestring)
string namestring,
string cvarnamestring,
int teamnum)
{
// =====================
// Global Entity Setup
......@@ -407,6 +410,9 @@ 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
notif_error = false;
......@@ -761,13 +767,14 @@ void Create_Notification_Entity_Choice(entity notif,
#ifdef SVQC
void Notification_GetCvars(entity this)
{
FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
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);
GetCvars_handleFloat(
this,
get_cvars_s,
get_cvars_f,
msg_choice_choices[it.nent_choice_idx],
sprintf("notification_%s", it.nent_name)
sprintf("notification_%s", cvarname)
);
});
}
......@@ -782,19 +789,21 @@ 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", \
e.nent_name, e.nent_default, description \
cvarname, 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", \
e.nent_name, e.nent_default, descriptiona, \
e.nent_name, e.nent_challow_def, descriptionb \
cvarname, e.nent_default, descriptiona, \
cvarname, e.nent_challow_def, descriptionb \
); \
NOTIF_WRITE(notif_msg); \
} MACRO_END
......@@ -831,7 +840,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, {
FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == 1), {
NOTIF_WRITE_ENTITY(it,
"0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
);
......@@ -839,7 +848,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, {
FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == 1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = print to console, "
"2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
......@@ -848,7 +857,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, {
FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == 1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = centerprint"
);
......@@ -856,7 +865,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, {
FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == 1), {
NOTIF_WRITE_ENTITY(it,
"Enable this multiple notification"
);
......@@ -864,7 +873,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, {
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == 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"
......@@ -876,7 +885,7 @@ void Dump_Notifications(int fh, bool alsoprint)
NOTIF_WRITE_HARDCODED(
"allow_chatboxprint", "1",
"Allow INFO notifications to be printed to chat box"
"Allow INFO notifications to be printed to chat box "
"0 = do not allow, "
"1 = allow only if allowed by individual notification_INFO* cvars, "
"2 = force all INFO notifications to be printed to the chatbox"
......@@ -1367,7 +1376,8 @@ 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))) {
switch (cvar(sprintf("notification_%s", notif.nent_name)))
string cvarname = (notif.nent_cvarname ? notif.nent_cvarname : notif.nent_name);
switch (cvar(sprintf("notification_%s", cvarname)))
{
case 1: break;
case 2: found_choice = notif.nent_optionb; break;
......
......@@ -109,7 +109,9 @@ void Create_Notification_Entity(entity notif,
float var_default,
float var_cvar,
MSG typeId,
string namestring);
string namestring,
string cvarnamestring,
int teamnum);
void Create_Notification_Entity_Annce(entity notif,
float var_cvar,
string namestring,
......@@ -628,8 +630,10 @@ 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;
// MSG_ANNCE entity values
.int nent_channel;
......@@ -703,26 +707,34 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
return it;
}
#define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, default, sound, channel, volume, position) \
MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, default, sound, channel, volume, position)
#define MSG_ANNCE_NOTIF(name, default, sound, channel, volume, position) \
MSG_ANNCE_NOTIF_(ANNCE_##name, default, sound, channel, volume, position)
#define MSG_ANNCE_NOTIF_(name, default, sound, channel, volume, position) \
NOTIF_ADD_AUTOCVAR(name, default) \
NOTIF_ADD_AUTOCVAR(ANNCE_##name, default) \
MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, default, sound, channel, volume, position)
#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(name), MSG_ANNCE, strtoupper(#name)); \
Create_Notification_Entity_Annce(this, ACVNN(name), strtoupper(#name), \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity_Annce(this, ACVNN(cvarname), strtoupper(#name), \
channel, /* channel */ \
sound, /* snd */ \
volume, /* vol */ \
position); /* position */ \
}
#define MSG_INFO_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
MSG_INFO_NOTIF_(teamnum, INFO_##name, INFO_##cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle)
#define MSG_INFO_NOTIF(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
MSG_INFO_NOTIF_(INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle)
#define MSG_INFO_NOTIF_(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
NOTIF_ADD_AUTOCVAR(name, default) \
NOTIF_ADD_AUTOCVAR(INFO_##name, default) \
MSG_INFO_NOTIF_(0, INFO_##name, INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle)
#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(name), MSG_INFO, strtoupper(#name)); \
Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_INFO, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
args, /* args */ \
hudargs, /* hudargs */ \
icon, /* icon */ \
......@@ -738,7 +750,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)); \
Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name), #name, 0); \
Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
args, /* args */ \
hudargs, /* hudargs */ \
......@@ -750,13 +762,17 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
this.nent_iconargs = iconargs; \
}
#define MSG_CENTER_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
MSG_CENTER_NOTIF_(teamnum, CENTER_##name, CENTER_##cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
#define MSG_CENTER_NOTIF(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
MSG_CENTER_NOTIF_(CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
#define MSG_CENTER_NOTIF_(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
NOTIF_ADD_AUTOCVAR(name, default) \
NOTIF_ADD_AUTOCVAR(CENTER_##name, default) \
MSG_CENTER_NOTIF_(0, CENTER_##name, CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
#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(name), MSG_CENTER, strtoupper(#name)); \
Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
args, /* args */ \
"", /* hudargs */ \
"", /* icon */ \
......@@ -769,24 +785,28 @@ 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)); \
Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name), #name, 0); \
Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \
anncename, /* anncename */ \
infoname, /* infoname */ \
centername); /* centername */ \
}
#define MSG_CHOICE_NOTIF_TEAM(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \
MSG_CHOICE_NOTIF_(teamnum, CHOICE_##name, CHOICE_##cvarname, default, challow, chtype, optiona, optionb)
#define MSG_CHOICE_NOTIF(name, default, challow, chtype, optiona, optionb) \
MSG_CHOICE_NOTIF_(CHOICE_##name, default, challow, chtype, optiona, optionb)
#define MSG_CHOICE_NOTIF_(name, default, challow, chtype, optiona, optionb) \
NOTIF_ADD_AUTOCVAR(name, default) \
NOTIF_ADD_AUTOCVAR(name##_ALLOWED, challow) \
NOTIF_ADD_AUTOCVAR(CHOICE_##name, default) \
NOTIF_ADD_AUTOCVAR(CHOICE_##name##_ALLOWED, challow) \
MSG_CHOICE_NOTIF_(0, CHOICE_##name, CHOICE_##name, default, challow, chtype, optiona, optionb)
#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(name), MSG_CHOICE, strtoupper(#name)); \
Create_Notification_Entity_Choice(this, ACVNN(name), strtoupper(#name), \
Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), #cvarname, teamnum); \
Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \
challow, /* challow_def */ \
autocvar_notification_##name##_ALLOWED, /* challow_var */ \
autocvar_notification_##cvarname##_ALLOWED, /* challow_var */ \
chtype, /* chtype */ \
optiona, /* optiona */ \
optionb); /* optionb */ \
......
......@@ -64,8 +64,8 @@ void XonoticGameMessageSettingsTab_fill(entity me)
me.gotoRC(me, 9, 0); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Gamemode Settings")));
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_CAPTURE_TIME_RED", _("Display capture times in Capture The Flag"), "-"));
makeMulti(e, "notification_CHOICE_CTF_CAPTURE_TIME_BLUE notification_CHOICE_CTF_CAPTURE_TIME_YELLOW notification_CHOICE_CTF_CAPTURE_TIME_PINK notification_CHOICE_CTF_CAPTURE_BROKEN_RED notification_CHOICE_CTF_CAPTURE_BROKEN_BLUE notification_CHOICE_CTF_CAPTURE_BROKEN_YELLOW notification_CHOICE_CTF_CAPTURE_BROKEN_PINK notification_CHOICE_CTF_CAPTURE_UNBROKEN_RED notification_CHOICE_CTF_CAPTURE_UNBROKEN_BLUE notification_CHOICE_CTF_CAPTURE_UNBROKEN_YELLOW notification_CHOICE_CTF_CAPTURE_UNBROKEN_PINK");
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_CAPTURE_TIME", _("Display capture times in Capture The Flag"), "-"));
makeMulti(e, "notification_CHOICE_CTF_CAPTURE_BROKEN notification_CHOICE_CTF_CAPTURE_UNBROKEN");
e.sendCvars = true;
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_PICKUP_ENEMY", _("Display name of flag stealer in Capture The Flag"), "-"));
......@@ -80,7 +80,7 @@ void XonoticGameMessageSettingsTab_fill(entity me)
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_allow_chatboxprint", _("Display all info messages in the chatbox"), "-"));
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_INFO_QUIT_DISCONNECT", _("Display player statuses in the chatbox"), "-"));
makeMulti(e, "notification_INFO_QUIT_KICK_IDLING notification_INFO_JOIN_CONNECT_TEAM_BLUE notification_INFO_JOIN_CONNECT_TEAM_PINK notification_INFO_JOIN_CONNECT_TEAM_RED notification_INFO_JOIN_CONNECT_TEAM_YELLOW");
makeMulti(e, "notification_INFO_QUIT_KICK_IDLING notification_INFO_JOIN_CONNECT_TEAM");
me.TR(me);
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox_T(0, "notification_CENTER_POWERUP_INVISIBILITY", _("Powerup notifications"), "-"));
......
......@@ -703,7 +703,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype)
else if(CTF_DIFFTEAM(player, flag))
Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_NUM(flag.team, CENTER_CTF_PICKUP));
else
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_TEAM : CENTER_CTF_PICKUP_TEAM_ENEMY), Team_ColorCode(flag.team));
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_RETURN : CENTER_CTF_PICKUP_RETURN_ENEMY), Team_ColorCode(flag.team));
Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, APP_NUM(flag.team, CHOICE_CTF_PICKUP_TEAM), Team_ColorCode(player.team), player.netname);
......
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