From e956bb75eadc6981dd0a4ce5ce1b6b2d5c7aa00c Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 29 May 2016 03:41:00 +0100 Subject: Fix 005 not showing some modes with the same rank as others. --- src/mode.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/mode.cpp') diff --git a/src/mode.cpp b/src/mode.cpp index 89ff37fa1..0f5d45783 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -837,11 +837,19 @@ std::string ModeParser::GiveModeList(ModeMasks m) return type1 + "," + type2 + "," + type3 + "," + type4; } +struct PrefixModeSorter +{ + bool operator()(ModeHandler* lhs, ModeHandler* rhs) + { + return lhs->GetPrefixRank() < rhs->GetPrefixRank(); + } +}; + std::string ModeParser::BuildPrefixes(bool lettersAndModes) { std::string mletters; std::string mprefixes; - std::map > prefixes; + std::vector prefixes; for (unsigned char mode = 'A'; mode <= 'z'; mode++) { @@ -849,15 +857,15 @@ std::string ModeParser::BuildPrefixes(bool lettersAndModes) if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix())) { - prefixes[modehandlers[pos]->GetPrefixRank()] = std::make_pair( - modehandlers[pos]->GetPrefix(), modehandlers[pos]->GetModeChar()); + prefixes.push_back(modehandlers[pos]); } } - for(std::map >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); n++) + std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter()); + for (std::vector::const_reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n) { - mletters = mletters + n->second.first; - mprefixes = mprefixes + n->second.second; + mletters += (*n)->GetPrefix(); + mprefixes += (*n)->GetModeChar(); } return lettersAndModes ? "(" + mprefixes + ")" + mletters : mletters; -- cgit v1.2.3