diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-01-24 12:58:01 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-01-24 12:58:01 +0100 |
commit | 932e8d13f81c7c94a89dc3702f6d45bc185f5dcf (patch) | |
tree | cb50264af2ff50ccf8070ce9123ee350d95ff7f8 /src/modules | |
parent | 9a962e1c512ffc00bcfce105e9dbdabd9abcdd86 (diff) |
Convert UserChanList to an intrusively linked list
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_auditorium.cpp | 18 | ||||
-rw-r--r-- | src/modules/m_channelban.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_delayjoin.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_hostcycle.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_ircv3.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_nickflood.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_nonicks.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 2 |
9 files changed, 32 insertions, 36 deletions
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 502a9fb9f..62aa7ec75 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -129,19 +129,21 @@ class ModuleAuditorium : public Module BuildExcept(memb, excepts); } - void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception) CXX11_OVERRIDE + void OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) CXX11_OVERRIDE { - UCListIter i = include.begin(); - while (i != include.end()) + for (IncludeChanList::iterator i = include.begin(); i != include.end(); ) { - Channel* c = *i++; - Membership* memb = c->GetUser(source); - if (!memb || IsVisible(memb)) + Membership* memb = *i; + if (IsVisible(memb)) + { + ++i; continue; + } + // this channel should not be considered when listing my neighbors - include.erase(c); + i = include.erase(i); // however, that might hide me from ops that can see me... - const UserMembList* users = c->GetUsers(); + const UserMembList* users = memb->chan->GetUsers(); for(UserMembCIter j = users->begin(); j != users->end(); j++) { if (IS_LOCAL(j->first) && CanSee(j->first, memb)) diff --git a/src/modules/m_channelban.cpp b/src/modules/m_channelban.cpp index 3260c0fa4..300caa123 100644 --- a/src/modules/m_channelban.cpp +++ b/src/modules/m_channelban.cpp @@ -42,15 +42,9 @@ class ModuleBadChannelExtban : public Module } for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - if (InspIRCd::Match((**i).name, rm)) + if (InspIRCd::Match((*i)->chan->name, rm)) { - if (status) - { - Membership* memb = (**i).GetUser(user); - if (memb && memb->hasMode(status)) - return MOD_RES_DENY; - } - else + if (!status || (*i)->hasMode(status)) return MOD_RES_DENY; } } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index d12d2728d..c72f88faa 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -192,7 +192,7 @@ class CommandCheck : public Command for (UCListIter i = targuser->chans.begin(); i != targuser->chans.end(); i++) { - Channel* c = *i; + Channel* c = (*i)->chan; chliststr.append(c->GetPrefixChar(targuser)).append(c->name).append(" "); } diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 70c6b8717..e183fbe46 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -50,7 +50,7 @@ class ModuleDelayJoin : public Module void CleanUser(User* user); void OnUserPart(Membership*, std::string &partmessage, CUList&) CXX11_OVERRIDE; void OnUserKick(User* source, Membership*, const std::string &reason, CUList&) CXX11_OVERRIDE; - void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception) CXX11_OVERRIDE; + void OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) CXX11_OVERRIDE; void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE; ModResult OnRawMode(User* user, Channel* channel, const char mode, const std::string ¶m, bool adding, int pcnt) CXX11_OVERRIDE; }; @@ -123,15 +123,15 @@ void ModuleDelayJoin::OnUserKick(User* source, Membership* memb, const std::stri populate(except, memb); } -void ModuleDelayJoin::OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception) +void ModuleDelayJoin::OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) { - UCListIter i = include.begin(); - while (i != include.end()) + for (IncludeChanList::iterator i = include.begin(); i != include.end(); ) { - Channel* c = *i++; - Membership* memb = c->GetUser(source); - if (memb && unjoined.get(memb)) - include.erase(c); + Membership* memb = *i; + if (unjoined.get(memb)) + i = include.erase(i); + else + ++i; } } diff --git a/src/modules/m_hostcycle.cpp b/src/modules/m_hostcycle.cpp index 79b4169ec..d3646e899 100644 --- a/src/modules/m_hostcycle.cpp +++ b/src/modules/m_hostcycle.cpp @@ -32,7 +32,7 @@ class ModuleHostCycle : public Module already_sent_t silent_id = ++LocalUser::already_sent_id; already_sent_t seen_id = ++LocalUser::already_sent_id; - UserChanList include_chans(user->chans); + IncludeChanList include_chans(user->chans.begin(), user->chans.end()); std::map<User*,bool> exceptions; FOREACH_MOD(OnBuildNeighborList, (user, include_chans, exceptions)); @@ -56,10 +56,10 @@ class ModuleHostCycle : public Module std::string newfullhost = user->nick + "!" + newident + "@" + newhost; - for (UCListIter i = include_chans.begin(); i != include_chans.end(); ++i) + for (IncludeChanList::const_iterator i = include_chans.begin(); i != include_chans.end(); ++i) { - Channel* c = *i; - Membership* memb = c->GetUser(user); + Membership* memb = *i; + Channel* c = memb->chan; const std::string joinline = ":" + newfullhost + " JOIN " + c->name; std::string modeline; diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp index e8018aea6..5cb2ab6b1 100644 --- a/src/modules/m_ircv3.cpp +++ b/src/modules/m_ircv3.cpp @@ -33,7 +33,7 @@ class ModuleIRCv3 : public Module void WriteNeighboursWithExt(User* user, const std::string& line, const LocalIntExt& ext) { - UserChanList chans(user->chans); + IncludeChanList chans(user->chans.begin(), user->chans.end()); std::map<User*, bool> exceptions; FOREACH_MOD(OnBuildNeighborList, (user, chans, exceptions)); @@ -48,9 +48,9 @@ class ModuleIRCv3 : public Module // Now consider sending it to all other users who has at least a common channel with the user std::set<User*> already_sent; - for (UCListIter i = chans.begin(); i != chans.end(); ++i) + for (IncludeChanList::const_iterator i = chans.begin(); i != chans.end(); ++i) { - const UserMembList* userlist = (*i)->GetUsers(); + const UserMembList* userlist = (*i)->chan->GetUsers(); for (UserMembList::const_iterator m = userlist->begin(); m != userlist->end(); ++m) { /* diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index c3cff2cd1..93fbbfaaa 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -140,7 +140,7 @@ class ModuleNickFlood : public Module { for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - Channel *channel = *i; + Channel* channel = (*i)->chan; ModResult res; nickfloodsettings *f = nf.ext.get(channel); @@ -179,7 +179,7 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i) { - Channel *channel = *i; + Channel* channel = (*i)->chan; ModResult res; nickfloodsettings *f = nf.ext.get(channel); diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index a41f50901..15ee4e7f8 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -53,7 +53,7 @@ class ModuleNoNickChange : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - Channel* curr = *i; + Channel* curr = (*i)->chan; ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick"); diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index c84e74892..4fb4ae942 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -81,7 +81,7 @@ class ModuleOperPrefixMode : public Module modechange.push_back(user->nick); for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++) { - modechange[0] = (*v)->name; + modechange[0] = (*v)->chan->name; ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient); } } |