From 9f9e49509ea6d4c4ab0b70e15356d50e1376fdba Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 23 Aug 2006 21:16:02 +0000 Subject: Fix and finish 005 numeric. PREFIX= is now calculated automatically if you add any prefixes. You do not need to mess with the numeric yourself. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5001 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/mode.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mode.cpp b/src/mode.cpp index 301fbc872..3a0937d91 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -644,7 +644,7 @@ std::string ModeParser::ParaModeList() bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two) { - return (one.second) < (two.second); + return one.second > two.second; } std::string ModeParser::BuildPrefixes() @@ -652,18 +652,28 @@ std::string ModeParser::BuildPrefixes() std::string mletters = ""; std::string mprefixes = ""; pfxcontainer pfx; + std::map prefix_to_mode; for (unsigned char mode = 'A'; mode <= 'z'; mode++) { unsigned char pos = (mode-65) | MASK_CHANNEL; if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix())) + { pfx.push_back(std::make_pair(modehandlers[pos]->GetPrefix(), modehandlers[pos]->GetPrefixRank())); + prefix_to_mode[modehandlers[pos]->GetPrefix()] = modehandlers[pos]->GetModeChar(); + } } sort(pfx.begin(), pfx.end(), ModeParser::PrefixComparison); - return ""; + for (pfxcontainer::iterator n = pfx.begin(); n != pfx.end(); n++) + { + mletters = mletters + n->first; + mprefixes = mprefixes + prefix_to_mode.find(n->first)->second; + } + + return "(" + mprefixes + ")" + mletters; } bool ModeParser::AddModeWatcher(ModeWatcher* mw) -- cgit v1.2.3