From fcc5ed3e8ac612ccbbe293c15dee8fcce5fa9ae5 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 22 Feb 2006 20:36:01 +0000 Subject: Cleanups on module unload or user /QUIT git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3290 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_safelist.cpp | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index b7bc502f3..c474b9997 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -62,7 +62,7 @@ class ModuleSafeList : public Module void Implements(char* List) { - List[I_OnPreCommand] = List[I_OnBackgroundTimer] = 1; + List[I_OnPreCommand] = List[I_OnBackgroundTimer] = List[I_OnCleanup] = List[I_OnUserQuit] = 1; } /* @@ -175,13 +175,6 @@ class ModuleSafeList : public Module user->Shrink("safelist_last"); } - /* no? let's check when they did a /list last.. */ - /*if ((ld) && (*list_start >= TIME - 100)) - { - Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** You are attempting to LIST too quickly. Please wait a while."); - return 1; - }*/ - /* * start at channel 0! ;) */ @@ -201,6 +194,41 @@ class ModuleSafeList : public Module this->OnBackgroundTimer(TIME); return 1; } + + virtual void OnCleanup(int target_type, void* item) + { + if(target_type == TYPE_USER) + { + userrec* u = (userrec*)item; + ListData* ld = u->GetExt("safelist_cache"); + if (ld) + { + u->Shrink("safelist_cache"); + delete ld; + } + for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++) + { + userrec* u2 = (userrec*)(*iter); + if (u2 == u) + { + listusers.erase(iter); + break; + } + } + time_t* last_list_time = (time_t*)user->GetExt("safelist_last"); + if (last_list_time) + { + delete last_list_time; + user->Shrink("safelist_last"); + } + } + } + + virtual void OnUserQuit(userrec* user, std::string message) + { + this->OnCleanup(TYPE_USER,user); + } + }; -- cgit v1.2.3