X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_callerid.cpp;h=7fea35d348638c86af47e7f97311bc6e9cb82d5a;hb=f51d9ad5ab7015f78a29039ca7ed169b281ff6bb;hp=6d7d8413f47705574d42c6e59279b8f7b9f4cd72;hpb=f40c98ecabc2ac5d525316a900043bb154c4cccc;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 6d7d8413f..7fea35d34 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -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)