diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_auditorium.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_deaf.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_delayjoin.cpp | 41 | ||||
-rw-r--r-- | src/modules/m_invisible.cpp | 41 | ||||
-rw-r--r-- | src/modules/m_silence.cpp | 4 |
5 files changed, 27 insertions, 104 deletions
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index d27ccfaad..ec321bb35 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -52,8 +52,8 @@ class ModuleAuditorium : public Module OnRehash(NULL); - Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnRehash, I_OnHostCycle }; - ServerInstance->Modules->Attach(eventlist, this, 7); + Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnBuildNeighborList, I_OnNamesListItem, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 6); } @@ -137,34 +137,14 @@ class ModuleAuditorium : public Module BuildExcept(memb, excepts); } - ModResult OnHostCycle(User* user) + void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception) { - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - if ((*f)->IsModeSet('u')) - return MOD_RES_DENY; - - return MOD_RES_PASSTHRU; - } - - void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) - { - Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - std::vector<std::string> to_leave; - if (parthandler) + UCListIter i = include.begin(); + while (i != include.end()) { - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - { - if ((*f)->IsModeSet('u')) - to_leave.push_back((*f)->name); - } - /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ - for (std::vector<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++) - { - std::vector<std::string> parameters; - parameters.push_back(*n); - /* This triggers our OnUserPart, above, making the PART silent */ - parthandler->Handle(parameters, user); - } + Channel* c = *i++; + if (c->IsModeSet('u')) + include.erase(c); } } }; diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index 78040e81f..2d13be98b 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -60,8 +60,8 @@ class ModuleDeaf : public Module throw ModuleException("Could not add new modes!"); OnRehash(NULL); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_OnBuildExemptList }; - ServerInstance->Modules->Attach(eventlist, this, 4); + Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 3); } @@ -98,11 +98,6 @@ class ModuleDeaf : public Module return MOD_RES_PASSTHRU; } - virtual void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text) - { - BuildDeafList(message_type, chan, sender, status, text, exempt_list); - } - virtual void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list) { const UserMembList *ulist = chan->GetUsers(); diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 1a84ee694..1db0e7c0d 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -36,18 +36,17 @@ class ModuleDelayJoin : public Module { if (!ServerInstance->Modes->AddMode(&djm)) throw ModuleException("Could not add new modes!"); - Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnText, I_OnHostCycle }; - ServerInstance->Modules->Attach(eventlist, this, 7); + Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnBuildNeighborList, I_OnNamesListItem, I_OnText }; + ServerInstance->Modules->Attach(eventlist, this, 6); } ~ModuleDelayJoin(); Version GetVersion(); void OnNamesListItem(User* issuer, Membership*, std::string &prefixes, std::string &nick); void OnUserJoin(Membership*, bool, bool, CUList&); void CleanUser(User* user); - ModResult OnHostCycle(User* user); void OnUserPart(Membership*, std::string &partmessage, CUList&); void OnUserKick(User* source, Membership*, const std::string &reason, CUList&); - void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message); + void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception); void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list); }; @@ -125,37 +124,15 @@ void ModuleDelayJoin::OnUserKick(User* source, Membership* memb, const std::stri populate(except, memb); } -ModResult ModuleDelayJoin::OnHostCycle(User* user) +void ModuleDelayJoin::OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception) { - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) + UCListIter i = include.begin(); + while (i != include.end()) { - Channel* chan = *f; - Membership* memb = chan->GetUser(user); - - if (memb && unjoined.get(memb)) - { - return MOD_RES_DENY; - } - } - return MOD_RES_PASSTHRU; -} - -void ModuleDelayJoin::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) -{ - Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - if (!parthandler) - return; - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - { - Channel* chan = *f; - Membership* memb = chan->GetUser(user); + Channel* c = *i++; + Membership* memb = c->GetUser(source); if (memb && unjoined.get(memb)) - { - std::vector<std::string> parameters; - parameters.push_back(chan->name); - /* Send a fake PART from the channel, which will be silent */ - parthandler->Handle(parameters, user); - } + include.erase(c); } } diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 9c4a58278..1e8be61f5 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -115,8 +115,8 @@ class ModuleInvisible : public Module /* Yeah i know people can take this out. I'm not about to obfuscate code just to be a pain in the ass. */ ServerInstance->Users->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible"); Implementation eventlist[] = { - I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, I_OnUserPart, I_OnUserQuit, - I_OnHostCycle, I_OnSendWhoLine, I_OnNamesListItem + I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, + I_OnBuildNeighborList, I_OnSendWhoLine, I_OnNamesListItem }; ServerInstance->Modules->Attach(eventlist, this, 8); }; @@ -127,9 +127,7 @@ class ModuleInvisible : public Module Version GetVersion(); void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts); - void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts); - void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message); - ModResult OnHostCycle(User* user); + void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exceptions); ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); void OnSendWhoLine(User* source, User* user, Channel* channel, std::string& line); @@ -162,41 +160,14 @@ void ModuleInvisible::OnUserJoin(Membership* memb, bool sync, bool created, CULi } } -void ModuleInvisible::OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) +void ModuleInvisible::OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exceptions) { - if (memb->user->IsModeSet('Q')) - { - BuildExcept(memb, excepts); - } -} - -void ModuleInvisible::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) -{ - if (user->IsModeSet('Q')) + if (source->IsModeSet('Q')) { - Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - std::vector<std::string> to_leave; - if (parthandler) - { - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - to_leave.push_back((*f)->name); - /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ - for (std::vector<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++) - { - std::vector<std::string> parameters; - parameters.push_back(*n); - /* This triggers our OnUserPart, above, making the PART silent */ - parthandler->Handle(parameters, user); - } - } + include.clear(); } } -ModResult ModuleInvisible::OnHostCycle(User* user) -{ - return user->IsModeSet('Q') ? MOD_RES_DENY : MOD_RES_PASSTHRU; -} - /* No privmsg response when hiding - submitted by Eric at neowin */ ModResult ModuleInvisible::OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index eae6bf35c..dd7a62726 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -277,8 +277,8 @@ class ModuleSilence : public Module ServerInstance->AddCommand(&cmdsilence); ServerInstance->AddCommand(&cmdsvssilence); - Implementation eventlist[] = { I_OnRehash, I_OnBuildExemptList, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage, I_OnUserPreInvite }; - ServerInstance->Modules->Attach(eventlist, this, 6); + Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage, I_OnUserPreInvite }; + ServerInstance->Modules->Attach(eventlist, this, 5); } void OnRehash(User* user) |