]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_callerid.cpp
Fix m_chanlog crashing.
[user/henk/code/inspircd.git] / src / modules / m_callerid.cpp
index 6d7d8413f47705574d42c6e59279b8f7b9f4cd72..7fea35d348638c86af47e7f97311bc6e9cb82d5a 100644 (file)
@@ -48,7 +48,7 @@ void RemoveData(User* who)
 
 void RemoveFromAllAccepts(InspIRCd* ServerInstance, User* who)
 {
-       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); ++i)
+       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i)
        {
                callerid_data* dat = GetData(i->second, false);
                if (!dat) continue;
@@ -222,13 +222,13 @@ public:
                        delete myumode;
                        throw new ModuleException("Could not add usermode and command!");
                }
-               Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
-               ServerInstance->Modules->Attach(eventlist, this, 6);
+               Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage, I_OnCleanup };
+               ServerInstance->Modules->Attach(eventlist, this, 7);
        }
 
        ~ModuleCallerID()
        {
-               delete mycommand;
+               delete myumode;
        }
 
        Version GetVersion()
@@ -279,6 +279,14 @@ public:
                return 0;
        }
 
+       void OnCleanup(int type, void* item)
+       {
+               if (type != TYPE_USER) return;
+               User* u = (User*)item;
+               /* Cleanup only happens on unload (before dtor), so keep this O(n) instead of O(n^2) which deferring to OnUserQuit would do.  */
+               RemoveData(u);
+       }
+
        int OnUserPreNick(User* user, const std::string& newnick)
        {
                if (!tracknick)