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/bots.cpp | 30 +++++++------ src/botserv.c | 62 +++++++++++++-------------- src/channels.c | 47 +++++++++++---------- src/chanserv.c | 97 +++++++++++++++++++++++-------------------- src/command.cpp | 16 ------- src/commands.c | 4 +- src/config.c | 83 +++++++++++++++++++----------------- 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 +- src/language.c | 2 +- src/memoserv.c | 28 ++++++------- src/messages.c | 5 +-- src/modules/cs_appendtopic.c | 2 - src/modules/cs_enforce.c | 21 ++++++---- src/modules/ns_noop_convert.c | 2 +- src/nickalias.cpp | 1 - src/nickcore.cpp | 7 +++- src/nickserv.c | 64 +++++++++++++++------------- src/operserv.c | 2 +- src/protocol.cpp | 2 +- src/regchannel.cpp | 19 +++++++-- src/send.c | 2 +- src/servers.c | 35 ++++++++-------- src/users.c | 18 +++----- 70 files changed, 634 insertions(+), 627 deletions(-) (limited to 'src') diff --git a/src/bots.cpp b/src/bots.cpp index 4cb4556f2..8a4198b74 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -19,23 +19,22 @@ BotInfo::BotInfo(const char *nnick) this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? nbots++; this->cmdTable = NULL; - this->flags = 0; this->chancount = 0; if (s_ChanServ && !stricmp(s_ChanServ, nnick)) - this->flags |= BI_CHANSERV; + this->SetFlag(BI_CHANSERV); else if (s_BotServ && !stricmp(s_BotServ, nnick)) - this->flags |= BI_BOTSERV; + this->SetFlag(BI_BOTSERV); else if (s_HostServ && !stricmp(s_HostServ, nnick)) - this->flags |= BI_HOSTSERV; + this->SetFlag(BI_HOSTSERV); else if (s_OperServ && !stricmp(s_OperServ, nnick)) - this->flags |= BI_OPERSERV; + this->SetFlag(BI_OPERSERV); else if (s_MemoServ && !stricmp(s_MemoServ, nnick)) - this->flags |= BI_MEMOSERV; + this->SetFlag(BI_MEMOSERV); else if (s_NickServ && !stricmp(s_NickServ, nnick)) - this->flags |= BI_NICKSERV; + this->SetFlag(BI_NICKSERV); else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) - this->flags |= BI_GLOBAL; + this->SetFlag(BI_GLOBAL); FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); @@ -57,23 +56,22 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? nbots++; this->cmdTable = NULL; - this->flags = 0; this->chancount = 0; if (s_ChanServ && !stricmp(s_ChanServ, nnick)) - this->flags |= BI_CHANSERV; + this->SetFlag(BI_CHANSERV); else if (s_BotServ && !stricmp(s_BotServ, nnick)) - this->flags |= BI_BOTSERV; + this->SetFlag(BI_BOTSERV); else if (s_HostServ && !stricmp(s_HostServ, nnick)) - this->flags |= BI_HOSTSERV; + this->SetFlag(BI_HOSTSERV); else if (s_OperServ && !stricmp(s_OperServ, nnick)) - this->flags |= BI_OPERSERV; + this->SetFlag(BI_OPERSERV); else if (s_MemoServ && !stricmp(s_MemoServ, nnick)) - this->flags |= BI_MEMOSERV; + this->SetFlag(BI_MEMOSERV); else if (s_NickServ && !stricmp(s_NickServ, nnick)) - this->flags |= BI_NICKSERV; + this->SetFlag(BI_NICKSERV); else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) - this->flags |= BI_GLOBAL; + this->SetFlag(BI_GLOBAL); FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); diff --git a/src/botserv.c b/src/botserv.c index c160c496b..c9e1f3ed7 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -168,44 +168,44 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) */ /* We first retrieve the user status on the channel if needed */ - if (ci->botflags & (BS_DONTKICKOPS | BS_DONTKICKVOICES)) + if (ci->botflags.HasFlag(BS_DONTKICKOPS) || ci->botflags.HasFlag(BS_DONTKICKVOICES)) cstatus = chan_get_user_status(ci->c, u); if (buf && !check_access(u, ci, CA_NOKICK) && - (!(ci->botflags & BS_DONTKICKOPS) + (!ci->botflags.HasFlag(BS_DONTKICKOPS) || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT))) + && (!ci->botflags.HasFlag(BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { - && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { /* Bolds kicker */ - if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { + if (ci->botflags.HasFlag(BS_KICK_BOLDS) && strchr(buf, 2)) { check_ban(ci, u, TTB_BOLDS); bot_kick(ci, u, BOT_REASON_BOLD); return; } /* Color kicker */ - if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) { + if (ci->botflags.HasFlag(BS_KICK_COLORS) && strchr(buf, 3)) { check_ban(ci, u, TTB_COLORS); bot_kick(ci, u, BOT_REASON_COLOR); return; } /* Reverses kicker */ - if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) { + if (ci->botflags.HasFlag(BS_KICK_REVERSES) && strchr(buf, 22)) { check_ban(ci, u, TTB_REVERSES); bot_kick(ci, u, BOT_REASON_REVERSE); return; } /* Underlines kicker */ - if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) { + if (ci->botflags.HasFlag(BS_KICK_UNDERLINES) && strchr(buf, 31)) { check_ban(ci, u, TTB_UNDERLINES); bot_kick(ci, u, BOT_REASON_UNDERLINE); return; } /* Caps kicker */ - if ((ci->botflags & BS_KICK_CAPS) + if (ci->botflags.HasFlag(BS_KICK_CAPS) && ((c = strlen(buf)) >= ci->capsmin)) { int i = 0; int l = 0; @@ -231,7 +231,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Bad words kicker */ - if (ci->botflags & BS_KICK_BADWORDS) { + if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { int i; int mustkick = 0; char *nbuf; @@ -364,7 +364,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Flood kicker */ - if (ci->botflags & BS_KICK_FLOOD) { + if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { time_t now = time(NULL); ud = get_user_data(ci->c, u); @@ -386,7 +386,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Repeat kicker */ - if (ci->botflags & BS_KICK_REPEAT) { + if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { ud = get_user_data(ci->c, u); if (!ud) { return; @@ -417,7 +417,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) /* Fantaisist commands */ - if (buf && (ci->botflags & BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) { + if (buf && ci->botflags.HasFlag(BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) { cmd = strtok(buf, " "); if (cmd && (cmd[0] == *BSFantasyCharacter)) { @@ -454,8 +454,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(cmd, u, ci, params)); } else + { FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(cmd, u, ci, params)); - + } } } } @@ -502,7 +503,7 @@ void load_bs_dbase() SAFE(read_string(&bi->real, f)); if (ver >= 10) { SAFE(read_int16(&tmp16, f)); - bi->flags |= tmp16; + //bi->flags |= tmp16; } SAFE(read_int32(&tmp32, f)); bi->created = tmp32; @@ -513,19 +514,19 @@ void load_bs_dbase() * changed in the config and different from database * names */ - if (s_ChanServ && bi->flags & BI_CHANSERV && strcmp(bi->nick, s_ChanServ)) + if (s_ChanServ && bi->HasFlag(BI_CHANSERV) && strcmp(bi->nick, s_ChanServ)) bi->ChangeNick(s_ChanServ); - else if (s_BotServ && bi->flags & BI_BOTSERV && strcmp(bi->nick, s_BotServ)) + else if (s_BotServ && bi->HasFlag(BI_BOTSERV) && strcmp(bi->nick, s_BotServ)) bi->ChangeNick(s_BotServ); - else if (s_HostServ && bi->flags & BI_HOSTSERV && strcmp(bi->nick, s_HostServ)) + else if (s_HostServ && bi->HasFlag(BI_HOSTSERV) && strcmp(bi->nick, s_HostServ)) bi->ChangeNick(s_HostServ); - else if (s_OperServ && bi->flags & BI_OPERSERV && strcmp(bi->nick, s_OperServ)) + else if (s_OperServ && bi->HasFlag(BI_OPERSERV) && strcmp(bi->nick, s_OperServ)) bi->ChangeNick(s_OperServ); - else if (s_MemoServ && bi->flags & BI_MEMOSERV && strcmp(bi->nick, s_MemoServ)) + else if (s_MemoServ && bi->HasFlag(BI_MEMOSERV) && strcmp(bi->nick, s_MemoServ)) bi->ChangeNick(s_MemoServ); - else if (s_NickServ && bi->flags & BI_NICKSERV && strcmp(bi->nick, s_NickServ)) + else if (s_NickServ && bi->HasFlag(BI_NICKSERV) && strcmp(bi->nick, s_NickServ)) bi->ChangeNick(s_NickServ); - else if (s_GlobalNoticer && bi->flags & BI_GLOBAL && strcmp(bi->nick, s_GlobalNoticer)) + else if (s_GlobalNoticer && bi->HasFlag(BI_GLOBAL) && strcmp(bi->nick, s_GlobalNoticer)) bi->ChangeNick(s_GlobalNoticer); } @@ -566,7 +567,8 @@ void save_bs_dbase() SAFE(write_string(bi->user, f)); SAFE(write_string(bi->host, f)); SAFE(write_string(bi->real, f)); - SAFE(write_int16(bi->flags, f)); + //SAFE(write_int16(bi->flags, f)); + SAFE(write_int16(0, f)); SAFE(write_int32(bi->created, f)); SAFE(write_int16(bi->chancount, f)); } @@ -893,8 +895,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, } } - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) + if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) @@ -937,9 +938,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, } /* Check if we need to do a signkick or not -GD */ - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) + if ((ci->HasFlag(CI_SIGNKICK) || ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK)) ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s (%s)", kav[2], requester->nick); else @@ -971,8 +970,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, } } - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) + if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; av[0] = ci->name; @@ -986,9 +984,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, av[2] = reason; } - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) + if (ci->HasFlag(CI_SIGNKICK) || ((ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK))) ircdproto->SendKick(ci->bi, av[0], av[1], "%s (%s)", av[2], requester->nick); else @@ -1025,7 +1021,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, } } - if (*mode == '-' && (ci->flags & CI_PEACE) + if (*mode == '-' && ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; diff --git a/src/channels.c b/src/channels.c index 8556179ea..9bd3abdc3 100644 --- a/src/channels.c +++ b/src/channels.c @@ -625,7 +625,7 @@ void chan_set_modes(const char *source, Channel *chan, int ac, const char **av, { if (check < 2) chan_set_correct_modes(user, chan, 0); - else if ((chan->ci->flags) && (chan->ci->flags & CI_SECUREOPS)) + else if (chan->ci->HasFlag(CI_SECUREOPS)) { /* Fixing bug #1006 oringinally caused by fixing #922 * we must check for secureops here, not in chan_set_correct_modes @@ -1509,7 +1509,7 @@ void do_cmode(const char *source, int ac, const char **av) if (!chan) { if (debug) { ci = cs_findchan(av[0]); - if (!(ci && (ci->flags & CI_FORBIDDEN))) + if (!(ci && (ci->HasFlag(CI_FORBIDDEN)))) alog("debug: MODE %s for nonexistent channel %s", merge_args(ac - 1, av + 1), av[0]); } @@ -1635,7 +1635,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) if (!c || !(ci = c->ci)) return; - if ((ci->flags & CI_FORBIDDEN) || (*(c->name) == '+')) + if ((ci->HasFlag(CI_FORBIDDEN)) || (*(c->name) == '+')) return; status = chan_get_user_status(c, user); @@ -1649,7 +1649,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) * to receive modes. I wonder who added that... *looks at Rob* ;) -GD */ if (give_modes && (get_ignore(user->nick) == NULL) - && (!user->nc || !(user->nc->flags & NI_AUTOOP))) { + && (!user->nc || !user->nc->HasFlag(NI_AUTOOP))) { if (owner && (IsFounder(user, ci) || check_access(user, ci, CA_AUTOOWNER))) add_modes |= CUS_OWNER; else if (admin && check_access(user, ci, CA_AUTOPROTECT)) @@ -1668,7 +1668,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) * Unless the channel has just been created. -heinz * Or the user matches CA_AUTODEOP... -GD */ - if (((ci->flags & CI_SECUREOPS) || (c->usercount == 1) + if (((ci->HasFlag(CI_SECUREOPS)) || (c->usercount == 1) || check_access(user, ci, CA_AUTODEOP)) && !is_ulined(user->server->name)) { if (owner && (status & CUS_OWNER) && !IsFounder(user, ci)) @@ -1823,7 +1823,7 @@ void chan_adduser2(User * user, Channel * c) if (s_BotServ && c->ci && c->ci->bi) { if (c->usercount == BSMinUsers) bot_join(c->ci); - if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) + if (c->usercount >= BSMinUsers && (c->ci->botflags.HasFlag(BS_GREET)) && user->nc && user->nc->greet && check_access(user, c->ci, CA_GREET)) { /* Only display the greet if the main uplink we're connected @@ -2071,7 +2071,7 @@ Entry *entry_create(char *mask) uint32 ip, cidr; entry = new Entry; - entry->type = ENTRYTYPE_NONE; + entry->SetFlag(ENTRYTYPE_NONE); entry->prev = NULL; entry->next = NULL; entry->nick = NULL; @@ -2113,18 +2113,18 @@ Entry *entry_create(char *mask) entry->nick = sstrdup(nick); /* Check if we have a wildcard user */ if (str_is_wildcard(nick)) - entry->type |= ENTRYTYPE_NICK_WILD; + entry->SetFlag(ENTRYTYPE_NICK_WILD); else - entry->type |= ENTRYTYPE_NICK; + entry->SetFlag(ENTRYTYPE_NICK); } if (user) { entry->user = sstrdup(user); /* Check if we have a wildcard user */ if (str_is_wildcard(user)) - entry->type |= ENTRYTYPE_USER_WILD; + entry->SetFlag(ENTRYTYPE_USER_WILD); else - entry->type |= ENTRYTYPE_USER; + entry->SetFlag(ENTRYTYPE_USER); } /* Only check the host if it's not a pure wildcard */ @@ -2132,7 +2132,7 @@ Entry *entry_create(char *mask) if (ircd->cidrchanbei && str_is_cidr(host, &ip, &cidr, &cidrhost)) { entry->cidr_ip = ip; entry->cidr_mask = cidr; - entry->type |= ENTRYTYPE_CIDR4; + entry->SetFlag(ENTRYTYPE_CIDR4); host = cidrhost; } else if (ircd->cidrchanbei && strchr(host, '/')) { /* Most IRCd's don't enforce sane bans therefore it is not @@ -2143,13 +2143,14 @@ Entry *entry_create(char *mask) * str_is_cidr() as this expects a standard cidr. * Add it to the internal list (so it is included in for example clear) * but do not use if during matching.. ~ Viper */ - entry->type = ENTRYTYPE_NONE; + entry->ClearFlags(); + entry->SetFlag(ENTRYTYPE_NONE); } else { entry->host = sstrdup(host); if (str_is_wildcard(host)) - entry->type |= ENTRYTYPE_HOST_WILD; + entry->SetFlag(ENTRYTYPE_HOST_WILD); else - entry->type |= ENTRYTYPE_HOST; + entry->SetFlag(ENTRYTYPE_HOST); } } delete [] mask; @@ -2246,28 +2247,28 @@ EList *list_create() int entry_match(Entry * e, const char *nick, const char *user, const char *host, uint32 ip) { /* If we don't get an entry, or it s an invalid one, no match ~ Viper */ - if (!e || e->type == ENTRYTYPE_NONE) + if (!e || !e->FlagCount()) return 0; - if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) && + if (ircd->cidrchanbei && (e->HasFlag(ENTRYTYPE_CIDR4)) && (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) return 0; - if ((e->type & ENTRYTYPE_NICK) + if ((e->HasFlag(ENTRYTYPE_NICK)) && (!nick || stricmp(e->nick, nick) != 0)) return 0; - if ((e->type & ENTRYTYPE_USER) + if ((e->HasFlag(ENTRYTYPE_USER)) && (!user || stricmp(e->user, user) != 0)) return 0; - if ((e->type & ENTRYTYPE_HOST) + if ((e->HasFlag(ENTRYTYPE_HOST)) && (!user || stricmp(e->host, host) != 0)) return 0; - if ((e->type & ENTRYTYPE_NICK_WILD) + if ((e->HasFlag(ENTRYTYPE_NICK_WILD)) && !Anope::Match(nick, e->nick, false)) return 0; - if ((e->type & ENTRYTYPE_USER_WILD) + if ((e->HasFlag(ENTRYTYPE_USER_WILD)) && !Anope::Match(user, e->user, false)) return 0; - if ((e->type & ENTRYTYPE_HOST_WILD) + if ((e->HasFlag(ENTRYTYPE_HOST_WILD)) && !Anope::Match(host, e->host, false)) return 0; diff --git a/src/chanserv.c b/src/chanserv.c index 340ab045c..c52cd9d07 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -134,7 +134,7 @@ class ChanServTimer : public Timer ChannelInfo *ci = cs_findchan(channel.c_str()); if (ci) - ci->flags &= ~CI_INHABIT; + ci->UnsetFlag(CI_INHABIT); ircdproto->SendPart(findbot(s_ChanServ), channel.c_str(), NULL); } @@ -394,13 +394,14 @@ void load_cs_dbase() SAFE(read = read_buffer(ci->last_topic_setter, f)); SAFE(read_int32(&tmp32, f)); ci->last_topic_time = tmp32; - SAFE(read_int32(&ci->flags, f)); + //SAFE(read_int32(&ci->flags, f)); + SAFE(read_int32(&tmp32, f)); /* Leaveops cleanup */ - if (ver <= 13 && (ci->flags & 0x00000020)) - ci->flags &= ~0x00000020; +// if (ver <= 13 && (ci->HasFlag()0x00000020)) +// ci->UnsetFlag()0x00000020; /* Temporary flags cleanup */ - ci->flags &= ~CI_INHABIT; + ci->UnsetFlag(CI_INHABIT); SAFE(read_string(&ci->forbidby, f)); SAFE(read_string(&ci->forbidreason, f)); @@ -517,7 +518,8 @@ void load_cs_dbase() ci->memos.memos[j] = new Memo; Memo *memo = ci->memos.memos[j]; SAFE(read_int32(&memo->number, f)); - SAFE(read_int16(&memo->flags, f)); + //SAFE(read_int16(&memo->flags, f)); + SAFE(read_int16(&tmp16, f)); SAFE(read_int32(&tmp32, f)); memo->time = tmp32; SAFE(read = read_buffer(memo->sender, f)); @@ -540,7 +542,7 @@ void load_cs_dbase() ci->bi = NULL; SAFE(read_int32(&tmp32, f)); - ci->botflags = tmp32; + //ci->botflags = tmp32; SAFE(read_int16(&tmp16, f)); n_ttb = tmp16; ci->ttb = new int16[2 * TTB_SIZE]; @@ -569,7 +571,9 @@ void load_cs_dbase() SAFE(read_int16(&ci->badwords[j].in_use, f)); if (ci->badwords[j].in_use) { SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_int16(&ci->badwords[j].type, f)); + //SAFE(read_int16(&ci->badwords[j].type, f)); + SAFE(read_int16(&tmp16, f)); + ci->badwords[j].type = BW_ANY; // for now } } } else { @@ -589,7 +593,7 @@ void load_cs_dbase() ChannelInfo *next; for (ci = chanlists[i]; ci; ci = next) { next = ci->next; - if (!(ci->flags & CI_FORBIDDEN) && !ci->founder) { + if (!(ci->HasFlag(CI_FORBIDDEN)) && !ci->founder) { alog("%s: database load: Deleting founderless channel %s", s_ChanServ, ci->name); delchan(ci); @@ -655,7 +659,8 @@ void save_cs_dbase() SAFE(write_string(ci->last_topic, f)); SAFE(written = write_buffer(ci->last_topic_setter, f)); SAFE(write_int32(ci->last_topic_time, f)); - SAFE(write_int32(ci->flags, f)); + //SAFE(write_int32(ci->flags, f)); + SAFE(write_int32(0, f)); SAFE(write_string(ci->forbidby, f)); SAFE(write_string(ci->forbidreason, f)); SAFE(write_int16(ci->bantype, f)); @@ -681,8 +686,9 @@ void save_cs_dbase() for (j = 0; j < ci->GetAkickCount(); ++j) { AutoKick *akick = ci->GetAkick(j); - SAFE(write_int16(akick->flags, f)); - if (akick->flags & AK_ISNICK) + //SAFE(write_int16(akick->flags, f)); + SAFE(write_int16(0, f)); + if (akick->HasFlag(AK_ISNICK)) SAFE(write_string(akick->nc->display, f)); else SAFE(write_string(akick->mask.c_str(), f)); @@ -714,7 +720,8 @@ void save_cs_dbase() for (j = 0; j < ci->memos.memos.size(); j++) { Memo *memo = ci->memos.memos[j]; SAFE(write_int32(memo->number, f)); - SAFE(write_int16(memo->flags, f)); + SAFE(write_int16(0, f)); + //SAFE(write_int16(memo->flags, f)); SAFE(write_int32(memo->time, f)); SAFE(written = write_buffer(memo->sender, f)); SAFE(write_string(memo->text, f)); @@ -727,7 +734,8 @@ void save_cs_dbase() else SAFE(write_string(NULL, f)); - SAFE(write_int32(ci->botflags, f)); + //SAFE(write_int32(ci->botflags, f)); + SAFE(write_int32(0, f)); tmp16 = TTB_SIZE; SAFE(write_int16(tmp16, f)); @@ -914,7 +922,7 @@ int check_valid_admin(User * user, Channel * chan, int servermode) return 0; /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_FORBIDDEN) + if (chan->ci->HasFlag(CI_FORBIDDEN)) return 0; if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { @@ -946,7 +954,7 @@ int check_valid_op(User * user, Channel * chan, int servermode) return 1; /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_FORBIDDEN) + if (chan->ci->HasFlag(CI_FORBIDDEN)) return 0; owner = ModeManager::FindChannelModeByName(CMODE_OWNER); @@ -1029,10 +1037,10 @@ int check_should_op(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) + if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user)) return 0; if (check_access(user, ci, CA_AUTOOP)) { @@ -1052,10 +1060,10 @@ int check_should_voice(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) + if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user)) return 0; if (check_access(user, ci, CA_AUTOVOICE)) { @@ -1072,7 +1080,7 @@ int check_should_halfop(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; if (check_access(user, ci, CA_AUTOHALFOP)) { @@ -1090,11 +1098,11 @@ int check_should_owner(User * user, char *chan) ChannelInfo *ci = cs_findchan(chan); ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if (((ci->flags & CI_SECUREFOUNDER) && IsRealFounder(user, ci)) - || (!(ci->flags & CI_SECUREFOUNDER) && IsFounder(user, ci))) { + if (((ci->HasFlag(CI_SECUREFOUNDER)) && IsRealFounder(user, ci)) + || (!(ci->HasFlag(CI_SECUREFOUNDER)) && IsFounder(user, ci))) { ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", cm->ModeChar, user->nick, user->nick); return 1; @@ -1110,7 +1118,7 @@ int check_should_protect(User * user, char *chan) ChannelInfo *ci = cs_findchan(chan); ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; if (check_access(user, ci, CA_AUTOPROTECT)) { @@ -1157,7 +1165,7 @@ int check_kick(User * user, const char *chan, time_t chants) return 0; } - if (ci->flags & CI_SUSPENDED || ci->flags & CI_FORBIDDEN) + if (ci->HasFlag(CI_SUSPENDED) || ci->HasFlag(CI_FORBIDDEN)) { if (is_oper(user)) return 0; @@ -1188,16 +1196,16 @@ int check_kick(User * user, const char *chan, time_t chants) { akick = ci->GetAkick(j); - 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) && match_usermask(akick->mask.c_str(), user))) { if (debug >= 2) - alog("debug: %s matched akick %s", user->nick, (akick->flags & AK_ISNICK) ? akick->nc->display : akick->mask.c_str()); - if (akick->flags & AK_ISNICK) + alog("debug: %s matched akick %s", user->nick, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str()); + if (akick->HasFlag(AK_ISNICK)) get_idealban(ci, user, mask, sizeof(mask)); else strlcpy(mask, akick->mask.c_str(), sizeof(mask)); @@ -1226,7 +1234,7 @@ int check_kick(User * user, const char *chan, time_t chants) * JOIN would not). */ /* Don't check for CI_INHABIT before for the Channel record cos else * c may be NULL even if it exists */ - if ((!(c = findchan(chan)) || c->usercount == 0) && !(ci->flags & CI_INHABIT)) + if ((!(c = findchan(chan)) || c->usercount == 0) && !ci->HasFlag(CI_INHABIT)) { ircdproto->SendJoin(findbot(s_ChanServ), chan, (c ? c->creation_time : chants)); /* @@ -1238,7 +1246,7 @@ int check_kick(User * user, const char *chan, time_t chants) } t = new ChanServTimer(CSInhabit, chan); - ci->flags |= CI_INHABIT; + ci->SetFlag(CI_INHABIT); } if (c) { @@ -1306,7 +1314,7 @@ void restore_topic(const char *chan) return; /* We can be sure that the topic will be in sync when we return -GD */ c->topic_sync = 1; - if (!(ci->flags & CI_KEEPTOPIC)) { + if (!(ci->HasFlag(CI_KEEPTOPIC))) { /* We need to reset the topic here, since it's currently empty and * should be updated with a TOPIC from the IRCd soon. -GD */ @@ -1356,7 +1364,7 @@ int check_topiclock(Channel * c, time_t topic_time) return 0; } - if (!(ci = c->ci) || !(ci->flags & CI_TOPICLOCK)) + if (!(ci = c->ci) || !(ci->HasFlag(CI_TOPICLOCK))) return 0; if (c->topic) @@ -1421,9 +1429,7 @@ void expire_chans() for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = next) { next = ci->next; - if (!ci->c && now - ci->last_used >= CSExpire - && !(ci-> - flags & (CI_FORBIDDEN | CI_NO_EXPIRE | CI_SUSPENDED))) + if (!ci->c && now - ci->last_used >= CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED)) { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci)); @@ -1500,7 +1506,7 @@ void cs_remove_nick(const NickCore * nc) for (j = ci->GetAkickCount(); j > 0; --j) { akick = ci->GetAkick(j - 1); - if ((akick->flags & AK_USED) && (akick->flags & AK_ISNICK) && akick->nc == nc) + if (akick->HasFlag(AK_USED) && akick->HasFlag(AK_ISNICK) && akick->nc == nc) ci->EraseAkick(akick); } } @@ -1560,7 +1566,7 @@ int check_access(User * user, ChannelInfo * ci, int what) if (level >= ACCESS_FOUNDER) return (what == CA_AUTODEOP || what == CA_NOJOIN) ? 0 : 1; /* Hacks to make flags work */ - if (what == CA_AUTODEOP && (ci->flags & CI_SECUREOPS) && level == 0) + if (what == CA_AUTODEOP && (ci->HasFlag(CI_SECUREOPS)) && level == 0) return 1; if (limit == ACCESS_INVALID) return 0; @@ -1785,7 +1791,7 @@ bool IsFounder(User *user, ChannelInfo *ci) } /* If they're QOP+ and theyre identified or theyre recognized and the channel isn't secure */ - if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->flags & CI_SECURE)))) + if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->HasFlag(CI_SECURE))))) return true; return false; @@ -1843,7 +1849,7 @@ int get_access(User *user, ChannelInfo *ci) NickAlias *na = findnick(user->nick); if (na) access = ci->GetAccess(na->nc); - if (access && user->IsRecognized() && !(ci->flags & CI_SECURE)) + if (access && user->IsRecognized() && !(ci->HasFlag(CI_SECURE))) return access->level; } @@ -1860,7 +1866,7 @@ void update_cs_lastseen(User * user, ChannelInfo * ci) return; if (IsFounder(user, ci) || nick_identified(user) - || (user->IsRecognized() && !(ci->flags & CI_SECURE))) + || (user->IsRecognized() && !ci->HasFlag(CI_SECURE))) if ((access = ci->GetAccess(user->nc))) access->last_seen = time(NULL); } @@ -1977,7 +1983,7 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask) { AutoKick *akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) || !(akick->flags & AK_STUCK)) + if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK)) continue; if (Anope::Match(akick->mask, mask, false)) @@ -2038,8 +2044,7 @@ void stick_all(ChannelInfo * ci) { AutoKick *akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) - || !(akick->flags & AK_STUCK)) + if (!akick->HasFlag(AK_USED) || (akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK))) continue; av[0] = "+b"; diff --git a/src/command.cpp b/src/command.cpp index fa5b21a2a..41e9045e5 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -13,7 +13,6 @@ Command::Command(const std::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) { - this->flags = 0; this->core = 0; this->mod_name = NULL; this->service = NULL; @@ -36,21 +35,6 @@ bool Command::OnHelp(User *u, const ci::string &subcommand) { return false; } void Command::OnSyntaxError(User *u) { } -void Command::SetFlag(CommandFlags flag) -{ - this->flags |= flag; -} - -void Command::UnsetFlag(CommandFlags flag) -{ - this->flags &= ~flag; -} - -bool Command::HasFlag(CommandFlags flag) const -{ - return this->flags & flag; -} - void Command::SetPermission(const std::string &reststr) { this->permission = reststr; diff --git a/src/commands.c b/src/commands.c index 9247307a3..d8fcf5589 100644 --- a/src/commands.c +++ b/src/commands.c @@ -123,14 +123,14 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * { if ((ci = cs_findchan(params[0].c_str()))) { - if ((ci->flags & CI_FORBIDDEN) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN))) + if ((ci->HasFlag(CI_FORBIDDEN)) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name); alog("Access denied for user %s with service %s and command %s because of FORBIDDEN channel %s", u->nick, service, cmd, ci->name); return; } - else if ((ci->flags & CI_SUSPENDED) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED))) + else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name); alog("Access denied for user %s with service %s and command %s because of SUSPENDED channel %s", diff --git a/src/config.c b/src/config.c index 070fcfb6d..03f1fde24 100644 --- a/src/config.c +++ b/src/config.c @@ -95,7 +95,7 @@ static std::string NSDefaults; char *NSGuestNickPrefix; bool NSAllowKillImmed; bool NSNoGroupChange; -int NSDefFlags; +Flags NSDefFlags; unsigned NSDefLanguage; time_t NSRegDelay; time_t NSResendDelay; @@ -117,7 +117,7 @@ bool NSModeOnID; bool NSAddAccessOnReg; static std::string CSDefaults; -int CSDefFlags; +Flags CSDefFlags; unsigned CSMaxReg; time_t CSExpire; int CSDefBantype; @@ -135,7 +135,7 @@ bool MSNotifyAll; unsigned MSMemoReceipt; static std::string BSDefaults; -int BSDefFlags; +Flags BSDefFlags; time_t BSKeepData; unsigned BSMinUsers; unsigned BSBadWordsMax; @@ -1785,29 +1785,34 @@ int read_config(int reload) } } - NSDefFlags = 0; - if (NSDefaults.empty()) NSDefFlags = NI_SECURE | NI_MEMO_SIGNON | NI_MEMO_RECEIVE; + if (NSDefaults.empty()) + { + NSDefFlags.SetFlag(NI_SECURE); + NSDefFlags.SetFlag(NI_MEMO_SIGNON); + NSDefFlags.SetFlag(NI_MEMO_RECEIVE); + } else if (NSDefaults != "none") { bool hadAutoop = false; spacesepstream options(NSDefaults); std::string option; - while (options.GetToken(option)) { - if (option == "kill") NSDefFlags |= NI_KILLPROTECT; - else if (option == "killquick") NSDefFlags |= NI_KILL_QUICK; - else if (option == "secure") NSDefFlags |= NI_SECURE; - else if (option == "private") NSDefFlags |= NI_PRIVATE; + while (options.GetToken(option)) + { + if (option == "kill") NSDefFlags.SetFlag(NI_KILLPROTECT); + else if (option == "killquick") NSDefFlags.SetFlag(NI_KILL_QUICK); + else if (option == "secure") NSDefFlags.SetFlag(NI_SECURE); + else if (option == "private") NSDefFlags.SetFlag(NI_PRIVATE); else if (option == "msg") { if (!UsePrivmsg) alog("msg in can only be used when UsePrivmsg is set"); - else NSDefFlags |= NI_MSG; + else NSDefFlags.SetFlag(NI_MSG); } - else if (option == "hideemail") NSDefFlags |= NI_HIDE_EMAIL; - else if (option == "hideusermask") NSDefFlags |= NI_HIDE_MASK; - else if (option == "hidequit") NSDefFlags |= NI_HIDE_QUIT; - else if (option == "memosignon") NSDefFlags |= NI_MEMO_SIGNON; - else if (option == "memoreceive") NSDefFlags |= NI_MEMO_RECEIVE; + else if (option == "hideemail") NSDefFlags.SetFlag(NI_HIDE_EMAIL); + else if (option == "hideusermask") NSDefFlags.SetFlag(NI_HIDE_MASK); + else if (option == "hidequit") NSDefFlags.SetFlag(NI_HIDE_QUIT); + else if (option == "memosignon") NSDefFlags.SetFlag(NI_MEMO_SIGNON); + else if (option == "memoreceive") NSDefFlags.SetFlag(NI_MEMO_RECEIVE); else if (option == "autoop") hadAutoop = true; } - if (!hadAutoop) NSDefFlags |= NI_AUTOOP; + if (!hadAutoop) NSDefFlags.SetFlag(NI_AUTOOP); } if (reload) { @@ -1820,37 +1825,41 @@ int read_config(int reload) retval = 0; } - CSDefFlags = 0; - if (CSDefaults.empty()) CSDefFlags = CI_KEEPTOPIC | CI_SECURE | CI_SECUREFOUNDER | CI_SIGNKICK; + if (CSDefaults.empty()) + { + CSDefFlags.SetFlag(CI_KEEPTOPIC); + CSDefFlags.SetFlag(CI_SECURE); + CSDefFlags.SetFlag(CI_SECUREFOUNDER); + CSDefFlags.SetFlag(CI_SIGNKICK); + } else if (CSDefaults != "none") { spacesepstream options(CSDefaults); std::string option; while (options.GetToken(option)) { - if (option == "keeptopic") CSDefFlags |= CI_KEEPTOPIC; - else if (option == "topiclock") CSDefFlags |= CI_TOPICLOCK; - else if (option == "private") CSDefFlags |= CI_PRIVATE; - else if (option == "restricted") CSDefFlags |= CI_RESTRICTED; - else if (option == "secure") CSDefFlags |= CI_SECURE; - else if (option == "secureops") CSDefFlags |= CI_SECUREOPS; - else if (option == "securefounder") CSDefFlags |= CI_SECUREFOUNDER; - else if (option == "signkick") CSDefFlags |= CI_SIGNKICK; - else if (option == "signkicklevel") CSDefFlags |= CI_SIGNKICK_LEVEL; - else if (option == "opnotice") CSDefFlags |= CI_OPNOTICE; - else if (option == "xop") CSDefFlags |= CI_XOP; - else if (option == "peace") CSDefFlags |= CI_PEACE; + if (option == "keeptopic") CSDefFlags.SetFlag(CI_KEEPTOPIC); + else if (option == "topiclock") CSDefFlags.SetFlag(CI_TOPICLOCK); + else if (option == "private") CSDefFlags.SetFlag(CI_PRIVATE); + else if (option == "restricted") CSDefFlags.SetFlag(CI_RESTRICTED); + else if (option == "secure") CSDefFlags.SetFlag(CI_SECURE); + else if (option == "secureops") CSDefFlags.SetFlag(CI_SECUREOPS); + else if (option == "securefounder") CSDefFlags.SetFlag(CI_SECUREFOUNDER); + else if (option == "signkick") CSDefFlags.SetFlag(CI_SIGNKICK); + else if (option == "signkicklevel") CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL); + else if (option == "opnotice") CSDefFlags.SetFlag(CI_OPNOTICE); + else if (option == "xop") CSDefFlags.SetFlag(CI_XOP); + else if (option == "peace") CSDefFlags.SetFlag(CI_PEACE); } } - BSDefFlags = 0; if (!BSDefaults.empty()) { spacesepstream options(BSDefaults); std::string option; while (options.GetToken(option)) { - if (option == "dontkickops") BSDefFlags |= BS_DONTKICKOPS; - else if (option == "dontkickvoices") BSDefFlags |= BS_DONTKICKVOICES; - else if (option == "greet") BSDefFlags |= BS_GREET; - else if (option == "fantasy") BSDefFlags |= BS_FANTASY; - else if (option == "symbiosis") BSDefFlags |= BS_SYMBIOSIS; + if (option == "dontkickops") BSDefFlags.SetFlag(BS_DONTKICKOPS); + else if (option == "dontkickvoices") BSDefFlags.SetFlag(BS_DONTKICKVOICES); + else if (option == "greet") BSDefFlags.SetFlag(BS_GREET); + else if (option == "fantasy") BSDefFlags.SetFlag(BS_FANTASY); + else if (option == "symbiosis") BSDefFlags.SetFlag(BS_SYMBIOSIS); } } 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)) && !ch