]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_override.cpp
More cleanup of quit servers
[user/henk/code/inspircd.git] / src / modules / m_override.cpp
index d931891c2e67a1ad86e578e6224da831cdd303fe..c443a88d850674636ddef84f62a7289d023cc2ae 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 
 /* $ModDesc: Provides support for unreal-style oper-override */
 
-typedef std::map<std::string,std::string> override_t;
-
 class ModuleOverride : public Module
 {
-       override_t overrides;
        bool RequireKey;
        bool NoisyOverride;
 
@@ -42,15 +39,6 @@ class ModuleOverride : public Module
                // re-read our config options on a rehash
                NoisyOverride = Conf.ReadFlag("override", "noisy", 0);
                RequireKey = Conf.ReadFlag("override", "requirekey", 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 On005Numeric(std::string &output)
@@ -60,17 +48,10 @@ class ModuleOverride : public Module
 
        bool CanOverride(User* source, const char* token)
        {
-               // checks to see if the oper's type has <type:override>
-               override_t::iterator j = overrides.find(source->oper->name);
+               std::string tokenlist = source->oper->getConfig("override");
 
-               if (j != overrides.end())
-               {
-                       // its defined or * is set, return its value as a boolean for if the token is set
-                       return ((j->second.find(token, 0) != std::string::npos) || (j->second.find("*", 0) != std::string::npos));
-               }
-
-               // its not defined at all, count as false
-               return false;
+               // its defined or * is set, return its value as a boolean for if the token is set
+               return ((tokenlist.find(token, 0) != std::string::npos) || (tokenlist.find("*", 0) != std::string::npos));
        }
 
 
@@ -106,14 +87,12 @@ class ModuleOverride : public Module
 
        ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector<std::string>& parameters)
        {
-               if (!IS_OPER(source))
-                       return MOD_RES_PASSTHRU;
                if (!source || !channel)
                        return MOD_RES_PASSTHRU;
+               if (!IS_OPER(source) || !IS_LOCAL(source))
+                       return MOD_RES_PASSTHRU;
 
-               unsigned int mode = 0;
-               if (channel->HasUser(source))
-                       mode = channel->GetPrefixValue(source);
+               unsigned int mode = channel->GetPrefixValue(source);
 
                if (mode < HALFOP_VALUE && CanOverride(source, "MODE"))
                {