summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h13
-rw-r--r--include/membership.h9
-rw-r--r--src/channels.cpp26
-rw-r--r--src/commands/cmd_who.cpp2
-rw-r--r--src/commands/cmd_whois.cpp8
-rw-r--r--src/modules/m_check.cpp6
6 files changed, 32 insertions, 32 deletions
diff --git a/include/channels.h b/include/channels.h
index 5109c0463..daf8be9e2 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -304,19 +304,6 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
*/
void UserList(User *user);
- /** Get a users prefix on this channel in a string.
- * @param user The user to look up
- * @return A character array containing the prefix string.
- * Unlike GetStatus and GetStatusFlags which will only return the
- * core specified modes @, % and + (op, halfop and voice), GetPrefixChar
- * will also return module-defined prefixes. If the user has to prefix,
- * an empty but non-null string is returned. If the user has multiple
- * prefixes, the highest is returned. If you do not recognise the prefix
- * character you can get, you can deal with it in a 'proprtional' manner
- * compared to known prefixes, using GetPrefixValue().
- */
- const char* GetPrefixChar(User *user);
-
/** Return all of a users mode prefixes into a char* string.
* @param user The user to look up
* @return A list of all prefix characters. The prefixes will always
diff --git a/include/membership.h b/include/membership.h
index d98b54731..c6b0bf14a 100644
--- a/include/membership.h
+++ b/include/membership.h
@@ -43,6 +43,15 @@ class CoreExport Membership : public Extensible, public intrusive_list_node<Memb
* @return True if a change was made
*/
bool SetPrefix(PrefixMode* mh, bool adding);
+
+ /** Get the highest prefix this user has on the channel
+ * @return A character containing the highest prefix.
+ * If the user has no prefix, 0 is returned. If the user has multiple prefixes,
+ * the highest is returned. If you do not recognise the prefix character you
+ * can get, you can deal with it in a 'proportional' manner compared to known
+ * prefixes, using GetPrefixValue().
+ */
+ char GetPrefixChar() const;
};
template <typename T>
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);