summaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-19 01:53:03 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-19 01:53:03 +0000
commite514a3793d251409428caf53cbb75f0be90a6f38 (patch)
tree349c4cfc9fc45735999fd81d39a515560ab0e083 /src/channels.c
parent68381e69d94735010df986b22c8e758981b50995 (diff)
Changed the mode param handling code to be more into the general mode handling code, this cleans up and fixes some small problems with mlocking params. This also helps clarify that the ChannelInfo mode functions are for mlock only. Also, this adds the OnMLock and OnUnMLock events which can be used to control if something can be (un)mlocked
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2660 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/src/channels.c b/src/channels.c
index ef5e225f6..e6ee45430 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -137,7 +137,7 @@ bool Channel::HasMode(ChannelModeName Name)
* Set a mode on a channel
* @param Name The mode name
*/
-void Channel::SetMode(ChannelModeName Name)
+void Channel::SetMode(ChannelModeName Name, const std::string param)
{
modes[Name] = true;
@@ -147,6 +147,18 @@ void Channel::SetMode(ChannelModeName Name)
ci->SetFlag(CI_PERSIST);
}
+ if (!param.empty())
+ {
+ /* They could be resetting the mode to change its params */
+ std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
+ if (it != Params.end())
+ {
+ Params.erase(it);
+ }
+
+ Params.insert(std::make_pair(Name, param));
+ }
+
FOREACH_MOD(I_OnChannelModeSet, OnChannelModeSet(this, Name));
}
@@ -154,13 +166,13 @@ void Channel::SetMode(ChannelModeName Name)
* Set a mode on a channel
* @param Mode The mode
*/
-void Channel::SetMode(char Mode)
+void Channel::SetMode(char Mode, const std::string param)
{
ChannelMode *cm;
if ((cm = ModeManager::FindChannelModeByChar(Mode)))
{
- SetMode(cm->Name);
+ SetMode(cm->Name, param);
}
}
@@ -181,6 +193,12 @@ void Channel::RemoveMode(ChannelModeName Name)
delete this;
}
+ std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
+ if (it != Params.end())
+ {
+ Params.erase(it);
+ }
+
FOREACH_MOD(I_OnChannelModeUnset, OnChannelModeUnset(this, Name));
}
@@ -198,29 +216,6 @@ void Channel::RemoveMode(char Mode)
}
}
-/** Set a channel mode param on the channel
- * @param Name The mode
- * @param param The param
- * @param true on success
- */
-bool Channel::SetParam(ChannelModeName Name, std::string &Value)
-{
- return Params.insert(std::make_pair(Name, Value)).second;
-}
-
-/** Unset a param from the channel
- * @param Name The mode
- */
-void Channel::UnsetParam(ChannelModeName Name)
-{
- std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
-
- if (it != Params.end())
- {
- Params.erase(it);
- }
-}
-
/** Get a param from the channel
* @param Name The mode
* @param Target a string to put the param into
@@ -677,14 +672,6 @@ void chan_set_modes(const char *source, Channel *chan, int ac, const char **av,
}
else
{
- if (check >= 0)
- {
- if (add)
- chan->SetMode(mode);
- else
- chan->RemoveMode(mode);
- }
-
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
@@ -701,18 +688,19 @@ void chan_set_modes(const char *source, Channel *chan, int ac, const char **av,
av++;
}
- if (*av && !cmp->IsValid(*av))
+ if (!cmp->IsValid(*av))
continue;
if (add)
{
std::string Param = *av;
- chan->SetParam(cmp->Name, Param);
+ chan->SetMode(mode, Param);
}
else
- chan->UnsetParam(cmp->Name);
+ {
+ chan->RemoveMode(mode);
+ }
}
-
- if (check < 0)
+ else
{
if (add)
chan->SetMode(mode);