From 458be36a321615c0f3004a6abde7e14d40f5da32 Mon Sep 17 00:00:00 2001 From: Adam- Date: Sun, 8 Nov 2009 20:06:21 +0000 Subject: Rewrote all of the old C style flag systems into a new Flag class which everything inherits from. This breaks reading and writing flags to the old databases (and probably many other things aswell) - Don't use it git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2636 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/bs_assign.c | 4 +-- src/core/bs_badwords.c | 2 +- src/core/bs_botlist.c | 4 +-- src/core/bs_info.c | 34 +++++++++---------- src/core/bs_kick.c | 32 +++++++++--------- src/core/bs_set.c | 28 ++++++++-------- src/core/cs_access.c | 10 +++--- src/core/cs_akick.c | 61 ++++++++++++++++------------------ src/core/cs_ban.c | 6 ++-- src/core/cs_drop.c | 10 +++--- src/core/cs_forbid.c | 2 +- src/core/cs_info.c | 37 +++++++++++---------- src/core/cs_kick.c | 6 ++-- src/core/cs_list.c | 26 +++++++++------ src/core/cs_modes.c | 25 +++++++------- src/core/cs_set.c | 88 +++++++++++++++++++++----------------------------- src/core/cs_suspend.c | 8 ++--- src/core/cs_xop.c | 4 +-- src/core/hs_del.c | 2 +- src/core/hs_delall.c | 2 +- src/core/hs_set.c | 2 +- src/core/hs_setall.c | 2 +- src/core/ms_cancel.c | 2 +- src/core/ms_check.c | 4 +-- src/core/ms_info.c | 28 ++++++++-------- src/core/ms_list.c | 6 ++-- src/core/ms_read.c | 6 ++-- src/core/ms_set.c | 31 ++++++++++-------- src/core/ns_access.c | 8 ++--- src/core/ns_alist.c | 8 ++--- src/core/ns_drop.c | 2 +- src/core/ns_forbid.c | 2 +- src/core/ns_getpass.c | 2 +- src/core/ns_ghost.c | 6 ++-- src/core/ns_group.c | 11 +++---- src/core/ns_identify.c | 6 ++-- src/core/ns_info.c | 20 ++++++------ src/core/ns_list.c | 38 +++++++++++----------- src/core/ns_logout.c | 2 +- src/core/ns_recover.c | 6 ++-- src/core/ns_register.c | 5 +-- src/core/ns_release.c | 8 ++--- src/core/ns_saset.c | 50 +++++++++++++++------------- src/core/ns_sendpass.c | 2 +- src/core/ns_set.c | 46 ++++++++++++++------------ src/core/ns_suspend.c | 14 ++++---- src/core/os_jupe.c | 2 +- src/core/os_svsnick.c | 2 +- 48 files changed, 355 insertions(+), 357 deletions(-) (limited to 'src/core') diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index 1ca280c4c..e6d619095 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -43,13 +43,13 @@ class CommandBSAssign : public Command ci = cs_findchan(chan); - if ((ci->botflags & BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration"))) + if (ci->botflags.HasFlag(BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration"))) { notice_lang(s_BotServ, u, ACCESS_DENIED); return MOD_CONT; } - if (bi->flags & BI_PRIVATE && !u->nc->HasCommand("botserv/assign/private")) + if (bi->HasFlag(BI_PRIVATE) && !u->nc->HasCommand("botserv/assign/private")) { notice_lang(s_BotServ, u, ACCESS_DENIED); return MOD_CONT; diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index 8c07fb36a..405dbf2a6 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -57,7 +57,7 @@ class CommandBSBadwords : public Command CommandReturn DoAdd(User *u, ChannelInfo *ci, const char *word) { char *opt, *pos; - int type = BW_ANY; + BadWordType type = BW_ANY; unsigned i = 0; BadWord *bw; diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 79902a752..c29ce19ee 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -34,7 +34,7 @@ class CommandBSBotList : public Command for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { - if (!(bi->flags & BI_PRIVATE)) { + if (!(bi->HasFlag(BI_PRIVATE))) { if (!count) notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); count++; @@ -48,7 +48,7 @@ class CommandBSBotList : public Command for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { - if (bi->flags & BI_PRIVATE) { + if (bi->HasFlag(BI_PRIVATE)) { u->SendMessage(s_BotServ, " %-15s (%s@%s)", bi->nick, bi->user, bi->host); count++; } diff --git a/src/core/bs_info.c b/src/core/bs_info.c index 64d999768..0ea8a5791 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -72,11 +72,7 @@ class CommandBSInfo : public Command tm = localtime(&bi->created); strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); - notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, - getstring(u, - (bi-> - flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : - BOT_INFO_OPT_NONE)); + notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, getstring(u, (bi->HasFlag(BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : BOT_INFO_OPT_NONE))); notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount); if (u->nc->HasPriv("botserv/administration")) @@ -96,7 +92,7 @@ class CommandBSInfo : public Command else notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); - if (ci->botflags & BS_KICK_BADWORDS) { + if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { if (ci->ttb[TTB_BADWORDS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -107,7 +103,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_BOLDS) { + if (ci->botflags.HasFlag(BS_KICK_BOLDS)) { if (ci->ttb[TTB_BOLDS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -118,7 +114,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_CAPS) { + if (ci->botflags.HasFlag(BS_KICK_CAPS)) { if (ci->ttb[TTB_CAPS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -131,7 +127,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_COLORS) { + if (ci->botflags.HasFlag(BS_KICK_COLORS)) { if (ci->ttb[TTB_COLORS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -142,7 +138,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_FLOOD) { + if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { if (ci->ttb[TTB_FLOOD]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -155,7 +151,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REPEAT) { + if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { if (ci->ttb[TTB_REPEAT]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -167,7 +163,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REVERSES) { + if (ci->botflags.HasFlag(BS_KICK_REVERSES)) { if (ci->ttb[TTB_REVERSES]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, getstring(u, BOT_INFO_ACTIVE), @@ -178,7 +174,7 @@ class CommandBSInfo : public Command } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_UNDERLINES) { + if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) { if (ci->ttb[TTB_UNDERLINES]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES_BAN, @@ -193,36 +189,36 @@ class CommandBSInfo : public Command end = buf; *end = 0; - if (ci->botflags & BS_DONTKICKOPS) { + if (ci->botflags.HasFlag(BS_DONTKICKOPS)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s", getstring(u, BOT_INFO_OPT_DONTKICKOPS)); need_comma = 1; } - if (ci->botflags & BS_DONTKICKVOICES) { + if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); need_comma = 1; } - if (ci->botflags & BS_FANTASY) { + if (ci->botflags.HasFlag(BS_FANTASY)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_FANTASY)); need_comma = 1; } - if (ci->botflags & BS_GREET) { + if (ci->botflags.HasFlag(BS_GREET)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_GREET)); need_comma = 1; } - if (ci->botflags & BS_NOBOT) { + if (ci->botflags.HasFlag(BS_NOBOT)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_NOBOT)); need_comma = 1; } - if (ci->botflags & BS_SYMBIOSIS) { + if (ci->botflags.HasFlag(BS_SYMBIOSIS)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_SYMBIOSIS)); diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index bd03ff006..0ce210019 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -65,14 +65,14 @@ class CommandBSKick : public Command } else { ci->ttb[TTB_BADWORDS] = 0; } - ci->botflags |= BS_KICK_BADWORDS; + ci->botflags.SetFlag(BS_KICK_BADWORDS); if (ci->ttb[TTB_BADWORDS]) notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]); else notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON); } else { - ci->botflags &= ~BS_KICK_BADWORDS; + ci->botflags.UnsetFlag(BS_KICK_BADWORDS); notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF); } } else if (option == "BOLDS") { @@ -91,14 +91,14 @@ class CommandBSKick : public Command } } else ci->ttb[TTB_BOLDS] = 0; - ci->botflags |= BS_KICK_BOLDS; + ci->botflags.SetFlag(BS_KICK_BOLDS); if (ci->ttb[TTB_BOLDS]) notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]); else notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON); } else { - ci->botflags &= ~BS_KICK_BOLDS; + ci->botflags.UnsetFlag(BS_KICK_BOLDS); notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF); } } else if (option == "CAPS") { @@ -135,7 +135,7 @@ class CommandBSKick : public Command if (ci->capspercent < 1 || ci->capspercent > 100) ci->capspercent = 25; - ci->botflags |= BS_KICK_CAPS; + ci->botflags.SetFlag(BS_KICK_CAPS); if (ci->ttb[TTB_CAPS]) notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, @@ -144,7 +144,7 @@ class CommandBSKick : public Command notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent); } else { - ci->botflags &= ~BS_KICK_CAPS; + ci->botflags.UnsetFlag(BS_KICK_CAPS); notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF); } } else if (option == "COLORS") { @@ -163,14 +163,14 @@ class CommandBSKick : public Command } } else ci->ttb[TTB_COLORS] = 0; - ci->botflags |= BS_KICK_COLORS; + ci->botflags.SetFlag(BS_KICK_COLORS); if (ci->ttb[TTB_COLORS]) notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]); else notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON); } else { - ci->botflags &= ~BS_KICK_COLORS; + ci->botflags.UnsetFlag(BS_KICK_COLORS); notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF); } } else if (option == "FLOOD") { @@ -207,7 +207,7 @@ class CommandBSKick : public Command if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData) ci->floodsecs = 10; - ci->botflags |= BS_KICK_FLOOD; + ci->botflags.SetFlag(BS_KICK_FLOOD); if (ci->ttb[TTB_FLOOD]) notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, @@ -216,7 +216,7 @@ class CommandBSKick : public Command notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs); } else { - ci->botflags &= ~BS_KICK_FLOOD; + ci->botflags.UnsetFlag(BS_KICK_FLOOD); notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF); } } else if (option == "REPEAT") { @@ -245,7 +245,7 @@ class CommandBSKick : public Command if (ci->repeattimes < 2) ci->repeattimes = 3; - ci->botflags |= BS_KICK_REPEAT; + ci->botflags.SetFlag(BS_KICK_REPEAT); if (ci->ttb[TTB_REPEAT]) notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]); @@ -253,7 +253,7 @@ class CommandBSKick : public Command notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON, ci->repeattimes); } else { - ci->botflags &= ~BS_KICK_REPEAT; + ci->botflags.UnsetFlag(BS_KICK_REPEAT); notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF); } } else if (option == "REVERSES") { @@ -273,14 +273,14 @@ class CommandBSKick : public Command } } else ci->ttb[TTB_REVERSES] = 0; - ci->botflags |= BS_KICK_REVERSES; + ci->botflags.SetFlag(BS_KICK_REVERSES); if (ci->ttb[TTB_REVERSES]) notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]); else notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON); } else { - ci->botflags &= ~BS_KICK_REVERSES; + ci->botflags.UnsetFlag(BS_KICK_REVERSES); notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF); } } else if (option == "UNDERLINES") { @@ -300,14 +300,14 @@ class CommandBSKick : public Command } } else ci->ttb[TTB_UNDERLINES] = 0; - ci->botflags |= BS_KICK_UNDERLINES; + ci->botflags.SetFlag(BS_KICK_UNDERLINES); if (ci->ttb[TTB_UNDERLINES]) notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]); else notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON); } else { - ci->botflags &= ~BS_KICK_UNDERLINES; + ci->botflags.UnsetFlag(BS_KICK_UNDERLINES); notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF); } } else diff --git a/src/core/bs_set.c b/src/core/bs_set.c index 7c5366003..d5d40abd5 100644 --- a/src/core/bs_set.c +++ b/src/core/bs_set.c @@ -48,12 +48,12 @@ class CommandBSSet : public Command if (value == "ON") { - bi->flags |= BI_PRIVATE; + bi->SetFlag(BI_PRIVATE); notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick); } else if (value == "OFF") { - bi->flags &= ~BI_PRIVATE; + bi->UnsetFlag(BI_PRIVATE); notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick); } else @@ -68,11 +68,11 @@ class CommandBSSet : public Command else { if (option == "DONTKICKOPS") { if (value == "ON") { - ci->botflags |= BS_DONTKICKOPS; + ci->botflags.SetFlag(BS_DONTKICKOPS); notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_DONTKICKOPS; + ci->botflags.UnsetFlag(BS_DONTKICKOPS); notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, ci->name); } else { @@ -81,11 +81,11 @@ class CommandBSSet : public Command } } else if (option == "DONTKICKVOICES") { if (value == "ON") { - ci->botflags |= BS_DONTKICKVOICES; + ci->botflags.SetFlag(BS_DONTKICKVOICES); notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_DONTKICKVOICES; + ci->botflags.UnsetFlag(BS_DONTKICKVOICES); notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, ci->name); } else { @@ -94,10 +94,10 @@ class CommandBSSet : public Command } } else if (option == "FANTASY") { if (value == "ON") { - ci->botflags |= BS_FANTASY; + ci->botflags.SetFlag(BS_FANTASY); notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_FANTASY; + ci->botflags.UnsetFlag(BS_FANTASY); notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET FANTASY", @@ -105,10 +105,10 @@ class CommandBSSet : public Command } } else if (option == "GREET") { if (value == "ON") { - ci->botflags |= BS_GREET; + ci->botflags.SetFlag(BS_GREET); notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_GREET; + ci->botflags.UnsetFlag(BS_GREET); notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET GREET", @@ -116,12 +116,12 @@ class CommandBSSet : public Command } } else if (u->nc->HasCommand("botserv/set/nobot") && option == "NOBOT") { if (value == "ON") { - ci->botflags |= BS_NOBOT; + ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) ci->bi->UnAssign(u, ci); notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_NOBOT; + ci->botflags.UnsetFlag(BS_NOBOT); notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET NOBOT", @@ -129,10 +129,10 @@ class CommandBSSet : public Command } } else if (option == "SYMBIOSIS") { if (value == "ON") { - ci->botflags |= BS_SYMBIOSIS; + ci->botflags.SetFlag(BS_SYMBIOSIS); notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name); } else if (value == "OFF") { - ci->botflags &= ~BS_SYMBIOSIS; + ci->botflags.UnsetFlag(BS_SYMBIOSIS); notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET SYMBIOSIS", diff --git a/src/core/cs_access.c b/src/core/cs_access.c index cd8ccb0cf..11fc323e7 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -61,7 +61,7 @@ static int access_list(User * u, int index, ChannelInfo * ci, int *sent_header) *sent_header = 1; } - if (ci->flags & CI_XOP) + if (ci->HasFlag(CI_XOP)) { xop = get_xop_level(access->level); notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1, xop, access->nc->display); @@ -107,7 +107,7 @@ static int access_view(User *u, int index, ChannelInfo *ci, int *sent_header) strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm); } - if (ci->flags & CI_XOP) + if (ci->HasFlag(CI_XOP)) { xop = get_xop_level(access->level); notice_lang(s_ChanServ, u, CHAN_ACCESS_VIEW_XOP_FORMAT, index + 1, xop, access->nc->display, access->creator.c_str(), timebuf); @@ -155,7 +155,7 @@ class CommandCSAccess : public Command if (is_list || cmd == "CLEAR" ? 0 : (cmd == "DEL" ? (!nick || s) : !s)) this->OnSyntaxError(u); /* We still allow LIST in xOP mode, but not others */ - else if ((ci->flags & CI_XOP) && !is_list) + else if ((ci->HasFlag(CI_XOP)) && !is_list) { if (ModeManager::FindChannelModeByName(CMODE_HALFOP)) notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP_HOP, s_ChanServ); @@ -202,7 +202,7 @@ class CommandCSAccess : public Command notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY); return MOD_CONT; } - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)); { notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; @@ -446,7 +446,7 @@ class CommandCSLevels : public Command */ if (cmd == "SET" ? !s : (cmd.substr(0, 3) == "DIS" ? (!what || s) : !!what)) this->OnSyntaxError(u); - else if (ci->flags & CI_XOP) + else if (ci->HasFlag(CI_XOP)) notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP); else if (!IsFounder(u, ci) && !u->nc->HasPriv("chanserv/access/modify")) notice_lang(s_ChanServ, u, ACCESS_DENIED); diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index c93c3a0aa..078cd0e2e 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -65,7 +65,7 @@ int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header) { AutoKick *akick = ci->GetAkick(index); - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) return 0; if (!*sent_header) { notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); @@ -73,7 +73,7 @@ int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header) } notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, - ((akick->flags & AK_ISNICK) ? akick->nc-> + ((akick->HasFlag(AK_ISNICK)) ? akick->nc-> display : akick->mask.c_str()), (!akick->reason.empty() ? akick-> reason.c_str() : getstring(u, NO_REASON))); @@ -95,7 +95,7 @@ int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header) char timebuf[64]; struct tm tm; - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) return 0; if (!*sent_header) { notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); @@ -110,17 +110,10 @@ int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header) snprintf(timebuf, sizeof(timebuf), "%s", getstring(u, UNKNOWN)); } - notice_lang(s_ChanServ, u, - ((akick-> - flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : - CHAN_AKICK_VIEW_FORMAT), index + 1, - ((akick->flags & AK_ISNICK) ? akick->nc-> - display : akick->mask.c_str()), - !akick->creator.empty() ? akick->creator.c_str() : getstring(u, - UNKNOWN), - timebuf, - (!akick->reason.empty() ? akick-> - reason.c_str() : getstring(u, NO_REASON))); + notice_lang(s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1, + ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()), + !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf, + (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON))); return 1; } @@ -167,7 +160,7 @@ class CommandCSAKick : public Command } else { - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask.c_str()); return; @@ -188,7 +181,7 @@ class CommandCSAKick : public Command /* Check whether target nick has equal/higher access * or whether the mask matches a user with higher/equal access - Viper */ - if ((ci->flags & CI_PEACE) && nc) + if ((ci->HasFlag(CI_PEACE)) && nc) { if ((nc == ci->founder) || (get_access_nc(nc, ci) >= get_access(u, ci))) { @@ -196,7 +189,7 @@ class CommandCSAKick : public Command return; } } - else if ((ci->flags & CI_PEACE)) + else if ((ci->HasFlag(CI_PEACE))) { char buf[BUFSIZE]; /* Match against all currently online users with equal or @@ -223,7 +216,7 @@ class CommandCSAKick : public Command { for (NickAlias *na2 = nalists[i]; na2; na2 = na2->next) { - if (na2->status & NS_FORBIDDEN) + if (na2->HasFlag(NS_FORBIDDEN)) continue; if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci)))) @@ -242,11 +235,11 @@ class CommandCSAKick : public Command for (unsigned j = 0; j < ci->GetAkickCount(); ++j) { akick = ci->GetAkick(j); - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) continue; - if ((akick->flags & AK_ISNICK) ? akick->nc == nc : akick->mask == mask) + if ((akick->HasFlag(AK_ISNICK)) ? akick->nc == nc : akick->mask == mask) { - notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->flags & AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), ci->name); + notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), ci->name); return; } } @@ -291,7 +284,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) + if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK)) continue; if (akick->mask == mask) break; @@ -303,7 +296,7 @@ class CommandCSAKick : public Command return; } - akick->flags |= AK_STUCK; + akick->SetFlag(AK_STUCK); notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name); if (ci->c) @@ -331,7 +324,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) + if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK)) continue; if (akick->mask == mask) break; @@ -343,7 +336,7 @@ class CommandCSAKick : public Command return; } - akick->flags &= ~AK_STUCK; + akick->UnsetFlag(AK_STUCK); notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->mask.c_str(), ci->name); } @@ -387,10 +380,10 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) continue; - if (((akick->flags & AK_ISNICK) && akick->nc == nc) - || (!(akick->flags & AK_ISNICK) + if (((akick->HasFlag(AK_ISNICK)) && akick->nc == nc) + || (!(akick->HasFlag(AK_ISNICK)) && akick->mask == mask)) break; } @@ -428,13 +421,13 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) continue; if (!mask.empty()) { - if (!(akick->flags & AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) continue; - if ((akick->flags & AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) continue; } akick_list(u, i, ci, &sent_header); @@ -467,13 +460,13 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED)) + if (!(akick->HasFlag(AK_USED))) continue; if (!mask.empty()) { - if (!(akick->flags & AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) continue; - if ((akick->flags & AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) continue; } akick_view(u, i, ci, &sent_header); diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index 9901479ae..b6873ba89 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -55,7 +55,7 @@ class CommandCSBan : public Command } else if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->flags & CI_PEACE) + } else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(s_ChanServ, u, ACCESS_DENIED); /* @@ -80,8 +80,8 @@ class CommandCSBan : public Command if (!is_on_chan(c, u2)) return MOD_CONT; - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) + if ((ci->HasFlag(CI_SIGNKICK)) + || ((ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(u, ci, CA_SIGNKICK))) ircdproto->SendKick(whosends(ci), ci->name, target, "%s (%s)", reason, u->nick); diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index 3a5ca45a7..74d799af8 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -37,19 +37,19 @@ class CommandCSDrop : public Command ci = cs_findchan(chan); - if ((ci->flags & CI_FORBIDDEN) && !u->nc->HasCommand("chanserv/drop")) + if ((ci->HasFlag(CI_FORBIDDEN)) && !u->nc->HasCommand("chanserv/drop")) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); return MOD_CONT; } - if ((ci->flags & CI_SUSPENDED) && !u->nc->HasCommand("chanserv/drop")) + if ((ci->HasFlag(CI_SUSPENDED)) && !u->nc->HasCommand("chanserv/drop")) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); return MOD_CONT; } - if ((ci->flags & CI_SECUREFOUNDER ? !IsRealFounder(u, ci) : !IsFounder(u, ci)) && !u->nc->HasCommand("chanserv/drop")) + if ((ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci)) && !u->nc->HasCommand("chanserv/drop")) { notice_lang(s_ChanServ, u, ACCESS_DENIED); return MOD_CONT; @@ -66,7 +66,7 @@ class CommandCSDrop : public Command } } - if (ircd->chansqline && (ci->flags & CI_FORBIDDEN)) + if (ircd->chansqline && (ci->HasFlag(CI_FORBIDDEN))) { ircdproto->SendSQLineDel(ci->name); } @@ -81,7 +81,7 @@ class CommandCSDrop : public Command * drop the channel before issuing the wallops. */ if (WallDrop) { - if ((level < ACCESS_FOUNDER) || (!IsRealFounder(u, ci) && ci->flags & CI_SECUREFOUNDER)) + if ((level < ACCESS_FOUNDER) || (!IsRealFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER))) ircdproto->SendGlobops(s_ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick, chan); } diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index edc0ef37d..ccfc1f5bd 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -60,7 +60,7 @@ class CommandCSForbid : public Command return MOD_CONT; } - ci->flags |= CI_FORBIDDEN; + ci->SetFlag(CI_FORBIDDEN); ci->forbidby = sstrdup(u->nick); if (reason) ci->forbidreason = sstrdup(reason); diff --git a/src/core/cs_info.c b/src/core/cs_info.c index 8a13b73a2..5271764b9 100644 --- a/src/core/cs_info.c +++ b/src/core/cs_info.c @@ -16,10 +16,10 @@ #include "module.h" class CommandCSInfo : public Command -{ // cannot be const, as it is modified. - void CheckOptStr(std::string &buf, int opt, const std::string &str, ChannelInfo *ci, NickCore *nc) +{ + void CheckOptStr(std::string &buf, ChannelInfoFlag opt, const std::string &str, ChannelInfo *ci, NickCore *nc) { - if (ci->flags & opt) + if (ci->HasFlag(opt)) { const char *commastr = getstring(nc, COMMA_SPACE); if (!buf.empty()) @@ -51,7 +51,7 @@ class CommandCSInfo : public Command ci = cs_findchan(chan); - if (ci->flags & CI_FORBIDDEN) + if (ci->HasFlag(CI_FORBIDDEN)) { if (is_oper(u) && ci->forbidby) notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, @@ -104,23 +104,26 @@ class CommandCSInfo : public Command notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype); std::string optbuf; - CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->nc); - CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->nc); - CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->nc); - CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->nc); - CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->nc); - CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->nc); - CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->nc); - CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->nc); - CheckOptStr(optbuf, CI_SIGNKICK | CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc); - CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->nc); - CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->nc); + CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->nc); + CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->nc); + CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->nc); + CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->nc); + CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->nc); + CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->nc); + CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->nc); + CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->nc); + if (ci->HasFlag(CI_SIGNKICK)) + CheckOptStr(optbuf, CI_SIGNKICK, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc); + else + CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc); + CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->nc); + CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->nc); notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS, optbuf.empty() ? getstring(u, CHAN_INFO_OPT_NONE) : optbuf.c_str()); notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK, get_mlock_modes(ci, 1)); // XXX: we could just as easily (and tidily) merge this in with the flags display above. - if (ci->flags & CI_NO_EXPIRE) + if (ci->HasFlag(CI_NO_EXPIRE)) { notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE); } @@ -135,7 +138,7 @@ class CommandCSInfo : public Command } } } - if (ci->flags & CI_SUSPENDED) + if (ci->HasFlag(CI_SUSPENDED)) { notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON))); } diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index 8ebe2f06b..960cfea9d 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -58,7 +58,7 @@ class CommandCSKick : public Command } else if (!is_same ? !check_access(u, ci, CA_KICK) : !check_access(u, ci, CA_KICKME)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->flags & CI_PEACE) + } else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(s_ChanServ, u, ACCESS_DENIED); } else if (is_protected(u2)) { @@ -66,8 +66,8 @@ class CommandCSKick : public Command } else { const char *av[3]; - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) + if ((ci->HasFlag(CI_SIGNKICK)) + || ((ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(u, ci, CA_SIGNKICK))) ircdproto->SendKick(whosends(ci), ci->name, target, "%s (%s)", reason, u->nick); diff --git a/src/core/cs_list.c b/src/core/cs_list.c index c6d2f8225..087d0c664 100644 --- a/src/core/cs_list.c +++ b/src/core/cs_list.c @@ -36,7 +36,9 @@ public: int count = 0, from = 0, to = 0, tofree = 0; char *tmp = NULL; char *s = NULL; - int32 matchflags = 0; + bool forbidden, suspended, channoexpire; + + forbidden = suspended = noexpire = false; if (!(!CSListOpersOnly || (is_oper(u)))) { @@ -98,11 +100,11 @@ public: { ci::string keyword_ci = keyword.c_str(); if (keyword_ci == "FORBIDDEN") - matchflags |= CI_FORBIDDEN; + forbidden = true; if (keyword_ci == "SUSPENDED") - matchflags |= CI_SUSPENDED; + suspended = true; if (keyword_ci == "NOEXPIRE") - matchflags |= CI_NO_EXPIRE; + channoexpire = true; } } @@ -116,10 +118,14 @@ public: { for (ci = chanlists[i]; ci; ci = ci->next) { - if (!is_servadmin && ((ci->flags & CI_PRIVATE) - || (ci->flags & CI_FORBIDDEN) || (ci->flags & CI_SUSPENDED))) + if (!is_servadmin && ((ci->HasFlag(CI_PRIVATE)) + || (ci->HasFlag(CI_FORBIDDEN)) || (ci->HasFlag(CI_SUSPENDED)))) + continue; + if (forbidden && !ci->HasFlag(CI_FORBIDDEN)) + continue; + else if (suspended && !ci->HasFlag(CI_SUSPENDED)) continue; - if ((matchflags != 0) && !(ci->flags & matchflags)) + else if (channoexpire && !ci->HasFlag(CI_NO_EXPIRE)) continue; if ((stricmp(pattern, ci->name) == 0) @@ -132,15 +138,15 @@ public: && (++nchans <= CSListMax)) { char noexpire_char = ' '; - if (is_servadmin && (ci->flags & CI_NO_EXPIRE)) + if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE))) noexpire_char = '!'; - if (ci->flags & CI_FORBIDDEN) + if (ci->HasFlag(CI_FORBIDDEN)) { snprintf(buf, sizeof(buf), "%-20s [Forbidden]", ci->name); } - else if (ci->flags & CI_SUSPENDED) + else if (ci->HasFlag(CI_SUSPENDED)) { snprintf(buf, sizeof(buf), "%-20s [Suspended]", ci->name); diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 8c45e328f..88b3770c7 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -26,7 +26,7 @@ * @param name The name, eg "OP" or "HALFOP" * @param notice Flag required on a channel to send a notice */ -static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const char *nick, bool set, int level, int levelself, const std::string &name, int32 notice) +static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const char *nick, bool set, int level, int levelself, const std::string &name, ChannelInfoFlag notice) { const char *av[2]; Channel *c = findchan(chan); @@ -36,9 +36,8 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c int is_same; - if (!nick) { + if (!nick) nick = u->nick; - } is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0); @@ -53,7 +52,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name); else if (is_same ? !check_access(u, ci, levelself) : !check_access(u, ci, level)) notice_lang(s_ChanServ, u, ACCESS_DENIED); - else if (!set && !is_same && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) + else if (!set && !is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) notice_lang(s_ChanServ, u, ACCESS_DENIED); else if (!set && is_protected(u2) && !is_same) notice_lang(s_ChanServ, u, ACCESS_DENIED); @@ -68,7 +67,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c chan_set_modes(s_ChanServ, c, 2, av, 3); - if (notice && ci->flags & notice) + if (notice && ci->HasFlag(notice)) ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s", name.c_str(), u2->nick, u->nick); } @@ -141,7 +140,7 @@ class CommandCSVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -168,7 +167,7 @@ class CommandCSDeVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -200,7 +199,7 @@ class CommandCSHalfOp : public Command return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -233,7 +232,7 @@ class CommandCSDeHalfOp : public Command } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -265,7 +264,7 @@ class CommandCSProtect : public Command return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -296,7 +295,7 @@ class CommandCSDeProtect : public Command return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -327,7 +326,7 @@ class CommandCSOwner : public Command return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OWNER, CA_OWNERME, "OWNER", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -358,7 +357,7 @@ class CommandCSDeOwner : public Command return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OWNER, CA_OWNERME, "DEOWNER", 0); + return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) diff --git a/src/core/cs_set.c b/src/core/cs_set.c index d04969f9f..e556c7a49 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -27,7 +27,7 @@ class CommandCSSet : public Command if (!na) { notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); return MOD_CONT; - } else if (na->status & NS_FORBIDDEN) { + } else if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); return MOD_CONT; } @@ -66,7 +66,7 @@ class CommandCSSet : public Command notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); return MOD_CONT; } - if (na->status & NS_FORBIDDEN) { + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); return MOD_CONT; } @@ -283,10 +283,10 @@ class CommandCSSet : public Command CommandReturn DoSetKeepTopic(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_KEEPTOPIC; + ci->SetFlag(CI_KEEPTOPIC); notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_KEEPTOPIC; + ci->UnsetFlag(CI_KEEPTOPIC); notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET KEEPTOPIC", @@ -298,10 +298,10 @@ class CommandCSSet : public Command CommandReturn DoSetTopicLock(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_TOPICLOCK; + ci->SetFlag(CI_TOPICLOCK); notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_TOPICLOCK; + ci->UnsetFlag(CI_TOPICLOCK); notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET TOPICLOCK", @@ -313,10 +313,10 @@ class CommandCSSet : public Command CommandReturn DoSetPrivate(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_PRIVATE; + ci->SetFlag(CI_PRIVATE); notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_PRIVATE; + ci->UnsetFlag(CI_PRIVATE); notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET PRIVATE", @@ -328,10 +328,10 @@ class CommandCSSet : public Command CommandReturn DoSetSecureOps(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECUREOPS; + ci->SetFlag(CI_SECUREOPS); notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECUREOPS; + ci->UnsetFlag(CI_SECUREOPS); notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET SECUREOPS", @@ -343,10 +343,10 @@ class CommandCSSet : public Command CommandReturn DoSetSecureFounder(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECUREFOUNDER; + ci->SetFlag(CI_SECUREFOUNDER); notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECUREFOUNDER; + ci->UnsetFlag(CI_SECUREFOUNDER); notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET SECUREFOUNDER", @@ -358,12 +358,12 @@ class CommandCSSet : public Command CommandReturn DoSetRestricted(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_RESTRICTED; + ci->SetFlag(CI_RESTRICTED); if (ci->levels[CA_NOJOIN] < 0) ci->levels[CA_NOJOIN] = 0; notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_RESTRICTED; + ci->UnsetFlag(CI_RESTRICTED); if (ci->levels[CA_NOJOIN] >= 0) ci->levels[CA_NOJOIN] = -2; notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name); @@ -377,10 +377,10 @@ class CommandCSSet : public Command CommandReturn DoSetSecure(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECURE; + ci->SetFlag(CI_SECURE); notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECURE; + ci->UnsetFlag(CI_SECURE); notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX); @@ -391,15 +391,16 @@ class CommandCSSet : public Command CommandReturn DoSetSignKick(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SIGNKICK; - ci->flags &= ~CI_SIGNKICK_LEVEL; + ci->SetFlag(CI_SIGNKICK); + ci->UnsetFlag(CI_SIGNKICK_LEVEL); notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name); } else if (stricmp(param, "LEVEL") == 0) { - ci->flags |= CI_SIGNKICK_LEVEL; - ci->flags &= ~CI_SIGNKICK; + ci->SetFlag(CI_SIGNKICK_LEVEL); + ci->UnsetFlag(CI_SIGNKICK); notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL); + ci->UnsetFlag(CI_SIGNKICK); + ci->UnsetFlag(CI_SIGNKICK_LEVEL); notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET SIGNKICK", @@ -411,10 +412,10 @@ class CommandCSSet : public Command CommandReturn DoSetOpNotice(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_OPNOTICE; + ci->SetFlag(CI_OPNOTICE); notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_OPNOTICE; + ci->UnsetFlag(CI_OPNOTICE); notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET OPNOTICE", @@ -428,7 +429,7 @@ class CommandCSSet : public Command CommandReturn DoSetXOP(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - if (!(ci->flags & CI_XOP)) { + if (!(ci->HasFlag(CI_XOP))) { ChanAccess *access; for (unsigned i = 0; i < ci->GetAccessCount(); i++) { @@ -463,14 +464,14 @@ class CommandCSSet : public Command ci->CleanAccess(); reset_levels(ci); - ci->flags |= CI_XOP; + ci->SetFlag(CI_XOP); } alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ci->name); notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_XOP; + ci->UnsetFlag(CI_XOP); alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ci->name); @@ -486,10 +487,10 @@ class CommandCSSet : public Command CommandReturn DoSetPeace(User * u, ChannelInfo * ci, const char *param) { if (stricmp(param, "ON") == 0) { - ci->flags |= CI_PEACE; + ci->SetFlag(CI_PEACE); notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_PEACE; + ci->UnsetFlag(CI_PEACE); notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX); @@ -505,10 +506,10 @@ class CommandCSSet : public Command return MOD_CONT; } if (stricmp(param, "ON") == 0) { - ci->flags |= CI_NO_EXPIRE; + ci->SetFlag(CI_NO_EXPIRE); notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name); } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_NO_EXPIRE; + ci->UnsetFlag(CI_NO_EXPIRE); notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name); } else { syntax_error(s_ChanServ, u, "SET NOEXPIRE", @@ -540,25 +541,15 @@ class CommandCSSet : public Command else if (!is_servadmin && !check_access(u, ci, CA_SET)) notice_lang(s_ChanServ, u, ACCESS_DENIED); else if (cmd == "FOUNDER") { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !IsRealFounder(u, - ci) : - !IsFounder(u, ci))) { + if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci))) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { + else DoSetFounder(u, ci, param); - } } else if (cmd == "SUCCESSOR") { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !IsRealFounder(u, - ci) : - !IsFounder(u, ci))) { + if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci))) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { + else DoSetSuccessor(u, ci, param); - } } else if (cmd == "DESC") { DoSetDesc(u, ci, param); } else if (cmd == "URL") { @@ -582,15 +573,10 @@ class CommandCSSet : public Command } else if (cmd == "SECUREOPS") { DoSetSecureOps(u, ci, param); } else if (cmd == "SECUREFOUNDER") { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !IsRealFounder(u, - ci) : - !IsFounder(u, ci))) { + if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci))) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { + else DoSetSecureFounder(u, ci, param); - } } else if (cmd == "RESTRICTED") { DoSetRestricted(u, ci, param); } else if (cmd == "SECURE") { diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index ccc722bb3..dd6511a47 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -44,7 +44,7 @@ class CommandCSSuspend : public Command } /* You should not SUSPEND a FORBIDEN channel */ - if (ci->flags & CI_FORBIDDEN) + if (ci->HasFlag(CI_FORBIDDEN)) { notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); return MOD_CONT; @@ -55,7 +55,7 @@ class CommandCSSuspend : public Command if (ci) { - ci->flags |= CI_SUSPENDED; + ci->SetFlag(CI_SUSPENDED); ci->forbidby = sstrdup(u->nick); if (reason) ci->forbidreason = sstrdup(reason); @@ -130,7 +130,7 @@ class CommandCSUnSuspend : public Command notice_lang(s_ChanServ, u, READ_ONLY_MODE); /* Only UNSUSPEND already suspended channels */ - if (!(ci->flags & CI_SUSPENDED)) + if (!(ci->HasFlag(CI_SUSPENDED))) { notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); return MOD_CONT; @@ -138,7 +138,7 @@ class CommandCSUnSuspend : public Command if (ci) { - ci->flags &= ~CI_SUSPENDED; + ci->UnsetFlag(CI_SUSPENDED); if (ci->forbidreason) { delete [] ci->forbidreason; diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index e79cb6515..52bf1e4f1 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -150,7 +150,7 @@ class XOPBase : public Command notice_lang(s_ChanServ, u, messages[XOP_NICKS_ONLY]); return MOD_CONT; } - else if (na->status & NS_FORBIDDEN) + else if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick); return MOD_CONT; @@ -380,7 +380,7 @@ class XOPBase : public Command ChannelInfo *ci = cs_findchan(chan); - if (!(ci->flags & CI_XOP)) + if (!(ci->HasFlag(CI_XOP))) notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ); else if (cmd == "ADD") return this->DoAdd(u, params, ci, level, messages); diff --git a/src/core/hs_del.c b/src/core/hs_del.c index 2b36f6a89..0781dc8f6 100644 --- a/src/core/hs_del.c +++ b/src/core/hs_del.c @@ -28,7 +28,7 @@ class CommandHSDel : public Command const char *nick = params[0].c_str(); if ((na = findnick(nick))) { - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c index 678852cf6..714f23eef 100644 --- a/src/core/hs_delall.c +++ b/src/core/hs_delall.c @@ -30,7 +30,7 @@ class CommandHSDelAll : public Command NickCore *nc; if ((na = findnick(nick))) { - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; diff --git a/src/core/hs_set.c b/src/core/hs_set.c index 26b6a1146..f9a3d80f1 100644 --- a/src/core/hs_set.c +++ b/src/core/hs_set.c @@ -107,7 +107,7 @@ class CommandHSSet : public Command if ((na = findnick(nick))) { - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); if (vIdent) diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c index e8a9c7dab..8343eb0f9 100644 --- a/src/core/hs_setall.c +++ b/src/core/hs_setall.c @@ -109,7 +109,7 @@ class CommandHSSetAll : public Command if ((na = findnick(nick))) { - if (na->status & NS_FORBIDDEN) + if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); if (vIdent) { diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c index 94e18262b..e01fef169 100644 --- a/src/core/ms_cancel.c +++ b/src/core/ms_cancel.c @@ -46,7 +46,7 @@ class CommandMSCancel : public Command for (i = mi->memos.size() - 1; i >= 0; --i) { - if ((mi->memos[i]->flags & MF_UNREAD) && !stricmp(mi->memos[i]->sender, u->nc->display) && (!(mi->memos[i]->flags & MF_NOTIFYS))) + if ((mi->memos[i]->HasFlag(MF_UNREAD)) && !stricmp(mi->memos[i]->sender, u->nc->display) && !mi->memos[i]->HasFlag(MF_NOTIFYS)) { delmemo(mi, mi->memos[i]->number); notice_lang(s_MemoServ, u, MEMO_CANCELLED, name); diff --git a/src/core/ms_check.c b/src/core/ms_check.c index ac48dac6d..2d3f2ce12 100644 --- a/src/core/ms_check.c +++ b/src/core/ms_check.c @@ -42,7 +42,7 @@ class CommandMSCheck : public Command return MOD_CONT; } - if ((na->status & NS_FORBIDDEN)) + if ((na->HasFlag(NS_FORBIDDEN))) { notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient); return MOD_CONT; @@ -62,7 +62,7 @@ class CommandMSCheck : public Command tm = localtime(&mi->memos[i]->time); strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, tm); - if (mi->memos[i]->flags & MF_UNREAD) + if (mi->memos[i]->HasFlag(MF_UNREAD)) notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick, timebuf); else notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick, timebuf); diff --git a/src/core/ms_info.c b/src/core/ms_info.c index a0077e09b..76e605478 100644 --- a/src/core/ms_info.c +++ b/src/core/ms_info.c @@ -38,13 +38,13 @@ class CommandMSInfo : public Command notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); return MOD_CONT; } - else if (na->status & NS_FORBIDDEN) + else if (na->HasFlag(NS_FORBIDDEN)) { notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name); return MOD_CONT; } mi = &na->nc->memos; - hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; + hardmax = na->nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0; } else if (name && *name == '#') { @@ -59,7 +59,7 @@ class CommandMSInfo : public Command return MOD_CONT; } mi = &ci->memos; - hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0; + hardmax = ci->HasFlag(CI_MEMO_HARDMAX) ? 1 : 0; } else if (name) /* It's not a chan and we aren't services admin */ { @@ -69,7 +69,7 @@ class CommandMSInfo : public Command else { mi = &u->nc->memos; - hardmax = u->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; + hardmax = u->nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0; } if (name && (ci || na->nc != u->nc)) @@ -78,7 +78,7 @@ class CommandMSInfo : public Command notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name); else if (mi->memos.size() == 1) { - if (mi->memos[0]->flags & MF_UNREAD) + if (mi->memos[0]->HasFlag(MF_UNREAD)) notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name); else notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name); @@ -88,7 +88,7 @@ class CommandMSInfo : public Command int count = 0, i; for (i = 0; i < mi->memos.size(); ++i) { - if (mi->memos[i]->flags & MF_UNREAD) + if (mi->memos[i]->HasFlag(MF_UNREAD)) ++count; } if (count == mi->memos.size()) @@ -121,11 +121,11 @@ class CommandMSInfo : public Command to rewrite the whole thing (it pisses me off). */ if (na) { - if ((na->nc->flags & NI_MEMO_RECEIVE) && (na->nc->flags & NI_MEMO_SIGNON)) + if (na->nc->HasFlag(NI_MEMO_RECEIVE) && na->nc->HasFlag(NI_MEMO_SIGNON)) notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name); - else if (na->nc->flags & NI_MEMO_RECEIVE) + else if (na->nc->HasFlag(NI_MEMO_RECEIVE)) notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, name); - else if (na->nc->flags & NI_MEMO_SIGNON) + else if (na->nc->HasFlag(NI_MEMO_SIGNON)) notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, name); else notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name); @@ -137,7 +137,7 @@ class CommandMSInfo : public Command notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS); else if (mi->memos.size() == 1) { - if (mi->memos[0]->flags & MF_UNREAD) + if (mi->memos[0]->HasFlag(MF_UNREAD)) notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD); else notice_lang(s_MemoServ, u, MEMO_INFO_MEMO); @@ -147,7 +147,7 @@ class CommandMSInfo : public Command int count = 0, i; for (i = 0; i < mi->memos.size(); ++i) { - if (mi->memos[i]->flags & MF_UNREAD) + if (mi->memos[i]->HasFlag(MF_UNREAD)) ++count; } if (count == mi->memos.size()) @@ -178,11 +178,11 @@ class CommandMSInfo : public Command notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT); /* Ripped too. But differently because of a seg fault (loughs) */ - if ((u->nc->flags & NI_MEMO_RECEIVE) && (u->nc->flags & NI_MEMO_SIGNON)) + if (u->nc->HasFlag(NI_MEMO_RECEIVE) && u->nc->HasFlag(NI_MEMO_SIGNON)) notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON); - else if (u->nc->flags & NI_MEMO_RECEIVE) + else if (u->nc->HasFlag(NI_MEMO_RECEIVE)) notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE); - else if (u->nc->flags & NI_MEMO_SIGNON) + else if (u->nc->HasFlag(NI_MEMO_SIGNON)) notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON); else notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF); diff --git a/src/core/ms_list.c b/src/core/ms_list.c index 950982ffc..bcd5e90a8 100644 --- a/src/core/ms_list.c +++ b/src/core/ms_list.c @@ -73,7 +73,7 @@ class CommandMSList : public Command { for (i = 0; i < mi->memos.size(); ++i) { - if (mi->memos[i]->flags & MF_UNREAD) + if (mi->memos[i]->HasFlag(MF_UNREAD)) break; } if (i == mi->memos.size()) @@ -87,7 +87,7 @@ class CommandMSList : public Command } for (i = 0; i < mi->memos.size(); ++i) { - if (!param.empty() && !(mi->memos[i]->flags & MF_UNREAD)) + if (!param.empty() && !(mi->memos[i]->HasFlag(MF_UNREAD))) continue; list_memo(u, i, mi, &sent_header, !param.empty(), chan.c_str()); } @@ -178,7 +178,7 @@ int list_memo(User *u, int index, MemoInfo *mi, int *sent_header, int newi, cons tm = *localtime(&m->time); strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm); timebuf[sizeof(timebuf) - 1] = 0; /* just in case */ - notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, (m->flags & MF_UNREAD) ? '*' : ' ', m->number, m->sender, timebuf); + notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, (m->HasFlag(MF_UNREAD)) ? '*' : ' ', m->number, m->sender, timebuf); return 1; } diff --git a/src/core/ms_read.c b/src/core/ms_read.c index 80af467d9..7e54d6629 100644 --- a/src/core/ms_read.c +++ b/src/core/ms_read.c @@ -72,7 +72,7 @@ class CommandMSRead : public Command int readcount = 0; for (i = 0; i < mi->memos.size(); ++i) { - if (mi->memos[i]->flags & MF_UNREAD) + if (mi->memos[i]->HasFlag(MF_UNREAD)) { read_memo(u, i, mi, chan.c_str()); ++readcount; @@ -180,10 +180,10 @@ int read_memo(User *u, int index, MemoInfo *mi, const char *chan) else notice_lang(s_MemoServ, u, MEMO_HEADER, m->number, m->sender, timebuf, s_MemoServ, m->number); notice_lang(s_MemoServ, u, MEMO_TEXT, m->text); - m->flags &= ~MF_UNREAD; + m->UnsetFlag(MF_UNREAD); /* Check if a receipt notification was requested */ - if (m->flags & MF_RECEIPT) + if (m->HasFlag(MF_RECEIPT)) rsend_notify(u, m, chan); return 1; diff --git a/src/core/ms_set.c b/src/core/ms_set.c index e941a7f3a..3ebb3b354 100644 --- a/src/core/ms_set.c +++ b/src/core/ms_set.c @@ -24,26 +24,27 @@ class CommandMSSet : public Command if (param == "ON") { - u->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE; + u->nc->SetFlag(NI_MEMO_SIGNON); + u->nc->SetFlag(NI_MEMO_RECEIVE); notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ); } else if (param == "LOGON") { - u->nc->flags |= NI_MEMO_SIGNON; - u->nc->flags &= ~NI_MEMO_RECEIVE; + u->nc->SetFlag(NI_MEMO_SIGNON); + u->nc->UnsetFlag(NI_MEMO_RECEIVE); notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ); } else if (param == "NEW") { - u->nc->flags &= ~NI_MEMO_SIGNON; - u->nc->flags |= NI_MEMO_RECEIVE; + u->nc->UnsetFlag(NI_MEMO_SIGNON); + u->nc->SetFlag(NI_MEMO_RECEIVE); notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ); } else if (param == "MAIL") { if (u->nc->email) { - u->nc->flags |= NI_MEMO_MAIL; + u->nc->SetFlag(NI_MEMO_MAIL); notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL); } else @@ -51,12 +52,14