mirror of
https://github.com/anope/anope.git
synced 2026-07-03 03:23:12 +02:00
Bug #1285 - Fixed setting -P on channels with only a service bot in it
(cherry picked from commit b5ec57a3f9)
This commit is contained in:
+17
-7
@@ -483,15 +483,19 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo
|
||||
{
|
||||
ci->UnsetFlag(CI_PERSIST);
|
||||
if (!Config->s_BotServ.empty() && ci->bi && this->FindUser(ci->bi) && Config->BSMinUsers && this->users.size() <= Config->BSMinUsers)
|
||||
{
|
||||
bool empty = this->users.size() == 1;
|
||||
this->ci->bi->Part(this);
|
||||
if (empty)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We set -P in an empty channel, delete the channel */
|
||||
if (cm->Name == CMODE_PERM && users.empty())
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
if (this->users.empty())
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for mlock */
|
||||
@@ -698,6 +702,9 @@ void Channel::SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
|
||||
*/
|
||||
void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool EnforceMLock)
|
||||
{
|
||||
/* Removing channel modes *may* delete this channel */
|
||||
dynamic_reference<Channel> this_reference(this);
|
||||
|
||||
spacesepstream sep_modes(mode);
|
||||
Anope::string m;
|
||||
|
||||
@@ -706,7 +713,7 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
|
||||
Anope::string modestring;
|
||||
Anope::string paramstring;
|
||||
int add = -1;
|
||||
for (unsigned int i = 0, end = m.length(); i < end; ++i)
|
||||
for (unsigned int i = 0, end = m.length(); i < end && this_reference; ++i)
|
||||
{
|
||||
ChannelMode *cm;
|
||||
|
||||
@@ -768,6 +775,9 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
|
||||
Log() << "warning: Channel::SetModesInternal() recieved more modes requiring params than params, modes: " << mode;
|
||||
}
|
||||
|
||||
if (!this_reference)
|
||||
return;
|
||||
|
||||
if (setter)
|
||||
Log(setter, this, "mode") << modestring << paramstring;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user