summaryrefslogtreecommitdiff
path: root/src/nickcore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nickcore.cpp')
-rw-r--r--src/nickcore.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 7dda6da5c..f92d4739c 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -17,7 +17,7 @@
Serialize::Checker<nickcore_map> NickCoreList("NickCore");
-NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), aliases("NickAlias")
+NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), chanaccess("ChannelInfo"), aliases("NickAlias")
{
if (coredisplay.empty())
throw CoreException("Empty display passed to NickCore constructor");
@@ -44,6 +44,9 @@ NickCore::~NickCore()
{
FOREACH_MOD(I_OnDelCore, OnDelCore(this));
+ if (!this->chanaccess->empty())
+ Log(LOG_DEBUG) << "Non-empty chanaccess list in destructor!";
+
for (std::list<User *>::iterator it = this->users.begin(); it != this->users.end();)
{
User *user = *it++;
@@ -253,6 +256,25 @@ void NickCore::ClearCert()
this->cert.clear();
}
+void NickCore::AddChannelReference(ChannelInfo *ci)
+{
+ ++(*this->chanaccess)[ci];
+}
+
+void NickCore::RemoveChannelReference(ChannelInfo *ci)
+{
+ int& i = (*this->chanaccess)[ci];
+ if (--i <= 0)
+ this->chanaccess->erase(ci);
+}
+
+void NickCore::GetChannelReferences(std::deque<ChannelInfo *> &queue)
+{
+ queue.clear();
+ for (std::map<ChannelInfo *, int>::iterator it = this->chanaccess->begin(), it_end = this->chanaccess->end(); it != it_end; ++it)
+ queue.push_back(it->first);
+}
+
NickCore* NickCore::Find(const Anope::string &nick)
{
nickcore_map::const_iterator it = NickCoreList->find(nick);