]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_restrictchans.cpp
Remove VF_SERVICEPROVIDER, prevent heap allocation of ConfigReader
[user/henk/code/inspircd.git] / src / modules / m_restrictchans.cpp
index 68aa455e7bdcbf84420d4536b204d8a27e429f94..8cc882d9050e736d0d387180a92e6962dc5fbf9c 100644 (file)
 
 class ModuleRestrictChans : public Module
 {
-
-
-       std::map<irc::string,int> allowchans;
+       std::set<irc::string> allowchans;
 
        void ReadConfig()
        {
-               ConfigReader* MyConf = new ConfigReader(ServerInstance);
                allowchans.clear();
-               for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
+               for (int i = 0;; i++)
                {
-                       std::string txt;
-                       txt = MyConf->ReadValue("allowchannel", "name", i);
-                       irc::string channel = txt.c_str();
-                       allowchans[channel] = 1;
+                       ConfigTag* tag = ServerInstance->Config->ConfValue("allowchannel", i);
+                       if (!tag)
+                               return;
+                       std::string txt = tag->getString("name");
+                       allowchans.insert(txt.c_str());
                }
-               delete MyConf;
        }
 
  public:
-       ModuleRestrictChans(InspIRCd* Me)
-               : Module(Me)
+       ModuleRestrictChans()
        {
-
                ReadConfig();
                Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 2);
@@ -76,7 +71,7 @@ class ModuleRestrictChans : public Module
 
        virtual Version GetVersion()
        {
-               return Version("$Id$",VF_VENDOR,API_VERSION);
+               return Version("Only opers may create new channels if this module is loaded",VF_VENDOR);
        }
 };