summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-06 09:16:45 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-06 09:16:45 +0000
commit9f80dcb281f5fa2d464f6fbe4e031282b3121e40 (patch)
tree62a64abdf2184b6cd62d3b624b900186056cbdcf /src
parent82243d9beb827fca5708efe9e047ff2fec4bfe8c (diff)
Backport improved NAMES code into m_spy
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5429 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_spy.cpp62
1 files changed, 45 insertions, 17 deletions
diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp
index e47a91799..53a7f0d7f 100644
--- a/src/modules/m_spy.cpp
+++ b/src/modules/m_spy.cpp
@@ -3,13 +3,13 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
*
* Written by Craig Edwards, Craig McLure, and others.
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -32,34 +32,62 @@ using namespace std;
void spy_userlist(userrec *user, chanrec *c)
{
- static char list[MAXBUF];
+ char list[MAXBUF];
+ size_t dlen, curlen;
- if (!c || !user)
- return;
+ dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+ int numusers = 0;
+ char* ptr = list + dlen;
CUList *ulist= c->GetUsers();
+
+ /* Improvement by Brain - this doesnt change in value, so why was it inside
+ * the loop?
+ */
+ bool has_user = c->HasUser(user);
+
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- strlcat(list,c->GetPrefixChar(i->second),MAXBUF);
- strlcat(list,i->second->nick,MAXBUF);
- strlcat(list," ",MAXBUF);
- if (strlen(list)>(480-NICKMAX))
+ if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
+ {
+ /*
+ * user is +i, and source not on the channel, does not show
+ * nick in NAMES list
+ */
+ continue;
+ }
+
+ size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", c->GetPrefixChar(i->second), i->second->nick);
+
+ curlen += ptrlen;
+ ptr += ptrlen;
+
+ numusers++;
+
+ if (curlen > (480-NICKMAX))
{
- /* list overflowed into
- * multiple numerics */
+ /* list overflowed into multiple numerics */
user->WriteServ(std::string(list));
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+
+ /* reset our lengths */
+ dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+ ptr = list + dlen;
+
+ ptrlen = 0;
+ numusers = 0;
}
}
+
/* if whats left in the list isnt empty, send it */
- if (list[strlen(list)-1] != ':')
+ if (numusers)
{
user->WriteServ(std::string(list));
}
-}
+ user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name);
+
+}
class cmd_spylist : public command_t