pdirt/data/
pdirt/data/HELP/
pdirt/data/HELP/0/
pdirt/data/HELP/F/
pdirt/data/HELP/G/
pdirt/data/HELP/H/
pdirt/data/HELP/J/
pdirt/data/HELP/K/
pdirt/data/HELP/O/
pdirt/data/HELP/Q/
pdirt/data/HELP/R/
pdirt/data/HELP/U/
pdirt/data/HELP/V/
pdirt/data/HELP/Y/
pdirt/data/HELP/Z/
pdirt/data/MESSAGES/
pdirt/data/POWERINFO/
pdirt/data/WIZ_ZONES/
pdirt/drv/
pdirt/drv/bin/
pdirt/drv/compiler/converter/
pdirt/drv/compiler/libs/
pdirt/drv/compiler/scripts/
pdirt/drv/include/AberChat/
pdirt/drv/include/InterMud/
pdirt/drv/include/machine/
pdirt/drv/src/InterMud/
pdirt/drv/src/Players/
pdirt/drv/utils/UAFPort/
pdirt/drv/utils/dnsresolv/
pdirt/drv/utils/gdbm/
#define COMMUNICATE_C
#include <stdlib.h>
#include "verbs.h"
#include "kernel.h"
#include "config.h"
#include "colors.h"
#include "communicate.h"
#include "sflags.h"
#include "sflag.h"
#include "pflags.h"
#include "lflags.h"
#include "cflags.h"
#include "sendsys.h"
#include "mudtypes.h"
#include "mobile.h"
#include "bprintf.h"
#include "uaf.h"
#include "parse.h"
#include "objsys.h"
#include "special.h"
#include "log.h"
#ifdef INTERMUD
#include "InterMud/intermud.h"
#endif
/**************************************************************************
 ** The char define is used in build_voice_text, and the str is used to
 ** call build_voice_text. They should contain the same char though.
 **************************************************************************/
#define WIZLINE_CHAR	':'
#define WIZLINE_STR	":"
#define AWIZLINE_CHAR	'*'
#define AWIZLINE_STR	"*"
#define DGODLINE_CHAR	']'
#define DGODLINE_STR	"]"
#define GODLINE_CHAR	'>'
#define GODLINE_STR	">"

PRIVATE char str[MAX_COM_LEN];
PRIVATE void _wiz (const int level, char *text);
typedef unsigned char   uint8;


char *build_voice_text (char *name,
                        char *verb,
                        char *text,
                        char *quote,
                        color_code_type indent_color,
                        color_code_type speech_color)
{
    #define LCL_SCREEN_WIDTH    80
    #define LCL_MAX_WORD_LENGTH 20

    uint8 pos;
    uint8 max_chars_per_line;
    uint8 min_chars_per_line;
    uint8 max_num_lines;
    uint8 indent_chars=0;
    char  *start;
    char  *end;
    char  *buffer;

    /*
     * Hamlet says '...'
     * Player + Verb + Quote + Text + Quote
     */
    max_chars_per_line = LCL_SCREEN_WIDTH -
                         xstrlen (verb) -
                         xstrlen (name) -
                         strlen (color_strings[speech_color]) -
                         (xstrlen (quote) * 2);
    min_chars_per_line = max_chars_per_line - LCL_MAX_WORD_LENGTH;
    max_num_lines      = (strlen (text) / min_chars_per_line) + 1;

    /*
     * Allocate space for the text, copy in the initial text, and
     * determine the indention needed for this text.
     */
    buffer = (char *) malloc ((LCL_SCREEN_WIDTH * max_num_lines) +
                              strlen (color_strings[indent_color]) +
                              strlen (color_strings[speech_color]));
    if (strlen(name) == 0)
    {
      sprintf (buffer, "%s%s %s%s", color_strings[indent_color],
            verb, color_strings[speech_color], quote);
      indent_chars = 1+ xstrlen (name) + xstrlen (verb) + xstrlen (quote);
    }
    else if (verb[0] == WIZLINE_CHAR) 
    {
      sprintf(buffer, "%s%s%s %s%s", color_strings[indent_color],
	    name, verb, color_strings[speech_color], quote);
      indent_chars = 1 + strlen (name) + strlen (verb) + strlen (quote);
    } 
    else if (verb[0] == AWIZLINE_CHAR) 
    {
      sprintf(buffer,"%s%s%s%s %s%s", color_strings[indent_color],
              verb,name,verb,color_strings[speech_color], quote);
      indent_chars = 1 + strlen(name) + 2 + strlen (quote);
    } 
    else if (verb[0] == GODLINE_CHAR) 
    {
      sprintf(buffer,"%s<%s> %s%s",color_strings[indent_color],
              name,color_strings[speech_color],quote);
      indent_chars = 1 + strlen(name) + 2 + strlen(quote);
    } 
    else if (verb[0] == DGODLINE_CHAR)
    {
       sprintf(buffer,"%s[%s] %s%s",color_strings[indent_color],
              name,color_strings[speech_color],quote);
       indent_chars = 1 + strlen(name) + 2 + strlen(quote);
    }
    else if (xstrlen(verb) != 1 && xstrlen(name) != 0)
    {
       sprintf (buffer, "%s%s %s %s%s", color_strings[indent_color],
            name, verb, color_strings[speech_color], quote);
       indent_chars = 2+ xstrlen (name) + xstrlen (verb) + xstrlen (quote);
    }
    
    start = text;
    while (strlen (start) > max_chars_per_line)
    {
        /*
         * Search backwards up to MAX_WORD_LENGTH characters for a space.
         */
        for (end = start + max_chars_per_line, pos = 0;
             *end != ' ' && pos != LCL_MAX_WORD_LENGTH;
             pos++, end--)
            ;

        /*
         * If we didn't find a space, we need to go ahead and just cut
         * the word off at the maximum length.
         */
        if (pos == LCL_MAX_WORD_LENGTH)
        {
            strncat (buffer, start, max_chars_per_line);
            strcat (buffer, "\n");
            start += max_chars_per_line;
        }
        /*
         * Otherwise, cut the word off nicely at the space.
         */
        else
        {
            strncat (buffer, start, end - start);
            strcat (buffer, "\n");
            start = end + 1;
        }

        /*
         * Indent the next line to be under the previous text
         */
        for (pos = 0; pos < indent_chars; pos++)
            strcat (buffer, " ");
        /*
         * Put in the color text, since a newline has passed
         */
        strcat (buffer, color_strings[speech_color]);
    }
    
    /*
     * Tack on the last line of text, the end quote mark, and a newline
     */
    strcat (buffer, start);
    strcat (buffer, quote);
    strcat (buffer, "\n");
    /*
     * Return the created buffer to the caller
     */
    return buffer;
}


void rawcom()
{
  char x[MAX_COM_LEN], y[MAX_COM_LEN];
  
  if (!ptstflg(mynum, PFL_RAW))
    {
      erreval();
      return;
    }
  getreinput(x);
  if (EMPTY(x))
    bprintf("What do you want to announce?\n");
  else
  {
     sprintf(y, "&+w** SYSTEM :&* %s\a\a\n", x);
     send_msg(DEST_ALL, MODE_QUIET|MODE_BRACKET, LVL_GOD, LVL_MAX, NOBODY,
           mynum,"%s RAW'd", pname(mynum));
     broad(y);
  }
}

void namerawcom()
{
  char x[MAX_COM_LEN], y[MAX_COM_LEN];
  
  if (!ptstflg(mynum, PFL_NAMERAW))
    {
      erreval();
      return;
    }
  getreinput(x);

  if (EMPTY(x))
     bprintf("What do you want to announce?\n");
  else
  {
     sprintf(y, "&+w** SYSTEM <%s> :&* %s\a\a\n", pname(mynum), x);
     broad(y);
  }
}

void wishcom (void)
{
  char x[MAX_COM_LEN];
  
  if (EMPTY (item1))
  {
      bprintf ("Wish for what?\n");
      return;
  }

  if (ltstflg(ploc(mynum),LFL_JAIL) && (plev(mynum) < LVL_ARCHWIZARD))
  {  bprintf("I bet you do! I would too.\n");
     return;
  } 

  getreinput (x);
  
  send_msg (DEST_ALL, MODE_QUIET, LVL_APPREN, LVL_MAX, NOBODY, NOBODY,
            "[&+wWish from \001p%s\003&*]\n[&+w%s&*]\n", pname (mynum), x);
  
  sillycom ("\001s%s\002%s begs and grovels to the powers that be.\n\003");
  bprintf ("Ok\n");
}

void conversecom(void)
{
  if (cur_player->converse.active) {
    bprintf("You are already in converse mode. Type ** to exit.\n");
    bprintf("To execute a command as normal start it with * '*nod'.\n");
  }
  else {
    cur_player->converse.active = True;
    strcpy(cur_player->converse.old_prompt,cur_player->prompt);
    if ((cur_player->converse.talking_to = pl1) == -1) {
      bprintf("&+wYou are now in converse mode. Type ** to exit.&*\n");
      strcpy(cur_player->prompt,": ");
    }
    else {
      bprintf("You are conversing with %s.  Type ** to quit.\n",pname(pl1));
      sprintf(cur_player->prompt,"[%s]: ",pname(pl1));
    }
  }
}

A_COMMAND(tellcom)
{
  int b;
  char *buffer;
 
  if (EMPTY (item1))
    {
      bprintf ("Tell who?\n");
      return;
    }
#ifdef INTERMUD
  if (strchr(item1,'@'))
  {
      imTell();
      return;
  }
#endif
  if (ltstflg(ploc(mynum),LFL_JAIL) && (plev(mynum) < LVL_ARCHWIZARD) )
  {  bprintf("I think you are the one that needs telling.\n");
     return;
  }  
  if ((b = pl1) == -1)
    {
      bprintf ("No one with that name is playing.\n");
      return;
    }
  if (b == mynum)
    {
      bprintf ("You talk to yourself.\n");
      return;
    }
  if (pl1 >= max_players)
    {   if (mob_fun(b) != NULL)
        {  param_s.buf = txt2;
           param_s.plx = mynum;
           param_s.ob  = -1;
           param_s.pl  = pl1;
           param_s.loc = ploc(mynum);
           param_s.ret = 1;
           param_s.misc = -1;
           mob_fun(b)(E_ONCOMM);
           /* Return value:
            * 1 : default error message 
            * -1: Do nothing.
            * 0 : Say buffer back.
            */
           if (param_s.ret == 1)
           {   bprintf("What's the use in talking to a mobile?\n");
               return;
           }
           if (param_s.ret == -1)
           {
              return;
           } else
           {
              buffer = build_voice_text ((char *)see_name (mynum,b),
                                           "&+wtells you",
                                           txt2,
                                           "&+w\"&+w",
                                           COLOR_HILIGHT_MAGENTA,
                                           COLOR_HILIGHT_WHITE);
              sendf(mynum,"%s", buffer);
              free(buffer);
           }
           return;
        } else
        {  bprintf("What's the use in talking to a mobile?\n");
           return;
        }
    }

  if (EMPTY (txt2))
    {
      bprintf ("What do you want to tell them?\n");
      return;
    }
  /* Don't allow talking while asleep */
  if (psitting(mynum)==2)
    {
       bprintf("You mumble in your sleep.\n");
       send_msg(ploc(mynum),MODE_NODEAF,pvis(mynum),LVL_MAX,mynum,NOBODY,
             "%s mumbles in %s sleep.\n",pname(mynum), his_or_her(mynum));
       return;
    }
  if (psitting(pl1)==2 && plev(mynum) < LVL_ARCHWIZARD)
    { 
       bprintf("%s is asleep and can't hear you right now.\n",pname(pl1));
       return;
    }
  if (psitting(mynum)==3 && plev(mynum) < LVL_ARCHWIZARD)
    {  bprintf("You are too deep in trance to do that.\n");
       return;
    }
 if (psitting(pl1)==3 && plev(mynum) < LVL_ARCHWIZARD)
    {   bprintf("%s is deep in trance to hear you now.\n",pname(pl1));
        return;
    }
  if (plev(mynum) < LVL_DEMI && ploc(pl1) != ploc(mynum) &&
      (ltstflg(ploc(mynum), LFL_SOUNDPROOF) ||
       ltstflg(ploc(pl1), LFL_SOUNDPROOF)))
    {
      bprintf("Your message can't get through the thick walls %s.\n",
	      ltstflg(ploc(mynum), LFL_SOUNDPROOF) ? "here" : "there");
      return;
    }
  if (plev(mynum) < plev(pl1) && check_busy(pl1))
  {   bprintf("%s is busy right now.\n",pname(pl1));
      return;
  }
  
  if (pl1 < max_players && pl1 >= 0 && players[pl1].linkdead == True)
  {   bprintf("%s is linkdead so %s can't talk to you at the moment.\n",
              pname(pl1), psex(pl1) ? "she" : "he");
      return;
  }

  if (players[pl1].editor.active)
  {   bprintf("%s is writing something important, please try later.\n",pname(pl1));
      return;
  }
  else if (plev(mynum) >= plev(pl1) && ststflg(pl1, SFL_BUSY) &&
	   (players[pl1]. aliased || players[pl1].polymorphed != -1))
  {
      bprintf("%s isn't %sself right now..\n", pname(pl1), him_or_her(pl1));
      return;
  }
  else if (ststflg(pl1,SFL_CODING))
  {   bprintf("%s is very busy at the moment, try again later.\n",pname(pl1));
      return;
  }

  if (ststflg(pl1,SFL_AWAY) || ststflg(pl1,SFL_KLOCKED)) 
  { bprintf ("%s\n",build_setin(mynum, globalbuf,players[pl1].setaway,pname(pl1),NULL));
  }
  if (ststflg(mynum, SFL_AWAY)) 
  {
    if (plast_cmd(mynum) < 0)
      bprintf ("Note: You're still marked as 'idle'.\n");
    else
      bprintf("Note: You're still marked as 'away'.\n");
  }

  if (ststflg(mynum, SFL_SAYBACK))
  {   buffer = build_voice_text ("You tell",
                                           pname(b),
                                           txt2,
                                           "&+w\"&+w",
                                           COLOR_HILIGHT_MAGENTA,
                                           COLOR_HILIGHT_WHITE);
        bprintf("%s",buffer); 
        free(buffer);
  } 
  else 
     bprintf("Ok.\n");

  buffer = build_voice_text ((char *)see_name (b, mynum),
                                           "tells you",
                                           txt2,
                                           "&+w\"&+w",
                                           COLOR_HILIGHT_MAGENTA,
                                           COLOR_HILIGHT_WHITE);
  sendf(b,"%s", buffer);
  free(buffer);
}

void saycom (void)
{ char *intonation_me;
  char *intonation_others;
  char foo[MAX_COM_LEN];
  char vname[PNAME_LEN+4];
  char *buffer;
  char lastchar;
 
  getreinput (foo);
  if (EMPTY (txt1))
    {
      bprintf ("What do you want to say?\n");
      return;
    }
  if (psitting(mynum)==2)
    {
      bprintf("You mumble in your sleep.\n");
      sendf(ploc(mynum),"%s mumbles in %s sleep.\n",pname(mynum),his_or_her(mynum));
      return;
    }
  if (psitting(mynum)==3)
    {  bprintf("You are too deep in trance to speak.\n");
       return;
    }
  getreinput(foo);

  lastchar = foo[strlen(foo)-1];

  intonation_me = "You say";
  intonation_others = "says";

if (strlen(foo) >= 2)
  switch (lastchar) {
  case '!' : 
	intonation_me = "You exclaim";
	intonation_others = "exclaims"; 
	break;
  case '?' : 
	intonation_me = "You ask"; 
	intonation_others = "asks";
	break; 
  case ')' :
	if (foo[strlen(foo)-2] == ':')
        {  intonation_me = "You smile and say";
	   intonation_others = "smiles and says";
        }
        else if (foo[strlen(foo)-2] == ';')
        {  intonation_me = "You wink and say";
           intonation_others = "winks and says";
        }
        break;
  case '(' :
        if (foo[strlen(foo)-2] == ':')
        {  intonation_me = "You pout and say";
           intonation_others = "pouts and says";
        }
        break;
  case '/':
	if (foo[strlen(foo)-2] == ':')
        {  intonation_me = "You frown and say";
           intonation_others = "frowns and says";
        }
	break;
  default:
  }

  if (ststflg(mynum, SFL_SAYBACK))
  {
    buffer = build_voice_text ("",
                               intonation_me,
                               foo,
                               "'",
                               COLOR_NONE,
                               COLOR_HILIGHT_CYAN);
    bprintf("%s",buffer);
    free(buffer);
  }
  else
    bprintf("Ok.\n");

  sprintf(vname,"\001p%s\003",pname(mynum));

  buffer = build_voice_text (vname,
                             intonation_others,
                             foo,
                             "'",
                             COLOR_NONE,
                             COLOR_HILIGHT_CYAN);
  send_msg(ploc(mynum), MODE_NODEAF, LVL_MIN, LVL_MAX, mynum, NOBODY,
	   "%s",buffer);
	   
	if (rom_fun(ploc(mynum)) != NULL)
	{  param_s.plx = mynum;
	   param_s.loc = ploc(mynum);
	   param_s.buf = foo;
	   rom_fun(ploc(mynum))(E_ONSAY);
	}
  free(buffer);
}

extern char * shout_test (int player, int sender, char *text)
{
  static char buff[MAX_COM_LEN];
  char *buffer;

  if((player == sender) || (plev(player) >= LVL_APPREN && ststflg(player, SFL_NOSHOUT)) ||
	(plev(player) < LVL_APPREN && ststflg(player, SFL_DEAF)) ||
        (psitting(player) > 1) ||
	(plev(player) < LVL_ADVISOR &&  ltstflg(ploc(player), LFL_SOUNDPROOF) &&
	ploc(sender) != ploc(player))) return NULL;

  if (plev (player) >= LVL_APPREN || plev (sender) >= LVL_APPREN
      || ploc (player) == ploc (sender) || (sender >= max_players))
  {   buffer = build_voice_text(see_name(player,sender),"shouts", text, "'",
                       COLOR_NONE,COLOR_HILIGHT_CYAN);
  }
  else
    buffer = build_voice_text("A voice","shouts", text, "'", COLOR_NONE,COLOR_HILIGHT_CYAN);
  
  sprintf(buff,"%s",buffer);
  free(buffer);
  return buff;
}

extern char * puff_shout_test (int player, int sender, char *text)
{
  static char buff[MAX_COM_LEN];
  char *buffer;

  if( (player == sender) || (plev(player) >= LVL_APPREN && ststflg(player, SFL_NOSHOUT)) ||
      (plev(player) < LVL_APPREN && ststflg(player, SFL_DEAF)) ||
      (psitting(player) > 1 || ststflg(player,SFL_NOCOMM)) ||
      (plev(player) < LVL_ADVISOR &&  ltstflg(ploc(player), LFL_SOUNDPROOF) && ploc(sender) != ploc(player)) ||
      (ststflg(player,SFL_NOPUFF)) )
           return NULL;
  
  buffer = build_voice_text(pname(sender),"shouts", text, "'",
                       COLOR_NONE,COLOR_HILIGHT_CYAN);

  sprintf(buff,"%s",buffer);
  free(buffer);
  return buff;
}

void shoutcom (void)
{
  char blob[MAX_COM_LEN];

  if (ltstflg(ploc(mynum),LFL_JAIL) && (plev(mynum) < LVL_ARCHWIZARD) )
  {  bprintf("Your shouting is absorbed by the walls.\n");
     return;
  } 

  if (psitting(mynum) == 2 || ststflg(mynum,SFL_NOCOMM))
  {  bprintf("You shout and scream, but no one responds...\n");
     return;
  }

  if (plev (mynum) < LVL_APPREN && ststflg (mynum, SFL_NOSHOUT))
    {
      bprintf ("I'm sorry, you can't shout anymore.\n");
      return;
    }
  else if (ltstflg(ploc(mynum), LFL_SOUNDPROOF) && (plev(mynum) < LVL_DEMI))
    {
      bprintf("The world around you seems to absorb your cries.\n");
      return;
    }
  else
    {
      getreinput (blob);
      if (EMPTY (blob))
        {
          bprintf ("What do you want to shout?\n");
          return;
        }
      else
        send_g_msg (DEST_ALL, shout_test, mynum, blob);
  }
  if (ststflg(mynum, SFL_SAYBACK))
    bprintf ("You shout &+w'%s'&*\n", blob);
  else bprintf("Ok.\n");
}

/*##################################################################### */
/*#     eehandler:      the command that handles echos/emotes         # */
/*##################################################################### */

A_COMMAND(eehandler)
{ int type = verbnumber;
  char *w;
  char input[1024];
  
  if (EMPTY (item1))          /* The player must supply a message */
    {
      bprintf ("What?\n");
      return;
    }

  /* Check if the player has been nasty and has been sent to jail for his
   * or her wrongdoings. Because if he/she is, we don't allow any emote or
   * echo whatsoever.
   */
  if (ltstflg(ploc(mynum),LFL_JAIL) && (plev(mynum) < LVL_ARCHWIZARD) )
  {  bprintf("Your emotions are probably what got you in here.\n");
     return;
  }

  getreinput (input);       /* Get rest of input */

  switch (type) {           /* What kind of message should it be ? */
  case DO_ECHO:
  case DO_ECHOTO:
      if (!ptstflg (mynum, PFL_ECHO))      /* Privilege check */
        {
          bprintf ("You hear echos.\n");
          return;
        }
      if (type == DO_ECHO)
      {
	  if (ststflg(mynum, SFL_SAYBACK))
	    bprintf ("You echo : %s\n", input);

	  send_msg (ploc (mynum), MODE_QUIET|MODE_BRACKET, LVL_GOD, LVL_MAX, NOBODY,
		    mynum, "%s has ECHOed : %s", pname(mynum), input);
	  sendf (ploc(mynum), "%s\n", input);
      }
      else if (type == DO_ECHOTO) 
      {
	for (w = input; *w != ' '; w++);  /* Strip first word from input */
	     w++;

	if (mynum == pl1)           /* Check if the TO parameter is correct */
            bprintf ("What's the point in that?\n");
        else if (pl1 == -1)
            bprintf ("I don't know anyone with that name.\n");
	else 
        {
	  sendf (pl1, "%s\n", w);

	  if (ststflg(mynum, SFL_SAYBACK))
	    bprintf ("You echoto %s : &+w%s&*\n", pname(pl1), w);
	}
      }
      if (!ststflg(mynum, SFL_SAYBACK))
	bprintf ("Ok.\n");
      break;

  case DO_ECHOALL:
      if (!ptstflg (mynum, PFL_ECHOALL))
      {
          bprintf ("You hear echos.\n");
          return;
      }

      send_msg (DEST_ALL, MODE_QUIET|MODE_BRACKET, LVL_ARCHWIZARD, LVL_MAX, NOBODY,
                mynum, "%s has ECHOALLed", pname(mynum));

      if (!ststflg(mynum, SFL_SAYBACK))
	bprintf ("Ok.\n");
      else
	bprintf ("Your echoall : &+w%s&*\n", input);
      sendf(DEST_ALL, "%s\n", input);

      break;

  case DO_EMOTE:
  case DO_EMOTETO:
  case DO_EMOTEALL:
      if (!ptstflg (mynum, PFL_EMOTE) && (!ltstflg(ploc(mynum), LFL_PARTY)))
      {
	  bprintf ("You can't do that.\n");
	  return;
      }
     
      if (plev(mynum) < LVL_APPREN && psitting(mynum) > 1)
      {   bprintf("You can't do that while resting.\n"); 
          return;
      }

      /* mortals may NOT emoteto/emotall! */
      if (type != DO_EMOTE && plev (mynum) < LVL_APPREN) 
      {
	bprintf ("You are not allowed to do this.\n");
	return;
      }
      if (type == DO_EMOTE) 
      {
	if (ststflg(mynum, SFL_SAYBACK)) 
        {
          if (pvis(mynum) > 0)
  	    bprintf ("&+w-> &*(%s) %s\n", pname(mynum), input);
          else
            bprintf("&+w-> &*%s %s\n", pname(mynum), input);
	}
	send_msg (ploc (mynum), 0, LVL_MIN, LVL_MAX, mynum, NOBODY,
		  "\001p%s\003 %s\n", pname (mynum), input);
      } 
      else if (type == DO_EMOTETO) 
      {
	for (w = input; *w != ' '; w++);
	    w++;
	if (mynum == pl1)
	  bprintf ("What is the point in that?\n");
        else if (pl1 == -1)
          bprintf ("I can't find any player with that name.\n");
	else if (ststflg(mynum, SFL_SAYBACK)) 
        {
          if (pvis(mynum) > 0)
	    bprintf ("&+w<-%s-> &* (%s) %s\n", pname(pl1),pname(mynum), w);
          else
	    bprintf ("&+w<-%s-> &*%s %s\n", pname(pl1),pname(mynum), w);
	  sendf (pl1, "\001p%s\003 %s\n", pname (mynum), w);
	}
      }
      else if (type == DO_EMOTEALL) 
      {
	  if (ststflg (mynum, SFL_SAYBACK)) 
              bprintf ("&+w-> &*%s %s\n", pname(mynum), input);
	  
	  if (pvis(mynum) > 0)
	    send_msg (DEST_ALL, 0, LVL_MIN, LVL_MAX, mynum, NOBODY,
		      "\001p(%s)\003 %s\n", pname (mynum), input);
	  else
	    send_msg(DEST_ALL, 0, LVL_MIN, LVL_MAX, mynum, NOBODY,
		     "\001p%s\003 %s\n", pname(mynum), input);
      }
      if (!ststflg(mynum, SFL_SAYBACK))
	bprintf ("Ok.\n");
      break;
  default: mudlog("Case slip in eehandler (Unknown type)"); break;
  }
}

A_COMMAND(notalklinecom)
{ int flg = 0;
  char line[256];
 
  if (ststflg(mynum,SFL_NOCOMM))
  {  bprintf("You no longer have the ability to use the public channels, so why would you\n"
             "want to disable them?\n");
     return;
  }
  
  switch(verbnumber)  {
  case VERB_NOGOD:
      flg = SFL_NO_GOD; sprintf(line, "God");
      break;
  case VERB_NODGOD:
      flg = SFL_NO_DGOD; sprintf(line, "Demi-God");
      break;
  case VERB_NOAWIZ:
      flg = SFL_NO_AWIZ; sprintf(line, "Archwiz");
      break;
  case VERB_NOWIZ:
      flg = SFL_NO_WIZ; sprintf(line, "Wiz");
      break;
  case VERB_NOGOSSIP:
      flg = SFL_NO_GOSSIP; sprintf(line, "Gossip");
      break;
  case VERB_NOCHAT:
      flg = SFL_NO_CHAT; sprintf(line, "Chat");
      break;
  default: return;
  } /* end switch */
  
  if(!ststflg(mynum,flg))
  {
      bprintf("&+w[&+w%s line &+w= &+wOff&+w]&*\n",line);
      ssetflg(mynum,flg);
  }
  else
  {
      bprintf("&+w[&+w%s line &+w= &+wOn&+w]&*\n",line);
      sclrflg(mynum,flg);
  }
}

EXTERN char *gossip_test (int player, int sender, char *text)
{
  if (ststflg(player, SFL_NO_GOSSIP) ||
      ststflg(player, SFL_NOCOMM) ||
      (plev(player) < LVL_APPREN && ststflg(player, SFL_DEAF)) ||
       (ploc(player) != ploc(sender) && (ltstflg(ploc(sender), LFL_SOUNDPROOF) ||
        ltstflg(ploc(player), LFL_SOUNDPROOF)
       )
      )
     )
  return NULL;

  sprintf(str, "%s", build_voice_text(see_name(player, sender), "gossips", text, "'",
            COLOR_NORMAL_WHITE, COLOR_NORMAL_WHITE));

  return str;
}

PUBLIC void gossipcom(void)
{
  if (ststflg(mynum,SFL_NOCOMM))
  {  bprintf("Gossip has been disabled.\n");
     return;
  } 
  if (jail_check(mynum,LVL_ARCHWIZARD) )
  {  bprintf("I wouldn't be worrying about the gossip right now.\n"
             "You should be cooling off.\n");
     return;
  }
 
  if (plev (mynum) < LVL_APPREN && ststflg (mynum, SFL_NO_GOSSIP)) 
  {
    bprintf ("I'm sorry, you can't gossip anymore.\n");
    return;
  }
  
  if (psitting(mynum)==3) 
  {  bprintf("You feel too devine to gossip.\n");
     return;
  }

  getreinput (wordbuf);
  
  if (EMPTY (wordbuf)) 
  {
    bprintf ("What do you want to gossip?\n");
    return;
  }

  if (global_clock == cur_player->p_last_comm) 
  {
     bprintf ("You need to slow down and enounciate your gossip\n");
     return; 
  }
  cur_player->p_last_comm = global_clock;

  send_g_msg (DEST_ALL, gossip_test, mynum, wordbuf);
}

EXTERN char * chat_test(int player, int sender, char *text)
{   char *buffer; 
    if (ststflg(player,SFL_NO_CHAT) || (psitting(player)==3) ||
        ststflg(player,SFL_NOCOMM))
        return NULL;

    buffer = build_voice_text(see_name(player,sender),"chats",text,"'",
            COLOR_NORMAL_WHITE,COLOR_NORMAL_WHITE);
    sprintf(str,"%s",buffer);
    free(buffer);
    return str;
}

EXTERN char *cemote_test(int player, int sender, char *text)
{   char *buffer;

    if (ststflg(player,SFL_NO_CHAT) || (psitting(player) == 3) || 
        ststflg(player,SFL_NOCOMM))
        return NULL;
    
    buffer = build_voice_text("Chat:&*",see_name(player,sender),text,"", 
               COLOR_NORMAL_WHITE, COLOR_NONE);
    sprintf(str,"%s",buffer);
    free(buffer);
    return str;
}

PUBLIC void cemotecom()
{
    if (ststflg(mynum,SFL_NOCOMM))
    {  bprintf("Better luck next time, cemote wont work.\n");
       return;
    }
    if (ststflg(mynum,SFL_NO_CHAT))
    {  bprintf("Whats the use of using a channel you aren't listening to?\n");
       return;
    }
    if (jail_check(mynum,LVL_ARCHWIZARD))
    {  bprintf("The gamedriver is very upset and holds your message back\n");
       return;
    }
    if (!ptstflg(mynum,PFL_EMOTE))
    {  bprintf("You aren't up to it yet.\n");
       return;
    }
    if (psitting(mynum) == 3)
    {  bprintf("Your trance is too strong to do that.\n");
       return;
    } 
    getreinput(wordbuf);
    
    if (EMPTY(wordbuf))
       bprintf("What do you want to chat-emote?\n");
    else
       send_g_msg(DEST_ALL,cemote_test,mynum,wordbuf);
}

PUBLIC void chatcom()
{    
    if (ststflg(mynum,SFL_NOCOMM))
    {  bprintf("No chatting for you anymore.\n");
       return;
    }
    if (ststflg(mynum,SFL_NO_CHAT))
    {  bprintf("Why would you want to chat if you dont want to listen?.\n");
       return;
    }
    if (jail_check(mynum,LVL_ARCHWIZARD) )
    {  bprintf("I can understand you want to tell all your friends about this...\n");
       return;
    }
    if (psitting(mynum) == 3)
    {  bprintf("You would loose your trance if you do that.\n");
       return;
    }
    if (global_clock == cur_player->p_last_comm) 
    {
       bprintf ("You need to slow down and enounciate your chats\n");
       return; 
    }
    cur_player->p_last_comm = global_clock;

    getreinput(wordbuf);

    if (EMPTY(wordbuf))
       bprintf("What do you want to chat?\n");
    else
       send_g_msg(DEST_ALL,chat_test,mynum,wordbuf);
}

PUBLIC void wizcom (void)
{
  if (jail_check(mynum,LVL_ARCHWIZARD) )
  {  bprintf("I'm sorry, this room isn't in service right now.\n");
     return;
  }
  getreinput (wordbuf);
  (void) _wiz (LVL_APPRENTICE, wordbuf);
}

PUBLIC void awizcom (void)
{
  getreinput (wordbuf);
  (void) _wiz (LVL_ARCHWIZARD, wordbuf);
}

PUBLIC void godcom (void)
{
  getreinput (wordbuf);
  (void) _wiz (LVL_GOD, wordbuf);
}

PUBLIC void demigodcom (void)
{
  getreinput (wordbuf);
  (void) _wiz (LVL_DEMI, wordbuf);
}

/* handles wiz communication */
PRIVATE void _wiz (const int level, char *text)
{ register int t;
  int plx;
  char *buffer;
  
  if (EMPTY(text))
  {  bprintf("What do you want to say?\n");
     return;
  }

  if (strlen (text) > 230)
    text[230] = '\0';

  if (ststflg (mynum, SFL_NOCOMM))
  {   bprintf("All your comm channels are disabled.\n");
      return;
  }

  if (ststflg (mynum, SFL_NO_WIZ) && level==LVL_APPRENTICE)
  {
      bprintf ("Maybe you should turn NOWIZ off first!\n");
      return;
  } 
  else if (ststflg (mynum, SFL_NO_AWIZ) && level==LVL_ARCHWIZARD)
  {
      bprintf ("Maybe you should turn NOAWIZ off first!\n");
      return;
  } 
  else if (ststflg (mynum, SFL_NO_DGOD) && level==LVL_DEMI)
  {
      bprintf ("Maybe you should turn NODGOD off first!\n");
      return;
  }
  else if (ststflg (mynum, SFL_NO_GOD) && level==LVL_GOD)
  {
      bprintf ("Maybe you should turn NOGOD off first!\n");
      return;
  }

  plx = mynum;

  for (t = 0; t < max_players; t++)
    if (!EMPTY (pname (t)) && plev (t) >= level)
      {
	switch (level) {
	case LVL_APPRENTICE:
            buffer = build_voice_text (see_name(t, plx),
                                       WIZLINE_STR,
                                       wordbuf,
                                       "",
                                       COLOR_NORMAL_WHITE,
                                       COLOR_NORMAL_WHITE);
	    send_msg (t, MODE_COLOR | MODE_NSFLAG | MS(SFL_NO_WIZ), 
	              LVL_APPRENTICE, LVL_MAX, NOBODY, NOBODY,
		      "%s",buffer);
            free(buffer);
	    break;
	case LVL_ARCHWIZARD:
            buffer = build_voice_text (see_name(t, plx),
                                       AWIZLINE_STR,
                                       wordbuf,
                                       "",
                                       COLOR_NORMAL_WHITE,
                                       COLOR_NORMAL_WHITE);
	    send_msg (t, MODE_COLOR | MODE_NSFLAG | MS(SFL_NO_AWIZ), 
	              LVL_ARCHWIZARD, LVL_MAX, NOBODY, NOBODY,
		      "%s",buffer);
            free(buffer);
	    break;
	case LVL_DEMI:
            buffer = build_voice_text (see_name(t,plx),
                                       DGODLINE_STR,
                                       wordbuf,
                                       "",
                                       COLOR_NORMAL_WHITE,
                                       COLOR_NORMAL_WHITE);
	    send_msg (t, MODE_COLOR | MODE_NSFLAG | MS(SFL_NO_DGOD), 
	              LVL_DEMI, LVL_MAX, NOBODY, NOBODY,
		      "%s",buffer);
            free(buffer);
	    break;
	case LVL_GOD:
            buffer = build_voice_text (see_name(t, plx),
                                       GODLINE_STR,
                                       wordbuf,
                                       "",
                                       COLOR_NORMAL_WHITE,
                                       COLOR_NORMAL_WHITE);
	    send_msg (t, MODE_COLOR | MODE_NSFLAG | MS(SFL_NO_GOD), 
	              LVL_GOD, LVL_MAX, NOBODY, NOBODY,
		      "%s",buffer);
            free(buffer);
	    break;
	default:
	    mudlog ("ERROR: case slip in xwiz.\n");
	    break;
	} /* End switch */
     }
}