]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Hopefully sped things up here -- I need to check this out on a box that I can run...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 23 Dec 2005 08:45:03 +0000 (08:45 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 23 Dec 2005 08:45:03 +0000 (08:45 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2642 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_blockcolor.cpp

index f63caf6c5e95e45881d32ab09826262719a30418..6f612f6b2dcb0cfb994a171a17e21ad45adf0ddf 100644 (file)
@@ -63,13 +63,26 @@ class ModuleBlockColor : public Module
                {
                        chanrec* c = (chanrec*)dest;
                        char ctext[MAXBUF];
+                       char *ctptr = ctext;
                        snprintf(ctext,MAXBUF,"%s",text.c_str());
+
+
                        if (c->IsCustomModeSet('c'))
                        {
-                               if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
+                               /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
+                               while (ctptr && *ctptr)
                                {
-                                       WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
-                                       return 1;
+                                       switch (*ctptr)
+                                       {
+                                               case 2:
+                                               case 3:
+                                               case 31:
+                                                       WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
+                                                       return 1;
+                                                       break;
+                                       }
+
+                                       *ctptr++;
                                }
                        }
                }
@@ -82,13 +95,26 @@ class ModuleBlockColor : public Module
                {
                        chanrec* c = (chanrec*)dest;
                        char ctext[MAXBUF];
+                       char *ctptr = ctext;
                        snprintf(ctext,MAXBUF,"%s",text.c_str());
+
+
                        if (c->IsCustomModeSet('c'))
                        {
-                               if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
+                               /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
+                               while (ctptr && *ctptr)
                                {
-                                       WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
-                                       return 1;
+                                       switch (*ctptr)
+                                       {
+                                               case 2:
+                                               case 3:
+                                               case 31:
+                                                       WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
+                                                       return 1;
+                                                       break;
+                                       }
+
+                                       *ctptr++;
                                }
                        }
                }