summaryrefslogtreecommitdiff
path: root/src/modes.cpp
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-12-05 22:12:48 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-12-05 22:12:48 +0000
commit4630ae454ad64eb9abca106a1b2261c2f45e263a (patch)
treeab65f050172173d030166bb16278a8ccd984b51f /src/modes.cpp
parent42b8cfe404d7a00de14ecd00a5f6f58fc4fc00af (diff)
Added options:mlock in the config so you can set what modes should be locked on new channels
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2690 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modes.cpp')
-rw-r--r--src/modes.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/modes.cpp b/src/modes.cpp
index 7094b79b1..e43596620 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -22,6 +22,60 @@ std::map<ChannelModeName, ChannelMode *> ModeManager::ChannelModesByName;
* efficiency.
*/
+/* Default mlocked modes on */
+std::bitset<128> DefMLockOn;
+/* Default mlocked modes off */
+std::bitset<128> DefMLockOff;
+/* Map for default mlocked mode parameters */
+std::map<ChannelModeName, std::string> DefMLockParams;
+
+/** Parse the mode string from the config file and set the default mlocked modes
+ */
+void SetDefaultMLock()
+{
+ DefMLockOn.reset();
+ DefMLockOff.reset();
+ DefMLockParams.clear();
+ std::bitset<128> *ptr = NULL;
+
+ std::string modes, param;
+ spacesepstream sep(Config.MLock);
+ sep.GetToken(modes);
+
+ for (unsigned i = 0; i < modes.size(); ++i)
+ {
+ if (modes[i] == '+')
+ ptr = &DefMLockOn;
+ else if (modes[i] == '-')
+ ptr = &DefMLockOff;
+ else
+ {
+ if (!ptr)
+ continue;
+
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+
+ if (cm && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM))
+ {
+ ptr->set(cm->Name);
+
+ if (*ptr == DefMLockOn && cm->Type == MODE_PARAM)
+ {
+ if (sep.GetToken(param))
+ {
+ DefMLockParams.insert(std::make_pair(cm->Name, param));
+ }
+ else
+ {
+ alog("Warning: Got default mlock mode %c with no param?", cm->ModeChar);
+ ptr->set(cm->Name, false);
+ }
+ }
+ }
+ }
+ }
+}
+
/** Add a user mode to Anope
* @param Mode The mode
* @param um A UserMode or UserMode derived class
@@ -56,6 +110,9 @@ bool ModeManager::AddChannelMode(char Mode, ChannelMode *cm)
if (ret)
{
+ /* Apply this mode to the new default mlock if its used */
+ SetDefaultMLock();
+
FOREACH_MOD(I_OnChannelModeAdd, OnChannelModeAdd(cm));
}