Author: Ghostwolf <foxxe@wtfs.net>
[ircu2.10.12-pk.git] / ircd / m_map.c
index 589c37ff0365079547cfd36b1513ed2d941399f6..1e4e48b097ff6bdb10d9cf087a06f8d700124f7d 100644 (file)
 #include "s_serv.h"
 #include "send.h"
 #include "querycmds.h"
+#include "map.h"
 
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
-static void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length)
-{
-  static char prompt[64];
-  struct DLink *lp;
-  char *p = &prompt[prompt_length];
-  int cnt = 0;
-
-  *p = '\0';
-  if (prompt_length > 60)
-    send_reply(cptr, RPL_MAPMORE, prompt, cli_name(server));
-  else {
-    char lag[512];
-    if (cli_serv(server)->lag>10000)
-       lag[0]=0;
-    else if (cli_serv(server)->lag<0)
-       strcpy(lag,"(0s)");
-    else
-       sprintf(lag,"(%is)",cli_serv(server)->lag);
-    send_reply(cptr, RPL_MAP, prompt, (
-               (IsBurst(server)) ? "*" : (IsBurstAck(server) ? "!" : "")),
-              cli_name(server), lag, (server == &me) ? UserStats.local_clients :
-              cli_serv(server)->clients);
-  }
-  if (prompt_length > 0)
-  {
-    p[-1] = ' ';
-    if (p[-2] == '`')
-      p[-2] = ' ';
-  }
-  if (prompt_length > 60)
-    return;
-  strcpy(p, "|-");
-  for (lp = cli_serv(server)->down; lp; lp = lp->next)
-    if (match(mask, cli_name(lp->value.cptr)))
-      cli_flags(lp->value.cptr) &= ~FLAGS_MAP;
-    else
-    {
-      cli_flags(lp->value.cptr) |= FLAGS_MAP;
-      cnt++;
-    }
-  for (lp = cli_serv(server)->down; lp; lp = lp->next)
-  {
-    if ((cli_flags(lp->value.cptr) & FLAGS_MAP) == 0)
-      continue;
-    if (--cnt == 0)
-      *p = '`';
-    dump_map(cptr, lp->value.cptr, mask, prompt_length + 2);
-  }
-  if (prompt_length > 0)
-    p[-1] = '-';
-}
-
-
 /*
  * m_map - generic message handler
  * -- by Run
@@ -163,22 +111,25 @@ static void dump_map(struct Client *cptr, struct Client *server, char *mask, int
  */
 int m_map(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
-  if (parc < 2)
+#ifdef HEAD_IN_SAND_MAP
+  map_dump_head_in_sand(sptr);
+#else
+  if(parc < 2)
     parv[1] = "*";
-
-  dump_map(sptr, &me, parv[1], 0);
+  map_dump(sptr, &me, parv[1], 0);
+#endif /* HEAD_IN_SAND_MAP */
   send_reply(sptr, RPL_MAPEND);
 
   return 0;
 }
 
-#ifdef HEAD_IN_SAND_MAP
-int m_map_redirect(struct Client* cptr, struct Client* sptr, int parc,
-                  char* parv[])
+int mo_map(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
-  sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s", sptr,
-               "/MAP has been disabled, from CFV-165.  "
-               "Visit " URL_SERVERS);
+  if (parc < 2)
+    parv[1] = "*";
+
+  map_dump(sptr, &me, parv[1], 0);
+  send_reply(sptr, RPL_MAPEND);
+
   return 0;
 }
-#endif