FINGER UTILITY
--------------

1) Add the following function prototypes to mud.h:

   DECLARE_DO_FUN( do_finger       );
   void    save_finger     args( ( CHAR_DATA *ch ) );
   void    fwrite_finger   args( ( CHAR_DATA *ch, FILE *fp ) );
   void    read_finger     args( ( CHAR_DATA *ch, char *argument ) );
   void    fread_finger    args( ( CHAR_DATA *ch, FILE *fp ) );

2) Put the "do_finger" function in player.c, like this:

/** BEGIN FUNCTION **/
void do_finger( CHAR_DATA *ch, char *argument )
{
  char buf[MAX_STRING_LENGTH];
  char arg[MAX_INPUT_LENGTH];
  CHAR_DATA *victim;

  buf[0] = '\0';
  if(IS_NPC(ch))
     return;

  if ( argument[0] == '\0' )
  {
      send_to_char("Finger whom?\n\r", ch );
      return;
  }

  victim = get_char_world(ch, argument);
  if ( ( victim == NULL ) || (!victim) )
  {
      read_finger( ch, argument );
      return;
  }
  if ( !can_see( ch, victim ) )
  {
      send_to_char("They aren't here.\n\r", ch );
      return;
  }

  if  ( IS_NPC( victim ) )
  {
      send_to_char("Not on NPC's.\n\r", ch );
      return;
  } 

  send_to_char("          Finger Info\n\r", ch);
  send_to_char("          -----------\n\r", ch);
  ch_printf(ch, "&CName: &W%-12s\n\r", victim->name);
  ch_printf(ch, "&CMud Age: &W%2d\n\r", get_age( victim ));
  ch_printf(ch, "&CLevel: &W%2d             &CSex: &W%s\n\r",
                victim->level,
                victim->sex == SEX_MALE   ? "male"   :
                victim->sex == SEX_FEMALE ? "female" : "neutral" );
  ch_printf(ch, "&CClass: &W%-10s     &CRace: &W%s\n\r",
     npc_class[victim->class], npc_race[victim->race] );
  ch_printf(ch, "&CTitle: &W%s\n\r", victim->pcdata->title );
  ch_printf(ch, "&CLast on: &W%s\n\r", (char *) ctime( &ch->logon ) );
  return;

}
/** END FUNCTION  **/

3) Add this function to save.c:

/** BEGIN FUNCTION **/
void read_finger( CHAR_DATA *ch, char *argument )
{
  FILE *fp;
  char buf [ MAX_STRING_LENGTH ];
  char fingload [ MAX_INPUT_LENGTH ];
  char arg [ MAX_INPUT_LENGTH ];
  char arg2 [ MAX_INPUT_LENGTH ];

  buf[0] = '\0';

  /* This names the player finger file Joe.F in the player's directory.
   * If you want a different extension for your finger files, 
   * then just change the "F" to whatever extension you want.
   * BE SURE if you change the extension here, to change it in the
   * save_finger function
   */
  sprintf( fingload, "%s%c/%s.F", PLAYER_DIR, tolower(argument[0]),
                     capitalize( argument ) );
                     
  fclose(fpReserve); 
  if ( !( fp = fopen ( fingload, "r" ) ) )
  {
    sprintf( buf, "Load_finger_Info: fopen %s ", argument );
    bug( buf, 0 );
    perror( fingload );
    ch_printf(ch, "The character %s doesn't exist.\n\r", argument );
  }
  else
     fread_finger ( ch, fp );

  fclose( fp );
  fpReserve = fopen( NULL_FILE, "r" );
  return;
} 
/** END FUNCTION  **/

4) Add this function to save.c:

/** BEGIN FUNCTION **/
void fread_finger ( CHAR_DATA *ch, FILE *fp )
{  
  char *finger;
  char  buf[MAX_STRING_LENGTH];
  
  buf[0] = '\0';
   
  send_to_char("          Finger Info\n\r");
  send_to_char("          -----------\n\r\n\r");
  finger = fread_string( fp );
  ch_printf(ch, "%s\n\r", finger);
  return;
}
/** END FUNCTION **/

5) Add this function to save.c:

/** BEGIN FUNCTION **/
void fwrite_finger( CHAR_DATA *ch, FILE *fp )
{  
  fprintf( fp, "&CName: &W%s\n",                ch->name        );
  fprintf( fp, "&CMud Age: &W%-13d\n\r",            get_age( ch )   );
  fprintf( fp, "&CLevel: &W%-16d",              ch->level       );
  fprintf( fp, "&CSex: &W%s\n",   ch->sex == SEX_MALE ? "male" :  
                        ch->sex == SEX_FEMALE ? "female" : "neutral" );
  fprintf( fp, "&CClass: &W%-15s",      capitalize(get_class(ch)) );   
  fprintf( fp, "&CRace: &W%s\n",        capitalize(get_race(ch)) ); 
  fprintf( fp, "&CTitle: &W%s\n",                       ch->pcdata->title );
  fprintf( fp, "&CLast On: &W%s~\n", (char * ) ctime(&ch->logon) );
  return;
}
/** END FUNCTION **/

6) Also add this function to save.c:

/** BEGIN FUNCTION **/
void save_finger( CHAR_DATA *ch )
{
    FILE *fp;
    char buf [MAX_STRING_LENGTH];
    char fng [MAX_INPUT_LENGTH];
 
    if( IS_NPC(ch) || ch->level < 2 )
        return;
    if ( ch->desc && ch->desc->original )
        ch = ch->desc->original;
  /* This names the player finger file Joe.F in the player's directory.
   * If you want a different extension for your finger files, 
   * then just change the "F" to whatever extension you want.
   * BE SURE if you change the extension here, to change it in the
   * read_finger function
   */  
    sprintf( fng, "%s%c/%s.F", PLAYER_DIR, tolower(ch->name[0]),
                     capitalize( ch->name ) );
    fclose(fpReserve);
    if( !(fp = fopen(fng, "w")) )
    {                
        sprintf( buf, "Save_finger: fopen %s ", ch->name);
        bug( buf, 0 );
        perror(fng);
    }
    else
        fwrite_finger( ch, fp );

    fclose(fp);
    fpReserve = fopen( NULL_FILE, "r" );
    return;
}

/** END FUNCTION **/

7) Add this line to tables.c:
   Search for do_fill and put this line right below it:

   if ( !str_cmp( name, "do_finger" ))             return do_finger;

   Search for do_fill again and put this line right below it:
   if ( skill == do_finger )           return "do_finger";

NOTE: If you've added new commands, just place the above two lines in the proper
alphabetical order. In stock smaug, that would be directly below do_fill.


8) In act_comm.c, in the do_quit function add:

    save_finger( ch );
   Right below the save_char_obj( ch ); line.

   In the do_save function add:

    save_finger( ch );
   Right below the save_char_obj( ch );

This way whenever anyone quits, their finger info is saved and whenever they type
save, obviously their finger info gets saved.


DO NOT FORGET TO DO A "MAKE CLEAN" when you are done.

Also, in order to use the finger command you must create the command for it in
commands.dat. You can do this online, using the cedit command.