*/
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
* @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>
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())
* % 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;
}
if (memb)
- wholine.append(memb->chan->GetPrefixChar(u));
+ wholine.push_back(memb->GetPrefixChar());
wholine.append(" :0 " + u->fullname);
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;
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);