diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-09 16:05:07 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-09 16:05:07 +0000 |
commit | d483a20dcb724d28777908c5da0505624729a840 (patch) | |
tree | 12ab6a8373ff4776ef00d723a916b8d747a2c73c /src | |
parent | f7e755a60b6cbd245003d60fa0af0c130f1a4d1f (diff) |
Optimized userlist() (a lot faster with many users online)
Fixed bug where another users buffer could end up in the buffer of an
exiting client before they quit
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1345 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 36d593fdb..eaedeeb50 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1499,32 +1499,31 @@ void userlist(userrec *user,chanrec *c) } snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + + std::vector<char*> *ulist = c->GetUsers(); + for (int i = 0; i < ulist->size(); i++) { - if (has_channel(i->second,c)) + char* o = (*ulist)[i]; + userrec* otheruser = (userrec*)o; + if ((!has_channel(user,c)) && (strchr(otheruser->modes,'i'))) { - if (isnick(i->second->nick)) - { - if ((!has_channel(i->second,c)) && (strchr(i->second->modes,'i'))) - { - /* user is +i, and source not on the channel, does not show - * nick in NAMES list */ - continue; - } - strlcat(list,cmode(i->second,c),MAXBUF); - strlcat(list,i->second->nick,MAXBUF); - strlcat(list," ",MAXBUF); - if (strlen(list)>(480-NICKMAX)) - { - /* list overflowed into - * multiple numerics */ - WriteServ(user->fd,"%s",list); - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - } - } + /* user is +i, and source not on the channel, does not show + * nick in NAMES list */ + continue; + } + strlcat(list,cmode(otheruser,c),MAXBUF); + strlcat(list,otheruser->nick,MAXBUF); + strlcat(list," ",MAXBUF); + if (strlen(list)>(480-NICKMAX)) + { + /* list overflowed into + * multiple numerics */ + WriteServ(user->fd,"%s",list); + snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); } } - /* if whats left in the list isnt empty, send it */ if (list[strlen(list)-1] != ':') + /* if whats left in the list isnt empty, send it */ + if (list[strlen(list)-1] != ':') { WriteServ(user->fd,"%s",list); } @@ -4287,6 +4286,7 @@ int InspIRCd(char** argv, int argc) int currfd = current->fd; int floodlines = 0; // add the data to the users buffer + if (result > 0) if (!current->AddBuffer(data)) { // AddBuffer returned false, theres too much data in the user's buffer and theyre up to no good. |