diff options
author | Adam <Adam@anope.org> | 2010-11-14 17:34:17 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-11-14 17:34:17 -0500 |
commit | 4f8dfc2132e2c67bf8047cbba0a78ea22e870d28 (patch) | |
tree | b68a377caa1126de27d9c1b69b510cb0c9570515 | |
parent | 4415a779a3ff690e800198b27a16a80a630b1e3d (diff) |
Delete users and channels from the modestacker when they are destructed
-rw-r--r-- | include/modes.h | 5 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/modes.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 4 |
4 files changed, 25 insertions, 1 deletions
diff --git a/include/modes.h b/include/modes.h index f771c6e91..299d1a2db 100644 --- a/include/modes.h +++ b/include/modes.h @@ -483,6 +483,11 @@ class CoreExport ModeManager /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users */ static void ProcessModes(); + + /** Delete a user or channel from the stacker + * @param b The user/channel + */ + static void StackerDel(Base *b); }; #endif // MODES_H diff --git a/src/channels.cpp b/src/channels.cpp index 4ba9049a9..6e1e25f23 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -47,6 +47,8 @@ Channel::~Channel() { FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this)); + ModeManager::StackerDel(this); + Log(NULL, this, "destroy"); for (std::list<BanData *>::iterator it = this->bd.begin(), it_end = this->bd.end(); it != it_end; ++it) diff --git a/src/modes.cpp b/src/modes.cpp index 23cd0e402..f28e6a4b4 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -822,3 +822,18 @@ void ModeManager::ProcessModes() StackerObjects.clear(); } } + +/** Delete a user or channel from the stacker + * @param b The user/channel + */ +void ModeManager::StackerDel(Base *b) +{ + for (std::list<std::pair<Base *, StackerInfo *> >::iterator it = ModeManager::StackerObjects.begin(), it_end = ModeManager::StackerObjects.end(); it != it_end; ++it) + { + if (b == it->first) + { + ModeManager::StackerObjects.erase(it); + break; + } + } +} diff --git a/src/users.cpp b/src/users.cpp index 12502efae..9aa67b174 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -188,10 +188,12 @@ User::~User() Log(this, "disconnect") << "(" << this->realname << ") " << "disconnected from the network (" << this->server->GetName() << ")"; - this->Logout(); FOREACH_MOD(I_OnUserLogoff, OnUserLogoff(this)); + ModeManager::StackerDel(this); + this->Logout(); + --usercnt; if (is_oper(this)) |