From 65620235afcc04cab373ed5bd3dcdae646f3a0a5 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 4 Mar 2006 17:43:06 +0000 Subject: Tidied up m_override to avoid use of configreader during free-running git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3450 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_override.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/modules/m_override.cpp') diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 8dfc5dd6f..df6eb0616 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -24,9 +24,12 @@ using namespace std; /* $ModDesc: Provides support for unreal-style oper-override */ +typedef std::map override_t; + class ModuleOverride : public Module { Server *Srv; + override_t overrides; bool NoisyOverride; ConfigReader *Conf; @@ -43,7 +46,7 @@ class ModuleOverride : public Module Conf = new ConfigReader; // read our config options (main config file) - NoisyOverride = Conf->ReadFlag("override","noisy",0); + OnRehash(""); } virtual void OnRehash(std::string parameter) @@ -53,6 +56,13 @@ class ModuleOverride : public Module Conf = new ConfigReader; // re-read our config options on a rehash NoisyOverride = Conf->ReadFlag("override","noisy",0); + overrides.clear(); + for (int j =0; j < Conf->Enumerate("type"); j++) + { + std::string typen = Conf->ReadValue("type","name",j); + std::string tokenlist = Conf->ReadValue("type","override",j); + overrides[typen] = tokenlist; + } } void Implements(char* List) @@ -68,15 +78,11 @@ class ModuleOverride : public Module virtual bool CanOverride(userrec* source, char* token) { // checks to see if the oper's type has - for (int j =0; j < Conf->Enumerate("type"); j++) + override_t::iterator j = overrides.find(source->oper); + if (j != overrides.end()) { - std::string typen = Conf->ReadValue("type","name",j); - if (!strcmp(typen.c_str(),source->oper)) - { - // its defined, return its value as a boolean for if the token is set - std::string tokenlist = Conf->ReadValue("type","override",j); - return strstr(tokenlist.c_str(),token); - } + // its defined, return its value as a boolean for if the token is set + return strstr(j->second.c_str(),token); } // its not defined at all, count as false return false; -- cgit v1.2.3