diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-05-30 15:42:52 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-05-30 15:42:52 +0200 |
commit | acf049362779e2ab83cfb926457fcc968ab02c11 (patch) | |
tree | 2b0018fe29211cd6625acd60af855706b5a78c6d /src | |
parent | 685c30a5908de0fc2e8701d76bad0c13397eb8d9 (diff) | |
parent | e956bb75eadc6981dd0a4ce5ce1b6b2d5c7aa00c (diff) |
Merge pull request #1179 from SaberUK/insp20+fix-buildprefixes
[2.0] Fix 005 not showing some modes with the same rank as others.
Diffstat (limited to 'src')
-rw-r--r-- | src/mode.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
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<int,std::pair<char,char> > prefixes; + std::vector<ModeHandler*> 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<int,std::pair<char,char> >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); n++) + std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter()); + for (std::vector<ModeHandler*>::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; |