summaryrefslogtreecommitdiff
path: root/modules/chanserv
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-10-07 21:10:47 -0400
committerAdam <Adam@anope.org>2017-10-07 21:10:47 -0400
commit2312f1fbd06ac01bb55e1d99070cde05a09a5a17 (patch)
tree69239628ed39e342650574f93d441f58d6d82b7b /modules/chanserv
parent286bffa2cd6a3f564334c5a4669ea3aadfb27a0a (diff)
No longer expose c->ci and ci->c
Diffstat (limited to 'modules/chanserv')
-rw-r--r--modules/chanserv/access.cpp8
-rw-r--r--modules/chanserv/akick.cpp13
-rw-r--r--modules/chanserv/ban.cpp4
-rw-r--r--modules/chanserv/clone.cpp16
-rw-r--r--modules/chanserv/drop.cpp2
-rw-r--r--modules/chanserv/enforce.cpp48
-rw-r--r--modules/chanserv/entrymsg.cpp7
-rw-r--r--modules/chanserv/getkey.cpp2
-rw-r--r--modules/chanserv/invite.cpp2
-rw-r--r--modules/chanserv/list.cpp2
-rw-r--r--modules/chanserv/main/channel.cpp16
-rw-r--r--modules/chanserv/main/chanserv.cpp86
-rw-r--r--modules/chanserv/mode.cpp73
-rw-r--r--modules/chanserv/register.cpp3
-rw-r--r--modules/chanserv/set.cpp102
-rw-r--r--modules/chanserv/statusupdate.cpp9
-rw-r--r--modules/chanserv/suspend.cpp9
-rw-r--r--modules/chanserv/sync.cpp7
-rw-r--r--modules/chanserv/topic.cpp41
-rw-r--r--modules/chanserv/unban.cpp12
-rw-r--r--modules/chanserv/updown.cpp22
21 files changed, 256 insertions, 228 deletions
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp
index c68af6e6f..32a6422cb 100644
--- a/modules/chanserv/access.cpp
+++ b/modules/chanserv/access.cpp
@@ -344,8 +344,8 @@ class CommandCSAccess : public Command
ChanServ::ChanAccess *access = ci->GetAccess(number - 1);
Anope::string timebuf;
- if (ci->c)
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ if (Channel *c = ci->GetChannel())
+ for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
{
if (access->Matches(cit->second->user, cit->second->user->Account()))
timebuf = "Now";
@@ -378,8 +378,8 @@ class CommandCSAccess : public Command
continue;
Anope::string timebuf;
- if (ci->c)
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ if (Channel *c = ci->GetChannel())
+ for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
{
if (access->Matches(cit->second->user, cit->second->user->Account()))
timebuf = "Now";
diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp
index d49a63ca5..9014ad9d6 100644
--- a/modules/chanserv/akick.cpp
+++ b/modules/chanserv/akick.cpp
@@ -209,9 +209,9 @@ class CommandCSAKick : public Command
}
/* Check excepts BEFORE we get this far */
- if (ci->c)
+ if (Channel *c = ci->GetChannel())
{
- std::vector<Anope::string> modes = ci->c->GetModeList("EXCEPT");
+ std::vector<Anope::string> modes = c->GetModeList("EXCEPT");
for (unsigned int i = 0; i < modes.size(); ++i)
{
if (Anope::Match(modes[i], mask))
@@ -510,7 +510,7 @@ class CommandCSAKick : public Command
void DoEnforce(CommandSource &source, ChanServ::Channel *ci)
{
- Channel *c = ci->c;
+ Channel *c = ci->GetChannel();
int count = 0;
if (!c)
@@ -696,12 +696,13 @@ class CSAKick : public Module
EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
- if (!c->ci || c->MatchesList(u, "EXCEPT"))
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci || c->MatchesList(u, "EXCEPT"))
return EVENT_CONTINUE;
- for (unsigned j = 0, end = c->ci->GetAkickCount(); j < end; ++j)
+ for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j)
{
- AutoKick *ak = c->ci->GetAkick(j);
+ AutoKick *ak = ci->GetAkick(j);
bool kick = false;
if (ak->GetAccount())
diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp
index cd6b70b1f..4e8c0ded7 100644
--- a/modules/chanserv/ban.cpp
+++ b/modules/chanserv/ban.cpp
@@ -61,7 +61,7 @@ class CommandCSBan : public Command
return;
}
- Channel *c = ci->c;
+ Channel *c = ci->GetChannel();
if (c == NULL)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
@@ -213,7 +213,7 @@ class CommandCSBan : public Command
continue;
if (u != uc->user && ci->IsPeace() && u2_access >= u_access)
continue;
- else if (ci->c->MatchesList(uc->user, "EXCEPT"))
+ else if (c->MatchesList(uc->user, "EXCEPT"))
continue;
else if (uc->user->IsProtected())
continue;
diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp
index c0ed04a64..341d80944 100644
--- a/modules/chanserv/clone.cpp
+++ b/modules/chanserv/clone.cpp
@@ -101,27 +101,25 @@ public:
target_ci->SetTimeRegistered(Anope::CurTime);
ChanServ::registered_channel_map& map = ChanServ::service->GetChannels();
map[target_ci->GetName()] = target_ci;
- target_ci->c = Channel::Find(target_ci->GetName());
+ Channel *target_channel = Channel::Find(target_ci->GetName());
if (ci->GetBot())
ci->GetBot()->Assign(u, target_ci);
else
target_ci->SetBot(nullptr);
- if (target_ci->c)
+ if (target_channel)
{
- target_ci->c->ci = target_ci;
+ target_channel->CheckModes();
- target_ci->c->CheckModes();
-
- target_ci->c->SetCorrectModes(u, true);
+ target_channel->SetCorrectModes(u, true);
}
- if (target_ci->c && !target_ci->c->topic.empty())
+ if (target_channel && !target_channel->topic.empty())
{
target_ci->SetLastTopic(target_ci->GetLastTopic());
- target_ci->SetLastTopicSetter(target_ci->c->topic_setter);
- target_ci->SetLastTopicTime(target_ci->c->topic_time);
+ target_ci->SetLastTopicSetter(target_channel->topic_setter);
+ target_ci->SetLastTopicTime(target_channel->topic_time);
}
else
{
diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp
index cd8718801..d85e5390d 100644
--- a/modules/chanserv/drop.cpp
+++ b/modules/chanserv/drop.cpp
@@ -65,7 +65,7 @@ class CommandCSDrop : public Command
logger.Command(source, ci, _("{source} used {command} on {channel} (founder was: {0})"),
ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none");
- Reference<Channel> c = ci->c;
+ Reference<Channel> c = ci->GetChannel();
ci->Delete();
source.Reply(_("Channel \002{0}\002 has been dropped."), chan);
diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp
index 85649f662..c9ca14acf 100644
--- a/modules/chanserv/enforce.cpp
+++ b/modules/chanserv/enforce.cpp
@@ -34,11 +34,12 @@ class CommandCSEnforce : public Command
bool hadsecureops = ci->IsSecureOps();
ci->SetSecureOps(true);
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ Channel *c = ci->GetChannel();
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
- ci->c->SetCorrectModes(uc->user, false);
+ c->SetCorrectModes(uc->user, false);
}
if (!hadsecureops)
@@ -51,8 +52,9 @@ class CommandCSEnforce : public Command
{
logger.Command(source, ci, _("{source} used {command} on {channel} to enforce restricted"));
+ Channel *c = ci->GetChannel();
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
User *user = uc->user;
@@ -70,8 +72,8 @@ class CommandCSEnforce : public Command
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick();
- ci->c->SetMode(NULL, "BAN", mask);
- ci->c->Kick(NULL, user, reason);
+ c->SetMode(NULL, "BAN", mask);
+ c->Kick(NULL, user, reason);
}
source.Reply(_("\002Restricted\002 enforced on \002{0}\002."), ci->GetName());
@@ -81,8 +83,9 @@ class CommandCSEnforce : public Command
{
logger.Command(source, ci, _("{source} used {command} on {channel} to enforce registered only"));
+ Channel *c = ci->GetChannel();
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
User *user = uc->user;
@@ -100,9 +103,9 @@ class CommandCSEnforce : public Command
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick();
- if (!ci->c->HasMode("REGISTEREDONLY"))
- ci->c->SetMode(NULL, "BAN", mask);
- ci->c->Kick(NULL, user, reason);
+ if (!c->HasMode("REGISTEREDONLY"))
+ c->SetMode(NULL, "BAN", mask);
+ c->Kick(NULL, user, reason);
}
source.Reply(_("\002Registered only\002 enforced on \002{0}\002."), ci->GetName());
@@ -112,8 +115,9 @@ class CommandCSEnforce : public Command
{
logger.Command(source, ci, _("{source} used {command} on {channel} to enforce SSL only"));
+ Channel *c = ci->GetChannel();
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
User *user = uc->user;
@@ -131,9 +135,9 @@ class CommandCSEnforce : public Command
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick();
- if (!ci->c->HasMode("SSL"))
- ci->c->SetMode(NULL, "BAN", mask);
- ci->c->Kick(NULL, user, reason);
+ if (!c->HasMode("SSL"))
+ c->SetMode(NULL, "BAN", mask);
+ c->Kick(NULL, user, reason);
}
source.Reply(_("\002SSL only\002 enforced on %s."), ci->GetName().c_str());
@@ -143,8 +147,9 @@ class CommandCSEnforce : public Command
{
logger.Command(source, ci, _("{source} used {command} on {channel} to enforce bans"));
+ Channel *c = ci->GetChannel();
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
User *user = uc->user;
@@ -152,7 +157,7 @@ class CommandCSEnforce : public Command
if (user->IsProtected())
continue;
- if (ci->c->MatchesList(user, "BAN") && !ci->c->MatchesList(user, "EXCEPT"))
+ if (c->MatchesList(user, "BAN") && !c->MatchesList(user, "EXCEPT"))
users.push_back(user);
}
@@ -161,7 +166,7 @@ class CommandCSEnforce : public Command
User *user = users[i];
Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick();
- ci->c->Kick(NULL, user, reason);
+ c->Kick(NULL, user, reason);
}
source.Reply(_("\002Bans\002 enforced on %s."), ci->GetName().c_str());
@@ -171,8 +176,9 @@ class CommandCSEnforce : public Command
{
logger.Command(source, ci, _("{source} used {command} on {channel} to enforce limit"));
+ Channel *c = ci->GetChannel();
Anope::string l_str;
- if (!ci->c->GetParam("LIMIT", l_str))
+ if (!c->GetParam("LIMIT", l_str))
{
source.Reply(_("There is no limit is set on \002{0}\002."), ci->GetName());
return;
@@ -193,7 +199,7 @@ class CommandCSEnforce : public Command
std::vector<User *> users;
/* The newer users are at the end of the list, so kick users starting from the end */
- for (Channel::ChanUserList::reverse_iterator it = ci->c->users.rbegin(), it_end = ci->c->users.rend(); it != it_end; ++it)
+ for (Channel::ChanUserList::reverse_iterator it = c->users.rbegin(), it_end = c->users.rend(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
User *user = uc->user;
@@ -204,7 +210,7 @@ class CommandCSEnforce : public Command
if (!ci->AccessFor(user).empty())
continue;
- if (ci->c->users.size() - users.size() <= static_cast<unsigned>(l))
+ if (c->users.size() - users.size() <= static_cast<unsigned>(l))
continue;
users.push_back(user);
@@ -215,7 +221,7 @@ class CommandCSEnforce : public Command
User *user = users[i];
Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick();
- ci->c->Kick(NULL, user, reason);
+ c->Kick(NULL, user, reason);
}
source.Reply(_("LIMIT enforced on \002{0}\002, \002{1]\002 users removed."), ci->GetName(), users.size());
@@ -240,7 +246,7 @@ class CommandCSEnforce : public Command
return;
}
- if (!ci->c)
+ if (!ci->GetChannel())
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp
index ec3f833fd..efcea8e9d 100644
--- a/modules/chanserv/entrymsg.cpp
+++ b/modules/chanserv/entrymsg.cpp
@@ -285,9 +285,10 @@ class CSEntryMessage : public Module
void OnJoinChannel(User *u, Channel *c) override
{
- if (u && c && c->ci && u->server->IsSynced())
- for (EntryMsg *msg : c->ci->GetRefs<EntryMsg *>())
- u->SendMessage(c->ci->WhoSends(), "[{0}] {1}", c->ci->GetName(), msg->GetMessage());
+ ChanServ::Channel *ci = c->GetChannel();
+ if (ci && u->server->IsSynced())
+ for (EntryMsg *msg : ci->GetRefs<EntryMsg *>())
+ u->SendMessage(ci->WhoSends(), "[{0}] {1}", ci->GetName(), msg->GetMessage());
}
};
diff --git a/modules/chanserv/getkey.cpp b/modules/chanserv/getkey.cpp
index a1a3dd587..1f280ee52 100644
--- a/modules/chanserv/getkey.cpp
+++ b/modules/chanserv/getkey.cpp
@@ -46,7 +46,7 @@ class CommandCSGetKey : public Command
}
Anope::string key;
- if (!ci->c || !ci->c->GetParam("KEY", key))
+ if (!ci->GetChannel() || !ci->GetChannel()->GetParam("KEY", key))
{
source.Reply(_("Channel \002{0}\002 does not have a key."), ci->GetName());
return;
diff --git a/modules/chanserv/invite.cpp b/modules/chanserv/invite.cpp
index 2f236b6c6..df8bee8f9 100644
--- a/modules/chanserv/invite.cpp
+++ b/modules/chanserv/invite.cpp
@@ -41,7 +41,7 @@ class CommandCSInvite : public Command
return;
}
- ChanServ::Channel *ci = c->ci;
+ ChanServ::Channel *ci = c->GetChannel();
if (!ci)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), c->name);
diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp
index 6f9f06e60..1f89b0274 100644
--- a/modules/chanserv/list.cpp
+++ b/modules/chanserv/list.cpp
@@ -98,7 +98,7 @@ class CommandCSList : public Command
{
if (ci->IsPrivate() || ci->HasFieldS("CS_SUSPENDED"))
continue;
- if (ci->c && ci->c->HasMode("SECRET"))
+ if (ci->GetChannel() && ci->GetChannel()->HasMode("SECRET"))
continue;
if (mlocks)
diff --git a/modules/chanserv/main/channel.cpp b/modules/chanserv/main/channel.cpp
index a2d56b6ec..f4b0e2578 100644
--- a/modules/chanserv/main/channel.cpp
+++ b/modules/chanserv/main/channel.cpp
@@ -32,19 +32,13 @@ void ChannelImpl::Delete()
Anope::Logger.Debug("Deleting channel {0}", this->GetName());
- if (this->c)
+ ::Channel *c = this->GetChannel();
+ if (c)
{
- if (this->GetBot() && this->c->FindUser(this->GetBot()))
- this->GetBot()->Part(this->c);
-
- /* Parting the service bot can cause the channel to go away */
-
- if (this->c)
+ if (this->GetBot() && c->FindUser(this->GetBot()))
{
- if (this->c && this->c->CheckDelete())
- this->c->QueueForDeletion();
-
- this->c = NULL;
+ this->GetBot()->Part(c);
+ c = nullptr;
}
}
diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp
index 17716c3d4..2521ee22e 100644
--- a/modules/chanserv/main/chanserv.cpp
+++ b/modules/chanserv/main/chanserv.cpp
@@ -32,7 +32,6 @@
class ChanServCore : public Module
, public ChanServ::ChanServService
- , public EventHook<Event::ChannelCreate>
, public EventHook<Event::BotDelete>
, public EventHook<Event::BotPrivmsg>
, public EventHook<Event::DelCore>
@@ -61,7 +60,6 @@ class ChanServCore : public Module
public:
ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
, ChanServService(this)
- , EventHook<Event::ChannelCreate>(this)
, EventHook<Event::BotDelete>(this)
, EventHook<Event::BotPrivmsg>(this)
, EventHook<Event::DelCore>(this)
@@ -115,15 +113,21 @@ class ChanServCore : public Module
/** Constructor
* @param chan The channel
*/
- ChanServTimer(Reference<ServiceBot> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), inhabit(i), c(chan)
+ ChanServTimer(Reference<ServiceBot> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s"))
+ , ChanServ(cs)
+ , inhabit(i)
+ , c(chan)
{
if (!ChanServ || !c)
return;
+
inhabit.Set(c, true);
- if (!c->ci || !c->ci->GetBot())
+
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci || !ci->GetBot())
ChanServ->Join(c);
- else if (!c->FindUser(c->ci->GetBot()))
- c->ci->GetBot()->Join(c);
+ else if (!c->FindUser(ci->GetBot()))
+ ci->GetBot()->Join(c);
/* Set +ntsi to prevent rejoin */
c->SetMode(NULL, "NOEXTERNAL");
@@ -146,14 +150,17 @@ class ChanServCore : public Module
c->RemoveMode(NULL, "SECRET");
c->RemoveMode(NULL, "INVITE");
- if (!c->ci || !c->ci->GetBot())
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci || !ci->GetBot())
{
if (ChanServ)
ChanServ->Part(c);
}
/* If someone has rejoined this channel in the meantime, don't part the bot */
else if (c->users.size() <= 1)
- c->ci->GetBot()->Part(c);
+ {
+ ci->GetBot()->Part(c);
+ }
}
};
@@ -248,13 +255,6 @@ class ChanServCore : public Module
defaults.clear();
}
- void OnChannelCreate(Channel *c) override
- {
- c->ci = Find(c->name);
- if (c->ci)
- c->ci->c = c;
- }
-
void OnBotDelete(ServiceBot *bi) override
{
if (bi == ChanServ)
@@ -324,14 +324,15 @@ class ChanServCore : public Module
void OnDelChan(ChanServ::Channel *ci) override
{
- if (ci->c)
- {
- ci->c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false);
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
+ return;
- const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
- if (!require.empty())
- ci->c->SetModes(ci->WhoSends(), false, "-%s", require.c_str());
- }
+ c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false);
+
+ const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
+ if (!require.empty())
+ c->SetModes(ci->WhoSends(), false, "-%s", require.c_str());
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -371,7 +372,8 @@ class ChanServCore : public Module
if (!c)
return;
- if (c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (ci)
c->SetMode(nullptr, "REGISTERED", "", false);
else
c->RemoveMode(nullptr, "REGISTERED", "", false);
@@ -379,7 +381,7 @@ class ChanServCore : public Module
const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
if (!require.empty())
{
- if (c->ci)
+ if (ci)
c->SetModes(nullptr, false, "+%s", require.c_str());
else
c->SetModes(nullptr, false, "-%s", require.c_str());
@@ -396,7 +398,8 @@ class ChanServCore : public Module
void OnChannelSync(Channel *c) override
{
- bool perm = c->HasMode("PERM") || (c->ci && c->ci->IsPersist());
+ ChanServ::Channel *ci = c->GetChannel();
+ bool perm = c->HasMode("PERM") || (ci && ci->IsPersist());
if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me)))
{
this->Hold(c);
@@ -425,10 +428,11 @@ class ChanServCore : public Module
if (Anope::CurTime - ci->GetLastUsed() >= chanserv_expire)
{
- if (ci->c)
+ Channel *c = ci->GetChannel();
+ if (c)
{
time_t last_used = ci->GetLastUsed();
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->GetLastUsed(); ++cit)
+ for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end && last_used == ci->GetLastUsed(); ++cit)
ci->AccessFor(cit->second->user);
expire = last_used == ci->GetLastUsed();
}
@@ -465,14 +469,14 @@ class ChanServCore : public Module
{
if (ci->IsPersist())
{
- bool c;
- ci->c = Channel::FindOrCreate(ci->GetName(), c, ci->GetTimeRegistered());
+ bool created;
+ Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered());
if (ModeManager::FindChannelModeByName("PERM") != NULL)
{
- if (c)
- IRCD->Send<messages::MessageChannel>(ci->c);
- ci->c->SetMode(NULL, "PERM");
+ if (created)
+ IRCD->Send<messages::MessageChannel>(c);
+ c->SetMode(NULL, "PERM");
}
else
{
@@ -483,12 +487,12 @@ class ChanServCore : public Module
bi->Assign(nullptr, ci);
}
- if (ci->GetBot() != nullptr && ci->c->FindUser(ci->GetBot()) == nullptr)
+ if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr)
{
Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes",
Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes"));
ChannelStatus status(botmodes);
- ci->GetBot()->Join(ci->c, &status);
+ ci->GetBot()->Join(c, &status);
}
}
}
@@ -502,24 +506,26 @@ class ChanServCore : public Module
for (unsigned i = 0; i < defaults.size(); ++i)
ci->SetS<bool>(defaults[i].upper(), true);
- if (!ci->c)
+ Channel *c = ci->GetChannel();
+ if (!c)
return;
/* Mark the channel as persistent */
- if (ci->c->HasMode("PERM"))
+ if (c->HasMode("PERM"))
ci->SetPersist(true);
/* Persist may be in def cflags, set it here */
else if (ci->IsPersist())
- ci->c->SetMode(NULL, "PERM");
+ c->SetMode(NULL, "PERM");
}
void OnJoinChannel(User *u, Channel *c) override
{
- if (!c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci)
return;
- time_t ts = c->ci->GetChannelTS();
+ time_t ts = ci->GetChannelTS();
if (ts == 0)
- ts = c->ci->GetTimeRegistered();
+ ts = ci->GetTimeRegistered();
if (c->creation_time > ts)
{
diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp
index 686b97514..7d7f7c85d 100644
--- a/modules/chanserv/mode.cpp
+++ b/modules/chanserv/mode.cpp
@@ -270,7 +270,7 @@ class CommandCSMode : public Command
return source.AccessFor(ci).HasPriv(cm->name + (self ? "ME" : ""));
}
- void DoLock(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
+ void DoLock(CommandSource &source, ChanServ::Channel *ci, Channel *c, const std::vector<Anope::string> &params)
{
User *u = source.GetUser();
const Anope::string &subcommand = params[2];
@@ -340,7 +340,7 @@ class CommandCSMode : public Command
break;
}
- if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c))
+ if (cm->type == MODE_LIST && c && IRCD->GetMaxListFor(c) && c->HasMode(cm->name) >= IRCD->GetMaxListFor(c))
{
source.Reply(_("List for mode \002{0}\002 is full."), cm->mchar);
break;
@@ -386,8 +386,8 @@ class CommandCSMode : public Command
source.Reply(_("Nothing to do."));
}
- if (ci->c)
- ci->c->CheckModes();
+ if (c)
+ c->CheckModes();
}
else if (subcommand.equals_ci("DEL") && !param.empty())
{
@@ -489,7 +489,7 @@ class CommandCSMode : public Command
}
}
- void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
+ void DoSet(CommandSource &source, ChanServ::Channel *ci, Channel *c, const std::vector<Anope::string> &params)
{
User *u = source.GetUser();
@@ -512,7 +512,7 @@ class CommandCSMode : public Command
case '*':
if (adding == -1 || !has_access)
break;
- for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && ci->c; ++j)
+ for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && c; ++j)
{
ChannelMode *cm = ModeManager::GetChannelModes()[j];
@@ -521,9 +521,9 @@ class CommandCSMode : public Command
if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM))
{
if (adding)
- ci->c->SetMode(NULL, cm);
+ c->SetMode(NULL, cm);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
}
}
}
@@ -540,9 +540,9 @@ class CommandCSMode : public Command
if (!has_access)
break;
if (adding)
- ci->c->SetMode(NULL, cm);
+ c->SetMode(NULL, cm);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
break;
case MODE_PARAM:
if (!has_access)
@@ -550,9 +550,9 @@ class CommandCSMode : public Command
if (adding && !sep.GetToken(param))
break;
if (adding)
- ci->c->SetMode(NULL, cm, param);
+ c->SetMode(NULL, cm, param);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
break;
case MODE_STATUS:
{
@@ -569,7 +569,7 @@ class CommandCSMode : public Command
break;
}
- for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::const_iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
@@ -584,9 +584,9 @@ class CommandCSMode : public Command
if (Anope::Match(uc->user->GetMask(), param))
{
if (adding)
- ci->c->SetMode(NULL, cm, uc->user->GetUID());
+ c->SetMode(NULL, cm, uc->user->GetUID());
else
- ci->c->RemoveMode(NULL, cm, uc->user->GetUID());
+ c->RemoveMode(NULL, cm, uc->user->GetUID());
}
}
}
@@ -622,9 +622,9 @@ class CommandCSMode : public Command
}
if (adding)
- ci->c->SetMode(NULL, cm, target->GetUID());
+ c->SetMode(NULL, cm, target->GetUID());
else
- ci->c->RemoveMode(NULL, cm, target->GetUID());
+ c->RemoveMode(NULL, cm, target->GetUID());
}
break;
}
@@ -635,15 +635,15 @@ class CommandCSMode : public Command
break;
if (adding)
{
- if (IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) < IRCD->GetMaxListFor(ci->c))
- ci->c->SetMode(NULL, cm, param);
+ if (IRCD->GetMaxListFor(c) && c->HasMode(cm->name) < IRCD->GetMaxListFor(c))
+ c->SetMode(NULL, cm, param);
}
else
{
- std::vector<Anope::string> v = ci->c->GetModeList(cm->name);
+ std::vector<Anope::string> v = c->GetModeList(cm->name);
for (unsigned j = 0; j < v.size(); ++j)
if (Anope::Match(v[j], param))
- ci->c->RemoveMode(NULL, cm, v[j]);
+ c->RemoveMode(NULL, cm, v[j]);
}
}
}
@@ -664,7 +664,7 @@ class CommandCSMode : public Command
new_params.push_back(params[0]);
new_params.push_back("SET");
new_params.push_back("-*");
- this->DoSet(source, ci, new_params);
+ this->DoSet(source, ci, ci->GetChannel(), new_params);
return;
}
@@ -697,7 +697,7 @@ class CommandCSMode : public Command
new_params.push_back("SET");
new_params.push_back("-" + stringify(cm->mchar));
new_params.push_back("*");
- this->DoSet(source, ci, new_params);
+ this->DoSet(source, ci, ci->GetChannel(), new_params);
}
public:
@@ -721,6 +721,8 @@ class CommandCSMode : public Command
return;
}
+ Channel *c = ci->GetChannel();
+
if (subcommand.equals_ci("LOCK") && params.size() > 2)
{
if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasOverridePriv("chanserv/administration"))
@@ -729,15 +731,19 @@ class CommandCSMode : public Command
return;
}
- this->DoLock(source, ci, params);
+ this->DoLock(source, ci, c, params);
+ return;
}
- else if (!ci->c)
+
+ if (!c)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
+ return;
}
- else if (subcommand.equals_ci("SET") && params.size() > 2)
+
+ if (subcommand.equals_ci("SET") && params.size() > 2)
{
- this->DoSet(source, ci, params);
+ this->DoSet(source, ci, c, params);
}
else if (subcommand.equals_ci("CLEAR"))
{
@@ -807,7 +813,8 @@ class CommandCSModes : public Command
return;
}