summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/commands/cs_clearusers.cpp12
-rw-r--r--modules/commands/cs_enforce.cpp49
-rw-r--r--modules/commands/cs_suspend.cpp17
-rw-r--r--modules/commands/os_sxline.cpp14
4 files changed, 58 insertions, 34 deletions
diff --git a/modules/commands/cs_clearusers.cpp b/modules/commands/cs_clearusers.cpp
index 9a50f70c9..d6eed6e4d 100644
--- a/modules/commands/cs_clearusers.cpp
+++ b/modules/commands/cs_clearusers.cpp
@@ -47,13 +47,17 @@ class CommandCSClearUsers : public Command
Anope::string buf = "CLEARUSERS command from " + source.GetNick() + " (" + source.nc->display + ")";
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+ std::vector<User *> users;
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it++;
-
- c->Kick(NULL, uc->user, "%s", buf.c_str());
+ User *user = (*it)->user;
+ if (!user->HasMode(UMODE_OPER) && user->server != Me)
+ users.push_back(user);
}
+ for (unsigned i = 0; i < users.size(); ++i)
+ c->Kick(NULL, users[i], "%s", buf.c_str());
+
bool override = !source.AccessFor(c->ci).HasPriv("FOUNDER");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci);
diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp
index 6c3fb3f39..2c524d9db 100644
--- a/modules/commands/cs_enforce.cpp
+++ b/modules/commands/cs_enforce.cpp
@@ -81,19 +81,25 @@ class CommandCSEnforce : public Command
Log(LOG_COMMAND, source, this) << "to enforce restricted";
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+ std::vector<User *> users;
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it++;
+ UserContainer *uc = *it;
User *user = uc->user;
if (ci->AccessFor(user).empty())
- {
- Anope::string mask;
- get_idealban(ci, user, mask);
- Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
- c->SetMode(NULL, CMODE_BAN, mask);
- c->Kick(NULL, user, "%s", reason.c_str());
- }
+ users.push_back(user);
+ }
+
+ for (unsigned i = 0; i < users.size(); ++i)
+ {
+ User *user = users[i];
+
+ Anope::string mask;
+ get_idealban(ci, user, mask);
+ Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
+ c->SetMode(NULL, CMODE_BAN, mask);
+ c->Kick(NULL, user, "%s", reason.c_str());
}
}
@@ -107,18 +113,25 @@ class CommandCSEnforce : public Command
Log(LOG_COMMAND, source, this) << "to enforce registered only";
+ std::vector<User *> users;
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
- UserContainer *uc = *it++;
+ UserContainer *uc = *it;
+ User *user = uc->user;
- if (!uc->user->IsIdentified())
- {
- get_idealban(ci, uc->user, mask);
- Anope::string reason = translate(uc->user, CHAN_NOT_ALLOWED_TO_JOIN);
- if (!c->HasMode(CMODE_REGISTEREDONLY))
- c->SetMode(NULL, CMODE_BAN, mask);
- c->Kick(NULL, uc->user, "%s", reason.c_str());
- }
+ if (!user->IsIdentified())
+ users.push_back(user);
+ }
+
+ for (unsigned i = 0; i < users.size(); ++i)
+ {
+ User *user = users[i];
+
+ get_idealban(ci, user, mask);
+ Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
+ if (!c->HasMode(CMODE_REGISTEREDONLY))
+ c->SetMode(NULL, CMODE_BAN, mask);
+ c->Kick(NULL, user, "%s", reason.c_str());
}
}
public:
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp
index 9cb829ad1..bce549e79 100644
--- a/modules/commands/cs_suspend.cpp
+++ b/modules/commands/cs_suspend.cpp
@@ -102,15 +102,18 @@ class CommandCSSuspend : public Command
if (ci->c)
{
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; )
- {
- UserContainer *uc = *it++;
-
- if (uc->user->HasMode(UMODE_OPER))
- continue;
+ std::vector<User *> users;
- ci->c->Kick(NULL, uc->user, "%s", !reason.empty() ? reason.c_str() : translate(uc->user, _("This channel has been suspended.")));
+ for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ {
+ UserContainer *uc = *it;
+ User *user = uc->user;
+ if (!user->HasMode(UMODE_OPER) && user->server != Me)
+ users.push_back(user);
}
+
+ for (unsigned i = 0; i < users.size(); ++i)
+ ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : translate(users[i], _("This channel has been suspended.")));
}
if (expiry_secs > 0)
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index ea7f7840d..9261bcddd 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -594,15 +594,19 @@ class CommandOSSQLine : public CommandOSSXLineBase
if (!Anope::Match(c->name, mask, false, true))
continue;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+
+ std::vector<User *> users;
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
UserContainer *uc = *it;
- ++it;
+ User *user = uc->user;
- if (uc->user->HasMode(UMODE_OPER) || uc->user->server == Me)
- continue;
- c->Kick(NULL, uc->user, "%s", reason.c_str());
+ if (!user->HasMode(UMODE_OPER) && user->server != Me)
+ users.push_back(user);
}
+
+ for (unsigned i = 0; i < users.size(); ++i)
+ c->Kick(NULL, users[i], "%s", reason.c_str());
}
}
else