From a59d08fffd3dc8a9850ce34c9928fb6382b9b37f Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 18 Oct 2009 16:01:33 +0000 Subject: Remove VF_SERVICEPROVIDER, prevent heap allocation of ConfigReader git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11904 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_opermodes.cpp | 47 ++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'src/modules/m_opermodes.cpp') 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 , // 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; } } } -- cgit v1.2.3