/***********************************************************************************************************
 * This is my finger code that I made for Rom 2.4b6 I couldn't find a Working Finger type command and the  *
 * common do_whois on ROM was just boring, and well Doesn't do well if the immortal needs to see the IP    *
 * address of a player that isn't logged on incase he/she broke a rule and needs to be banned etc. And the *
 * Players cannot see what race/class/sex of other players and any other info you put in if the player is  *
 * Not logged in, with the common do_whois So here is my do_finger code for rom, I hope the explanation on *
 * How to add it in is good enough any questions or comments                                               *
 * Email: cherun@tampabay.net                                                                              *
 * Aim: ms1 phr34k                                                                                         *
 * I do not ask for credit but if you use it just drop me a line and tell me what you think of it Maybe I  *
 * will touch it up more and throw out a better one for the newer coders out there                         *
 *                                                                                                         *
 * Cherun Owner of Chaos Ring.                                                                             *
 ***********************************************************************************************************/

//Anything that has // before it is a instruction.

//First off open merc.h and Find the line
CD *    get_char_world    args( ( CHAR_DATA *ch, char *argument ) );
//Add underneath that line, this allows you to see player info if they are offline
CD *	get_char_finger	args( ( CHAR_DATA *ch, char *argument ) );

//Now find the class_type table, we are adding in a new field so when you finger
//a Player their Class shows up as Warrior instead of warrior with a lowercase it
//Also allows you to color it in so class looks purty on do_finger.
//So now find class_type and find the line in it that looks like this
char    who_name    [11];   /* Three-letter name for 'who' */
//Add underneath that this line.
char *  finger_name;		/* For do_finger Class output */

//Now in mob_index_data you need to find the line
char *            description;
//Add underneath that
char *			  lasthost;

//Now in char_data You need to find the line
char *             prefix;
//Add underneath that
char *			  lasthost;


//Ok now Open up interp.h file and find the line
DECLARE_DO_FUN(	do_fill			);
//Add underneath it
DECLARE_DO_FUN(	do_finger		);

//Now open up interp.c and find the line
{"wimpy",		do_wimpy,	POS_DEAD,	0, LOG_NORMAL, 1},
//Underneath that line add
{"finger",		do_finger,	POS_DEAD,	0, LOG_NORMAL, 1},

//Ok Now you need to open up the const.c File this is where we will
//Add the new field to class_table so that in finger You can have Capital
//Letters for the class output OR color it or both however you want it.
//So find the class_table and and it will look something like this
{
     "mage", "Mag", STAT_INT, OBJ_VNUM_SCHOOL_DAGGER,
     {3018, 9618}, 75, 20, 6, 6, 8, TRUE,
     "mage basics", "mage default" },

//What we need to do is after the "Mag", add "Mage", You may color it but this
//Is just the basics of it So now your "mage" info should look like this
{
     "mage", "Mag", "Mage", STAT_INT, OBJ_VNUM_SCHOOL_DAGGER,
     {3018, 9618}, 75, 20, 6, 6, 8, TRUE,
     "mage basics", "mage default" },
//You must do this to all classes in class_table.

//Now open up the file act_comm.c and go to the do_quit function
//Find the part that looks like this
id = ch->id;
    d = ch->desc;
    extract_char (ch, TRUE);
//Add Right after the extract_char (ch, TRUE); this
ch->lasthost = str_dup(d->host);

//Now open up nanny.c and find CON_GET_OLD_PASSWORD and find the line
//That looks like this
sprintf (log_buf, "%s@%s has connected.", ch->name, d->host);
            log_string (log_buf);
            wiznet (log_buf, NULL, NULL, WIZ_SITES, 0, get_trust (ch));
//Add after it
ch->lasthost = str_dup(d->host);

//Now find CON_GET_NEW_CLASS and find the line
sprintf (log_buf, "%s@%s new player.", ch->name, d->host);
            log_string (log_buf);
//Add after it
ch->lasthost = str_dup(d->host);

//Now that thats done, Lets open up save.c Here is where the majority of the stuff goes.
//Find the line that looks like this under fwrite_char
fprintf (fp, "Name %s~\n", ch->name);
//Add underneath it this
fprintf(fp, "Lasthost %s~\n", ch->lasthost);

//Now find the line in load_char_obj that looks like this
ch->name = str_dup (name);
//Add underneath it
ch->lasthost = str_dup("");

//Now find the line
 KEY ("LastLevel", ch->pcdata->last_level, fread_number (fp));
//Add underneath that
KEY("Lasthost",	ch->lasthost,	fread_string( fp ) );

//Now at the VERY END of save.c after EVERYTHING add this:
void do_finger( CHAR_DATA *ch, char *argument )
{
    char strsave[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    char letter;
    CHAR_DATA *victim;
    FILE *fp;
    char *word;
    bool fMatch;
    bool drop_out = FALSE;

    char *f_name	= capitalize( argument );
    char *f_title	= "";
    int   f_sex		= 0;
    int   f_race	= race_lookup("");
    int	  f_class	= class_lookup("");
    char *f_lasthost	= "";

    if ( IS_NPC(ch) ) return;

    if (!check_parse_name( argument ))
    {
	send_to_char( "Thats an illegal name.\n\r", ch );
	return;
    }

    if ( ( victim = get_char_finger( ch, argument ) ) != NULL )
    {
	f_title		= victim->pcdata->title;
	f_sex		= victim->sex;
	f_race		= victim->race;
	f_class		= victim->class;
	f_lasthost	= victim->lasthost;
    }
    else
    {
	if ( !char_exists(FILE_PLAYER,argument) )
	{
	    send_to_char( "That player doesn't exist.\n\r", ch );
	    return;
	}

	fflush( fpReserve );
	fclose( fpReserve );
	sprintf( strsave, "%s%s", PLAYER_DIR, capitalize(argument) );
	if ( ( fp = fopen( strsave, "r" ) ) != NULL )
	{
	    if ( ( letter = fread_letter( fp ) ) == EOF)
	    {
		send_to_char("Their playerfile has been corrupted.\n\r",ch);
		fflush( fp );
		fclose( fp );
		fpReserve = fopen( NULL_FILE, "r" );
		return;
	    }
	    fread_to_eol( fp );

	    while ( !drop_out )
	    {
		word   = feof( fp ) ? "End" : fread_word( fp );
		fMatch = FALSE;

		switch ( UPPER(word[0]) )
		{
		default:
		case '*':
		    fMatch = TRUE;
		    fread_to_eol( fp );
		    break;

		case 'C':
			KEY( "Cla",		f_class,	fread_number( fp ) );
			KEY( "Class",	f_class,	fread_number( fp ) );
			break;

		case 'E':
		    if ( !str_cmp( word, "End" ) ) drop_out = TRUE;
		    break;


		case 'L':
			KEY( "Lasthost",	f_lasthost,	fread_string( fp ) );
		    break;

		case 'R':
		    KEY ("Race", f_race, race_lookup (fread_string (fp)));
		    break;

		case 'S':
		    KEY( "Sex",		f_sex,			fread_number( fp ) );
		    break;

		case 'T':
			if (!str_cmp (word, "Title") || !str_cmp (word, "Titl"))
                {
                    f_title = fread_string (fp);
                    if (ch->pcdata->title[0] != '.'
                        && ch->pcdata->title[0] != ','
                        && ch->pcdata->title[0] != '!'
                        && ch->pcdata->title[0] != '?')
                    {
                        sprintf (buf, " %s", f_title);
                        free_string (f_title);
                        f_title = str_dup (buf);
                    }
                    fMatch = TRUE;
                    break;
                }
		    break;
		}
		if ( !fMatch ) fread_to_eol( fp );
	    }
	}
	else
	{
	    bug( "Do_finger: fopen", 0 );
	    perror( strsave );
	}
	fflush( fp );
	fclose( fp );
	fpReserve = fopen( NULL_FILE, "r" );
    }
    send_to_char("--------------------------------------------------------------------------------\n\r",ch);
    sprintf( buf, "%s%s%s.\n\r", f_name, drop_out ? "": "", f_title );
    send_to_char( buf, ch );
    send_to_char("--------------------------------------------------------------------------------\n\r",ch);
	sprintf( buf, "Last Connected from: %s\n\r",
	IS_IMMORTAL(ch) ? f_lasthost : "^^^^.^^^^.^^^^.^^^^" );
	send_to_char(buf, ch );
    sprintf( buf, "Sex: %s. \n\r", 
	f_sex == SEX_MALE ? "Male" : f_sex == SEX_FEMALE ? "Female" : "Neither");
    send_to_char( buf, ch );
	sprintf( buf, "Class: %s.\n\r",
	class_table[f_class].finger_name  );
	send_to_char(buf, ch);
    sprintf( buf, "Race: %s.\n\r",
       pc_race_table[f_race].who_name );
       send_to_char(buf, ch);
    send_to_char("--------------------------------------------------------------------------------\n\r",ch);
    return;
}


/*
 * There you have it do_finger that works on rom! Thank you - Cherun
 */