]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanprotect.cpp
Fix bug #509 reported by Casey: bans were not applied on non-opped users (1.2 only)
[user/henk/code/inspircd.git] / src / modules / m_chanprotect.cpp
index daa728e61211d1f9bdc657a9e0ab31f6f5ae2221..e85744d06a242ebca6bbb31a9207e309ec96057c 100644 (file)
@@ -62,7 +62,7 @@ class FounderProtectBase
                return std::make_pair(false, parameter);
        }
 
-       void RemoveMode(Channel* channel, char mc)
+       void RemoveMode(Channel* channel, char mc, irc::modestacker* stack)
        {
                CUList* cl = channel->GetUsers();
                std::string item = extend + std::string(channel->name);
@@ -75,10 +75,16 @@ class FounderProtectBase
                {
                        if (i->first->GetExt(item))
                        {
-                               modestack.Push(mc, i->first->nick);
+                               if (stack)
+                                       stack->Push(mc, i->first->nick);
+                               else
+                                       modestack.Push(mc, i->first->nick);
                        }
                }
 
+               if (stack)
+                       return;
+
                while (modestack.GetStackedLine(stackresult))
                {
                        for (size_t j = 0; j < stackresult.size(); j++)
@@ -165,12 +171,12 @@ class ChanFounder : public ModeHandler, public FounderProtectBase
                return FounderProtectBase::ModeSet(source, dest, channel, parameter);
        }
 
-       void RemoveMode(Channel* channel)
+       void RemoveMode(Channel* channel, irc::modestacker* stack)
        {
-               FounderProtectBase::RemoveMode(channel, this->GetModeChar());
+               FounderProtectBase::RemoveMode(channel, this->GetModeChar(), stack);
        }
 
-       void RemoveMode(User* user)
+       void RemoveMode(User* user, irc::modestacker* stack)
        {
        }
 
@@ -231,12 +237,12 @@ class ChanProtect : public ModeHandler, public FounderProtectBase
                return FounderProtectBase::ModeSet(source, dest, channel, parameter);
        }
 
-       void RemoveMode(Channel* channel)
+       void RemoveMode(Channel* channel, irc::modestacker* stack)
        {
-               FounderProtectBase::RemoveMode(channel, this->GetModeChar());
+               FounderProtectBase::RemoveMode(channel, this->GetModeChar(), stack);
        }
 
-       void RemoveMode(User* user)
+       void RemoveMode(User* user, irc::modestacker* stack)
        {
        }
 
@@ -294,8 +300,8 @@ class ModuleChanProtect : public Module
  public:
  
        ModuleChanProtect(InspIRCd* Me)
-               : Module(Me), FirstInGetsFounder(false), QPrefix(0), APrefix(0), DeprivSelf(false), DeprivOthers(false), booting(true)
-       {       
+               : Module(Me), FirstInGetsFounder(false), QPrefix(0), APrefix(0), DeprivSelf(false), DeprivOthers(false), booting(true), cp(NULL), cf(NULL)
+       {
                /* Load config stuff */
                OnRehash(NULL,"");
                booting = false;
@@ -350,6 +356,15 @@ class ModuleChanProtect : public Module
                std::string apre = Conf.ReadValue("options", "aprefix", 0);
                APrefix = apre.empty() ? 0 : apre[0];
 
+               if ((APrefix && QPrefix) && APrefix == QPrefix)
+                       throw CoreException("What the smeg, why are both your +q and +a prefixes the same character?");
+
+               if (cp && ServerInstance->Modes->FindPrefix(APrefix) == cp)
+                       throw CoreException("Looks like the +a prefix you picked for m_chanprotect is already in use. Pick another.");
+
+               if (cf && ServerInstance->Modes->FindPrefix(QPrefix) == cf)
+                       throw CoreException("Looks like the +q prefix you picked for m_chanprotect is already in use. Pick another.");
+
                DeprivSelf = Conf.ReadFlag("options","deprotectself",0);
                DeprivOthers = Conf.ReadFlag("options","deprotectothers",0);