From 942fd2bcfd384a12c900999fe663202c87319a68 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 6 Apr 2021 20:06:18 +0100 Subject: Switch simple iterator loops to use range-based for loops. --- src/modules/m_nickflood.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/modules/m_nickflood.cpp') 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; -- cgit v1.3.1-10-gc9f91