]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_hidelist.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_hidelist.cpp
index 2d3f0be7c4b5b3c4bd6947459f448b3b812f5659..d076e2e639a79ac0d398cfba7b4657de7f48db30 100644 (file)
@@ -1,7 +1,9 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
+ *   Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2014, 2016 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -58,19 +60,26 @@ class ModuleHideList : public Module
  public:
        void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
-               stdalgo::delete_all(watchers);
-               watchers.clear();
-
                ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist");
+               typedef std::vector<std::pair<std::string, unsigned int> > NewConfigs;
+               NewConfigs newconfigs;
                for (ConfigIter i = tags.first; i != tags.second; ++i)
                {
                        ConfigTag* tag = i->second;
                        std::string modename = tag->getString("mode");
+                       if (modename.empty())
+                               throw ModuleException("Empty <hidelist:mode> at " + tag->getTagLocation());
                        // If rank is set to 0 everyone inside the channel can view the list,
                        // but non-members may not
                        unsigned int rank = tag->getUInt("rank", HALFOP_VALUE);
-                       watchers.push_back(new ListWatcher(this, modename, rank));
+                       newconfigs.push_back(std::make_pair(modename, rank));
                }
+
+               stdalgo::delete_all(watchers);
+               watchers.clear();
+
+               for (NewConfigs::const_iterator i = newconfigs.begin(); i != newconfigs.end(); ++i)
+                       watchers.push_back(new ListWatcher(this, i->first, i->second));
        }
 
        ~ModuleHideList()
@@ -80,7 +89,7 @@ class ModuleHideList : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides support for hiding the list of listmodes", VF_VENDOR);
+               return Version("Allows list mode lists to be hidden from users without a prefix mode ranked equal to or higher than a defined level.", VF_VENDOR);
        }
 };