]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_customprefix.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / modules / m_customprefix.cpp
index 67d1d2fe98ef57f8deaa96049a77b90bb9000e9f..65c2cbd31ef572570215aab7df4cdc20ae587ae0 100644 (file)
 
 #include "inspircd.h"
 
-/* $ModDesc: Allows custom prefix modes to be created. */
-
-class CustomPrefixMode : public ModeHandler
+class CustomPrefixMode : public PrefixMode
 {
  public:
        reference<ConfigTag> tag;
-       int rank;
        bool depriv;
+
        CustomPrefixMode(Module* parent, ConfigTag* Tag)
-               : ModeHandler(parent, Tag->getString("name"), 0, PARAM_ALWAYS, MODETYPE_CHANNEL), tag(Tag)
+               : PrefixMode(parent, Tag->getString("name"), 0)
+               , tag(Tag)
        {
-               list = true;
-               m_paramtype = TR_NICK;
                std::string v = tag->getString("prefix");
                prefix = v.c_str()[0];
                v = tag->getString("letter");
                mode = v.c_str()[0];
-               rank = tag->getInt("rank");
-               levelrequired = tag->getInt("ranktoset", rank);
+               prefixrank = tag->getInt("rank");
+               levelrequired = tag->getInt("ranktoset", prefixrank);
                depriv = tag->getBool("depriv", true);
        }
 
-       unsigned int GetPrefixRank()
-       {
-               return rank;
-       }
-
        ModResult AccessCheck(User* src, Channel*, std::string& value, bool adding)
        {
                if (!adding && src->nick == value && depriv)
                        return MOD_RES_ALLOW;
                return MOD_RES_PASSTHRU;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               return MODEACTION_ALLOW;
-       }
 };
 
 class ModuleCustomPrefix : public Module
@@ -72,7 +59,7 @@ class ModuleCustomPrefix : public Module
                        tags.first++;
                        CustomPrefixMode* mh = new CustomPrefixMode(this, tag);
                        modes.push_back(mh);
-                       if (mh->rank <= 0)
+                       if (mh->GetPrefixRank() == 0)
                                throw ModuleException("Rank must be specified for prefix at " + tag->getTagLocation());
                        if (!isalpha(mh->GetModeChar()))
                                throw ModuleException("Mode must be a letter for prefix at " + tag->getTagLocation());
@@ -82,15 +69,14 @@ class ModuleCustomPrefix : public Module
                        }
                        catch (ModuleException& e)
                        {
-                               throw ModuleException(e.err + " (while creating mode from " + tag->getTagLocation() + ")");
+                               throw ModuleException(e.GetReason() + " (while creating mode from " + tag->getTagLocation() + ")");
                        }
                }
        }
 
        ~ModuleCustomPrefix()
        {
-               for (std::vector<CustomPrefixMode*>::iterator i = modes.begin(); i != modes.end(); i++)
-                       delete *i;
+               stdalgo::delete_all(modes);
        }
 
        Version GetVersion() CXX11_OVERRIDE