summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.c46
-rw-r--r--src/core/cs_register.c1
-rw-r--r--src/core/cs_set.c33
3 files changed, 43 insertions, 37 deletions
diff --git a/src/channels.c b/src/channels.c
index d90bdf94f..aa01b99e0 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -190,12 +190,6 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
modes[cm->Name] = true;
- /* Channel mode +P or so was set, mark this channel as persistant */
- if (cm->Name == CMODE_PERM && ci)
- {
- ci->SetFlag(CI_PERSIST);
- }
-
if (!param.empty())
{
if (cm->Type != MODE_PARAM)
@@ -214,6 +208,14 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
Params.insert(std::make_pair(cm->Name, param));
}
+ /* Channel mode +P or so was set, mark this channel as persistant */
+ if (cm->Name == CMODE_PERM)
+ {
+ this->SetFlag(CH_PERSIST);
+ if (ci)
+ ci->SetFlag(CI_PERSIST);
+ }
+
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, cm->Name));
@@ -305,7 +307,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
{
if (param.empty())
{
- alog("Channel::SetModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name);
+ alog("Channel::RemoveModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name);
return;
}
@@ -316,15 +318,6 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
modes[cm->Name] = false;
- if (cm->Name == CMODE_PERM && ci)
- {
- ci->UnsetFlag(CI_PERSIST);
- if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1)
- ircdproto->SendPart(ci->bi, this, NULL);
- if (!users)
- delete this;
- }
-
if (cm->Type == MODE_PARAM)
{
std::map<ChannelModeName, std::string>::iterator it = Params.find(cm->Name);
@@ -334,9 +327,28 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
}
}
+ if (cm->Name == CMODE_PERM)
+ {
+ this->UnsetFlag(CH_PERSIST);
+
+ if (ci)
+ {
+ ci->UnsetFlag(CI_PERSIST);
+ if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1)
+ ircdproto->SendPart(ci->bi, this, NULL);
+ }
+ }
+
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, cm->Name));
+ /* We set -P in an empty channel, delete the channel */
+ if (cm->Name == CMODE_PERM && !users)
+ {
+ delete this;
+ return;
+ }
+
/* Check for mlock */
/* Non registered channel, no mlock */
@@ -733,7 +745,7 @@ void chan_deluser(User * user, Channel * c)
c->usercount--;
/* Channel is persistant, it shouldn't be deleted and the service bot should stay */
- if (c->ci && c->ci->HasFlag(CI_PERSIST))
+ if (c->HasFlag(CH_PERSIST) || (c->ci && c->ci->HasFlag(CI_PERSIST)))
return;
if (Config.s_BotServ && c->ci && c->ci->bi && c->usercount == Config.BSMinUsers - 1)
diff --git a/src/core/cs_register.c b/src/core/cs_register.c
index 364fed989..fd4c38f70 100644
--- a/src/core/cs_register.c
+++ b/src/core/cs_register.c
@@ -93,7 +93,6 @@ class CommandCSRegister : public Command
else if (ci->HasFlag(CI_PERSIST) && (cm = ModeManager::FindChannelModeByName(CMODE_PERM)))
{
c->SetMode(NULL, CMODE_PERM);
- ci->SetFlag(CI_PERSIST);
}
FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci));
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index 3d2876f38..d2c2d6845 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -568,7 +568,7 @@ class CommandCSSet : public Command
/* Set the perm mode */
if (cm && ci->c && !ci->c->HasMode(CMODE_PERM))
{
- ci->c->SetMode(NULL, CMODE_PERM);
+ ci->c->SetMode(NULL, cm);
}
}
@@ -581,27 +581,22 @@ class CommandCSSet : public Command
ci->UnsetFlag(CI_PERSIST);
/* Unset perm mode */
- if (ci->c && ci->c->HasMode(CMODE_PERM))
+ if (cm && ci->c && ci->c->HasMode(CMODE_PERM))
+ ci->c->RemoveMode(NULL, cm);
+ if (Config.s_BotServ && ci->bi && ci->c->usercount == Config.BSMinUsers - 1)
+ ircdproto->SendPart(ci->bi, ci->c, NULL);
+
+ /* No channel mode, no BotServ, but using ChanServ as the botserv bot
+ * which was assigned when persist was set on
+ */
+ if (!cm && !Config.s_BotServ && ci->bi)
{
- ci->c->RemoveMode(NULL, CMODE_PERM);
+ /* Unassign bot */
+ findbot(Config.s_ChanServ)->UnAssign(NULL, ci);
}
- /* Persist is set off... remove the bot and delete the channel if its empty */
- else if (ci->c)
- {
- if (Config.s_BotServ && ci->bi && ci->c->usercount == Config.BSMinUsers - 1)
- ircdproto->SendPart(ci->bi, ci->c, NULL);
- if (!ci->c->users)
- delete ci->c;
- /* No channel mode, no BotServ, but using ChanServ as the botserv bot
- * which was assigned when persist was set on
- */
- if (!cm && !Config.s_BotServ && ci->bi)
- {
- /* Unassign bot */
- findbot(Config.s_ChanServ)->UnAssign(NULL, ci);
- }
- }
+ if (ci->c && !ci->c->users)
+ delete ci->c;
}
notice_lang(Config.s_ChanServ, u, CHAN_SET_PERSIST_OFF, ci->name);