]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix snomask stacking to only delay (last message repeated) part of the snomask
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 10 Mar 2009 22:55:55 +0000 (22:55 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 10 Mar 2009 22:55:55 +0000 (22:55 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11201 e03df62e-2008-0410-955e-edbf42e46eb7

include/snomasks.h
src/snomasks.cpp

index 767c785da2bf993423f66ac1d7aa61cfc5b4f706..742528c06cec5f4a1d57710460744c5625f8d5d6 100644 (file)
@@ -23,6 +23,7 @@ class Snomask : public Extensible
        char MySnomask;
        std::string Description;
        std::string LastMessage;
+       bool LastBlocked;
        unsigned int Count;
 
        /** Create a new Snomask
@@ -35,7 +36,7 @@ class Snomask : public Extensible
         */
        void SendMessage(const std::string &message);
 
-       /** Sends out a pending message
+       /** Sends out the (last message repeated N times) message
         */
        void Flush();
 };
index 13eb326bf2773596a0b926dfeafbe509f8a80763..8415dad348d55fe60caa2522e8ee8cca4257c941 100644 (file)
@@ -70,8 +70,6 @@ void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
        if (n != SnoMasks.end())
        {
                n->second->SendMessage(text);
-               // XXX: Always try flush here. This removes snomask stacking effectively, as it's too annoying in it's present form. This may be reworked for RC3, or delayed until post-release.
-               n->second->Flush();
        }
 }
 
@@ -119,51 +117,60 @@ void Snomask::SendMessage(const std::string &message)
        {
                this->Flush();
                LastMessage = message;
-       }
-       else
-       {
-               Count++;
-       }
-}
 
-void Snomask::Flush()
-{
-       if (this->LastMessage.empty())
-               return;
+               std::string desc = this->Description;
+               int MOD_RESULT = 0;
+               char mysnomask = MySnomask;
+               ServerInstance->Logs->Log("snomask", DEFAULT, "%s: %s", desc.c_str(), message.c_str());
 
-       ServerInstance->Logs->Log("snomask", DEFAULT, "%s: %s", this->Description.c_str(), this->LastMessage.c_str());
-       if (Count > 1)
-               ServerInstance->Logs->Log("snomask", DEFAULT, "%s: (last message repeated %u times)", this->Description.c_str(), Count);
+               FOREACH_RESULT(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, message));
 
+               LastBlocked = (MOD_RESULT == 1); // 1 blocks the message
 
-       int MOD_RESULT = 0;
-       char mysnomask = MySnomask;
-       std::string desc = this->Description;
+               if (!LastBlocked)
+               {
+                       /* Only opers can receive snotices, so we iterate the oper list */
+                       std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
 
-       FOREACH_RESULT(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, this->LastMessage));
+                       while (i != ServerInstance->Users->all_opers.end())
+                       {
+                               User* a = *i;
+                               if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(mysnomask) && !a->quitting)
+                               {
+                                       a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), desc.c_str(), message.c_str());
+                               }
 
-       if (MOD_RESULT != 1) // 1 blocks the message
-       {
-               /* Only opers can receive snotices, so we iterate the oper list */
-               std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
+                               i++;
+                       }
+               }
+       }
+       Count++;
+}
 
-               while (i != ServerInstance->Users->all_opers.end())
+void Snomask::Flush()
+{
+       if (Count > 1)
+       {
+               ServerInstance->Logs->Log("snomask", DEFAULT, "%s: (last message repeated %u times)", this->Description.c_str(), Count);
+               if (!LastBlocked)
                {
-                       User* a = *i;
-                       if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(mysnomask) && !a->quitting)
-                       {
+                       /* Only opers can receive snotices, so we iterate the oper list */
+                       std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
 
-                               a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), desc.c_str(), this->LastMessage.c_str());
-                               if (Count > 1)
+                       while (i != ServerInstance->Users->all_opers.end())
+                       {
+                               User* a = *i;
+                               if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(MySnomask) && !a->quitting)
                                {
                                        a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick.c_str(), this->Description.c_str(), Count);
                                }
-                       }
 
-                       i++;
+                               i++;
+                       }
                }
-       }
 
+       }
        LastMessage = "";
-       Count = 1;
+       LastBlocked = false;
+       Count = 0;
 }