overriding message suppression, revisited

This is more robust than the previous hack.  The issue of whether to
use it in other places is still unexplored.  Ultimately it's the user's
fault if overzealous message suppression hides something important.
[For an eerie game, try 'MSGTYPE=hide .'.]
This commit is contained in:
PatR
2016-01-19 18:16:13 -08:00
parent 7482be39e8
commit 2e2b54e548
6 changed files with 46 additions and 25 deletions

View File

@@ -1500,6 +1500,8 @@ boolean norepeat; /* called from Norep(via pline) */
struct plinemsg_type *tmp = plinemsg_types;
while (tmp) {
/* we don't exclude entries with negative msgtype values
because then the msg might end up matching a later pattern */
if (regex_match(msg, tmp->regex))
return tmp->msgtype;
tmp = tmp->next;
@@ -1507,6 +1509,26 @@ boolean norepeat; /* called from Norep(via pline) */
return norepeat ? MSGTYP_NOREP : MSGTYP_NORMAL;
}
/* negate one or more types of messages so that their type handling will
be disabled or re-enabled; MSGTYPE_NORMAL (value 0) is not affected */
void
hide_unhide_msgtypes(hide, hide_mask)
boolean hide;
int hide_mask;
{
struct plinemsg_type *tmp;
int mt;
/* negative msgtype value won't be recognized by pline, so does nothing */
for (tmp = plinemsg_types; tmp; tmp = tmp->next) {
mt = tmp->msgtype;
if (!hide)
mt = -mt; /* unhide: negate negative, yielding positive */
if (mt > 0 && ((1 << mt) & hide_mask))
tmp->msgtype = -tmp->msgtype;
}
}
int
msgtype_count()
{