+ if (u->registered != 7)
+ {
+ log(DEFAULT,"*** BUG *** WriteCommon on an unregistered user");
+ return;
+ }
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ // FIX: Stops a message going to the same person more than once
+ memset(&already_sent,0,MAX_DESCRIPTORS);
+
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
+ {
+ if (((ucrec*)(*v))->channel)
+ {
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
+ {
+ already_sent[i->second->fd] = 1;
+ WriteFrom_NoFormat(i->second->fd,u,textbuffer);
+ sent_to_at_least_one = true;
+ }
+ }
+ }
+ }
+
+ /*
+ * if the user was not in any channels, no users will receive the text. Make sure the user
+ * receives their OWN message for WriteCommon
+ */
+ if (!sent_to_at_least_one)
+ {
+ WriteFrom_NoFormat(u->fd,u,textbuffer);
+ }
+}
+
+void WriteCommon_NoFormat(userrec *u, const char* text)
+{
+ bool sent_to_at_least_one = false;
+
+ 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;
+ }
+
+ // FIX: Stops a message going to the same person more than once
+ memset(&already_sent,0,MAX_DESCRIPTORS);
+
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
+ {
+ if (((ucrec*)(*v))->channel)
+ {
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
+ {
+ already_sent[i->second->fd] = 1;
+ WriteFrom_NoFormat(i->second->fd,u,text);
+ sent_to_at_least_one = true;
+ }
+ }
+ }
+ }
+
+ /*
+ * if the user was not in any channels, no users will receive the text. Make sure the user
+ * receives their OWN message for WriteCommon
+ */
+ if (!sent_to_at_least_one)
+ {
+ WriteFrom_NoFormat(u->fd,u,text);
+ }
+}