Finger Command
--------------

Original code by unknown author
Version 2.0 and 3.0 code by Samson of Alsherok

Terms of Use
------------

1. You may use this snippet in your code provided that any included
comment headers in the code are left intact. You may add your own, but
do not take mine out.

2. This snippet may not be posted for redistribution on any site
without obtaining prior written consent from the Alsherok team.

3. ( optional ) Register with the forums at http://forums.alsherok.net
Registration is not required to make use of the snippet, but since I no
longer provide email support for any of the code I release, forum posts
are your only avenue for direct support. This may seem overly stupid,
but you can blame the continuing abuse I suffer from spammers for this.
Don't post stuff to TMC or TMS asking about my code. I'm highly unlikely
to ever notice it there on the rare ocassions I skim posts in either place.

If forum registration doesn't appeal to you, then you can try to get ahold
of me via IMC on the code channel.

If you can't agree to these terms, don't use this code, and don't expect
me to help if something breaks while installing it. Harsh? Hardly. I'm
tired of people who come crawling to whine and complain when they haven't
bothered to comply with the terms first.

What this code does
-------------------

This code adds 5 commands to your mud:

'finger' 'email' 'wizinfo' 'icq' and 'privacy'

1. finger - Displays a short screen of information about whichever player
   is specified. Includes protections against getting immortal information.

2. email - Lets the player input an email address for others to see on the
   finger display. Also adds itself to the wizinfo table for immortals.

3. wizinfo - Displays the information in the wizinfo table for immortals.
   Recommended that this be set as an immortal only command.

4. icq - Lets the player input their ICQ number if they have one for others
   to see on the finger display. Also adds itself to the wizinfo table for
   immortals.

5. privacy - If a player enables this toggle, their finger information will
   not be displayed to other players. Immortals can still view it.

Code is also tied into the makewizlist command to rebuild the wizinfo
table on demand. This code also replaces the stock 'homepage' command.

Installation Instructions
-------------------------

1. To install this code:

   Copy finger.c and finger.h to your source directory.
   Add finger.o and finger.c to the appropriate sections of the Makefile.

2. Find the following code in mud.h:

	#define LEVEL_HIGOD		    LEVEL_GOD

      and below it add: #include "finger.h"

   Find the pc_data structure and add the following to it:

   char *email; /* Email address for finger - Samson */
   int icq; /* ICQ# for finger - Samson 1-4-99 */

   Locate this section: /* Bits for pc_data->flags. */

    In an available BV slot, add:

   #define PCFLAG_PRIVACY		   BVXX /* Added by Samson 6-11-99 Finger privacy */
   substituting the number for XX
   
3. In save.c, find function load_char_obj

   Locate the following lines:

    ch->pcdata->last_ignored		= NULL;
    ch->pcdata->tell_history		= NULL;	/* imm only lasttell cmnd */
    ch->pcdata->lt_index		= 0;	/* last tell index */
    ch->morph                           = NULL;

   And add the following lines after that:

   ch->pcdata->email = NULL; /* Initialize email address - Samson 1-4-99 */
   ch->pcdata->homepage = NULL; /* Initialize homepage - Samson 1-4-99 */
   ch->pcdata->icq = 0; /* Initalize icq# - Samson 1-4-99 */

  Further down, locate the following lines:

	ch->pcdata->bestowments	= str_dup( "" );
	ch->pcdata->title		= STRALLOC( "" );
	ch->pcdata->homepage	= str_dup( "" );

  And add the following lines below them:

      ch->pcdata->email = str_dup( "" ); /* Samson 4-19-98 */
      ch->pcdata->icq = 0; /* Samson 1-4-99 */

  Locate function fread_char, and find the following lines:

	case 'I':
	    if(!strcmp(word, "Ignored"))
	    {
	    	char *temp;
	    	char fname[1024];
	    	struct stat fst;
	    	int ign;
	    	IGNORE_DATA *inode;

  Insert the following line right below the case 'I':

	    KEY( "ICQ",	ch->pcdata->icq, fread_number( fp ) );

  Further down, locate the following lines:

		if (!ch->pcdata->bestowments)
		  ch->pcdata->bestowments = str_dup( "" );
		if (!ch->pcdata->title)
		  ch->pcdata->title	= STRALLOC( "" );
		if (!ch->pcdata->homepage)
		  ch->pcdata->homepage	= str_dup( "" );

  Add the following lines right after them:

               if( !ch->pcdata->email )
                  ch->pcdata->email = str_dup( "" );

  Further down, locate the following lines:

	    KEY( "Exp",		ch->exp,		fread_number( fp ) );
	    break;

	case 'T':
	    if ( !strcmp( word, "Tongue" ) )

  Above the KEY for exp, add the following line:

	    KEY( "Email", ch->pcdata->email, fread_string_nohash( fp ) );

  Locate function fwrite_char, and find the following lines:

	if ( ch->pcdata->bestowments && ch->pcdata->bestowments[0] != '\0' )
	  fprintf( fp, "Bestowments  %s~\n", 	ch->pcdata->bestowments );
	fprintf( fp, "Title        %s~\n",	ch->pcdata->title	);
	if ( ch->pcdata->homepage && ch->pcdata->homepage[0] != '\0' )
	  fprintf( fp, "Homepage     %s~\n",	ch->pcdata->homepage	);

  Add the following lines immediately below those:

   if( ch->pcdata->email && ch->pcdata->email[0] != '\0' ) /* Samson 4-19-98 */
      fprintf( fp, "Email        %s~\n", ch->pcdata->email );
   if( ch->pcdata->icq > 0 ) /* Samson 1-4-99 */
      fprintf( fp, "ICQ          %d\n", ch->pcdata->icq );

    Locate the following lines:

   /*
    * Save immortal stats, level & vnums for wizlist    -Thoric
    * and do_vnums command
    *
    * Also save the player flags so we the wizlist builder can see
    * who is a guest and who is retired.
    */
   if( ch->level >= LEVEL_IMMORTAL )
   {
      sprintf( strback, "%s%s", GOD_DIR, capitalize( ch->pcdata->filename ) );

      if( ( fp = fopen( strback, "w" ) ) == NULL )
      {
         perror( strsave );
         bug( "Save_god_level: fopen", 0 );
      }
      else
      {
         fprintf( fp, "Level        %d\n", ch->level );
         fprintf( fp, "Pcflags      %d\n", ch->pcdata->flags );
         if( ch->pcdata->r_range_lo && ch->pcdata->r_range_hi )
            fprintf( fp, "RoomRange    %d %d\n", ch->pcdata->r_range_lo, ch->pcdata->r_range_hi );
         if( ch->pcdata->o_range_lo && ch->pcdata->o_range_hi )
            fprintf( fp, "ObjRange     %d %d\n", ch->pcdata->o_range_lo, ch->pcdata->o_range_hi );
         if( ch->pcdata->m_range_lo && ch->pcdata->m_range_hi )
            fprintf( fp, "MobRange     %d %d\n", ch->pcdata->m_range_lo, ch->pcdata->m_range_hi );
         fclose( fp );
      }
   }

    Replace them with these lines:

   /*
    * Save immortal stats, level & vnums for wizlist - Thoric
    * and do_vnums command
    *
    * Also save the player flags so we the wizlist builder can see
    * who is a guest and who is retired.
    */
   if( ch->level >= LEVEL_IMMORTAL )
   {
      snprintf( strback, MAX_INPUT_LENGTH, "%s%s", GOD_DIR, capitalize( ch->pcdata->filename ) );

      if( !( fp = fopen( strback, "w" ) ) )
      {
         perror( strsave );
         bug( "%s: God file cannot be written.", __FUNCTION__ );
      }
      else
      {
         fprintf( fp, "Level        %d\n", ch->level );
         fprintf( fp, "Pcflags      %d\n", ch->pcdata->flags );
         if( ch->pcdata->homepage && ch->pcdata->homepage[0] != '\0' )
            fprintf( fp, "Homepage     %s~\n", ch->pcdata->homepage );
         if( ch->pcdata->r_range_lo && ch->pcdata->r_range_hi )
            fprintf( fp, "RoomRange    %d %d\n", ch->pcdata->r_range_lo, ch->pcdata->r_range_hi	);
         if( ch->pcdata->o_range_lo && ch->pcdata->o_range_hi )
            fprintf( fp, "ObjRange     %d %d\n", ch->pcdata->o_range_lo, ch->pcdata->o_range_hi	);
         if( ch->pcdata->m_range_lo && ch->pcdata->m_range_hi )
            fprintf( fp, "MobRange     %d %d\n", ch->pcdata->m_range_lo, ch->pcdata->m_range_hi	);
         if( ch->pcdata->email && ch->pcdata->email[0] != '\0' )
            fprintf( fp, "Email        %s~\n", ch->pcdata->email );
         if( ch->pcdata->icq > 0 )
            fprintf( fp, "ICQ          %d\n", ch->pcdata->icq );
         fprintf( fp, "End\n" );
         fclose( fp );
         fp = NULL;
      }
   }

4. In db.c

   Locate function free_char, and find the following lines:

	STRFREE( ch->pcdata->title	);
	STRFREE( ch->pcdata->bio	); 
	DISPOSE( ch->pcdata->bestowments ); /* no hash */
	DISPOSE( ch->pcdata->homepage	);  /* no hash */

   And add the following line below them:

      DISPOSE( ch->pcdata->email ); /* no hash */

   Locate the following lines in boot_db:

    log_string( "Making wizlist" );
    make_wizlist( );

   Below them, add these lines:

   log_string( "Building wizinfo" );
   build_wizinfo( TRUE );

   Locate function do_make_wizlist, and replace it with the following:

void do_makewizlist( CHAR_DATA *ch, char *argument )
{
  make_wizlist( );
  build_wizinfo( FALSE );
}

5. In player.c, find and comment out the function do_homepage.

6. In tables.c, add the appropriate entries for 
   do_finger, do_email, do_wizinfo, do_icq_number, and do_privacy

7. Add the text in finger.help to your help.are file.

8. Make clean, then recompile.

9. Create commands for 'finger' 'email' 'wizinfo' 'icq' and 'privacy'
   setting them to your desired levels.

If there are any problems with this installation, feel free to post your
question to the forums at http://forums.alsherok.net

This code has been installed and tested on Smaug 1.6 FUSS, which is a bugfixed
and cleaned up version of the base Smaug 1.4a code. The Smaug FUSS Project is
maintained on servers which run the Redhat and Fedora family of Linux. Limited
testing has also been done on the Cygwin package under WindowsXP SP1 and SP2.
Users of BSD, MSVC, MSVC++, or Macintosh platforms are on their own as The
Smaug FUSS Project does not have access to these development environments for testing.
The Smaug FUSS Project can be found at: http://www.smaugfuss.org

No guarantees are made that this code will be compatible with your codebase and any
modifications you may have made to it. No warranty of any kind is expressed or implied
by the use of this code, and we are not responsible for any damages which may result
from the application of this snippet to your codebase.

Adventure beckons in the lands of mystique....
Samson, Implementor of Alsherok
http://www.alsherok.net
telnet://alsherok.net:5500

IMC2 contact: Samson@Alsherok