summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-15 18:26:35 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-15 18:26:35 +0000
commitd3747f2943c403863bc31c8d3e9802ccc763f4d3 (patch)
tree7b3f110edbf8796b4f0fda3ca1c37d45b29d9552 /src
parentdf37ab42f454e3a96d59a2a86eb76bcb4af0818a (diff)
Add ModeHandler* versions of channel mode access
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12133 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp49
-rw-r--r--src/mode.cpp5
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 "";