summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-14 12:15:00 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-14 12:15:00 +0100
commit74ccc28da30896ee715504d53822f7b3ce6ec86f (patch)
treefaa72eeee26610355d23b71c27a2b1670629836e /src/channels.cpp
parent51b5f06c48b98a256eb56ea5f7e4d5d170555e84 (diff)
Move GetPrefixChar() from Channel to Membership
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp26
1 files changed, 12 insertions, 14 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;