summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-08-11 17:14:39 -0400
committerAdam <Adam@anope.org>2013-08-11 17:14:39 -0400
commitf1956b039d3c7be38ad03fbb79be6a4eed440cf0 (patch)
tree483b29cf3c67af4742945213eb88a173ae5b6d6a /src
parent53d5b7c29ea2f0164b562549cef579fe2b276abf (diff)
Remove channels from accesss lists when they expire/drop
Diffstat (limited to 'src')
-rw-r--r--src/access.cpp6
-rw-r--r--src/regchannel.cpp25
2 files changed, 31 insertions, 0 deletions
diff --git a/src/access.cpp b/src/access.cpp
index 173f3c979..985b69390 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -154,6 +154,12 @@ ChanAccess::~ChanAccess()
const NickAlias *na = NickAlias::Find(this->mask);
if (na != NULL)
na->nc->RemoveChannelReference(this->ci);
+ else
+ {
+ ChannelInfo *c = ChannelInfo::Find(this->mask);
+ if (c)
+ c->RemoveChannelReference(this->ci->name);
+ }
}
}
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index b79d07890..85b1f5b68 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -401,6 +401,12 @@ void ChannelInfo::AddAccess(ChanAccess *taccess)
na->nc->AddChannelReference(this);
taccess->nc = na->nc;
}
+ else
+ {
+ ChannelInfo *ci = ChannelInfo::Find(taccess->mask);
+ if (ci != NULL)
+ ci->AddChannelReference(this->name);
+ }
}
ChanAccess *ChannelInfo::GetAccess(unsigned index) const
@@ -656,3 +662,22 @@ bool IsFounder(const User *user, const ChannelInfo *ci)
return false;
}
+
+void ChannelInfo::AddChannelReference(const Anope::string &what)
+{
+ ++references[what];
+}
+
+void ChannelInfo::RemoveChannelReference(const Anope::string &what)
+{
+ int &i = references[what];
+ if (--i <= 0)
+ references.erase(what);
+}
+
+void ChannelInfo::GetChannelReferences(std::deque<Anope::string> &chans)
+{
+ chans.clear();
+ for (Anope::map<int>::iterator it = references.begin(); it != references.end(); ++it)
+ chans.push_back(it->first);
+}