-void spy_userlist(userrec *user,chanrec *c)
-{
- static char list[MAXBUF];
-
- if ((!c) || (!user))
- return;
-
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-
- std::map<char*,char*> *ulist= c->GetUsers();
- for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- char* o = i->second;
- userrec* otheruser = (userrec*)o;
- 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_NoFormat(user->fd,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] != ':')
- {
- WriteServ_NoFormat(user->fd,list);
- }
-}
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", c->GetPrefixChar(i->first), i->first->nick);
+
+ curlen += ptrlen;
+ ptr += ptrlen;
+
+ numusers++;
+
+ if (curlen > (480-NICKMAX))
+ {
+ /* list overflowed into multiple numerics */
+ user->WriteServ(std::string(list));
+
+ /* reset our lengths */
+ dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+ ptr = list + dlen;
+
+ ptrlen = 0;
+ numusers = 0;
+ }
+ }