finger.c
DBZu/src/finger.c · 5.9 KB
From the archive DBZu.zip
Download the archive « Back to the archive contents
#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
#include "mud.h"
#if defined(KEY)
#undef KEY
#endif
#define KEY( literal, field, value ) \
if ( !str_cmp( word, literal ) ) \
{ \
field = value; \
fMatch = TRUE; \
break; \
}
bool check_parse_name args( ( char *name, bool newchar ) );
void do_finger( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim = NULL;
CMDTYPE *command;
ROOM_INDEX_DATA *temproom, *original = NULL;
int level = LEVEL_IMMORTAL;
char buf[MAX_STRING_LENGTH], fingload[MAX_INPUT_LENGTH];
struct stat fst;
char *laston = NULL;
bool loaded = FALSE, skip = FALSE;
if( IS_NPC(ch) )
{
send_to_char( "Mobs can't use the finger command.\n\r", ch );
return;
}
if( !argument || argument[0] == '\0' )
{
send_to_char( "Finger whom?\n\r", ch );
return;
}
sprintf( buf, "0.%s", argument );
if( ( victim = get_char_world( ch, buf ) ) != NULL )
{
if ( IS_IMMORTAL(victim) && !IS_IMMORTAL(ch) )
{
send_to_char( "You cannot finger an immortal.\n\r", ch );
return;
}
}
/* Check for offline players */
else
{
DESCRIPTOR_DATA *d;
sprintf( fingload, "%s%c/%s", PLAYER_DIR, tolower(argument[0]), capitalize( argument ) );
/* Bug fix stop /dev/null crash */
if( stat( fingload, &fst ) == -1 || !check_parse_name( capitalize( argument ), FALSE ) )
{
ch_printf( ch, "&YNo such player named '%s'.\n\r", argument );
return;
}
/*laston = ctime( &fst.st_mtime );*/
temproom = get_room_index( ROOM_VNUM_LIMBO );
if( !temproom )
{
bug( "%s", "do_finger: Limbo room is not available!" );
send_to_char( "Fatal error, report to the immortals.\n\r", ch );
return;
}
CREATE( d, DESCRIPTOR_DATA, 1 );
d->next = NULL;
d->prev = NULL;
d->connected = CON_GET_NAME;
d->outsize = 2000;
CREATE( d->outbuf, char, d->outsize );
argument[0] = UPPER( argument[0] );
loaded = load_char_obj( d, argument, FALSE, FALSE );
LINK( d->character, first_char, last_char, next, prev );
original = d->character->in_room;
char_to_room( d->character, temproom );
victim = d->character; /* Hopefully this will work, if not, we're SOL */
d->character->desc = NULL;
d->character = NULL;
DISPOSE( d->outbuf );
DISPOSE( d );
/* Link dead check? Was crashing on "IP Info" line below */
if (!victim->desc)
loaded = FALSE;
if( IS_IMMORTAL(victim) && !IS_IMMORTAL(ch) )
{
send_to_char( "You cannot finger an immortal.\n\r", ch );
skip = TRUE;
}
loaded = TRUE;
}
if( !skip )
{
send_to_char( "&z Finger Info\n\r", ch );
send_to_char( "&c -----------\n\r", ch );
ch_printf( ch, "&zName&O :&W %-20s &zMUD Age&O: &w%d\n\r", victim->name, get_age( victim ) );
/* ch_printf( ch, "&zRace&O : &w%s\n\r",
capitalize( get_race(victim) ) ); */
ch_printf( ch, "&zSex : &w%-20s\n\r",
victim->sex == SEX_MALE ? "Male" :
victim->sex == SEX_FEMALE ? "Female" : "Neutral" );
ch_printf( ch, "&zTitle&O : &w%s\n\r", victim->pcdata->title );
ch_printf( ch, "&zEmail&O : &w%s\n\r", victim->pcdata->email != NULL ? victim->pcdata->email : "Not specified" );
ch_printf( ch, "&zAIM&O : &w%d\n\r", victim->pcdata->aim );
if (victim->pcdata->clan)
ch_printf( ch, "&zClan&O : &G%s\n\r", victim->pcdata->clan->name );
if( loaded )
ch_printf( ch, "&zLast on&O : &W%s\n\r", ctime( &victim->pcdata->lastlogon ) );
else
ch_printf( ch, "&zLast on&O : &RCurrently Online\n\n\r", laston );
if ( IS_IMMORTAL(ch) )
{
send_to_char( "&wImmortal Information\n\r", ch );
send_to_char( "--------------------\n\r", ch );
/* ch_printf( ch, "&wIP Info : &G%s\n\r", loaded ? "Unknown" : victim->desc->host ); */
ch_printf( ch, "&wTime played : &G%ld hours\n\r", (long int)GET_TIME_PLAYED( victim ) );
ch_printf( ch, "&wAuthorized by : &G%s\n\r",
victim->pcdata->authed_by ? victim->pcdata->authed_by : ( sysdata.WAIT_FOR_AUTH ? "Not Authed" : "TheCode" ) );
if( victim->level < ch->level )
{
/* Added by Tarl 19 Dec 02 to remove Huh? when ch not high enough to view comments. */
command = find_command( "comment" );
if( !command )
level = LEVEL_IMMORTAL;
else
level = command->level;
if( ch->level >= command->level )
{
sprintf( buf, "comment list %s", victim->name );
interpret( ch, buf );
}
}
}
// pager_printf_color (ch, "\n\r&wDescription:\n\r&G%s\n\r", victim->description ? victim->description : "Not created" );
}
if( loaded )
{
int x, y;
char_from_room( victim );
char_to_room( victim, original );
quitting_char = victim;
/*save_char_obj( victim );*/
if( sysdata.save_pets && victim->pcdata->pet )
extract_char( victim->pcdata->pet, TRUE );
saving_char = NULL;
extract_char( victim, TRUE );
for ( x = 0; x < MAX_WEAR; x++ )
for ( y = 0; y < MAX_LAYERS; y++ )
save_equipment[x][y] = NULL;
}
return;
}