]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Store prefix rank in a ModeHandler field, change ModeHandler::GetPrefixRank() to...
authorattilamolnar <attilamolnar@hush.com>
Thu, 6 Jun 2013 01:10:10 +0000 (03:10 +0200)
committerattilamolnar <attilamolnar@hush.com>
Thu, 6 Jun 2013 01:10:10 +0000 (03:10 +0200)
include/mode.h
src/mode.cpp
src/modes/cmode_o.cpp
src/modes/cmode_v.cpp
src/modules/m_customprefix.cpp
src/modules/m_ojoin.cpp
src/modules/m_operprefix.cpp

index 172b014deb166e4078bb931cb74fc2bd9b8a5bb7..3805b174bc3c56120b87db33e6c8fbacd69c1e08 100644 (file)
@@ -155,6 +155,11 @@ class CoreExport ModeHandler : public ServiceProvider
         */
        int levelrequired;
 
+       /** The prefix rank of this mode, used to compare prefix
+        * modes
+        */
+       unsigned int prefixrank;
+
  public:
        /**
         * The constructor for ModeHandler initalizes the mode handler.
@@ -186,7 +191,7 @@ class CoreExport ModeHandler : public ServiceProvider
         * PrefixModeValue enum and Channel::GetPrefixValue() for
         * more information.
         */
-       virtual unsigned int GetPrefixRank();
+       unsigned int GetPrefixRank() const { return prefixrank; }
        /**
         * Returns the mode's type
         */
index ac0b111b14dd20b316021680f4628bd3004c2e18..2f56c332789c06ad3dba4e0dee316e7ba4c313d6 100644 (file)
@@ -29,7 +29,7 @@
 ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type)
        : ServiceProvider(Creator, Name, SERVICE_MODE), m_paramtype(TR_TEXT),
        parameters_taken(Params), mode(modeletter), prefix(0), oper(false),
-       list(false), m_type(type), levelrequired(HALFOP_VALUE)
+       list(false), m_type(type), levelrequired(HALFOP_VALUE), prefixrank(0)
 {
 }
 
@@ -44,11 +44,6 @@ ModeHandler::~ModeHandler()
 {
 }
 
-unsigned int ModeHandler::GetPrefixRank()
-{
-       return 0;
-}
-
 int ModeHandler::GetNumParams(bool adding)
 {
        switch (parameters_taken)
index f0a7294800af1741816209ee12ebed5f417f3124..d500f23b1ea21610c6d95e03e254ab0ff90a5d4a 100644 (file)
@@ -34,11 +34,7 @@ ModeChannelOp::ModeChannelOp() : ModeHandler(NULL, "op", 'o', PARAM_ALWAYS, MODE
        prefix = '@';
        levelrequired = OP_VALUE;
        m_paramtype = TR_NICK;
-}
-
-unsigned int ModeChannelOp::GetPrefixRank()
-{
-       return OP_VALUE;
+       prefixrank = OP_VALUE;
 }
 
 ModeAction ModeChannelOp::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
index 867c132431d9e74107c53a71be30e5609ad2d4e9..fe62c407f6a91175d4230031de542ebe0fc4ce5d 100644 (file)
@@ -34,11 +34,7 @@ ModeChannelVoice::ModeChannelVoice() : ModeHandler(NULL, "voice", 'v', PARAM_ALW
        prefix = '+';
        levelrequired = HALFOP_VALUE;
        m_paramtype = TR_NICK;
-}
-
-unsigned int ModeChannelVoice::GetPrefixRank()
-{
-       return VOICE_VALUE;
+       prefixrank = VOICE_VALUE;
 }
 
 ModeAction ModeChannelVoice::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
index 67d1d2fe98ef57f8deaa96049a77b90bb9000e9f..d627bbb96327311aa3cafb02f48ebe32aec737e4 100644 (file)
@@ -25,8 +25,8 @@ class CustomPrefixMode : public ModeHandler
 {
  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)
        {
@@ -36,16 +36,11 @@ class CustomPrefixMode : public ModeHandler
                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)
@@ -72,7 +67,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());
index ff92f3fae8b2187cd34b9124a21e1650062c8209..999cd5b6486a72bd0311fa9eaa02f81b7dafbd0a 100644 (file)
@@ -110,11 +110,7 @@ class NetworkPrefix : public ModeHandler
                prefix = NPrefix;
                levelrequired = INT_MAX;
                m_paramtype = TR_NICK;
-       }
-
-       unsigned int GetPrefixRank()
-       {
-               return NETWORK_VALUE;
+               prefixrank = NETWORK_VALUE;
        }
 
        ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
index d061a5eab677f9c2384b0c5b8c6c46cc52b1cc8c..9c15cf5b2aa0d2ac7fe90fd5ffc77ebc460b0a4f 100644 (file)
@@ -38,11 +38,7 @@ class OperPrefixMode : public ModeHandler
                        prefix = pfx.empty() ? '!' : pfx[0];
                        levelrequired = OPERPREFIX_VALUE;
                        m_paramtype = TR_NICK;
-               }
-
-               unsigned int GetPrefixRank()
-               {
-                       return OPERPREFIX_VALUE;
+                       prefixrank = OPERPREFIX_VALUE;
                }
 
                ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)