diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-02-14 12:15:00 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-02-14 12:15:00 +0100 |
commit | 74ccc28da30896ee715504d53822f7b3ce6ec86f (patch) | |
tree | faa72eeee26610355d23b71c27a2b1670629836e /src | |
parent | 51b5f06c48b98a256eb56ea5f7e4d5d170555e84 (diff) |
Move GetPrefixChar() from Channel to Membership
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 26 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_whois.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 6 |
4 files changed, 23 insertions, 19 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 7d8bff661..c47bcb119 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -686,10 +686,13 @@ void Channel::UserList(User *user) continue; } - prefixlist = this->GetPrefixChar(i->first); + Membership* memb = i->second; + + prefixlist.clear(); + prefixlist.push_back(memb->GetPrefixChar()); nick = i->first->nick; - FOREACH_MOD(OnNamesListItem, (user, i->second, prefixlist, nick)); + FOREACH_MOD(OnNamesListItem, (user, memb, prefixlist, nick)); /* Nick was nuked, a module wants us to skip it */ if (nick.empty()) @@ -723,23 +726,18 @@ void Channel::UserList(User *user) * % for halfop etc. If the user has several modes set, the highest mode * the user has must be returned. */ -const char* Channel::GetPrefixChar(User *user) +char Membership::GetPrefixChar() const { - static char pf[2] = {0, 0}; - *pf = 0; + char pf = 0; unsigned int bestrank = 0; - UserMembIter m = userlist.find(user); - if (m != userlist.end()) + for (std::string::const_iterator i = modes.begin(); i != modes.end(); ++i) { - for(unsigned int i=0; i < m->second->modes.length(); i++) + PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(*i); + if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix()) { - PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(m->second->modes[i]); - if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix()) - { - bestrank = mh->GetPrefixRank(); - pf[0] = mh->GetPrefix(); - } + bestrank = mh->GetPrefixRank(); + pf = mh->GetPrefix(); } } return pf; diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index d7084d53b..2be724e91 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -224,7 +224,7 @@ void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, } if (memb) - wholine.append(memb->chan->GetPrefixChar(u)); + wholine.push_back(memb->GetPrefixChar()); wholine.append(" :0 " + u->fullname); diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index 29322f802..61a4ad891 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -65,12 +65,16 @@ std::string CommandWhois::ChannelList(User* source, User* dest, bool spy) for (UCListIter i = dest->chans.begin(); i != dest->chans.end(); i++) { - Channel* c = (*i)->chan; + Membership* memb = *i; + Channel* c = memb->chan; /* If the target is the sender, neither +p nor +s is set, or * the channel contains the user, it is not a spy channel */ if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source))) - list.append(c->GetPrefixChar(dest)).append(c->name).append(" "); + { + list.push_back(memb->GetPrefixChar()); + list.append(c->name).push_back(' '); + } } return list; diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index c72f88faa..1fa7aa3e2 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -192,8 +192,10 @@ class CommandCheck : public Command for (UCListIter i = targuser->chans.begin(); i != targuser->chans.end(); i++) { - Channel* c = (*i)->chan; - chliststr.append(c->GetPrefixChar(targuser)).append(c->name).append(" "); + Membership* memb = *i; + Channel* c = memb->chan; + chliststr.push_back(memb->GetPrefixChar()); + chliststr.append(c->name).push_back(' '); } std::stringstream dump(chliststr); |