diff options
Diffstat (limited to 'src')
70 files changed, 634 insertions, 627 deletions
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); - SA |
