diff options
| author | Sadie Powell <sadie@witchery.services> | 2023-10-10 21:14:50 +0100 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2023-10-11 15:51:52 +0100 |
| commit | a3241065c55fd2a69e8793b89a5d0b1a957b3fd0 (patch) | |
| tree | 82f80ce2f3bbbdc1c1ef05fe611093cf0b34eab6 /modules/pseudoclients | |
| parent | dc371aad6d059dbf7f30f6878c680532bedd4146 (diff) | |
Start migrating to range-based for loops.
Diffstat (limited to 'modules/pseudoclients')
| -rw-r--r-- | modules/pseudoclients/botserv.cpp | 10 | ||||
| -rw-r--r-- | modules/pseudoclients/chanserv.cpp | 15 | ||||
| -rw-r--r-- | modules/pseudoclients/global.cpp | 4 | ||||
| -rw-r--r-- | modules/pseudoclients/memoserv.cpp | 7 | ||||
| -rw-r--r-- | modules/pseudoclients/nickserv.cpp | 24 | ||||
| -rw-r--r-- | modules/pseudoclients/operserv.cpp | 4 |
6 files changed, 25 insertions, 39 deletions
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index 7fa60b8e6..25cf8ab88 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -34,8 +34,8 @@ class BotServCore : public Module if (chan->ci && chan->ci->bi == user) { const Anope::string &botmodes = Config->GetModule(this)->Get<const Anope::string>("botmodes"); - for (unsigned i = 0; i < botmodes.length(); ++i) - chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->bi->GetUID()); + for (auto botmode : botmodes) + chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmode), chan->ci->bi->GetUID()); } } @@ -56,12 +56,10 @@ class BotServCore : public Module BotInfo *bi = user->server == Me ? dynamic_cast<BotInfo *>(user) : NULL; if (bi && Config->GetModule(this)->Get<bool>("smartjoin")) { - std::vector<Anope::string> bans = c->GetModeList("BAN"); - /* We check for bans */ - for (unsigned int i = 0; i < bans.size(); ++i) + for (const auto &entry : c->GetModeList("BAN")) { - Entry ban("BAN", bans[i]); + Entry ban("BAN", entry); if (ban.Matches(user)) c->RemoveMode(NULL, "BAN", ban.GetMask()); } diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 9349ee6bc..ca7c7b9ab 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -146,10 +146,8 @@ class ChanServCore : public Module, public ChanServService nc->GetChannelReferences(chans); int max_reg = Config->GetModule(this)->Get<int>("maxregistered"); - for (unsigned i = 0; i < chans.size(); ++i) + for (auto *ci : chans) { - ChannelInfo *ci = chans[i]; - if (ci->GetFounder() == nc) { NickCore *newowner = NULL; @@ -220,9 +218,9 @@ class ChanServCore : public Module, public ChanServService std::deque<Anope::string> chans; ci->GetChannelReferences(chans); - for (unsigned i = 0; i < chans.size(); ++i) + for (const auto &chan : chans) { - ChannelInfo *c = ChannelInfo::Find(chans[i]); + ChannelInfo *c = ChannelInfo::Find(chan); if (!c) continue; @@ -303,8 +301,8 @@ class ChanServCore : public Module, public ChanServService void OnCreateChan(ChannelInfo *ci) override { /* Set default chan flags */ - for (unsigned i = 0; i < defaults.size(); ++i) - ci->Extend<bool>(defaults[i].upper()); + for (const auto &def : defaults) + ci->Extend<bool>(def.upper()); } EventReturn OnCanSet(User *u, const ChannelMode *cm) override @@ -385,9 +383,8 @@ class ChanServCore : public Module, public ChanServService ChannelMode *perm = ModeManager::FindChannelModeByName("PERM"); /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ - for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + for (const auto &[_, ci] : *RegisteredChannelList) { - ChannelInfo *ci = it->second; if (!persist->HasExt(ci)) continue; diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index 11c0a44fa..c720282c7 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -19,8 +19,8 @@ class GlobalCore : public Module, public GlobalService { if (s != Me && !s->IsJuped()) s->Notice(sender, message); - for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i) - this->ServerGlobal(sender, s->GetLinks()[i], message); + for (auto *link : s->GetLinks()) + this->ServerGlobal(sender, link, message); } public: diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 4efd20ee6..d6946247f 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -94,10 +94,8 @@ class MemoServCore : public Module, public MemoServService if (ci->c) { - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (const auto &[_, cu] : ci->c->users) { - ChanUserContainer *cu = it->second; - if (ci->AccessFor(cu->user).HasPriv("MEMO")) { if (cu->user->Account() && cu->user->Account()->HasExt("MEMO_RECEIVE")) @@ -112,9 +110,8 @@ class MemoServCore : public Module, public MemoServService if (nc->HasExt("MEMO_RECEIVE")) { - for (unsigned i = 0; i < nc->aliases->size(); ++i) + for (auto *na : *nc->aliases) { - const NickAlias *na = nc->aliases->at(i); User *user = User::Find(na->nick, true); if (user && user->IsIdentified()) user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), mi->memos->size()); diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index e17f8a5ba..4cdb3a238 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -147,8 +147,8 @@ class NickServCore : public Module, public NickServService /* On shutdown, restart, or mod unload, remove all of our holds for nicks (svshold or qlines) * because some IRCds do not allow us to have these automatically expire */ - for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it) - this->Release(it->second); + for (const auto &[_, na] : *NickAliasList) + this->Release(na); } void OnRestart() override @@ -340,14 +340,14 @@ class NickServCore : public Module, public NickServService Configuration::Block *block = Config->GetModule(this); if (block->Get<bool>("modeonid", "yes")) - - for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) + { + for (const auto &[_, cc] : u->chans) { - ChanUserContainer *cc = it->second; Channel *c = cc->chan; if (c) c->SetCorrectModes(u, true); } + } const Anope::string &modesonid = block->Get<const Anope::string>("modesonid"); if (!modesonid.empty()) @@ -363,9 +363,8 @@ class NickServCore : public Module, public NickServService "any third-party person."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); } - for (std::set<NickServCollide *>::iterator it = collides.begin(); it != collides.end(); ++it) + for (auto *c : collides) { - NickServCollide *c = *it; if (c->GetUser() == u && c->GetNick() && c->GetNick()->nc == u->Account()) { delete c; @@ -382,9 +381,8 @@ class NickServCore : public Module, public NickServService void OnNickUpdate(User *u) override { - for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) + for (const auto &[_, cc] : u->chans) { - ChanUserContainer *cc = it->second; Channel *c = cc->chan; if (c) c->SetCorrectModes(u, true); @@ -414,10 +412,8 @@ class NickServCore : public Module, public NickServService void OnServerSync(Server *s) override { - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (const auto &[_, u] : UserListByNick) { - User *u = it->second; - if (u->server == s) { if (u->HasMode("REGISTERED") && !u->IsIdentified(true)) @@ -498,8 +494,8 @@ class NickServCore : public Module, public NickServService void OnNickCoreCreate(NickCore *nc) override { /* Set default flags */ - for (unsigned i = 0; i < defaults.size(); ++i) - nc->Extend<bool>(defaults[i].upper()); + for (const auto &def : defaults) + nc->Extend<bool>(def.upper()); } void OnUserQuit(User *u, const Anope::string &msg) override diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index b37247864..0d6c719c8 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -122,10 +122,8 @@ class SQLineManager : public XLineManager XLine *CheckChannel(Channel *c) { - for (std::vector<XLine *>::const_iterator it = this->GetList().begin(), it_end = this->GetList().end(); it != it_end; ++it) + for (auto *x : this->GetList()) { - XLine *x = *it; - if (x->regex) { if (x->regex->Matches(c->name)) |
