diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 49 | ||||
-rw-r--r-- | src/mode.cpp | 5 |
2 files changed, 25 insertions, 29 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 3f0fc4a36..31038484e 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -36,7 +36,12 @@ void Channel::SetMode(char mode,bool mode_on) modes[mode-65] = mode_on; } -void Channel::SetModeParam(char mode, std::string parameter) +void Channel::SetMode(ModeHandler* mh, bool on) +{ + modes[mh->GetModeChar() - 65] = on; +} + +void Channel::SetModeParam(char mode, const std::string& parameter) { CustomModeList::iterator n = custom_mode_params.find(mode); // always erase, even if changing, so that the map gets the new value @@ -53,6 +58,11 @@ void Channel::SetModeParam(char mode, std::string parameter) } } +void Channel::SetModeParam(ModeHandler* mode, const std::string& parameter) +{ + SetModeParam(mode->GetModeChar(), parameter); +} + std::string Channel::GetModeParameter(char mode) { CustomModeList::iterator n = custom_mode_params.find(mode); @@ -61,6 +71,14 @@ std::string Channel::GetModeParameter(char mode) return ""; } +std::string Channel::GetModeParameter(ModeHandler* mode) +{ + CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar()); + if (n != custom_mode_params.end()) + return n->second; + return ""; +} + int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) { if (u) @@ -706,30 +724,13 @@ char* Channel::ChanModes(bool showkey) { *offset++ = n + 65; extparam.clear(); - switch (n) + if (n == 'k' - 65 && !showkey) { - case CM_KEY: - // Unfortunately this must be special-cased, as we definitely don't want to always display key. - if (showkey) - { - extparam = this->GetModeParameter('k'); - } - else - { - extparam = "<key>"; - } - break; - case CM_NOEXTERNAL: - case CM_TOPICLOCK: - case CM_INVITEONLY: - case CM_MODERATED: - case CM_SECRET: - case CM_PRIVATE: - /* We know these have no parameters */ - break; - default: - extparam = this->GetModeParameter(n + 65); - break; + extparam = "<key>"; + } + else + { + extparam = this->GetModeParameter(n + 65); } if (!extparam.empty()) { diff --git a/src/mode.cpp b/src/mode.cpp index 9c3b75101..fb154d5e2 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -99,11 +99,6 @@ int ModeHandler::GetNumParams(bool adding) return 0; } -char ModeHandler::GetModeChar() -{ - return mode; -} - std::string ModeHandler::GetUserParameter(User* user) { return ""; |