summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/extern.h7
-rw-r--r--include/regchannel.h3
-rw-r--r--src/core/os_defcon.c41
-rw-r--r--src/operserv.c42
4 files changed, 64 insertions, 29 deletions
diff --git a/include/extern.h b/include/extern.h
index f64ab78d6..e6005b4e8 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -642,7 +642,12 @@ E void SetOperType(NickCore *nc);
E SList akills, sglines, sqlines, szlines;
E int DefConModesSet;
-E ChannelInfo DefConModesCI;
+E Flags<ChannelModeName> DefConModesOn;
+E Flags<ChannelModeName> DefConModesOff;
+E std::map<ChannelModeName, std::string> DefConModesOnParams;
+E bool SetDefConParam(ChannelModeName, std::string &);
+E bool GetDefConParam(ChannelModeName, std::string *);
+E void UnsetDefConParam(ChannelModeName);
E void operserv(User *u, char *buf);
E void os_init();
diff --git a/include/regchannel.h b/include/regchannel.h
index 33908cb3a..b6d380f40 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -69,9 +69,6 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag>
std::bitset<128> mlock_off; /* Modes mlocked off */
public:
- // XXX Hack for defcon, though this really isn't needed now and should be destroyed
- ChannelInfo() { }
-
/** Default constructor
* @param chname The channel name
*/
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
index f2d2cf8ec..81d25624f 100644
--- a/src/core/os_defcon.c
+++ b/src/core/os_defcon.c
@@ -184,7 +184,7 @@ class OSDEFCON : public Module
{
ChannelMode *cm = ModeManager::FindChannelModeByName(Name);
- if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesCI.HasMLock(Name, false))
+ if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOff.HasFlag(Name))
{
c->RemoveMode(Name);
ircdproto->SendMode(findbot(s_OperServ), c->name, "-%c", cm->ModeChar);
@@ -195,16 +195,19 @@ class OSDEFCON : public Module
{
ChannelMode *cm = ModeManager::FindChannelModeByName(Name);
- if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesCI.HasMLock(Name, true))
+ if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOn.HasFlag(Name))
{
std::string param;
- DefConModesCI.GetParam(Name, &param);
-
+ GetDefConParam(Name, &param);
+
c->SetMode(Name);
std::string buf = "+" + std::string(&cm->ModeChar);
if (!param.empty())
+ {
buf += " " + param;
+ c->SetParam(Name, param);
+ }
ircdproto->SendMode(findbot(s_OperServ), c->name, buf.c_str());
}
}
@@ -421,7 +424,8 @@ void defconParseModeString(const char *str)
spacesepstream ss(str);
- DefConModesCI.ClearMLock();
+ DefConModesOn.ClearFlags();
+ DefConModesOff.ClearFlags();
ss.GetToken(modes);
/* Loop while there are modes to set */
@@ -451,8 +455,8 @@ void defconParseModeString(const char *str)
}
else if (add)
{
- DefConModesCI.SetMLock(cm->Name, true);
- DefConModesCI.RemoveMLock(cm->Name, false);
+ DefConModesOn.SetFlag(cm->Name);
+ DefConModesOff.UnsetFlag(cm->Name);
if (cm->Type == MODE_PARAM)
{
@@ -467,22 +471,18 @@ void defconParseModeString(const char *str)
if (!cmp->IsValid(param.c_str()))
continue;
- DefConModesCI.SetParam(cmp->Name, param);
+ SetDefConParam(cmp->Name, param);
}
}
else
{
- DefConModesCI.RemoveMLock(cm->Name, true);
-
- if (DefConModesCI.HasMLock(cm->Name, true))
+ if (DefConModesOn.HasFlag(cm->Name))
{
- DefConModesCI.RemoveMLock(cm->Name, true);
+ DefConModesOn.UnsetFlag(cm->Name);
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
-
- DefConModesCI.UnsetParam(cmp->Name);
+ UnsetDefConParam(cm->Name);
}
}
}
@@ -492,10 +492,11 @@ void defconParseModeString(const char *str)
if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)))
{
/* We can't mlock +L if +l is not mlocked as well. */
- if (DefConModesCI.HasMLock(cm->Name, true) && !DefConModesCI.HasMLock(CMODE_LIMIT, true))
+ if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_LIMIT))
{
- DefConModesCI.RemoveMLock(CMODE_REDIRECT, true);
- DefConModesCI.UnsetParam(CMODE_REDIRECT);
+ DefConModesOn.UnsetFlag(CMODE_REDIRECT);
+
+ //DefConModesCI.UnsetParam(CMODE_REDIRECT);
alog("DefConChanModes must lock mode +l as well to lock mode +L");
}
}
@@ -504,9 +505,9 @@ void defconParseModeString(const char *str)
/* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)))
{
- if (DefConModesCI.HasMLock(cm->Name, true) && !DefConModesCI.HasMLock(CMODE_INVITE, true))
+ if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE))
{
- DefConModesCI.RemoveMLock(CMODE_NOKNOCK, true);
+ DefConModesOn.UnsetFlag(CMODE_NOKNOCK);
alog("DefConChanModes must lock mode +i as well to lock mode +K");
}
}
diff --git a/src/operserv.c b/src/operserv.c
index 0c78ea707..4acedbbd9 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -36,12 +36,44 @@ std::vector<NewsItem *> News;
std::vector<std::bitset<32> > DefCon;
int DefConModesSet = 0;
-ChannelInfo DefConModesCI; /* ChannelInfo containg params for locked modes
- * during DefCon; I would've done this nicer if i
- * could, but all damn mode functions require a
- * ChannelInfo struct! --gdex
- */
+/* Defcon modes mlocked on */
+Flags<ChannelModeName> DefConModesOn;
+/* Defcon modes mlocked off */
+Flags<ChannelModeName> DefConModesOff;
+/* Map of Modesa and Params for DefCon */
+std::map<ChannelModeName, std::string> DefConModesOnParams;
+
+bool SetDefConParam(ChannelModeName Name, std::string &buf)
+{
+ return DefConModesOnParams.insert(std::make_pair(Name, buf)).second;
+}
+bool GetDefConParam(ChannelModeName Name, std::string *buf)
+{
+ std::map<ChannelModeName, std::string>::iterator it = DefConModesOnParams.find(Name);
+
+ buf->clear();
+
+ if (it != DefConModesOnParams.end())
+ {
+ *buf = it->second;
+ return true;
+ }
+
+ return false;
+}
+
+void UnsetDefConParam(ChannelModeName Name)
+{
+ std::map<ChannelModeName, std::string>::iterator it = DefConModesOnParams.find(Name);
+
+ if (it != DefConModesOnParams.end())
+ {
+ DefConModesOnParams.erase(it);
+ }
+}
+
+/*************************************************************************/
void moduleAddOperServCmds();
/*************************************************************************/