summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-26 18:03:20 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-26 18:03:20 +0000
commitdc3c2ec158d8bc235773d07fd8ff420baad1c23f (patch)
tree8ff165ef0d98ac9208504a2828a53de02d0a5181 /src
parent5a2675d174e661c55843b3795afe2d688e7197f9 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp115
1 files changed, 34 insertions, 81 deletions
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<char*> *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<char*> *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<char*> *ulist = Ptr->GetUsers();
+ for (int j = 0; j < ulist->size(); j++)
{
- if (user->chans[i].channel == Ptr)
- {
- std::vector<char*> *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<char*> *ulist = Ptr->GetUsers();
+ for (int j = 0; j < ulist->size(); j++)
{
- if (user->chans[i].channel == Ptr)
- {
- std::vector<char*> *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<char*> *ulist = Ptr->GetUsers();
+ for (int j = 0; j < ulist->size(); j++)
{
- if (user->chans[i].channel == Ptr)
- {
- std::vector<char*> *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);
- // }
- // }
- //}
}