summaryrefslogtreecommitdiff
path: root/modules/commands/os_oper.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/os_oper.cpp
parentdc371aad6d059dbf7f30f6878c680532bedd4146 (diff)
Start migrating to range-based for loops.
Diffstat (limited to 'modules/commands/os_oper.cpp')
-rw-r--r--modules/commands/os_oper.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp
index 0d17b0cd6..67612ea74 100644
--- a/modules/commands/os_oper.cpp
+++ b/modules/commands/os_oper.cpp
@@ -50,15 +50,17 @@ class CommandOSOper : public Command
{
bool HasPrivs(CommandSource &source, OperType *ot) const
{
- std::list<Anope::string> commands = ot->GetCommands(), privs = ot->GetPrivs();
-
- for (std::list<Anope::string>::iterator it = commands.begin(); it != commands.end(); ++it)
- if (!source.HasCommand(*it))
+ for (const auto &command : ot->GetCommands())
+ {
+ if (!source.HasCommand(command))
return false;
+ }
- for (std::list<Anope::string>::iterator it = privs.begin(); it != privs.end(); ++it)
- if (!source.HasPriv(*it))
+ for (const auto &priv : ot->GetPrivs())
+ {
+ if (!source.HasPriv(priv))
return false;
+ }
return true;
}
@@ -151,20 +153,17 @@ class CommandOSOper : public Command
else if (subcommand.equals_ci("LIST"))
{
source.Reply(_("Name Type"));
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
if (!nc->o)
continue;
source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str());
if (std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
source.Reply(_(" This oper is configured in the configuration file."));
- for (std::list<User *>::const_iterator uit = nc->users.begin(); uit != nc->users.end(); ++uit)
+ for (auto *u : nc->users)
{
- User *u = *uit;
- source.Reply(_(" %s is online using this oper block."), u->nick.c_str());
+ source.Reply(_(" %s is online using this oper block."), u->nick.c_str());
}
}
}
@@ -173,9 +172,8 @@ class CommandOSOper : public Command
if (params.size() < 2)
{
source.Reply(_("Available opertypes:"));
- for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i)
+ for (auto *ot : Config->MyOperTypes)
{
- OperType *ot = Config->MyOperTypes[i];
source.Reply("%s", ot->GetName().c_str());
}
return;
@@ -196,9 +194,9 @@ class CommandOSOper : public Command
source.Reply(_("Available commands for \002%s\002:"), ot->GetName().c_str());
Anope::string buf;
std::list<Anope::string> cmds = ot->GetCommands();
- for (std::list<Anope::string>::const_iterator it = cmds.begin(), it_end = cmds.end(); it != it_end; ++it)
+ for (const auto &cmd : cmds)
{
- buf += *it + " ";
+ buf += cmd + " ";
if (buf.length() > 400)
{
source.Reply("%s", buf.c_str());
@@ -218,9 +216,9 @@ class CommandOSOper : public Command
source.Reply(_("Available privileges for \002%s\002:"), ot->GetName().c_str());
Anope::string buf;
std::list<Anope::string> privs = ot->GetPrivs();
- for (std::list<Anope::string>::const_iterator it = privs.begin(), it_end = privs.end(); it != it_end; ++it)
+ for (const auto &priv : privs)
{
- buf += *it + " ";
+ buf += priv + " ";
if (buf.length() > 400)
{
source.Reply("%s", buf.c_str());
@@ -267,10 +265,8 @@ class OSOper : public Module
~OSOper() override
{
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- NickCore *nc = it->second;
-
if (nc->o && dynamic_cast<MyOper *>(nc->o))
{
delete nc->o;