]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Replace mode letter parameter of OnRawMode() with a ModeHandler*, remove pcnt
authorAttila Molnar <attilamolnar@hush.com>
Fri, 21 Feb 2014 13:18:49 +0000 (14:18 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Fri, 21 Feb 2014 13:18:49 +0000 (14:18 +0100)
include/modules.h
src/mode.cpp
src/modules.cpp
src/modules/m_delayjoin.cpp
src/modules/m_mlock.cpp
src/modules/m_permchannels.cpp
src/modules/m_servprotect.cpp

index 7df6f4f3b9675608f63ccb7a251bc5cf895add2c..9c0b22b6c075fd90a2cbdba4eaa11919ff64ac25 100644 (file)
@@ -853,15 +853,14 @@ class CoreExport Module : public classbase, public usecountbase
         * Return 1 from this function to block the mode character from being processed entirely.
         * @param user The user who is sending the mode
         * @param chan The channel the mode is being sent to (or NULL if a usermode)
-        * @param mode The mode character being set
+        * @param mh The mode handler for the mode being changed
         * @param param The parameter for the mode or an empty string
         * @param adding true of the mode is being added, false if it is being removed
-        * @param pcnt The parameter count for the mode (0 or 1)
         * @return ACR_DENY to deny the mode, ACR_DEFAULT to do standard mode checking, and ACR_ALLOW
         * to skip all permission checking. Please note that for remote mode changes, your return value
         * will be ignored!
         */
-       virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt);
+       virtual ModResult OnRawMode(User* user, Channel* chan, ModeHandler* mh, const std::string& param, bool adding);
 
        /** Called whenever a user joins a channel, to determine if key checks should go ahead or not.
         * This method will always be called for each join, wether or not the channel is actually +k, and
index 17379b620f78137d9ca812da8fb28c56dd140101..053a10ba11d5209afbcb633a19a00a005785c8ea 100644 (file)
@@ -251,7 +251,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
                parameter = parameter.substr(0, 250);
 
        ModResult MOD_RESULT;
-       FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, modechar, parameter, adding, pcnt));
+       FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mh, parameter, adding));
 
        if (IS_LOCAL(user) && (MOD_RESULT == MOD_RES_DENY))
                return MODEACTION_DENY;
@@ -535,7 +535,7 @@ void ModeParser::DisplayListModes(User* user, Channel* chan, std::string &mode_s
                        return;
 
                ModResult MOD_RESULT;
-               FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mletter, "", true, 0));
+               FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mh, "", true));
                if (MOD_RESULT == MOD_RES_DENY)
                        continue;
 
index 3baf4bc4e9b2110093aee14fdccaca170aad32f7..cbb8661ae8ec2a2dd107441f1699e71a751badd4 100644 (file)
@@ -114,7 +114,7 @@ ModResult   Module::OnCheckReady(LocalUser*) { DetachEvent(I_OnCheckReady); return
 ModResult      Module::OnUserRegister(LocalUser*) { DetachEvent(I_OnUserRegister); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnUserPreKick(User*, Membership*, const std::string&) { DetachEvent(I_OnUserPreKick); return MOD_RES_PASSTHRU; }
 void           Module::OnUserKick(User*, Membership*, const std::string&, CUList&) { DetachEvent(I_OnUserKick); }
-ModResult      Module::OnRawMode(User*, Channel*, const char, const std::string &, bool, int) { DetachEvent(I_OnRawMode); return MOD_RES_PASSTHRU; }
+ModResult      Module::OnRawMode(User*, Channel*, ModeHandler*, const std::string&, bool) { DetachEvent(I_OnRawMode); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnCheckInvite(User*, Channel*) { DetachEvent(I_OnCheckInvite); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnCheckKey(User*, Channel*, const std::string&) { DetachEvent(I_OnCheckKey); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnCheckLimit(User*, Channel*) { DetachEvent(I_OnCheckLimit); return MOD_RES_PASSTHRU; }
index e183fbe4600041ae581b938ca627c8455fab3df7..dd07710bdf3e695a7acec82ff256a5977c433b49 100644 (file)
@@ -52,7 +52,7 @@ class ModuleDelayJoin : public Module
        void OnUserKick(User* source, Membership*, const std::string &reason, CUList&) CXX11_OVERRIDE;
        void OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) CXX11_OVERRIDE;
        void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE;
-       ModResult OnRawMode(User* user, Channel* channel, const char mode, const std::string &param, bool adding, int pcnt) CXX11_OVERRIDE;
+       ModResult OnRawMode(User* user, Channel* channel, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE;
 };
 
 ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
@@ -162,7 +162,7 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std:
 }
 
 /* make the user visible if he receives any mode change */
-ModResult ModuleDelayJoin::OnRawMode(User* user, Channel* channel, const char mode, const std::string &param, bool adding, int pcnt)
+ModResult ModuleDelayJoin::OnRawMode(User* user, Channel* channel, ModeHandler* mh, const std::string& param, bool adding)
 {
        if (!user || !channel || param.empty())
                return MOD_RES_PASSTHRU;
index 45f5dd85378c00fccd066b9edeb20a21efb4830e..d9c43ec1087c6b0026a21c85b4b4d0493754638f 100644 (file)
@@ -34,7 +34,7 @@ class ModuleMLock : public Module
                return Version("Implements the ability to have server-side MLOCK enforcement.", VF_VENDOR);
        }
 
-       ModResult OnRawMode(User* source, Channel* channel, const char mode, const std::string& parameter, bool adding, int pcnt)
+       ModResult OnRawMode(User* source, Channel* channel, ModeHandler* mh, const std::string& parameter, bool adding)
        {
                if (!channel)
                        return MOD_RES_PASSTHRU;
@@ -46,6 +46,7 @@ class ModuleMLock : public Module
                if (!mlock_str)
                        return MOD_RES_PASSTHRU;
 
+               const char mode = mh->GetModeChar();
                std::string::size_type p = mlock_str->find(mode);
                if (p != std::string::npos)
                {
index 1de07ba070af75825fca3af7b731984af16437ee..edb752f671d633f340c61c2bc452e6f04c9940c8 100644 (file)
@@ -275,9 +275,9 @@ public:
                }
        }
 
-       ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt) CXX11_OVERRIDE
+       ModResult OnRawMode(User* user, Channel* chan, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE
        {
-               if (chan && (chan->IsModeSet(p) || mode == p.GetModeChar()))
+               if (chan && (chan->IsModeSet(p) || mh == &p))
                        dirty = true;
 
                return MOD_RES_PASSTHRU;
index b35ee3487e4581257a6b162e39c18462c83ded65..26453020f6ce8376d9e576cf9bf956ea75603ac4 100644 (file)
@@ -64,7 +64,7 @@ class ModuleServProtectMode : public Module
                }
        }
 
-       ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt) CXX11_OVERRIDE
+       ModResult OnRawMode(User* user, Channel* chan, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE
        {
                /* Check that the mode is not a server mode, it is being removed, the user making the change is local, there is a parameter,
                 * and the user making the change is not a uline
@@ -81,7 +81,7 @@ class ModuleServProtectMode : public Module
                                 * This includes any prefix permission mode, even those registered in other modules, e.g. +qaohv. Using ::ModeString()
                                 * here means that the number of modes is restricted to only modes the user has, limiting it to as short a loop as possible.
                                 */
-                               if (u->IsModeSet(bm) && memb && memb->modes.find(mode) != std::string::npos)
+                               if (u->IsModeSet(bm) && memb && memb->hasMode(mh->GetModeChar()))
                                {
                                        /* BZZZT, Denied! */
                                        user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You are not permitted to remove privileges from %s services", chan->name.c_str(), ServerInstance->Config->Network.c_str());