diff options
author | Sadie Powell <sadie@witchery.services> | 2020-04-11 14:29:30 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-04-11 14:29:30 +0100 |
commit | 41f781a9a6560eab393b18815dbdfa9073c6810b (patch) | |
tree | 778a9f3f86d461e135be9e8b309d6b33e833343b | |
parent | c5680d6493a07e6625cc84db0639811bb1a45aee (diff) |
Clean up the logic for parsing oper mode privileges.
-rw-r--r-- | src/users.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/users.cpp b/src/users.cpp index 72a6c23af..e8e292615 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -428,30 +428,24 @@ void OperInfo::init() AllowedOperCommands.AddList(tag->getString("commands")); AllowedPrivs.AddList(tag->getString("privs")); - std::string modes = tag->getString("usermodes"); - for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c) + const std::string umodes = tag->getString("usermodes"); + for (std::string::const_iterator c = umodes.begin(); c != umodes.end(); ++c) { - if (*c == '*') - { + const char& chr = *c; + if (chr == '*') this->AllowedUserModes.set(); - } - else if (*c >= 'A' && *c <= 'z') - { - this->AllowedUserModes[*c - 'A'] = true; - } + else if (ModeParser::IsModeChar(chr)) + this->AllowedUserModes[chr - 'A'] = true; } - modes = tag->getString("chanmodes"); - for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c) + const std::string cmodes = tag->getString("chanmodes"); + for (std::string::const_iterator c = cmodes.begin(); c != cmodes.end(); ++c) { - if (*c == '*') - { + const char& chr = *c; + if (chr == '*') this->AllowedChanModes.set(); - } - else if (*c >= 'A' && *c <= 'z') - { - this->AllowedChanModes[*c - 'A'] = true; - } + else if (ModeParser::IsModeChar(chr)) + this->AllowedChanModes[chr - 'A'] = true; } } } |