]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_map.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / m_map.c
index 423f055f05ada73e9de5a425c8a749c900448596..c2ab6be4ccd05379cfa4d8568e6de2da6d2928fe 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_map.c 254 2005-09-21 23:35:12Z nenolod $
+ *  $Id: m_map.c 3368 2007-04-03 10:11:06Z nenolod $
  */
 
 #include "stdinc.h"
@@ -28,7 +28,7 @@
 #include "numeric.h"
 #include "send.h"
 #include "s_conf.h"
-#include "sprintf_irc.h"
+#include "scache.h"
 
 #define USER_COL       50      /* display | Users: %d at col 50 */
 
@@ -41,14 +41,13 @@ struct Message map_msgtab = {
 };
 
 mapi_clist_av1 map_clist[] = { &map_msgtab, NULL };
-DECLARE_MODULE_AV1(map, NULL, NULL, map_clist, NULL, NULL, "$Revision: 254 $");
+DECLARE_MODULE_AV1(map, NULL, NULL, map_clist, NULL, NULL, "$Revision: 3368 $");
 
 static void dump_map(struct Client *client_p, struct Client *root, char *pbuf);
 
 static char buf[BUFSIZE];
 
 /* m_map
-**     parv[0] = sender prefix
 */
 static int
 m_map(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
@@ -61,19 +60,19 @@ m_map(struct Client *client_p, struct Client *source_p, int parc, const char *pa
        }
 
        dump_map(client_p, &me, buf);
-       sendto_one(client_p, form_str(RPL_MAPEND), me.name, client_p->name);
+       sendto_one_numeric(client_p, RPL_MAPEND, form_str(RPL_MAPEND));
        return 0;
 }
 
 /*
 ** mo_map
-**      parv[0] = sender prefix
 */
 static int
 mo_map(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        dump_map(client_p, &me, buf);
-       sendto_one(client_p, form_str(RPL_MAPEND), me.name, client_p->name);
+       scache_send_missing(client_p);
+       sendto_one_numeric(client_p, RPL_MAPEND, form_str(RPL_MAPEND));
 
        return 0;
 }
@@ -85,17 +84,17 @@ mo_map(struct Client *client_p, struct Client *source_p, int parc, const char *p
 static void
 dump_map(struct Client *client_p, struct Client *root_p, char *pbuf)
 {
-       int cnt = 0, i = 0, len;
+       int cnt = 0, i = 0, len, frac;
        struct Client *server_p;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        *pbuf = '\0';
 
-       strlcat(pbuf, root_p->name, BUFSIZE);
+       rb_strlcat(pbuf, root_p->name, BUFSIZE);
        if (has_id(root_p))
        {
-               strlcat(pbuf, "[", BUFSIZE);
-               strlcat(pbuf, root_p->id, BUFSIZE);
-               strlcat(pbuf, "]", BUFSIZE);
+               rb_strlcat(pbuf, "[", BUFSIZE);
+               rb_strlcat(pbuf, root_p->id, BUFSIZE);
+               rb_strlcat(pbuf, "]", BUFSIZE);
        }
        len = strlen(buf);
        buf[len] = ' ';
@@ -108,15 +107,16 @@ dump_map(struct Client *client_p, struct Client *root_p, char *pbuf)
                }
        }
 
-       ircsnprintf(buf + USER_COL, BUFSIZE - USER_COL,
-                " | Users: %5lu (%4.1f%%)", dlink_list_length(&root_p->serv->users),
-                100 * (float) dlink_list_length(&root_p->serv->users) / (float) Count.total);
+       frac = (1000 * rb_dlink_list_length(&root_p->serv->users) + Count.total / 2) / Count.total;
+       rb_snprintf(buf + USER_COL, BUFSIZE - USER_COL,
+                " | Users: %5lu (%2d.%1d%%)", rb_dlink_list_length(&root_p->serv->users),
+                frac / 10, frac % 10);
 
-       sendto_one(client_p, form_str(RPL_MAP), me.name, client_p->name, buf);
+       sendto_one_numeric(client_p, RPL_MAP, form_str(RPL_MAP), buf);
 
        if(root_p->serv->servers.head != NULL)
        {
-               cnt += dlink_list_length(&root_p->serv->servers);
+               cnt += rb_dlink_list_length(&root_p->serv->servers);
 
                if(cnt)
                {
@@ -129,7 +129,7 @@ dump_map(struct Client *client_p, struct Client *root_p, char *pbuf)
                }
        }
        i = 1;
-       DLINK_FOREACH(ptr, root_p->serv->servers.head)
+       RB_DLINK_FOREACH(ptr, root_p->serv->servers.head)
        {
                server_p = ptr->data;
                *pbuf = ' ';