summaryrefslogtreecommitdiff
path: root/src/modules/m_opermodes.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-18 16:01:33 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-18 16:01:33 +0000
commita59d08fffd3dc8a9850ce34c9928fb6382b9b37f (patch)
tree1d5debd7915dddc122feec50443f42d535cba311 /src/modules/m_opermodes.cpp
parentda6e45397e4ee86d6caf86d2fd5fd8f77af48a1e (diff)
Remove VF_SERVICEPROVIDER, prevent heap allocation of ConfigReader
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11904 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_opermodes.cpp')
-rw-r--r--src/modules/m_opermodes.cpp47
1 files changed, 17 insertions, 30 deletions
diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp
index d4b873918..9db0b5b4a 100644
--- a/src/modules/m_opermodes.cpp
+++ b/src/modules/m_opermodes.cpp
@@ -17,16 +17,9 @@
class ModuleModesOnOper : public Module
{
- private:
-
-
- ConfigReader *Conf;
-
public:
ModuleModesOnOper()
- {
-
- Conf = new ConfigReader;
+ {
Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
@@ -34,13 +27,10 @@ class ModuleModesOnOper : public Module
virtual void OnRehash(User* user)
{
- delete Conf;
- Conf = new ConfigReader;
}
virtual ~ModuleModesOnOper()
{
- delete Conf;
}
virtual Version GetVersion()
@@ -50,36 +40,33 @@ class ModuleModesOnOper : public Module
virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
{
+ TagIndex::iterator typetag = ServerInstance->Config->opertypes.find(opertype);
+ if (typetag == ServerInstance->Config->opertypes.end())
+ return;
// whenever a user opers, go through the oper types, find their <type:modes>,
// and if they have one apply their modes. The mode string can contain +modes
// to add modes to the user or -modes to take modes from the user.
- for (int j =0; j < Conf->Enumerate("type"); j++)
+ std::string ThisOpersModes = typetag->second->getString("modes");
+ if (!ThisOpersModes.empty())
{
- std::string typen = Conf->ReadValue("type","name",j);
- if (typen == user->oper)
- {
- std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
- if (!ThisOpersModes.empty())
- {
- ApplyModes(user, ThisOpersModes);
- }
- break;
- }
+ ApplyModes(user, ThisOpersModes);
}
if (!opername.empty()) // if user is local ..
{
- for (int j = 0; j < Conf->Enumerate("oper"); j++)
+ for (int i = 0;; i++)
{
- if (opername == Conf->ReadValue("oper", "name", j))
- {
- std::string ThisOpersModes = Conf->ReadValue("oper", "modes", j);
- if (!ThisOpersModes.empty())
- {
- ApplyModes(user, ThisOpersModes);
- }
+ ConfigTag* tag = ServerInstance->Config->ConfValue("oper", i);
+ if (!tag)
break;
+ if (tag->getString("name") != opername)
+ continue;
+ ThisOpersModes = tag->getString("modes");
+ if (!ThisOpersModes.empty())
+ {
+ ApplyModes(user, ThisOpersModes);
}
+ break;
}
}
}