diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/actions.c | 11 | ||||
| -rw-r--r-- | src/bots.cpp | 6 | ||||
| -rw-r--r-- | src/botserv.c | 47 | ||||
| -rw-r--r-- | src/channels.c | 237 | ||||
| -rw-r--r-- | src/chanserv.c | 4 | ||||
| -rw-r--r-- | src/core/bs_act.c | 2 | ||||
| -rw-r--r-- | src/core/bs_say.c | 2 | ||||
| -rw-r--r-- | src/core/cs_akick.c | 12 | ||||
| -rw-r--r-- | src/core/cs_clear.c | 121 | ||||
| -rw-r--r-- | src/core/cs_forbid.c | 10 | ||||
| -rw-r--r-- | src/core/cs_set.c | 4 | ||||
| -rw-r--r-- | src/core/cs_suspend.c | 10 | ||||
| -rw-r--r-- | src/core/os_chankill.c | 13 | ||||
| -rw-r--r-- | src/core/os_chanlist.c | 12 | ||||
| -rw-r--r-- | src/core/os_clearmodes.c | 46 | ||||
| -rw-r--r-- | src/core/os_userlist.c | 11 | ||||
| -rw-r--r-- | src/memoserv.c | 10 | ||||
| -rw-r--r-- | src/modes.cpp | 2 | ||||
| -rw-r--r-- | src/modules/cs_enforce.c | 46 | ||||
| -rw-r--r-- | src/nickserv.c | 7 | ||||
| -rw-r--r-- | src/protocol/bahamut.c | 16 | ||||
| -rw-r--r-- | src/protocol/inspircd11.c | 16 | ||||
| -rw-r--r-- | src/protocol/inspircd12.cpp | 16 | ||||
| -rw-r--r-- | src/protocol/ratbox.c | 16 | ||||
| -rw-r--r-- | src/protocol/unreal32.c | 16 | ||||
| -rw-r--r-- | src/regchannel.cpp | 2 | ||||
| -rw-r--r-- | src/users.c | 20 |
27 files changed, 333 insertions, 382 deletions
diff --git a/src/actions.c b/src/actions.c index 142f2ae61..39c646cce 100644 --- a/src/actions.c +++ b/src/actions.c @@ -75,7 +75,6 @@ void sqline(const std::string &mask, const std::string &reason) { int i; Channel *c, *next; - struct c_userlist *cu, *cunext; if (ircd->chansqline) { @@ -91,12 +90,14 @@ void sqline(const std::string &mask, const std::string &reason) if (!Anope::Match(c->name, mask, false)) continue; - for (cu = c->users; cu; cu = cunext) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - cunext = cu->next; - if (is_oper(cu->user)) + UserContainer *uc = *it; + ++it; + + if (is_oper(uc->user)) continue; - c->Kick(NULL, cu->user, "%s", reason.c_str()); + c->Kick(NULL, uc->user, "%s", reason.c_str()); } } } diff --git a/src/bots.cpp b/src/bots.cpp index 58206963c..d19386abc 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -92,7 +92,7 @@ void BotInfo::RejoinAll() for (i = 0; i < 256; ++i) for (ci = chanlists[i]; ci; ci = ci->next) - if (ci->bi == this && ci->c && (ci->c->usercount >= Config.BSMinUsers)) + if (ci->bi == this && ci->c && (ci->c->users.size() >= Config.BSMinUsers)) bot_join(ci); } @@ -108,7 +108,7 @@ void BotInfo::Assign(User *u, ChannelInfo *ci) ci->bi = this; ++this->chancount; - if (ci->c && ci->c->usercount >= Config.BSMinUsers) + if (ci->c && ci->c->users.size() >= Config.BSMinUsers) bot_join(ci); } @@ -119,7 +119,7 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci) if (MOD_RESULT == EVENT_STOP) return; - if (ci->c && ci->c->usercount >= Config.BSMinUsers) + if (ci->c && ci->c->users.size() >= Config.BSMinUsers) { if (u) ircdproto->SendPart(ci->bi, ci->c, "UNASSIGN from %s", u->nick.c_str()); diff --git a/src/botserv.c b/src/botserv.c index 855797ef1..25bebaed3 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -572,38 +572,31 @@ static BanData *get_ban_data(Channel * c, User * u) * Allocates it if necessary. */ -static UserData *get_user_data(Channel * c, User * u) +static UserData *get_user_data(Channel *c, User *u) { - struct c_userlist *user; - if (!c || !u) return NULL; - for (user = c->users; user; user = user->next) { - if (user->user == u) { - if (user->ud) { - time_t now = time(NULL); - - /* Checks whether data is obsolete */ - if (now - user->ud->last_use > Config.BSKeepData) { - if (user->ud->lastline) - delete [] user->ud->lastline; - /* We should not free and realloc, but reset to 0 - instead. */ - memset(user->ud, 0, sizeof(UserData)); - user->ud->last_use = now; - } + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + { + UserContainer *uc = *it; - return user->ud; - } else { - user->ud = new UserData; - user->ud->last_use = time(NULL); - user->ud->lines = 0; - user->ud->last_start = 0; - user->ud->lastline = NULL; - user->ud->times = 0; - return user->ud; + if (uc->user == u) + { + time_t now = time(NULL); + + /* Checks whether data is obsolete */ + if (now - uc->ud->last_use > Config.BSKeepData) + { + if (uc->ud->lastline) + delete [] uc->ud->lastline; + /* We should not free and realloc, but reset to 0 + instead. */ + memset(uc->ud, 0, sizeof(UserData)); + uc->ud->last_use = now; } + + return uc->ud; } } @@ -646,7 +639,7 @@ void bot_join(ChannelInfo * ci) /* Should we be invited? */ if (ci->c->HasMode(CMODE_INVITE) - || (limit && ci->c->usercount >= limit)) + || (limit && ci->c->users.size() >= limit)) ircdproto->SendNoticeChanops(ci->bi, ci->c, "%s invited %s into the channel.", ci->bi->nick.c_str(), ci->bi->nick.c_str()); diff --git a/src/channels.c b/src/channels.c index 5f18ad4bb..f0c6e704e 100644 --- a/src/channels.c +++ b/src/channels.c @@ -44,8 +44,6 @@ Channel::Channel(const std::string &name, time_t ts) this->creation_time = ts; this->topic = NULL; this->bans = this->excepts = this->invites = NULL; - this->users = NULL; - this->usercount = 0; this->bd = NULL; this->server_modetime = this->chanserv_modetime = 0; this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_sync = 0; @@ -128,31 +126,14 @@ void Channel::Sync() void Channel::JoinUser(User *user) { - struct u_chanlist *c; - if (debug) alog("debug: %s joins %s", user->nick.c_str(), this->name.c_str()); - c = new u_chanlist; - c->prev = NULL; - c->next = user->chans; - if (user->chans) - user->chans->prev = c; - user->chans = c; - c->chan = this; - c->status = 0; - - struct c_userlist *u; - - u = new c_userlist; - u->prev = NULL; - u->next = this->users; - if (this->users) - this->users->prev = u; - this->users = u; - u->user = user; - u->ud = NULL; - this->usercount++; + ChannelContainer *cc = new ChannelContainer(this); + user->chans.push_back(cc); + + UserContainer *uc = new UserContainer(user); + this->users.push_back(uc); if (get_ignore(user->nick.c_str()) == NULL) { @@ -178,12 +159,12 @@ void Channel::JoinUser(User *user) **/ if (Config.s_BotServ && this->ci && this->ci->bi && !this->ci->HasFlag(CI_PERSIST)) { - if (this->usercount == Config.BSMinUsers) + if (this->users.size() == Config.BSMinUsers) bot_join(this->ci); } if (Config.s_BotServ && this->ci && this->ci->bi) { - if (this->usercount >= Config.BSMinUsers && (this->ci->botflags.HasFlag(BS_GREET)) + if (this->users.size() >= Config.BSMinUsers && (this->ci->botflags.HasFlag(BS_GREET)) && user->nc && user->nc->greet && check_access(user, this->ci, CA_GREET)) { /* Only display the greet if the main uplink we're connected @@ -207,26 +188,17 @@ void Channel::DeleteUser(User *user) if (this->ci) update_cs_lastseen(user, this->ci); - struct c_userlist *u; - for (u = this->users; u && u->user != user; u = u->next); - if (!u) - return; - - if (u->ud) + CUserList::iterator it; + for (it = this->users.begin(); (*it)->user != user && it != this->users.end(); ++it); + if (it == this->users.end()) { - if (u->ud->lastline) - delete [] u->ud->lastline; - delete u->ud; + if (debug) + alog("debug: Channel::DelUser() tried to delete nonexistnat user %s from channel %s", user->nick.c_str(), this->name.c_str()); + return; } - if (u->next) - u->next->prev = u->prev; - if (u->prev) - u->prev->next = u->next; - else - this->users = u->next; - delete u; - this->usercount--; + delete *it; + this->users.erase(it); /* Channel is persistant, it shouldn't be deleted and the service bot should stay */ if (this->HasFlag(CH_PERSIST) || (this->ci && this->ci->HasFlag(CI_PERSIST))) @@ -242,10 +214,10 @@ void Channel::DeleteUser(User *user) if (this->ci && this->ci->HasFlag(CI_INHABIT)) return; - if (Config.s_BotServ && this->ci && this->ci->bi && this->usercount <= Config.BSMinUsers - 1) + if (Config.s_BotServ && this->ci && this->ci->bi && this->users.size() <= Config.BSMinUsers - 1) ircdproto->SendPart(this->ci->bi, this, NULL); - if (!this->users) + if (this->users.empty()) delete this; } @@ -463,13 +435,13 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool if (ci) { ci->UnsetFlag(CI_PERSIST); - if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1) + if (Config.s_BotServ && ci->bi && users.size() == Config.BSMinUsers - 1) ircdproto->SendPart(ci->bi, this, NULL); } } /* We set -P in an empty channel, delete the channel */ - if (cm->Name == CMODE_PERM && !users) + if (cm->Name == CMODE_PERM && users.empty()) { delete this; return; @@ -900,19 +872,16 @@ void Channel::KickInternal(const std::string &source, const std::string &nick, c if (debug) alog("debug: Channel::KickInternal kicking %s from %s", user->nick.c_str(), this->name.c_str()); - struct u_chanlist *c; - for (c = user->chans; c && this != c->chan; c = c->next); - if (c) + UChannelList::iterator it; + for (it = user->chans.begin(); (*it)->chan != this && it != user->chans.end(); ++it); + if (it != user->chans.end()) { - FOREACH_MOD(I_OnUserKicked, OnUserKicked(c->chan, user, source, reason)); - c->chan->DeleteUser(user); - if (c->next) - c->next->prev = c->prev; - if (c->prev) - c->prev->next = c->next; - else - user->chans = c->next; - delete c; + ChannelContainer *cc = *it; + + FOREACH_MOD(I_OnUserKicked, OnUserKicked(cc->chan, user, source, reason)); + cc->chan->DeleteUser(user); + delete cc; + user->chans.erase(it); } else if (debug) alog("debug: Channel::KickInternal got kick for user %s who isn't on channel %s ?", user->nick.c_str(), this->name.c_str()); @@ -959,7 +928,7 @@ char *chan_get_modes(Channel * chan, int complete, int plus) ChannelModeParam *cmp; std::map<char, ChannelMode *>::iterator it; - if (!chan->modes.count()) + if (chan->HasModes()) { for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it) { @@ -1009,11 +978,9 @@ char *chan_get_modes(Channel * chan, int complete, int plus) int chan_get_user_status(Channel * chan, User * user) { - struct u_chanlist *uc; - - for (uc = user->chans; uc; uc = uc->next) - if (uc->chan == chan) - return uc->status; + for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it) + if ((*it)->chan == chan) + return (*it)->status; return 0; } @@ -1024,14 +991,15 @@ int chan_get_user_status(Channel * chan, User * user) int chan_has_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; + for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it) + { + ChannelContainer *cc = *it; - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - if (debug) { - alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status); - } - return (uc->status & status); + if (cc->chan == chan) + { + if (debug) + alog("debug: chan_has_user_status wanted %d the user is %d", status, cc->status); + return (cc->status & status); } } return 0; @@ -1043,15 +1011,17 @@ int chan_has_user_status(Channel * chan, User * user, int16 status) void chan_remove_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; - if (debug >= 2) alog("debug: removing user status (%d) from %s for %s", status, user->nick.c_str(), chan->name.c_str()); - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - uc->status &= ~status; + for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it) + { + ChannelContainer *cc = *it; + + if (cc->chan == chan) + { + cc->status &= ~status; break; } } @@ -1063,7 +1033,6 @@ void chan_remove_user_status(Channel * chan, User * user, int16 status) void chan_set_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; UserMode *um; if (debug >= 2) @@ -1081,9 +1050,13 @@ void chan_set_user_status(Channel * chan, User * user, int16 status) user->SetMode(NULL, um); } - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - uc->status |= status; + for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it) + { + ChannelContainer *cc = *it; + + if (cc->chan == chan) + { + cc->status |= status; break; } } @@ -1164,7 +1137,6 @@ void get_channel_stats(long *nrec, long *memuse) { long count = 0, mem = 0; Channel *chan; - struct c_userlist *cu; BanData *bd; int i; std::string buf; @@ -1186,13 +1158,12 @@ void get_channel_stats(long *nrec, long *memuse) mem += get_memuse(chan->excepts); if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE)) mem += get_memuse(chan->invites); - for (cu = chan->users; cu; cu = cu->next) { - mem += sizeof(*cu); - if (cu->ud) { - mem += sizeof(*cu->ud); - if (cu->ud->lastline) - mem += strlen(cu->ud->lastline) + 1; - } + for (CUserList::iterator it = chan->users.begin(); it != chan->users.end(); ++it) + { + mem += sizeof(*it); + mem += sizeof((*it)->ud); + if ((*it)->ud->lastline) + mem += strlen((*it)->ud->lastline) + 1; } for (bd = chan->bd; bd; bd = bd->next) { if (bd->mask) @@ -1211,10 +1182,8 @@ void get_channel_stats(long *nrec, long *memuse) int is_on_chan(Channel * c, User * u) { - struct u_chanlist *uc; - - for (uc = u->chans; uc; uc = uc->next) - if (uc->chan == c) + for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it) + if ((*it)->chan == c) return 1; return 0; @@ -1227,14 +1196,15 @@ int is_on_chan(Channel * c, User * u) User *nc_on_chan(Channel * c, NickCore * nc) { - struct c_userlist *u; - if (!c || !nc) return NULL; - for (u = c->users; u; u = u->next) { - if (u->user->nc == nc) - return u->user; + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + { + UserContainer *uc = *it; + + if (uc->user->nc == nc) + return uc->user; } return NULL; } @@ -1251,17 +1221,9 @@ void do_join(const char *source, int ac, const char **av) { User *user; Channel *chan; - struct u_chanlist *c, *nextc; - char *channame; time_t ctime = time(NULL); - if (ircd->ts6) { - user = find_byuid(source); - if (!user) - user = finduser(source); - } else { - user = finduser(source); - } + user = finduser(source); if (!user) { if (debug) { alog("debug: JOIN from nonexistent user %s: %s", source, @@ -1275,18 +1237,18 @@ void do_join(const char *source, int ac, const char **av) while (sep.GetToken(buf)) { if (buf[0] == '0') { - c = user->chans; - while (c) { - nextc = c->next; - channame = sstrdup(c->chan->name.c_str()); - FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan)); - c->chan->DeleteUser(user); - FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(channame), channame, "")); - delete [] channame; - delete c; - c = nextc; + for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end();) + { + ChannelContainer *cc = *it++; + + std::string channame = cc->chan->name; + FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan)); + cc->chan->DeleteUser(user); + FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(channame.c_str()), channame, "")); + delete cc; + user->chans.erase(it); } - user->chans = NULL; + user->chans.clear(); continue; } @@ -1377,15 +1339,8 @@ void do_kick(const std::string &source, int ac, const char **av) void do_part(const char *source, int ac, const char **av) { User *user; - struct u_chanlist *c; - if (ircd->ts6) { - user = find_byuid(source); - if (!user) - user = finduser(source); - } else { - user = finduser(source); - } + user = finduser(source); if (!user) { if (debug) { alog("debug: PART from nonexistent user %s: %s", source, @@ -1400,29 +1355,21 @@ void do_part(const char *source, int ac, const char **av) { if (debug) alog("debug: %s leaves %s", source, buf.c_str()); - for (c = user->chans; c && buf != c->chan->name; c = c->next); - if (c) + UChannelList::iterator it; + for (it = user->chans.begin(); buf != (*it)->chan->name && it != user->chans.end(); ++it); + if (it != user->chans.end()) { - if (!c->chan) - { - alog("user: BUG parting %s: channel entry found but c->chan NULL", buf.c_str()); - return; - } + ChannelContainer *cc = *it; - FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan)); - std::string ChannelName = c->chan->name; + FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan)); + std::string ChannelName = cc->chan->name; - c->chan->DeleteUser(user); + cc->chan->DeleteUser(user); - FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : "")); + delete *it; + user->chans.erase(it); - if (c->next) - c->next->prev = c->prev; - if (c->prev) - c->prev->next = c->next; - else - user->chans = c->next; - delete c; + FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : "")); } } } @@ -1636,7 +1583,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->HasFlag(CI_SECUREOPS)) || (c->usercount == 1) + if (((ci->HasFlag(CI_SECUREOPS)) || (c->users.size() == 1) || check_access(user, ci, CA_AUTODEOP)) && !is_ulined(user->server->name)) { if (owner && (status & CUS_OWNER) && !IsFounder(user, ci)) diff --git a/src/chanserv.c b/src/chanserv.c index af458e42b..56a94839c 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -142,7 +142,7 @@ class ChanServTimer : public Timer c->ci->UnsetFlag(CI_INHABIT); /* If the channel has users again, don't part it and halt */ - if (c->usercount) + if (!c->users.empty()) return; if (c->ci->bi) @@ -697,7 +697,7 @@ bool ChannelInfo::CheckKick(User *user) /* If the channel doesnt have any users and if a bot isn't already in the channel, join it * NOTE: we use usercount == 1 here as there is one user, but they are about to be destroyed */ - if (this->c->usercount == 1 && !this->HasFlag(CI_INHABIT)) + if (this->c->users.size() == 1 && !this->HasFlag(CI_INHABIT)) { /* If channel was forbidden, etc, set it +si to prevent rejoin */ if (set_modes) diff --git a/src/core/bs_act.c b/src/core/bs_act.c index 8c54f9479..7849f322b 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -39,7 +39,7 @@ class CommandBSAct : public Command return MOD_CONT; } - if (!ci->c || ci->c->usercount < Config.BSMinUsers) + if (!ci->c || ci->c->users.size() < Config.BSMinUsers) { notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 6aa2bb552..65fd93922 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -43,7 +43,7 @@ class CommandBSSay : public Command return MOD_CONT; } - if (!ci->c || ci->c->usercount < Config.BSMinUsers) + if (!ci->c || ci->c->users.size() < Config.BSMinUsers) { notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 983dba89f..2a45cd83c 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -480,7 +480,6 @@ class CommandCSAKick : public Command void DoEnforce(User *u, ChannelInfo *ci, const std::vector<ci::string> ¶ms) { Channel *c = ci->c; - c_userlist *cu, *unext; int count = 0; if (!c) @@ -489,17 +488,14 @@ class CommandCSAKick : public Command return; } - cu = c->users; - - while (cu) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - unext = cu->next; - if (ci->CheckKick(cu->user)) + UserContainer *uc = *it++; + + if (ci->CheckKick(uc->user)) { - c->Kick(NULL, cu->user, "%s", Config.CSAutokickReason); count++; } - cu = unext; } notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count); diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 0cbb192e3..5f95e0cdc 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -38,127 +38,144 @@ class CommandCSClear : public Command if (c) ci = c->ci; - if (!c) { + if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!u || !check_access(u, ci, CA_CLEAR)) { + else if (!u || !check_access(u, ci, CA_CLEAR)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (what == "bans") { + else if (what == "bans") + { c->ClearBans(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_BANS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") { + } + else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") + { c->ClearExcepts(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") { + } + else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") + { c->ClearInvites(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - } else if (what == "modes") { + } + else if (what == "modes") + { c->ClearModes(); check_modes(c); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_MODES, chan); - } else if (what == "ops") { - const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ + } + else if (what == "ops") + { int isop, isadmin, isown; - struct c_userlist *cu, *bnext; - if (ircd->svsmode_ucmode) { - av[0] = chan; + if (ircd->svsmode_ucmode) + { ircdproto->SendSVSModeChan(c, "-o", NULL); - if (owner) { + if (owner) + { modebuf = '-'; modebuf += owner->ModeChar; ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - if (admin) { + if (admin) + { modebuf = '-'; modebuf += admin->ModeChar; ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - for (cu = c->users; cu; cu = bnext) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); + UserContainer *uc = *it; + + isop = chan_has_user_status(c, uc->user, CUS_OP); + isadmin = chan_has_user_status(c, uc->user, CUS_PROTECT); + isown = chan_has_user_status(c, uc->user, CUS_OWNER); if (!isop && !isadmin && !isown) continue; if (isown) - c->RemoveMode(NULL, CMODE_OWNER, cu->user->nick); + c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); if (admin) - c->RemoveMode(NULL, CMODE_PROTECT, cu->user->nick); + c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); if (isop) - c->RemoveMode(NULL, CMODE_OP, cu->user->nick); + c->RemoveMode(NULL, CMODE_OP, uc->user->nick); } - } else { - av[0] = chan; - for (cu = c->users; cu; cu = bnext) + } + else + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); + UserContainer *uc = *it; + + isop = chan_has_user_status(c, uc->user, CUS_OP); + isadmin = chan_has_user_status(c, uc->user, CUS_PROTECT); + isown = chan_has_user_status(c, uc->user, CUS_OWNER); if (!isop && !isadmin && !isown) continue; if (isown) - c->RemoveMode(NULL, CMODE_OWNER, cu->user->nick); + c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); if (isadmin) - c->RemoveMode(NULL, CMODE_PROTECT, cu->user->nick); + c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); if (isop) - c->RemoveMode(NULL, CMODE_OP, cu->user->nick); + c->RemoveMode(NULL, CMODE_OP, uc->user->nick); } } - notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_OPS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") { - struct c_userlist *cu, *bnext; - for (cu = c->users; cu; cu = bnext) + notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_OPS, chan); + } + else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; + UserContainer *uc = *it; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) + if (!chan_has_user_status(c, uc->user, CUS_HALFOP)) continue; - c->RemoveMode(NULL, CMODE_HALFOP, cu->user->nick); + c->RemoveMode(NULL, CMODE_HALFOP, uc->user->nick); } notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_HOPS, chan); - } else if (what == "voices") { - struct c_userlist *cu, *bnext; - - for (cu = c->users; cu; cu = bnext) + } + else if (what == "voices") + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; + UserContainer *uc = *it; - if (!chan_has_user_status(c, cu->user, CUS_VOICE)) + if (!chan_has_user_status(c, uc->user, CUS_VOICE)) continue; - c->RemoveMode(NULL, CMODE_VOICE, cu->user->nick); + c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); } notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_VOICES, chan); - } else if (what == "users") { - struct c_userlist *cu, *bnext; + } + else if (what == "users") { std::string buf = "CLEAR USERS command from " + u->nick; - for (cu = c->users; cu; cu = bnext) { - bnext = cu->next; - c->Kick(NULL, cu->user, buf.c_str()); + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + { + UserContainer *uc = *it++; + + c->Kick(NULL, uc->user, buf.c_str()); } + notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_USERS, chan); - } else { - syntax_error(Config.s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); } + else + syntax_error(Config.s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); + return MOD_CONT; } diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 718cd41a1..57a0b552b 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -67,21 +67,19 @@ class CommandCSForbid : public Command if ((c = findchan(ci->name.c_str()))) { - struct c_userlist *cu, *nextu; - /* Before banning everyone, it might be prudent to clear +e and +I lists.. * to prevent ppl from rejoining.. ~ Viper */ c->ClearExcepts(); c->ClearInvites(); - for (cu = c->users; cu; cu = nextu) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - nextu = cu->next; + UserContainer *uc = *it++; - if (is_oper(cu->user)) + if (is_oper(uc->user)) continue; - c->Kick(findbot(Config.s_ChanServ), cu->user, "%s", reason ? reason : getstring(cu->user->nc, CHAN_FORBID_REASON)); + c->Kick(findbot(Config.s_ChanServ), uc->user, "%s", reason ? reason : getstring(uc->user->nc, CHAN_FORBID_REASON)); } } diff --git a/src/core/cs_set.c b/src/core/cs_set.c index 277649cfb..158987acd 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -583,7 +583,7 @@ class CommandC |
