diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-10-13 21:26:38 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-10-13 21:26:38 +0000 |
| commit | d3d64c27b199622c90075d6f59dd08e44acbb378 (patch) | |
| tree | 68029e10dc754271235e2a4e3d04b3fb19ddd15c /src | |
| parent | 1fd66851320e239b531720c27614a5ad4c604c97 (diff) | |
Complete rewrite of everything associated with modes, this breaks saving and reading mlocked modes from the databases until the new databases are implemented
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2560 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
32 files changed, 1869 insertions, 3127 deletions
diff --git a/src/Makefile b/src/Makefile index a54d194c4..2f8845b4d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o command.o comm config.o datafiles.o encrypt.o hashcomp.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \ memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \ process.o protocol.o send.o servers.o sessions.o slist.o sockutil.o opertype.o users.o module.o modulemanager.o configreader.o \ - wildcard.o nickcore.o nickalias.o timers.o + wildcard.o nickcore.o nickalias.o timers.o modes.o INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \ ../include/pseudo.h ../include/sysconf.h ../include/config.h \ @@ -33,6 +33,7 @@ services: $(OBJS) $(MAKEBIN) $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS) $(OBJS): Makefile +modes.o: modes.cpp $(INCLUDES) timers.o: timers.cpp $(INCLUDES) nickcore.o: nickcore.cpp $(INCLUDES) nickalias.o: nickalias.cpp $(INCLUDES) diff --git a/src/botserv.c b/src/botserv.c index 3fc4c5c11..0e4f37600 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -772,12 +772,19 @@ void bot_join(ChannelInfo * ci) } } + std::string Limit; + int limit = 0; + if (ci->c->GetParam(CMODE_LIMIT, &Limit)) + { + limit = atoi(Limit.c_str()); + } + /* Should we be invited? */ - if ((ci->c->mode & anope_get_invite_mode()) - || (ci->c->limit && ci->c->usercount >= ci->c->limit)) + if (ci->c->HasMode(CMODE_INVITE) + || (limit && ci->c->usercount >= limit)) ircdproto->SendNoticeChanops(NULL, ci->c->name, - "%s invited %s into the channel.", - ci->bi->nick, ci->bi->nick); + "%s invited %s into the channel.", + ci->bi->nick, ci->bi->nick); } ircdproto->SendJoin(ci->bi, ci->c->name, ci->c->creation_time); ircdproto->SendBotOp(ci->bi->nick, ci->c->name); @@ -877,7 +884,8 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, if (!u) return; - if (ircd->protectedumode) { + if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) + { if (is_protected(u) && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", getstring(ACCESS_DENIED)); @@ -889,7 +897,8 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, && (get_access(u, ci) >= get_access(requester, ci))) return; - if (ircd->except) { + if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) + { if (is_excepted(ci, u) == 1) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", getstring(BOT_EXCEPT)); @@ -953,7 +962,8 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, if (!u || !is_on_chan(ci->c, u)) return; - if (ircd->protectedumode) { + if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) + { if (is_protected(u) && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", getstring(ACCESS_DENIED)); @@ -1007,7 +1017,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); - if (ircd->protectedumode) { + if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) { if (is_protected(u) && *mode == '-' && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", getstring(ACCESS_DENIED)); diff --git a/src/channels.c b/src/channels.c index f41219109..5984065e0 100644 --- a/src/channels.c +++ b/src/channels.c @@ -20,7 +20,279 @@ Channel *chanlist[1024]; #define HASH(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0) -/**************************** External Calls *****************************/ +/*************************************************************************/ + +/** + * See if a channel has a mode + * @param Name The mode name + * @return true or false + */ +bool Channel::HasMode(ChannelModeName Name) +{ + return modes[(size_t)Name]; +} + +/** + * Set a mode on a channel + * @param Name The mode name + */ +void Channel::SetMode(ChannelModeName Name) +{ + modes[(size_t)Name] = true; +} + +/** + * Set a mode on a channel + * @param Mode The mode + */ +void Channel::SetMode(char Mode) +{ + ChannelMode *cm; + + if ((cm = ModeManager::FindChannelModeByChar(Mode))) + { + SetMode(cm->Name); + } +} + +/** + * Remove a mode from a channel + * @param Name The mode name + */ +void Channel::RemoveMode(ChannelModeName Name) +{ + modes[(size_t)Name] = false; +} + +/** + * Remove a mode from a channel + * @param Mode The mode + */ +void Channel::RemoveMode(char Mode) +{ + ChannelMode *cm; + + if ((cm = ModeManager::FindChannelModeByChar(Mode))) + { + RemoveMode(cm->Name); + } +} + +/** Set a channel mode param on the channel + * @param Name The mode + * @param param The param + * @param true on success + */ +bool Channel::SetParam(ChannelModeName Name, std::string &Value) +{ + return Params.insert(std::make_pair(Name, Value)).second; +} + +/** Unset a param from the channel + * @param Name The mode + */ +void Channel::UnsetParam(ChannelModeName Name) +{ + std::map<ChannelModeName, std::string>::iterator it = Params.find(Name); + + if (it != Params.end()) + { + Params.erase(it); + } +} + +/** Get a param from the channel + * @param Name The mode + * @param Target a string to put the param into + * @return true on success + */ +const bool Channel::GetParam(ChannelModeName Name, std::string *Target) +{ + std::map<ChannelModeName, std::string>::iterator it = Params.find(Name); + + (*Target).clear(); + + if (it != Params.end()) + { + *Target = it->second; + return true; + } + + return false; +} + +/** Check if a mode is set and has a param + * @param Name The mode + */ +const bool Channel::HasParam(ChannelModeName Name) +{ + std::map<ChannelModeName, std::string>::iterator it = Params.find(Name); + + if (it != Params.end()) + { + return true; + } + + return false; +} + +/*************************************************************************/ + +/** Clear all the modes from the channel + * @param client The client unsetting the modes + */ +void Channel::ClearModes(char *client) +{ + ChannelMode *cm; + ChannelModeParam *cmp; + std::string buf, buf2; + const char *argv[2]; + BotInfo *sender = (client ? findbot(client) : whosends(ci)); + + for (size_t n = CMODE_BEGIN + 1; n != CMODE_END; ++n) + { + cm = ModeManager::FindChannelModeByName((ChannelModeName)n); + + if (cm && this->HasMode(cm->Name)) + { + if (cm->Type == MODE_REGULAR) + { + buf = '-'; + buf += cm->ModeChar; + + argv[0] = buf.c_str(); + + ircdproto->SendMode(sender, this->name, "-%c", cm->ModeChar); + chan_set_modes(sender->nick, this, 1, argv, 0); + } + else if (cm->Type == MODE_PARAM) + { + cmp = static_cast<ChannelModeParam *>(cm); + + buf = '-'; + buf += cmp->ModeChar; + buf2.clear(); + + if (!cmp->MinusNoArg) + { + buf2 = this->GetParam(cmp->Name, &buf2); + } + + argv[0] = buf.c_str(); + if (!buf2.empty()) + { + argv[1] = buf2.c_str(); + + ircdproto->SendMode(sender, this->name, "-%c %s", cm->ModeChar, buf2.c_str()); + chan_set_modes(sender->nick, this, 2, argv, 0); + } + else + { + argv[1] = NULL; + + ircdproto->SendMode(sender, this->name, "-%c", cm->ModeChar); + chan_set_modes(sender->nick, this, 1, argv, 0); + } + } + } + } + + modes.reset(); +} + +/** Clear all the bans from the channel + * @param client The client unsetting the modes + */ +void Channel::ClearBans(char *client) +{ + Entry *entry, *nexte; + BotInfo *sender = (client ? findbot(client) : whosends(ci)); + ChannelModeList *cml; + std::string buf; + const char *argv[2]; + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN)); + + if (cml && this->bans && this->bans->count) + { + buf = '-'; + buf += cml->ModeChar; + + for (entry = this->bans->entries; entry; entry = nexte) + { + nexte = entry->next; + + argv[0] = buf.c_str(); + argv[1] = sstrdup(entry->mask); + ircdproto->SendMode(sender, this->name, "%s %s", buf.c_str(), entry->mask); + chan_set_modes(sender->nick, this, 2, argv, 0); + delete [] argv[1]; + } + } +} + +/** Clear all the excepts from the channel + * @param client The client unsetting the modes + */ +void Channel::ClearExcepts(char *client) +{ + Entry *entry, *nexte; + BotInfo *sender = (client ? findbot(client) : whosends(ci)); + ChannelModeList *cml; + std::string buf; + const char *argv[2]; + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT)); + + if (cml && this->excepts && this->excepts->count) + { + buf = '+'; + buf += cml->ModeChar; + + for (entry = this->excepts->entries; entry; entry = nexte) + { + nexte = entry->next; + + argv[0] = buf.c_str(); + argv[1] = sstrdup(entry->mask); + ircdproto->SendMode(sender, this->name, "%s %s", buf.c_str(), entry->mask); + chan_set_modes(sender->nick, this, 2, argv, 0); + delete [] argv[1]; + } + } +} + +/** Clear all the invites from the channel + * @param client The client unsetting the modes + */ +void Channel::ClearInvites(char *client) +{ + Entry *entry, *nexte; + BotInfo *sender = (client ? findbot(client) : whosends(ci)); + ChannelModeList *cml; + std::string buf; + const char *argv[2]; + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE)); + + if (cml && this->invites && this->invites->count) + { + buf = '-'; + buf += cml->ModeChar; + + for (entry = this->invites->entries; entry; entry = nexte) + { + nexte = entry->next; + + argv[0] = buf.c_str(); + argv[1] = sstrdup(entry->mask); + ircdproto->SendMode(sender, this->name, "%s %s", buf.c_str(), entry->mask); + chan_set_modes(sender->nick, this, 2, argv, 0); + delete [] argv[1]; + } + } +} + /*************************************************************************/ void chan_deluser(User * user, Channel * c) @@ -66,33 +338,50 @@ void chan_deluser(User * user, Channel * c) char *chan_get_modes(Channel * chan, int complete, int plus) { static char res[BUFSIZE]; - char *end = res; - - if (chan->mode) { - unsigned int n = 0; - CBModeInfo *cbmi = cbmodeinfos; - - do { - if (chan->mode & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - - if (complete) { - cbmi = cbmodeinfos; + char params[BUFSIZE]; + char *end = res, *value, *pend = params, *pend2 = params; + std::string param; + ChannelMode *cm; + ChannelModeParam *cmp; + std::map<char, ChannelMode *>::iterator it; + + if (!chan->modes.count()) + { + for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it) + { + cm = it->second; - do { - if (cbmi->getvalue && (chan->mode & cbmi->flag) && - (plus || !(cbmi->flags & CBM_MINUS_NO_ARG))) { - char *value = cbmi->getvalue(chan); + if (chan->HasMode(cm->Name)) + { + *end++ = it->first; - if (value) { - *end++ = ' '; - while (*value) - *end++ = *value++; + if (complete) + { + if (cm->Type == MODE_PARAM) + { + cmp = static_cast<ChannelModeParam *>(cm); + + if (plus || !cmp->MinusNoArg) + { + chan->GetParam(cmp->Name, ¶m); + + if (!param.empty()) + { + value = const_cast<char *>(param.c_str()); + + *pend++ = ' '; + + while (*value) + *pend++ = *value++; + } + } } } - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + } } + + while (*pend2) + *end++ = *pend2++; } *end = 0; @@ -156,128 +445,158 @@ void chan_remove_user_status(Channel * chan, User * user, int16 status) /*************************************************************************/ -void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, - int check) +void chan_set_modes(const char *source, Channel *chan, int ac, const char **av, int check) { - int add = 1; - const char *modes = av[0]; + int add = 1, i, real_ac = ac; + ChannelMode *cm; + ChannelModeStatus *cms; + ChannelModeList *cml; + ChannelModeParam *cmp; + const char *modes, **real_av = av; char mode; - CBMode *cbm; - CMMode *cmm; - CUMode *cum; - unsigned char botmode = 0; BotInfo *bi; + unsigned char botmode = 0; User *user; - int i, real_ac = ac; - const char **real_av = av; + + modes = av[0]; if (debug) - alog("debug: Changing modes for %s to %s", chan->name, - merge_args(ac, av)); + alog("debug: Changing modes for %s to %s", chan->name, merge_args(ac, av)); ac--; - while ((mode = *modes++)) { - - switch (mode) { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; + while ((mode = *modes++)) + { + switch (mode) + { + case '+': + add = 1; + continue; + case '-': + add = 0; + continue; } - if (static_cast<int>(mode) < 0) { - if (debug) - alog("Debug: Malformed mode detected on %s.", chan->name); - continue; - } + if ((cm = ModeManager::FindChannelModeByChar(mode))) + { + /* v/h/o/a/q etc */ + if (cm->Type == MODE_STATUS) + { + cms = static_cast<ChannelModeStatus *>(cm); - if ((cum = &cumodes[static_cast<int>(mode)])->status != 0) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); - continue; - } - ac--; - av++; + if (ac == 0) + { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } - if ((cum->flags & CUF_PROTECT_BOTSERV) && !add) { - if ((bi = findbot(*av))) { - if (!botmode || botmode != mode) { - ircdproto->SendMode(bi, chan->name, "+%c %s", - mode, bi->nick); - botmode = mode; - continue; - } else { - botmode = mode; - continue; + ac--; + av++; + + if (cms->ProtectBotServ && !add) + { + if ((bi = findbot(*av))) + { + if (!botmode || botmode != mode) + { + ircdproto->SendMode(bi, chan->name, "+%c %s", mode, bi->nick); + botmode = mode; + continue; + } + else + { + botmode = mode; + continue; + } } } - } else { - if ((bi = findbot(*av))) { + else if ((bi = findbot(*av))) continue; - } - } - if (!(user = finduser(*av)) - && !(ircd->ts6 && (user = find_byuid(*av)))) { - if (debug) { - alog("debug: MODE %s %c%c for nonexistent user %s", - chan->name, (add ? '+' : '-'), mode, *av); + if (!(user = finduser(*av)) && !(ircd->ts6 && (user = find_byuid(*av)))) + { + if (debug) + { + alog("debug: MODE %s %c%c for nonexistent user %s", + chan->name, (add ? '+' : '-'), mode, *av); + } + continue; } - continue; - } - if (debug) - alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'), - mode, chan->name, user->nick); + if (debug) + alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'), + mode, chan->name, user->nick); - if (add) { - chan_set_user_status(chan, user, cum->status); - /* If this does +o, remove any DEOPPED flag */ - } else { - chan_remove_user_status(chan, user, cum->status); + if (add) + chan_set_user_status(chan, user, cms->Status); + /* If this does +o, remove any DEOPPED flag */ + else + chan_remove_user_status(chan, user, cms->Status); } + /* b/e/I etc */ + else if (cm->Type == MODE_LIST) + { + cml = static_cast<ChannelModeList *>(cm); + + if (ac == 0) + { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } + + ac--; + av++; - } else if ((cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) { - if (check >= 0) { if (add) - chan->mode |= cbm->flag; + cml->AddMask(chan, *av); else - chan->mode &= ~cbm->flag; + cml->DelMask(chan, *av); } + else + { + if (check >= 0) + { + if (add) + chan->SetMode(mode); + else + chan->RemoveMode(mode); + } + + if (cm->Type == MODE_PARAM) + { + cmp = static_cast<ChannelModeParam *>(cm); + + if (add || !cmp->MinusNoArg) + { + if (ac == 0) + { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } + + ac--; + av++; + } - if (cbm->setvalue) { - if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + if (*av && !cmp->IsValid(*av)) continue; + if (add) + { + std::string Param = *av; + chan->SetParam(cmp->Name, Param); } - ac--; - av++; + else + chan->UnsetParam(cmp->Name); } - cbm->setvalue(chan, add ? *av : NULL); - } - if (check < 0) { - if (add) - chan->mode |= cbm->flag; - else - chan->mode &= ~cbm->flag; - } - } else if ((cmm = &cmmodes[static_cast<int>(mode)])->addmask) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); - continue; + if (check < 0) + { + if (add) + chan->SetMode(mode); + else + chan->RemoveMode(mode); + } } - - ac--; - av++; - if (add) - cmm->addmask(chan, *av); - else - cmm->delmask(chan, *av); } } @@ -297,6 +616,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, */ real_ac--; real_av++; + for (i = 0; i < real_ac; i++) { if ((user = finduser(*real_av)) && is_on_chan(chan, user)) @@ -328,19 +648,24 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, void chan_set_user_status(Channel * chan, User * user, int16 status) { struct u_chanlist *uc; + UserMode *um; + char av[3]; if (debug >= 2) alog("debug: setting user status (%d) on %s for %s", status, user->nick, chan->name); - if (HelpChannel && ircd->supporthelper && (status & CUS_OP) + if (HelpChannel && ((um = ModeManager::FindUserModeByName(UMODE_HELPOP))) && (status & CUS_OP) && (stricmp(chan->name, HelpChannel) == 0) && (!chan->ci || check_access(user, chan->ci, CA_AUTOOP))) { if (debug) { - alog("debug: %s being given +h for having %d status in %s", + alog("debug: %s being given helpop for having %d status in %s", user->nick, status, chan->name); } - common_svsmode(user, "+h", NULL); + + snprintf(av, sizeof(av), "+%c", um->ModeChar); + + common_svsmode(user, av, NULL); } for (uc = user->chans; uc; uc = uc->next) { @@ -429,6 +754,7 @@ void get_channel_stats(long *nrec, long *memuse) struct c_userlist *cu; BanData *bd; int i; + std::string buf; for (i = 0; i < 1024; i++) { for (chan = chanlist[i]; chan; chan = chan->next) { @@ -436,23 +762,17 @@ void get_channel_stats(long *nrec, long *memuse) mem += sizeof(*chan); if (chan->topic) mem += strlen(chan->topic) + 1; - if (chan->key) - mem += strlen(chan->key) + 1; - if (ircd->fmode) { - if (chan->flood) - mem += strlen(chan->flood) + 1; - } - if (ircd->Lmode) { - if (chan->redirect) - mem += strlen(chan->redirect) + 1; - } + if (chan->GetParam(CMODE_KEY, &buf)) + mem += buf.length() + 1; + if (chan->GetParam(CMODE_FLOOD, &buf)) + mem += buf.length() + 1; + if (chan->GetParam(CMODE_REDIRECT, &buf)) + mem += buf.length() + 1; mem += get_memuse(chan->bans); - if (ircd->except) { + if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) mem += get_memuse(chan->excepts); - } - if (ircd->invitemode) { + if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE)) mem += get_memuse(chan->invites); - } for (cu = chan->users; cu; cu = cu->next) { mem += sizeof(*cu); if (cu->ud) { @@ -756,12 +1076,13 @@ void do_sjoin(const char *source, int ac, const char **av) Server *serv; struct c_userlist *cu; const char *s = NULL; - char *buf, *end, cubuf[7], *end2; + char *buf, *end, cubuf[7], *end2, value; const char *modes[6]; int is_sqlined = 0; int ts = 0; int is_created = 0; int keep_their_modes = 1; + ChannelModeList *cml; serv = findserver(servlist, source); @@ -792,9 +1113,9 @@ void do_sjoin(const char *source, int ac, const char **av) bot_join(c->ci); } /* Make sure +r is set */ - if (ircd->chanreg && ircd->regmode) + if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) { - c->mode |= ircd->regmode; + c->SetMode(CMODE_REGISTERED); ircdproto->SendMode(whosends(c->ci), c->name, "+r"); } } @@ -827,8 +1148,12 @@ void do_sjoin(const char *source, int ac, const char **av) if (ircd->sjoinbanchar) { if (*s == ircd->sjoinbanchar && keep_their_modes) { - buf = myStrGetToken(s, ircd->sjoinbanchar, 1); - add_ban(c, buf); + buf = myStrGetToken(s, ircd->sjoinbanchar, 1); + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN)); + if (cml->IsValid(buf)) + cml->AddMask(c, buf); + delete [] buf; if (!end) break; @@ -839,7 +1164,11 @@ void do_sjoin(const char *source, int ac, const char **av) if (ircd->sjoinexchar) { if (*s == ircd->sjoinexchar && keep_their_modes) { buf = myStrGetToken(s, ircd->sjoinexchar, 1); - add_exception(c, buf); + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT)); + if (cml->IsValid(buf)) + cml->AddMask(c, buf); + delete [] buf; if (!end) break; @@ -851,7 +1180,11 @@ void do_sjoin(const char *source, int ac, const char **av) if (ircd->sjoininvchar) { if (*s == ircd->sjoininvchar && keep_their_modes) { buf = myStrGetToken(s, ircd->sjoininvchar, 1); - add_invite(c, buf); + + cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE)); + if (cml->IsValid(buf)) + cml->AddMask(c, buf); + delete [] buf; if (!end) break; @@ -860,11 +1193,13 @@ void do_sjoin(const char *source, int ac, const char **av) } } - while (csmodes[static_cast<int>(*s)] != 0) - *end2++ = csmodes[static_cast<int>(*s++)]; + while ((value = ModeManager::GetStatusChar(*s))) + { + *end2++ = value; + *s++; + } *end2 = 0; - if (ircd->ts6) { user = find_byuid(s); if (!user) @@ -944,8 +1279,11 @@ void do_sjoin(const char *source, int ac, const char **av) end2 = cubuf + 1; - while (csmodes[static_cast<int>(*s)] != 0) - *end2++ = csmodes[static_cast<int>(*s++)]; + while ((value = ModeManager::GetStatusChar(*s))) + { + *end2++ = value; + *s++; + } *end2 = 0; if (ircd->ts6) { @@ -1017,8 +1355,11 @@ void do_sjoin(const char *source, int ac, const char **av) end2 = cubuf + 1; - while (csmodes[static_cast<int>(*s)] != 0) - *end2++ = csmodes[static_cast<int>(*s++)]; + while ((value = ModeManager::GetStatusChar(*s))) + { + *end2++ = value; + *s++; + } *end2 = 0; if (ircd->ts6) { @@ -1264,95 +1605,6 @@ void do_topic(const char *source, int ac, const char **av) /**************************** Internal Calls *****************************/ /*************************************************************************/ -void add_ban(Channel * chan, const char *mask) -{ - Entry *ban; - /* check for NULL values otherwise we will segfault */ - if (!chan || !mask) { - if (debug) { - alog("debug: add_ban called with NULL values"); - } - return; - } - - /* Check if the list already exists, if not create it. - * Create a new ban and add it to the list.. ~ Viper */ - if (!chan->bans) - chan->bans = list_create |
