]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_override.cpp
m_mysql Fix crash on rehash when the database tags have been changed in the config
[user/henk/code/inspircd.git] / src / modules / m_override.cpp
index bbd1c4e5128e6788ef57ad6e5dcccdf145c3bfe8..1d9447fc46a1679c4a4d34a4da062007bd9e3a0c 100644 (file)
@@ -35,23 +35,21 @@ class ModuleOverride : public Module
 
  public:
 
-       ModuleOverride()
-                       {
+       void init()
+       {
                // read our config options (main config file)
                OnRehash(NULL);
                ServerInstance->SNO->EnableSnomask('v', "OVERRIDE");
                Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange };
-               ServerInstance->Modules->Attach(eventlist, this, 6);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        void OnRehash(User* user)
        {
-               // on a rehash we delete our classes for good measure and create them again.
-               ConfigReader Conf;
-
                // re-read our config options on a rehash
-               NoisyOverride = Conf.ReadFlag("override", "noisy", 0);
-               RequireKey = Conf.ReadFlag("override", "requirekey", 0);
+               ConfigTag* tag = ServerInstance->Config->ConfValue("override");
+               NoisyOverride = tag->getBool("noisy");
+               RequireKey = tag->getBool("requirekey");
        }
 
        void On005Numeric(std::string &output)
@@ -137,7 +135,7 @@ class ModuleOverride : public Module
                                                }
 
                                                if (NoisyOverride)
-                                                       chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass invite-only", cname, user->nick.c_str());
+                                                       chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass invite-only", cname, user->nick.c_str());
                                                ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +i on "+std::string(cname));
                                        }
                                        return MOD_RES_ALLOW;
@@ -153,7 +151,7 @@ class ModuleOverride : public Module
                                        }
 
                                        if (NoisyOverride)
-                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel key", cname, user->nick.c_str());
+                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass the channel key", cname, user->nick.c_str());
                                        ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +k on "+std::string(cname));
                                        return MOD_RES_ALLOW;
                                }
@@ -168,7 +166,7 @@ class ModuleOverride : public Module
                                        }
 
                                        if (NoisyOverride)
-                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel limit", cname, user->nick.c_str());
+                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass the channel limit", cname, user->nick.c_str());
                                        ServerInstance->SNO->WriteGlobalSno('v', user->nick+" used oper override to bypass +l on "+std::string(cname));
                                        return MOD_RES_ALLOW;
                                }
@@ -183,7 +181,7 @@ class ModuleOverride : public Module
                                        }
 
                                        if (NoisyOverride)
-                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass channel ban", cname, user->nick.c_str());
+                                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass channel ban", cname, user->nick.c_str());
                                        ServerInstance->SNO->WriteGlobalSno('v',"%s used oper override to bypass channel ban on %s", user->nick.c_str(), cname);
                                        return MOD_RES_ALLOW;
                                }