diff options
| author | 2021-04-06 20:06:18 +0100 | |
|---|---|---|
| committer | 2021-04-07 10:36:11 +0100 | |
| commit | 942fd2bcfd384a12c900999fe663202c87319a68 (patch) | |
| tree | c2bad1906af27afbc3c7d96c3e5ca3c27c83f090 /src/modules/m_nickflood.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
Switch simple iterator loops to use range-based for loops.
Diffstat (limited to 'src/modules/m_nickflood.cpp')
| -rw-r--r-- | src/modules/m_nickflood.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 7d49b449d..b12273172 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -144,21 +144,19 @@ class ModuleNickFlood : public Module ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) override { - for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); i++) + for (const auto* memb : user->chans) { - Channel* channel = (*i)->chan; - ModResult res; - - nickfloodsettings *f = nf.ext.Get(channel); + nickfloodsettings *f = nf.ext.Get(memb->chan); if (f) { - res = CheckExemption::Call(exemptionprov, user, channel, "nickflood"); + ModResult res = CheckExemption::Call(exemptionprov, user, memb->chan, "nickflood"); if (res == MOD_RES_ALLOW) continue; if (f->islocked()) { - user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("%s has been locked for nickchanges for %u seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), duration, f->nicks, f->secs)); + user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("%s has been locked for nickchanges for %u seconds because there have been more than %u nick changes in %u seconds", + memb->chan->name.c_str(), duration, f->nicks, f->secs)); return MOD_RES_DENY; } @@ -166,7 +164,8 @@ class ModuleNickFlood : public Module { f->clear(); f->lock(); - channel->WriteNotice(InspIRCd::Format("No nick changes are allowed for %u seconds because there have been more than %u nick changes in %u seconds.", duration, f->nicks, f->secs)); + memb->chan->WriteNotice(InspIRCd::Format("No nick changes are allowed for %u seconds because there have been more than %u nick changes in %u seconds.", + duration, f->nicks, f->secs)); return MOD_RES_DENY; } } @@ -183,15 +182,12 @@ class ModuleNickFlood : public Module if (isdigit(user->nick[0])) /* allow switches to UID */ return; - for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); ++i) + for (const auto* memb : user->chans) { - Channel* channel = (*i)->chan; - ModResult res; - - nickfloodsettings *f = nf.ext.Get(channel); + nickfloodsettings *f = nf.ext.Get(memb->chan); if (f) { - res = CheckExemption::Call(exemptionprov, user, channel, "nickflood"); + ModResult res = CheckExemption::Call(exemptionprov, user, memb->chan, "nickflood"); if (res == MOD_RES_ALLOW) return; |
