- if (!u)
- {
- log(DEFAULT,"*** BUG *** WriteCommon was given an invalid parameter");
- return;
- }
-
- if (u->registered != 7) {
- log(DEFAULT,"*** BUG *** WriteCommon on an unregistered user");
- return;
- }
-
- char textbuffer[MAXBUF];
- va_list argsPtr;
- va_start (argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- memset(&already_sent,0,MAX_DESCRIPTORS);
-
- unsigned int y = u->chans.size();
- for (unsigned int i = 0; i < y; i++)
- {
- if (u->chans[i].channel)
- {
- std::map<char*,char*> *ulist= u->chans[i].channel->GetUsers();
- for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- char* o = i->second;
- userrec* otheruser = (userrec*)o;
- if (u != otheruser)
- {
- if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
- {
- already_sent[otheruser->fd] = 1;
- WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
- }
- }
- }
- }
- }
+ char textbuffer[MAXBUF];
+ char oper_quit[MAXBUF];
+ bool quit_munge = false;
+ va_list argsPtr;
+ int total;
+ unsigned int y;
+
+ if (!u)
+ {
+ log(DEFAULT,"*** BUG *** WriteCommon was given an invalid parameter");
+ return;
+ }
+
+ if (u->registered != 7)
+ {
+ log(DEFAULT,"*** BUG *** WriteCommon on an unregistered user");
+ return;
+ }
+
+ va_start(argsPtr, text);
+ total = vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ if ((Config->HideSplits) && (total > 6))
+ {
+ /* Yeah yeah, this is ugly. But its fast, live with it. */
+ char* check = textbuffer;
+
+ if ((*check++ == 'Q') && (*check++ == 'U') && (*check++ == 'I') && (*check++ == 'T') && (*check++ == ' ') && (*check++ == ':'))
+ {
+ std::stringstream split(check);
+ std::string server_one;
+ std::string server_two;
+
+ split >> server_one;
+ split >> server_two;
+
+ if ((FindServerName(server_one)) && (FindServerName(server_two)))
+ {
+ strlcpy(oper_quit,textbuffer,MAXQUIT);
+ strlcpy(check,"*.net *.split",MAXQUIT);
+ quit_munge = true;
+ }
+ }
+ }
+
+ if ((Config->HideBans) && (total > 13) && (!quit_munge))
+ {
+ char* check = textbuffer;
+
+ /* XXX - as above */
+ if ((*check++ == 'Q') && (*check++ == 'U') && (*check++ == 'I') && (*check++ == 'T') && (*check++ == ' ') && (*check++ == ':'))
+ {
+ check++;
+
+ if ((*check++ == '-') && (*check++ == 'L') && (*check++ == 'i') && (*check++ == 'n') && (*check++ == 'e') && (*check++ == 'd') && (*check++ == ':'))
+ {
+ strlcpy(oper_quit,textbuffer,MAXQUIT);
+ *(--check) = 0; // We don't need to strlcpy, we just chop it from the :
+ quit_munge = true;
+ }
+ }
+ }
+
+ memset(&already_sent,0,MAX_DESCRIPTORS);
+ y = u->chans.size();
+
+ for (unsigned int i = 0; i < y; i++)
+ {
+ if (u->chans[i].channel)
+ {
+ CUList *ulist= u->chans[i].channel->GetUsers();
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (u != i->second)
+ {
+ if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
+ {
+ already_sent[i->second->fd] = 1;
+
+ if (quit_munge)
+ {
+ WriteFrom_NoFormat(i->second->fd,u,*i->second->oper ? oper_quit : textbuffer);
+ }
+ else
+ WriteFrom_NoFormat(i->second->fd,u,textbuffer);
+ }
+ }
+ }
+ }
+ }