]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Store oper types and opers in separate containers
authorattilamolnar <attilamolnar@hush.com>
Tue, 13 Aug 2013 12:22:07 +0000 (14:22 +0200)
committerattilamolnar <attilamolnar@hush.com>
Tue, 13 Aug 2013 12:22:07 +0000 (14:22 +0200)
include/configreader.h
src/commands/cmd_stats.cpp
src/configreader.cpp
src/modules/m_spanningtree/opertype.cpp
src/modules/m_sqloper.cpp

index ee58c3bc9232502f3c807f02b39b66b9bb0fed8e..2aab0a075b10c9c878d609b2e03e6332a134583f 100644 (file)
@@ -507,11 +507,14 @@ class CoreExport ServerConfig
         */
        bool FullHostInTopic;
 
-       /** Oper block and type index.
-        * For anonymous oper blocks (type only), prefix with a space.
+       /** Oper blocks keyed by their name
         */
        OperIndex oper_blocks;
 
+       /** Oper types keyed by their name
+        */
+       OperIndex OperTypes;
+
        /** Max channels per user
         */
        unsigned int MaxChans;
index 9fef7bbd4297b02ba09c283436d31356a3b5b91d..846af57db30741b9c24ef0c1d0385f81b0d8944d 100644 (file)
@@ -325,11 +325,8 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
                break;
                case 'O':
                {
-                       for(OperIndex::iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); i++)
+                       for (OperIndex::const_iterator i = ServerInstance->Config->OperTypes.begin(); i != ServerInstance->Config->OperTypes.end(); ++i)
                        {
-                               // just the types, not the actual oper blocks...
-                               if (i->first[0] != ' ')
-                                       continue;
                                OperInfo* tag = i->second;
                                tag->init();
                                std::string umodes;
index af7a8ca59889f5fdad9ddbfba4acc39ebf12cbe7..957adc829f69bcbb2ebf1f0614c61dd299a8fd53 100644 (file)
@@ -123,11 +123,11 @@ void ServerConfig::CrossCheckOperClassType()
                std::string name = tag->getString("name");
                if (name.empty())
                        throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
-               if (oper_blocks.find(" " + name) != oper_blocks.end())
+               if (OperTypes.find(name) != OperTypes.end())
                        throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
 
                OperInfo* ifo = new OperInfo;
-               oper_blocks[" " + name] = ifo;
+               OperTypes[name] = ifo;
                ifo->name = name;
                ifo->type_block = tag;
 
@@ -152,8 +152,8 @@ void ServerConfig::CrossCheckOperClassType()
                        throw CoreException("<oper:name> missing from tag at " + tag->getTagLocation());
 
                std::string type = tag->getString("type");
-               OperIndex::iterator tblk = oper_blocks.find(" " + type);
-               if (tblk == oper_blocks.end())
+               OperIndex::iterator tblk = OperTypes.find(type);
+               if (tblk == OperTypes.end())
                        throw CoreException("Oper block " + name + " has missing type " + type);
                if (oper_blocks.find(name) != oper_blocks.end())
                        throw CoreException("Duplicate oper block with name " + name + " at " + tag->getTagLocation());
index 9e8c8ed9dccb8c135a9c44bbd56fdc98299e2d6d..6402b89dca9020878a17c739dcd114046014fe68 100644 (file)
@@ -36,8 +36,8 @@ CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *
        ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
        u->SetMode(opermh, true);
 
-       OperIndex::iterator iter = ServerInstance->Config->oper_blocks.find(" " + opertype);
-       if (iter != ServerInstance->Config->oper_blocks.end())
+       OperIndex::iterator iter = ServerInstance->Config->OperTypes.find(opertype);
+       if (iter != ServerInstance->Config->OperTypes.end())
                u->oper = iter->second;
        else
        {
index b9a883043f2a4e6e2b6c2ad0bf15ae96382fe7b3..295f4aa94d4aab48e3f4efb123aa36d4953f7bec 100644 (file)
@@ -78,8 +78,8 @@ class OpMeQuery : public SQLQuery
 
        bool OperUser(User* user, const std::string &pattern, const std::string &type)
        {
-               OperIndex::iterator iter = ServerInstance->Config->oper_blocks.find(" " + type);
-               if (iter == ServerInstance->Config->oper_blocks.end())
+               OperIndex::iterator iter = ServerInstance->Config->OperTypes.find(type);
+               if (iter == ServerInstance->Config->OperTypes.end())
                {
                        ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "bad type '%s' in returned row for oper %s", type.c_str(), username.c_str());
                        return false;