summaryrefslogtreecommitdiff
path: root/modules/commands/cs_enforce.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2023-10-10 21:14:50 +0100
committerSadie Powell <sadie@witchery.services>2023-10-11 15:51:52 +0100
commita3241065c55fd2a69e8793b89a5d0b1a957b3fd0 (patch)
tree82f80ce2f3bbbdc1c1ef05fe611093cf0b34eab6 /modules/commands/cs_enforce.cpp
parentdc371aad6d059dbf7f30f6878c680532bedd4146 (diff)
Start migrating to range-based for loops.
Diffstat (limited to 'modules/commands/cs_enforce.cpp')
-rw-r--r--modules/commands/cs_enforce.cpp37
1 files changed, 11 insertions, 26 deletions
diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp
index 801191293..eca2d0651 100644
--- a/modules/commands/cs_enforce.cpp
+++ b/modules/commands/cs_enforce.cpp
@@ -29,10 +29,8 @@ class CommandCSEnforce : public Command
bool hadsecureops = ci->HasExt("SECUREOPS");
ci->Extend<bool>("SECUREOPS");
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
-
ci->c->SetCorrectModes(uc->user, false);
}
@@ -48,9 +46,9 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -60,10 +58,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick();
ci->c->SetMode(NULL, "BAN", mask);
@@ -79,9 +75,8 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -91,10 +86,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick();
if (!ci->c->HasMode("REGISTEREDONLY"))
@@ -111,9 +104,8 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -123,10 +115,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick();
if (!ci->c->HasMode("SSL"))
@@ -143,9 +133,8 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -155,10 +144,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick();
ci->c->Kick(NULL, user, "%s", reason.c_str());
}
@@ -210,10 +197,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick();
ci->c->Kick(NULL, user, "%s", reason.c_str());
}