From 526dfce2251b5cf28e5731c0ee588cc00ed47bb8 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 27 Sep 2006 07:56:01 +0000 Subject: [PATCH] Comments git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5349 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/channels.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/channels.cpp b/src/channels.cpp index 5e2ef907c..bfd676429 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -892,6 +892,11 @@ const char* chanrec::GetPrefixChar(userrec *user) { if (n->second.size()) { + /* If the user has any prefixes, their highest prefix + * will always be at the head of the list, as the list is + * sorted in rank order highest first (see SetPrefix() + * for reasons why) + */ *pf = n->second.begin()->first; return pf; } @@ -973,11 +978,6 @@ int chanrec::GetStatus(userrec *user) return STATUS_NORMAL; } -/*bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two) -{ - return one.second > two.second; -}*/ - void chanrec::SetPrefix(userrec* user, char prefix, unsigned int prefix_value, bool adding) { prefixlist::iterator n = prefixes.find(user); @@ -989,6 +989,11 @@ void chanrec::SetPrefix(userrec* user, char prefix, unsigned int prefix_value, b if (std::find(n->second.begin(), n->second.end(), pfx) == n->second.end()) { n->second.push_back(pfx); + /* We must keep prefixes in rank order, largest first. + * This is for two reasons, firstly because x-chat *ass-u-me's* this + * state, and secondly it turns out to be a benefit to us later. + * See above in GetPrefix(). + */ std::sort(n->second.begin(), n->second.end(), ModeParser::PrefixComparison); } } -- 2.39.5