1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 10:13:12 +02:00

Fix os_mode to handle channels going away due to mode changes, and maybe cs_mode

This commit is contained in:
Adam
2015-02-05 20:16:36 -05:00
parent 64ca357b13
commit 9834518b28
2 changed files with 11 additions and 5 deletions
+1 -1
View File
@@ -487,7 +487,7 @@ class CommandCSMode : public Command
case '*':
if (adding == -1 || !has_access)
break;
for (unsigned j = 0; j < ModeManager::GetChannelModes().size(); ++j)
for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && ci->c; ++j)
{
ChannelMode *cm = ModeManager::GetChannelModes()[j];
+10 -4
View File
@@ -26,7 +26,7 @@ class CommandOSMode : public Command
const Anope::string &target = params[0];
const Anope::string &modes = params[1];
Channel *c = Channel::Find(target);
Reference<Channel> c = Channel::Find(target);
if (!c)
source.Reply(CHAN_X_NOT_IN_USE, target.c_str());
else if (c->bouncy_modes)
@@ -36,9 +36,15 @@ class CommandOSMode : public Command
bool all = params.size() > 2 && params[2].equals_ci("ALL");
const Channel::ModeList chmodes = c->GetModes();
for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end; ++it)
for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);
if (!c)
{
source.Reply(_("Modes cleared on %s and the channel destroyed."), target.c_str());
return;
}
if (all)
{
for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
@@ -65,7 +71,7 @@ class CommandOSMode : public Command
Anope::string log_modes, log_params;
sep.GetToken(mode);
for (unsigned i = 0; i < mode.length(); ++i)
for (unsigned i = 0; i < mode.length() && c; ++i)
{
char ch = mode[i];
@@ -116,7 +122,7 @@ class CommandOSMode : public Command
}
if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty())
Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << c->name;
Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target);
}
}