From dc3c2ec158d8bc235773d07fd8ff420baad1c23f Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 26 Apr 2005 18:03:20 +0000 Subject: Fixed problem where nobody could message a channel they werent a member of (including u-lines, eek) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1200 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 115 ++++++++++++++++--------------------------------------- 1 file changed, 34 insertions(+), 81 deletions(-) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 015f07b3a..d04051364 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -662,19 +662,13 @@ void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...) vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); - for (int i = 0; i < MAXCHANS; i++) - { - if (user->chans[i].channel == Ptr) - { - std::vector *ulist = user->chans[i].channel->GetUsers(); - for (int j = 0; j < ulist->size(); j++) - { - char* o = (*ulist)[j]; - userrec* otheruser = (userrec*)o; - if (otheruser->fd != FD_MAGIC_NUMBER) - WriteTo(user,otheruser,"%s",textbuffer); - } - } + std::vector *ulist = Ptr->GetUsers(); + for (int j = 0; j < ulist->size(); j++) + { + char* o = (*ulist)[j]; + userrec* otheruser = (userrec*)o; + if (otheruser->fd != FD_MAGIC_NUMBER) + WriteTo(user,otheruser,"%s",textbuffer); } @@ -705,39 +699,23 @@ void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...) vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); - for (int i = 0; i < MAXCHANS; i++) + std::vector *ulist = Ptr->GetUsers(); + for (int j = 0; j < ulist->size(); j++) { - if (user->chans[i].channel == Ptr) - { - std::vector *ulist = user->chans[i].channel->GetUsers(); - for (int j = 0; j < ulist->size(); j++) - { - char* o = (*ulist)[j]; - userrec* otheruser = (userrec*)o; - if ((otheruser->fd != FD_MAGIC_NUMBER) && (otheruser->fd != -1)) - WriteTo(user,otheruser,"%s",textbuffer); - } - } + char* o = (*ulist)[j]; + userrec* otheruser = (userrec*)o; + if ((otheruser->fd != FD_MAGIC_NUMBER) && (otheruser->fd != -1) && (otheruser != user)) + { + if (!user) + { + WriteServ(otheruser->fd,"%s",textbuffer); + } + else + { + WriteTo(user,otheruser,"%s",textbuffer); + } + } } - - - //for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) - //{ - // if (has_channel(i->second,Ptr)) - // { - // if ((i->second->fd != -1) && (i->second->fd != FD_MAGIC_NUMBER)) - // { - // if (!user) - // { - // WriteServ(i->second->fd,"%s",textbuffer); - // } - // else - // { - // WriteTo(user,i->second,"%s",textbuffer); - // } - // } - // } - //} } @@ -755,23 +733,15 @@ void WriteChannelWithServ(char* ServName, chanrec* Ptr, userrec* user, char* tex va_end(argsPtr); - for (int i = 0; i < MAXCHANS; i++) + std::vector *ulist = Ptr->GetUsers(); + for (int j = 0; j < ulist->size(); j++) { - if (user->chans[i].channel == Ptr) - { - std::vector *ulist = user->chans[i].channel->GetUsers(); - for (int j = 0; j < ulist->size(); j++) - { - char* o = (*ulist)[j]; - userrec* otheruser = (userrec*)o; - if (otheruser->fd != FD_MAGIC_NUMBER) - WriteServ(otheruser->fd,"%s",textbuffer); - } - } + char* o = (*ulist)[j]; + userrec* otheruser = (userrec*)o; + if (otheruser->fd != FD_MAGIC_NUMBER) + WriteServ(otheruser->fd,"%s",textbuffer); } - - //for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) //{ // if (i->second) @@ -801,31 +771,14 @@ void ChanExceptSender(chanrec* Ptr, userrec* user, char* text, ...) vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); - for (int i = 0; i < MAXCHANS; i++) + std::vector *ulist = Ptr->GetUsers(); + for (int j = 0; j < ulist->size(); j++) { - if (user->chans[i].channel == Ptr) - { - std::vector *ulist = user->chans[i].channel->GetUsers(); - for (int j = 0; j < ulist->size(); j++) - { - char* o = (*ulist)[j]; - userrec* otheruser = (userrec*)o; - if ((otheruser->fd != FD_MAGIC_NUMBER) && (user != otheruser)) - WriteFrom(otheruser->fd,user,"%s",textbuffer); - } - } + char* o = (*ulist)[j]; + userrec* otheruser = (userrec*)o; + if ((otheruser->fd != FD_MAGIC_NUMBER) && (user != otheruser)) + WriteFrom(otheruser->fd,user,"%s",textbuffer); } - - //for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) - //{ - // if (i->second) - // { - // if ((has_channel(i->second,Ptr)) && (user != i->second) && (i->second->fd != FD_MAGIC_NUMBER)) - // { - // WriteTo(user,i->second,"%s",textbuffer); - // } - // } - //} } -- cgit v1.2.3