legend/
legend/area/
legend/player/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael         *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  Envy Diku Mud improvements copyright (C) 1994 by Michael Quan, David   *
 *  Love, Guilherme 'Willie' Arnold, and Mitchell Tse.                     *
 *                                                                         *
 *  EnvyMud 2.0 improvements copyright (C) 1995 by Michael Quan and        * 
 *  Mitchell Tse.                                                          *
 *                                                                         *
 *  In order to use any part of this Envy Diku Mud, you must comply with   *
 *  the original Diku license in 'license.doc', the Merc license in        *
 *  'license.txt', as well as the Envy license in 'license.nvy'.           *
 *  In particular, you may not remove either of these copyright notices.   *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/

/* Wiznet version 0.1
 *
 * Written by The Maniac from Mythran Mud
 * (c) 1996 The Maniac
 *
 * History:
 * 07/28/96	0.1	Initial version
 *
 */
/***************************************************************************
 *  God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock        *
 *                                                                         *
 *  Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little *
 *  This mud is NOT to be copied in whole or in part, or to be run without *
 *  the permission of Matthew Little. Nobody else has permission to        *
 *  authorise the use of this code.                                        *
 ***************************************************************************/

#if defined( macintosh )
#include <types.h>
#else
#include <sys/types.h>
#endif
#if !defined( WIN32 )
#include <unistd.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

void do_wiznet (CHAR_DATA * ch, char *argument)
{
   char arg[MAX_STRING_LENGTH];
   char buf[MAX_STRING_LENGTH];

   if (ch->desc && ch->desc->original)
      ch = ch->desc->original;

   buf[0] = '\0';

   one_argument (argument, arg);

   if (arg[0] == '\0')
   {
      stc ("Syntax: wiznet [argument]\n\r", ch);
/*		stc("Argument being one of:\n\r", ch);
		stc("  on/off show ticks logins deaths reset saccing secure switch snoop\n\r  restore load newbie spam debug\n\r", ch);
		stc("\n\r\n\r", ch);
		return;
	}

	if (!str_cmp(argument, "show"))
        {
*/
      if (IS_SET (ch->pcdata->wiznet, WIZ_ON))
	 sprintf (buf, "On      [X]   Off    [ ]\n\r");
      else
	 sprintf (buf, "On      [ ]   Off    [X]\n\r");
      stc (buf, ch);

      sprintf (buf,
	       "Ticks   [%s]   Logins [%s]  Deaths   [%s]   Resets [%s]\n\r",
	       WCHAN (ch, WIZ_TICKS) ? "X" : " ", WCHAN (ch,
							 WIZ_LOGINS) ? "X" :
	       " ", WCHAN (ch, WIZ_DEATHS) ? "X" : " ", WCHAN (ch,
							       WIZ_RESETS) ?
	       "X" : " ");
      stc (buf, ch);


      sprintf (buf,
	       "Saccing [%s]   Secure [%s]  Switches [%s]   Snoops [%s]\n\r",
	       WCHAN (ch, WIZ_SACCING) ? "X" : " ", WCHAN (ch,
							   WIZ_SECURE) ? "X" :
	       " ", WCHAN (ch, WIZ_SWITCHES) ? "X" : " ", WCHAN (ch,
								 WIZ_SNOOPS) ?
	       "X" : " ");
      stc (buf, ch);

      sprintf (buf,
	       "Restore [%s]   Load   [%s]  Newbie   [%s]   Spam   [%s]\n\r",
	       WCHAN (ch, WIZ_RESTORE) ? "X" : " ", WCHAN (ch,
							   WIZ_LOAD) ? "X" :
	       " ", WCHAN (ch, WIZ_NEWBIE) ? "X" : " ", WCHAN (ch,
							       WIZ_SPAM) ? "X"
	       : " ");
      stc (buf, ch);

      sprintf (buf, 
               "Debug   [%s]   Helps  [%s]  Trans    [%s]   Advert [%s]\n\r",
	       WCHAN (ch, WIZ_DEBUG) ? "X" : " ",
	       WCHAN (ch, WIZ_HELPS) ? "X" : " ",
	       WCHAN (ch, WIZ_TRANS) ? "X" : " ",
	       WCHAN (ch, WIZ_ADVER) ? "X" : " ");
      stc (buf, ch);
      return;
   }

   if (!str_cmp (argument, "on"))
   {
      SET_BIT (ch->pcdata->wiznet, WIZ_ON);
      send_to_char ("Welcome to Wiznet.\n\r", ch);
   }
   else if (!str_cmp (argument, "off"))
   {
      REMOVE_BIT (ch->pcdata->wiznet, WIZ_ON);
      send_to_char ("Wiznet is now off.\n\r", ch);
   }
   else
   {
      if (!str_infix ("tick", argument))
      {
	 send_to_char ("Ticks toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_TICKS);
      }
      if (!str_infix ("advert", argument))
      {
	 send_to_char ("Adverts toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_ADVER);
      }
      if (!str_infix ("trans", argument))
      {
	 send_to_char ("Transports toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_TRANS);
      }
      if (!str_infix ("helps", argument))
      {
	 send_to_char ("Helps toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_HELPS);
      }
      if (!str_infix ("login", argument))
      {
	 send_to_char ("Logins toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_LOGINS);
      }
      if (!str_infix ("death", argument))
      {
	 send_to_char ("Deaths toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_DEATHS);
      }
      if (!str_infix ("reset", argument))
      {
	 send_to_char ("Resets toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_RESETS);
      }
      if (!str_infix ("sac", argument))
      {
	 send_to_char ("Saccing toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_SACCING);
      }
      if (!str_infix ("secure", argument))
      {
	 send_to_char ("Secure toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_SECURE);
      }
      if (!str_infix ("switch", argument))
      {
	 send_to_char ("Switches toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_SWITCHES);
      }
      if (!str_infix ("snoop", argument))
      {
	 send_to_char ("Snoops toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_SNOOPS);
      }
      if (!str_infix ("restore", argument))
      {
	 send_to_char ("Restores toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_RESTORE);
      }
      if (!str_infix ("load", argument))
      {
	 send_to_char ("Loading toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_LOAD);
      }
      if (!str_infix ("newbie", argument))
      {
	 send_to_char ("Newbies toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_NEWBIE);
      }
      if (!str_infix ("spam", argument))
      {
	 send_to_char ("Spamming toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_SPAM);
      }
      if (!str_infix ("debug", argument))
      {
	 send_to_char ("Wiznet debug info toggled\n\r", ch);
	 TOGGLE_BIT (ch->pcdata->wiznet, WIZ_DEBUG);
      }
   }
   return;
}

void wiznet (CHAR_DATA * ch, int chan, int level, char *string)
{
   DESCRIPTOR_DATA *d;
   char buf[MAX_STRING_LENGTH];

   buf[0] = '\0';

   strcat (buf, "#y[#oWIZNET#y]#n ");

   switch (chan)
   {
   case WIZ_TICKS:
      strcat (buf, "#p[#PTICK#p]#n ");
      break;
   case WIZ_DEATHS:
      strcat (buf, "#r[#RDEATH#r]#n ");
      break;
   case WIZ_RESETS:
      strcat (buf, "#p[#PRESET#p]#n ");
      break;
   case WIZ_SACCING:
      strcat (buf, "#g[#GSACCING#g]#n ");
      break;
   default:
   case WIZ_SECURE:
      strcat (buf, "#w-->#n ");
      break;
   case WIZ_SWITCHES:
      strcat (buf, "#b[#BSWITCH#b]#n ");
      break;
   case WIZ_SNOOPS:
      strcat (buf, "#w[#nSNOOP#w]#n ");
      break;
   case WIZ_RESTORE:
      strcat (buf, "#P[#rRESTORE#P]#n ");
      break;
   case WIZ_LOAD:
      strcat (buf, "#B[#bLOAD#B]#n ");
      break;
   case WIZ_NEWBIE:
      strcat (buf, "#G[#gNEWBIE#G]#n ");
      break;
   case WIZ_SPAM:
      strcat (buf, "#w[#ySPAM#w]#n ");
      break;
   case WIZ_DEBUG:
      strcat (buf, "#y[#r**#wDEBUG#r**#y]#n ");
      break;
   case WIZ_HELPS:
      strcat (buf, "#g[#GH#gE#GL#gP#GS#g]#n ");
      break;
   case WIZ_ADVER:
      strcat (buf, "#r[ADVERTISEMENT]#n ");
      break;
   case WIZ_TRANS:
      strcat (buf, "#y[#oT#yR#oA#yN#oS#y]#n ");
      break;
   }
   strcat (buf, string);
   strcat (buf, "\n\r");

   for (d = first_descriptor; d != NULL; d = d->next)
   {
      if (d->connected == CON_PLAYING	/* Playing ??? */
	  && (!d->original)	/* Fix ???? */
	  && (get_trust (d->character) >= level)	/* Powerfull enuf */
	  && (d->character != ch)	/* Not the sender */
	  && (WCHAN (d->character, WIZ_ON))	/* Is wiznet on */
	  && (WCHAN (d->character, chan)))	/* Is this chan on */
      {
	 send_to_char (buf, d->character);
      }
   }
   return;
}