staff.c

Argila2.0/pp/src/staff.c · 233.1 KB

From the archive Argila2.zip

Download the archive   « Back to the archive contents

/*------------------------------------------------------------------------\
|  staff.c : Staff Command Module                     www.yourmud.org     | 
|  Copyright (C) 2006, Project Argila: Auroness                           |
|                                                                         |
|  All rights reserved. See Licensing documents included.                 |
|                                                                         |
|  Based upon Shadows of Isildur RPI Engine                               |
|  Copyright C. W. McHenry [Traithe], 2004                                |
|  Derived under license from DIKU GAMMA (0.0).                           |
\------------------------------------------------------------------------*/

#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <mysql/mysql.h>

#include "structs.h"
#include "protos.h"
#include "utils.h"
#include "decl.h"
#include "sys/stat.h"

extern char *player_bits[];
extern char *exit_bits[];

#define IMOTE_OPCHAR '^'

void do_guide (CHAR_DATA *ch, char *argument, int cmd)
{
	ACCOUNT_DATA	*account = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};

	if ( !IS_SET (ch->flags, FLAG_GUEST) ) {
		send_to_char ("Sorry, but only guests may use this command.\n", ch);
		return;
	}

	if ( ch->pc->is_guide ) {
		send_to_char ("You've already logged in as a Guide.\n", ch);
		return;
	}

	if ( !ch->desc->account || !str_cmp (ch->desc->account->name, "Guest") ) {
		send_to_char ("Sorry, but your guest login was not matched to an account.\n", ch);
		return;
	}

	account = load_account (ch->desc->account->name);

	if ( !account ) {
		send_to_char ("Sorry, but your guest login was not matched to an account.\n", ch);
		return;
	}

	if ( !is_guide (account->name) ) {
		send_to_char ("Your account has not been granted Guide status by the staff.\n", ch);
		free_account (account);
		return;
	}

	if ( !*argument ) {
		send_to_char ("You'll need to include the password to your account.\n", ch);
		free_account (account);
		return;
	}

	argument = one_argument (argument, buf);

	if ( !check_password (buf, account->pwd) ) {
		send_to_char ("Sorry, but you've entered an incorrect password.\n", ch);
		free_account (account);
		return;
	}


	ch->pc->is_guide = TRUE;
	send_to_char ("You have successfully logged in and been granted Guide status.\n", ch);
	
	return;
}

CHAR_DATA *is_switched (CHAR_DATA *ch)
{
	CHAR_DATA *tch = NULL;

	for ( tch = character_list; tch; tch = tch->next ) {
		if ( tch->deleted )
			continue;
		if ( !tch->desc )
			continue;
		if ( tch->desc->original && tch->desc->original == ch )
			return tch;
	}

	return NULL;
}

void do_assign (CHAR_DATA *ch, char *argument, int cmd)
{
	char		buf [MAX_STRING_LENGTH] = {'\0'};
	char		buf2 [MAX_STRING_LENGTH] = {'\0'};
	char		admin [MAX_STRING_LENGTH] = {'\0'};
	char		clan [MAX_STRING_LENGTH] = {'\0'};

	if ( !*argument ) {
		send_to_char ("Usage: assign (add | remove) <admin name> (<clan name>)\n", ch);
		return;
	}

	argument = one_argument (argument, buf);

	if ( str_cmp (buf, "add") && str_cmp (buf, "remove") ) {
		send_to_char ("Usage: assign (add | remove) <admin name> (<clan name>)\n", ch);
		return;
	}

	argument = one_argument (argument, admin);
	argument = one_argument (argument, buf2);

	mysql_real_escape_string (database, clan, buf2, strlen(buf2));

	if ( !*admin ) {
		send_to_char ("Usage: assign (add | remove) <admin name> (<clan name>)\n", ch);
		return;
	}

	if ( islower (*admin) )
		*admin = toupper (*admin);

	if ( *clan && islower (*clan) )
		*clan = toupper (*clan);

	if ( !str_cmp (buf, "add") ) {
		mysql_safe_query ("INSERT INTO clan_assignments VALUES ('%s', '%s')", clan, admin);
		send_to_char ("The specified assignment has been added to the database.\n", ch);
		return;
	}
	else if ( !str_cmp (buf, "remove") ) {
		if ( *clan )
			mysql_safe_query ("DELETE FROM clan_assignments WHERE clan_name = '%s' AND imm_name = '%s'", clan, admin);
		else
			mysql_safe_query ("DELETE FROM clan_assignments WHERE imm_name = '%s'", admin);
		
		if ( *clan )
			send_to_char ("The specified assignment has been removed from the database.\n", ch);
		else
			send_to_char ("All clan assignments for the specified admin have been removed.\n", ch);
		return;
	}

	send_to_char ("Usage: assign (add | remove) <admin name> <clan name>\n", ch);
	return;
}

void do_roster (CHAR_DATA *ch, char *argument, int cmd)
{
	CHAR_DATA	*tch = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};
	char		buf2 [MAX_STRING_LENGTH] = {'\0'};
	char		admin [MAX_STRING_LENGTH] = {'\0'};
	char		title [MAX_STRING_LENGTH] = {'\0'};

	if ( !*argument ) {
		send_to_char ("Usage: roster (add | remove) <admin name> (<title>)\n", ch);
		return;
	}

	argument = one_argument (argument, buf);

	if ( str_cmp (buf, "add") && str_cmp (buf, "remove") ) {
		send_to_char ("Usage: roster (add | remove) <admin name> (<title>)\n", ch);
		return;
	}

	argument = one_argument (argument, admin);
	argument = one_argument (argument, buf2);

	mysql_real_escape_string (database, title, buf2, strlen(buf2));

	if ( !*admin || (!*title && !str_cmp (buf, "add")) ) {
		send_to_char ("Usage: roster (add | remove) <admin name> (<title>)\n", ch);
		return;
	}

	if ( islower (*admin) )
		*admin = toupper (*admin);

	if ( islower (*title) )
		*title = toupper (*title);

	if ( !str_cmp (buf, "add") && !(tch = load_pc (admin)) ) {
		send_to_char ("That PC could not be found in our database.\n", ch);
		return;
	}

	if ( !str_cmp (buf, "add") && tch->pc->level < 3 ) {
		send_to_char ("All staff listed on the roster must be at least level 3.\n", ch);
		return;
	}

	if ( tch )
		unload_pc (tch);

	if ( !str_cmp (buf, "add") ) {
		mysql_safe_query ("INSERT INTO staff_roster VALUES ('%s', '%s', %d)", admin, title, (int)time(0));
		send_to_char ("The specified individual has been added to the staff roster.\n", ch);
		return;
	}
	else if ( !str_cmp (buf, "remove") ) {
		mysql_safe_query ("DELETE FROM staff_roster WHERE name = '%s'", admin);
		mysql_safe_query ("DELETE FROM clan_assignments WHERE imm_name = '%s'", admin);
		send_to_char ("The specified individual has been removed from the roster.\n", ch);
		return;
	}

	send_to_char ("Usage: roster (add | remove) <admin name> (<title>)\n", ch);
	return;
}

void do_nuke (CHAR_DATA *ch, char *argument, int cmd)
{
	ACCOUNT_DATA	*account = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	char			buf2 [MAX_STRING_LENGTH] = {'\0'};

	if ( !*argument ) {
		send_to_char ("Nuke which account?\n", ch);
		return;
	}

	*argument = toupper (*argument);
	argument = one_argument (argument, buf);

	if ( !(account = load_account (buf)) ) {
		send_to_char ("There is no account by that name in our database.\n", ch);
		return;
	}

	if ( GET_TRUST (ch) < 5 && account->admin ) {
		send_to_char ("Only level 5 admins may delete other admin accounts.\n", ch);
		return;
	}

	if ( !str_cmp (buf, IMPLEMENTOR_ACCOUNT) ) {
		send_to_char ("Naughty, naughty...\n", ch);
		return;
	}

	if ( !*argument || *argument != '!' ) {
		snprintf (buf2, MAX_STRING_LENGTH,  "Please type \'nuke %s !\', sans quotes, to confirm.\n", buf);
		send_to_char (buf2, ch);
		return;
	}

	mysql_safe_query ("DELETE FROM forum_users WHERE username = '%s'", buf);

	snprintf (buf2, MAX_STRING_LENGTH,  "Account %s has been excised from the database.\n", buf);
	send_to_char (buf2, ch);
	
	return;
}

void do_register (CHAR_DATA *ch, char *argument, int cmd)
{
	ACCOUNT_DATA	*account = NULL;
	int				i = 0;
	char			name [MAX_STRING_LENGTH] = {'\0'};
	char			email [MAX_STRING_LENGTH] = {'\0'};

	argument = one_argument (argument, name);
	argument = one_argument (argument, email);

	if ( !*name || !*email ) {
		send_to_char ("Usage: register <new account name> <email address>\n", ch);
		return;
	}

	if ( strlen(name) > 36 ) {
		send_to_char ("The account name must be 36 characters or less.\n", ch);
		return;
	}

	if ( !isalpha (*name) ) {
		send_to_char ("The first character of the account name MUST be a letter.\n", ch);
		return;
	}

	for ( i = 0; i < strlen(name); i++ ) {
		if ( !isalpha (name [i]) && !isdigit (name [i]) ) {
			send_to_char ("Account names may only contain letters and numbers.\n", ch);
			return;
		}
	}

	*name = toupper (*name);

	if ( !str_cmp (name, "Anonymous") || !str_cmp (name, IMPLEMENTOR_ACCOUNT) ) {
		send_to_char ("That account name cannot be registered.\n", ch);
		return;
	}

	if ( (account = load_account (name)) ) {
		send_to_char ("That account name has already been taken.\n", ch);
		return;
	}

	if ( !strstr (email, "@") || !strstr (email, ".") ) {
		send_to_char ("Email addresses must be given in the form of \'address@domain.com\'.\n", ch);
		return;
	}

	new_accounts++;
	mysql_safe_query ("UPDATE newsletter_stats SET new_accounts=new_accounts+1");

	CREATE (account, ACCOUNT_DATA, 1);

	account->email = str_dup (email);
	account->name = str_dup (name);
	account->created_on = time(0);

	setup_new_account(account);

	send_to_char ("The new account has been registered, and notification has been emailed.\n", ch);
	
	return;
}

void post_log (DESCRIPTOR_DATA *d)
{
	CHAR_DATA	*ch = NULL;
	char		report [MAX_STRING_LENGTH] = {'\0'};

    ch = d->character;
    if ( !*d->pending_message->message ) {
    	send_to_char ("No newsletter report posted.\n", ch);
        return;
    }
        
	mysql_real_escape_string (database, report, d->pending_message->message, strlen(d->pending_message->message));

	if ( !str_cmp (ch->delay_who, "blog") ) {
		mysql_safe_query ("INSERT INTO building_log VALUES ('%s', '%s', %d)", ch->tname,
		report, (int) time(0));
		send_to_char ("Your building report has been filed.\n", ch);
		return;
	}
	
	else if ( !str_cmp (ch->delay_who, "clog") ) {
		mysql_safe_query ("INSERT INTO coding_log VALUES ('%s', '%s', %d)", ch->tname,
		report, (int) time(0));
		send_to_char ("Your coding report has been filed.\n", ch);
		return;
	}
	
	else if ( !str_cmp (ch->delay_who, "plog") ) {
		mysql_safe_query ("INSERT INTO plot_log VALUES ('%s', '%s', %d)", ch->tname,
		report, (int) time(0));
		send_to_char ("Your plot report has been filed.\n", ch);
		return;
	}
	
	else if ( !str_cmp (ch->delay_who, "alog") ) {
		mysql_safe_query ("INSERT INTO announcements VALUES ('%s', '%s', %d)", ch->tname,
		report, (int) time(0));
		send_to_char ("Your announcement has been filed.\n", ch);
		return;
	}
	
	else if ( !str_cmp (ch->delay_who, "wlog") ) {
		mysql_safe_query ("INSERT INTO website_log VALUES ('%s', '%s', %d)", ch->tname,
		report, (int) time(0));
		send_to_char ("Your website update has been filed.\n", ch);
		return;
	}
	
	else send_to_char ("There seems to be a problem with this command.\n", ch);

	ch->delay_who = NULL;
	unload_message (d->pending_message);
	
	return;
}

void do_clog (CHAR_DATA *ch, char *argument, int cmd)
{
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	
	send_to_char ("Enter a coding report to be included in the next newsletter:\n", ch);

    make_quiet (ch);

    CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);

    ch->desc->str = &ch->desc->pending_message->message;
    ch->desc->max_str = MAX_STRING_LENGTH;

	ch->delay_who = str_dup ("clog");

    ch->desc->proc = post_log;
    
    return;
}

void do_alog (CHAR_DATA *ch, char *argument, int cmd)
{
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	send_to_char ("Enter a general staff announcement to be included in the next newsletter:\n", ch);

	make_quiet (ch);

	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);

	ch->desc->str = &ch->desc->pending_message->message;
	ch->desc->max_str = MAX_STRING_LENGTH;

	ch->delay_who = str_dup ("alog");

	ch->desc->proc = post_log;

	return;
}

void do_blog (CHAR_DATA *ch, char *argument, int cmd)
{
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	send_to_char ("Enter a building report to be included in the next newsletter:\n", ch);
	
	make_quiet (ch);
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	
	ch->desc->str = &ch->desc->pending_message->message;
	ch->desc->max_str = MAX_STRING_LENGTH;
	
	ch->delay_who = str_dup ("blog");
	
	ch->desc->proc = post_log;
	
	return;
}

void do_wlog (CHAR_DATA *ch, char *argument, int cmd)
{
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	send_to_char ("Enter a website report to be included in the next newsletter:\n", ch);
	
	make_quiet (ch);
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	
	ch->desc->str = &ch->desc->pending_message->message;
	ch->desc->max_str = MAX_STRING_LENGTH;
	
	ch->delay_who = str_dup ("wlog");
	
	ch->desc->proc = post_log;
	
	return;
}

void do_plog (CHAR_DATA *ch, char *argument, int cmd)
{
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	send_to_char ("Enter a plot report to be included in the next newsletter:\n", ch);
	
	make_quiet (ch);
	
	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	
	ch->desc->str = &ch->desc->pending_message->message;
	ch->desc->max_str = MAX_STRING_LENGTH;
	
	ch->delay_who = str_dup ("plog");
	
	ch->desc->proc = post_log;
	
	return;
}

void do_wclone (CHAR_DATA *ch, char *argument, int cmd)
{
	char	    	buf [MAX_STRING_LENGTH] = {'\0'};
	OBJ_DATA	    *fbook = NULL;
	OBJ_DATA		*tbook = NULL;
	WRITING_DATA	*fwriting = NULL;
	WRITING_DATA	*twriting = NULL;
	char			*temp_arg1 = NULL;
	char			*temp_arg2 = NULL;

	argument = one_argument (argument, buf);
	fbook = get_obj_in_list_vis (ch, buf, ch->right_hand);

	if ( !fbook )
		fbook = get_obj_in_list_vis (ch, buf, ch->left_hand);

	if ( !fbook )
		fbook = get_obj_in_list_vis (ch, buf, ch->room->contents);

	if ( !fbook ) {
		send_to_char ("Which written object did you wish to clone from?\n", ch);
		return;
	}
	
	if ( GET_ITEM_TYPE (fbook) != ITEM_PARCHMENT &&
		 GET_ITEM_TYPE (fbook) != ITEM_BOOK ) {
		send_to_char ("The object you want to clone from isn't a parchment or book.\n", ch);
		return;
	}

	if ( !fbook->writing_loaded )
		load_writing (fbook);

	argument = one_argument (argument, buf);
	tbook = get_obj_in_list_vis (ch, buf, ch->right_hand);

	if ( !tbook )
		tbook = get_obj_in_list_vis (ch, buf, ch->left_hand);

	if ( !tbook )
		tbook = get_obj_in_list_vis (ch, buf, ch->room->contents);

	if ( !tbook ) {
		send_to_char ("Which written object did you wish to clone to?\n", ch);
		return;
	}
	
	if ( GET_ITEM_TYPE (fbook) != ITEM_PARCHMENT &&
		 GET_ITEM_TYPE (fbook) != ITEM_BOOK ) {
		send_to_char ("The object you want to clone to isn't a parchment or book.\n", ch);
		return;
	}

	if ( GET_ITEM_TYPE (fbook) != GET_ITEM_TYPE (tbook) ) {
		send_to_char ("This command only works with two written objects of the same type.\n", ch);
		return;
	}

	if ( !fbook->writing ) {
		send_to_char ("The specified source has no writing in it.\n", ch);
		return;
	}

	if ( fbook == tbook ) {
		send_to_char ("Source and destination can't be the same.\n", ch);
		return;
	}

	for ( fwriting = fbook->writing; fwriting; fwriting = fwriting->next_page ) {
		if ( fwriting == fbook->writing ) {
			if ( !tbook->writing ){
				CREATE (tbook->writing, WRITING_DATA, 1);
			}
			
			twriting = tbook->writing;
			twriting->message = add_hash(fwriting->message);
			twriting->author = add_hash(fwriting->author);
			twriting->date = add_hash (fwriting->date);
			twriting->ink = add_hash (fwriting->ink);
			twriting->script = fwriting->script;
			twriting->skill = fwriting->skill;
			twriting->torn = FALSE;
			twriting->language = fwriting->language;
			twriting->next_page = NULL;
		}
		else for ( twriting = tbook->writing; twriting; twriting = twriting->next_page ) {
			if ( !twriting->next_page ) {
				CREATE (twriting->next_page, WRITING_DATA, 1);
				twriting->next_page->message = add_hash(fwriting->message);
				twriting->next_page->author = add_hash(fwriting->author);
				twriting->next_page->date = add_hash (fwriting->date);
				twriting->next_page->ink = add_hash (fwriting->ink);
				twriting->next_page->script = fwriting->script;
				twriting->next_page->skill = fwriting->skill;
				twriting->next_page->torn = FALSE;
				twriting->language = fwriting->language;
				twriting->next_page->next_page = NULL;
				break;
			}
		}
	}

	tbook->o.od.value[0] = fbook->o.od.value[0];

	if ( fbook->book_title && *fbook->book_title ) {
		tbook->book_title = add_hash(fbook->book_title);
		tbook->title_skill = fbook->title_skill;
		tbook->title_script = fbook->title_script;
		tbook->title_language = fbook->title_language;
	}

	temp_arg1 = obj_short_desc(fbook);
	temp_arg2 = obj_short_desc(tbook);
	snprintf (buf, MAX_STRING_LENGTH,  "Writing cloned from #2%s#0 to #2%s#0.", temp_arg1, temp_arg2);
	act (buf, FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT);

	save_writing (tbook);

	return;
}

void do_wizlock (CHAR_DATA *ch, char *argument, int cmd)
{
	if ( maintenance_lock ) {
		unlink ("maintenance_lock");
	}
	else {
		system ("touch maintenance_lock");
	}
	
	send_to_char ("Wizlock toggled.\n", ch);
}

void do_stayput (CHAR_DATA *ch, char *argument, int cmd)
{
	CHAR_DATA	*tch = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};

	if ( !*argument ) {
		send_to_char ("Toggle who's stayput flag?\n", ch);
		return;
	}

	argument = one_argument (argument, buf);

	if ( !(tch = get_char_room_vis (ch, buf)) ) {
		send_to_char ("They aren't here.\n", ch);
		return;
	}

	if ( !IS_NPC (tch) ) {
		send_to_char ("This command is for use on NPCs only.\n", ch);
		return;
	}

	if ( port != PLAYER_PORT ) {
		send_to_char ("This command is for use on the player port only.\n", ch);
		return;
	}

	if ( IS_SET (tch->act, ACT_STAYPUT) ) {
		send_to_char ("This mobile will no longer save over reboots.\n", ch);
		REMOVE_BIT (tch->act, ACT_STAYPUT);
		return;
	}
	else {
		send_to_char ("This mobile will now save over reboots.\n", ch);
		SET_BIT (tch->act, ACT_STAYPUT);
		save_stayput_mobiles();
		return;
	}
	
	return;
}

void delete_role (CHAR_DATA *ch, char *argument)
{
	int			i = 1;
	ROLE_DATA	*role = NULL;
	bool		deleted = FALSE;

	if ( !isdigit (*argument) ) {
		send_to_char ("Syntax: role display <role number>\n", ch);
		return;
	}

	if ( strtol(argument, NULL, 10) == 1 ) {
		if ( GET_TRUST(ch) == 4 && str_cmp (role_list->poster, ch->tname) ) {
			send_to_char ("Sorry, but you are only allowed to delete your own roles.\n", ch);
			return;
		}
		
		if ( !role_list->next )
			role_list = NULL;
		else
			role_list = role_list->next;
		
		deleted = TRUE;
	}
	else {
		for ( role = role_list, i = 1; role && role->next; role = role->next, i++ ) {
			if ( i + 1 == strtol(argument, NULL, 10)) {
				if ( GET_TRUST(ch) == 4 && str_cmp (role->next->poster, ch->tname) ) {
					send_to_char ("Sorry, but you are only allowed to delete your own roles.\n", ch);
					return;
				}
			
				role->next = role->next->next;
				deleted = TRUE;
				break;
			}
		}
	}

	if ( !deleted ) {
		send_to_char ("That role number was not found.\n", ch);
		return;
	}

	send_to_char ("The specified special role has been removed as an option from chargen.\n", ch);
	save_roles();
	
	return;
}

void display_role (CHAR_DATA *ch, char *argument)
{
	char	output [MAX_STRING_LENGTH] = {'\0'};
	int		i = 1;
	ROLE_DATA	*role;

	if ( !isdigit (*argument) ) {
		send_to_char ("Syntax: role display <role number>\n", ch);
		return;
	}

	for ( role = role_list; role; role = role->next ) {
		if ( i == strtol(argument, NULL, 10))
			break;
		i++;
	}

	if ( !role ) {
		send_to_char ("That role number was not found.\n", ch);
		return;
	}

	snprintf (output, MAX_STRING_LENGTH,
			"\n#2Role Summary:#0  %s\n"
            "#2Posting Admin:#0 %s\n"
            "#2Posted On:#0     %s\n"
            "#2Point Cost:#0    %d\n"
			"\n"
			"%s", role->summary, role->poster, role->date, role->cost, role->body);

	page_string (ch->desc, output);
	
	return;
}

void list_roles (CHAR_DATA *ch)
{
	char		output [MAX_STRING_LENGTH] = {'\0'};
	ROLE_DATA	*role = NULL;
	int		i = 1;

	*output = '\0';

	for ( role = role_list; role; role = role->next ) {
		snprintf (output + strlen(output), MAX_STRING_LENGTH,  "%6d. %s\n", i, role->summary);
		i++;
	}

	if ( !*output ) {
		send_to_char ("No special roles are currently available in chargen.\n", ch);
		return;
	}

	send_to_char ("\n#2The following special roles have been made available in chargen:\n#0", ch);
	page_string (ch->desc, output);
	
	return;
}

/*                                                                          *
 * funtion: post_role                   < e.g.> role new 2 clothier         *
 *                                                                          *
 *                                                                          */
void post_role (DESCRIPTOR_DATA *d)
{
	CHAR_DATA	*ch = NULL;
	ROLE_DATA	*role = NULL;
	char		*date = NULL;

	ch = d->character;

	if ( !*ch->pc->msg ) {
		send_to_char ("Role post aborted.\n", ch);
		return;
	}

	if ( !role_list ) {
		CREATE (role_list, ROLE_DATA, 1);
		role = role_list;
	}
	else{
		for ( role = role_list; role; role = role->next ) {
			if ( !role->next ) {
				CREATE (role->next, ROLE_DATA, 1);
				role = role->next;
				break;
			}
		}
	}

	/* Get a date string from current time ( default = "" ) */
	date = timestr(date);
	role->cost = ch->delay_info1;
	role->summary = str_dup (ch->delay_who);
	role->body = str_dup (ch->pc->msg);
	role->date = str_dup (date);
	role->poster = str_dup (ch->pc->account);
	role->timestamp = (int) time(0);

	ch->delay_who = NULL;
	ch->delay_info1 = 0;

	save_roles ();

	mem_free (date);
	
	return;
}

void new_role (CHAR_DATA *ch, char *argument)
{
	char	buf [MAX_STRING_LENGTH] = {'\0'};
	int		cost = 0;

	argument = one_argument (argument, buf);

	if ( IS_NPC (ch) ) {
		send_to_char ("Please don't post roles while switched. Thanks!\n", ch);
		return;
	}

	if ( !isdigit (*buf) ) {
		send_to_char ("Syntax: role new <point cost> <summary line>\n", ch);
		return;
	}
	
	cost = strtol(buf, NULL, 10);

	if ( cost < 1 || cost > 50 ) {
		send_to_char ("Permissible costs are from 1-50, inclusive.\n", ch);
		return;
	}

	if ( !*argument ) {
		send_to_char ("Syntax: role new <point cost> <summary line>\n", ch);
		return;
	}

	send_to_char ("\n#2Enter a detailed summary of the role you wish to post, to\n"
        	      "give prospective players a better idea as to what sort of RP\n"
              	      "will be required to successfully portray it.#0\n", ch);

	make_quiet (ch);
	ch->delay_info1 = cost;
	ch->delay_who = str_dup (argument);
	ch->pc->msg = (char *)alloc((int)sizeof(char), 1);
	*ch->pc->msg = '\0';
	ch->desc->str = &ch->pc->msg;
	ch->desc->max_str = MAX_STRING_LENGTH;
	ch->desc->proc = post_role;
}

void update_role (CHAR_DATA *ch, char *argument)
{
	ROLE_DATA	*role = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};
	int			i = 0;

	argument = one_argument (argument, buf);

	if ( !*buf || !isdigit (*buf) ) {
		send_to_char ("Please specify a role number to update.\n", ch);
		return;
	}

	if ( strtol(buf, NULL, 10) == 1 ) {
		role = role_list;
	}
	else for ( role = role_list, i = 1; role; role = role->next, i++ ) {
		if ( i == strtol(buf, NULL, 10))
			break;
	}

	if ( !role ) {
		send_to_char ("I could not find that role number to update.\n", ch);
		return;
	}

	argument = one_argument (argument, buf);

	if ( !*buf ) {
		send_to_char ("Please specify which field in the role to update.\n", ch);
		return;
	}
	else if ( !str_cmp (buf, "contact") ) {
		argument = one_argument (argument, buf);
		if ( !*buf ) {
			send_to_char ("Please specify who the new point of contact should be.\n", ch);
			return;
		}
		if ( !load_account (buf) ) {
			send_to_char ("That is not the name of a currently registered MUD account.\n", ch);
			return;
		}
		mem_free (role->poster);
		role->poster = str_dup (CAP(buf));
		send_to_char ("The point of contact for that role has been updated.\n", ch);
		save_roles();
	}
	else if ( !str_cmp (buf, "cost") ) {
		argument = one_argument (argument, buf);
		if ( !*buf || !isdigit (*buf) ) {
			send_to_char ("Please specify what the new cost should be.\n", ch);
			return;
		}
		role->cost = strtol(buf, NULL, 10);
		send_to_char ("The cost for that role has been updated.\n", ch);
		save_roles();
	}
}

void do_role (CHAR_DATA *ch, char *argument, int cmd)
{
	char		buf [MAX_STRING_LENGTH] = {'\0'};

	argument = one_argument (argument, buf);

	if ( IS_NPC(ch) ) {
		send_to_char ("Sorry, but this can't be done while switched.\n", ch);
		return;
	}

	if ( !str_cmp (buf, "new") )
		new_role (ch, argument);
	else if ( !str_cmp (buf, "list") )
		list_roles (ch);
	else if ( !str_cmp (buf, "display") )
		display_role (ch, argument);
	else if ( !str_cmp (buf, "delete") )
		delete_role (ch, argument);
	else if ( !str_cmp (buf, "update") )
		update_role (ch, argument);
	else
		send_to_char ("Syntax: role (new|list|display|delete|update) <argument(s)>\n", ch);
}

void do_clockout (CHAR_DATA *ch, char *argument, int cmd)
{
	if ( !IS_NPC(ch) ) {
		send_to_char ("Eh?\n", ch);
		return;
	}

	if ( port == BUILDER_PORT )
		return;

	if ( !ch->shop ) {
		send_to_char ("This command is only for NPC shopkeepers.\n", ch);
		return;
	}

	REMOVE_BIT (ch->flags, FLAG_KEEPER);
	send_to_char ("You will no longer sell things until you 'clockin'.\n", ch);
} 

void do_clockin (CHAR_DATA *ch, char *argument, int cmd)
{
	if ( !IS_NPC(ch) ) {
		send_to_char ("Eh?\n", ch);
		return;
	}

	if ( port == BUILDER_PORT )
		return;

	if ( !ch->shop ) {
		send_to_char ("This command is only for NPC shopkeepers.\n", ch);
		return;
	}

	SET_BIT (ch->flags, FLAG_KEEPER);
	send_to_char ("You are now open for business again.\n", ch);
} 

void do_roll (CHAR_DATA *ch, char *argument, int cmd)
{
	int		die, number, total;
	char	buf [MAX_STRING_LENGTH] = {'\0'};
	
	*buf = '\0';

	argument = one_argument (argument, buf);

	if ( !*buf || isalpha(*buf) || strtol(buf, NULL, 10) > 1000 || strtol(buf, NULL, 10) < 1 ) {
		send_to_char ("Usage: 'roll X Y', equivalent to rolling XdY.\n", ch);
		return;
	}

	die = strtol(buf, NULL, 10);

	argument = one_argument (argument, buf);

	if ( !*buf || isalpha(*buf) || strtol(buf, NULL, 10) > 1000 || strtol(buf, NULL, 10) < 1 ) {
		send_to_char ("Usage: 'roll X Y', equivalent to rolling XdY.\n", ch);
		return;
	}

	number = strtol(buf, NULL, 10);

	total = dice(die,number);

	snprintf (buf, MAX_STRING_LENGTH,  "Rolling %dd%d... #2%d#0\n", die,number,total);
	send_to_char (buf, ch);
}
	
void do_deduct (CHAR_DATA *ch, char *argument, int cmd)
{
	CHAR_DATA		*tch = NULL;
	ACCOUNT_DATA	*account = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	bool			loaded = FALSE;

	if ( !*argument ) {
		send_to_char ("Who would you like to deduct?\n", ch);
		return;
	}

	if ( IS_NPC (ch) ) {
		send_to_char ("This is a PC-only command.\n", ch);
		return;
	}

	argument = one_argument(argument, buf);

	if ( !(tch = get_char_room_vis (ch, buf)) &&
			  !(tch = get_char_vis (ch, buf)) ) {
                if ( !(tch = load_pc (buf)) ) {
                        send_to_char ("No PC with that name was found. Is it spelled correctly?\n", ch);
                        return;
                }
                else loaded = TRUE;
	}

        account = load_account (tch->pc->account);

	if ( !account ) {
		act ("Hmm... there seems to be a problem with that character's account. Please notify the staff.", FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT);
		return;
	}

	argument = one_argument (argument, buf);

	if ( !isdigit(*buf) ) {
		send_to_char ("You must specify a number of roleplay points to deduct.\n", ch);
		return;
	}

	if ( strtol(buf, NULL, 10) < 1 || strtol(buf, NULL, 10) > account->roleplay_points ) {
		act ("The specified number must be greater than 0 and less than or equal to the named character's RP point total.", FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT);
		return;
	}

	account->roleplay_points -= strtol(buf, NULL, 10);
	account->last_rpp = (int) time(0);
	save_account (account);

	tch->pc->last_rpp = (int) time(0);
	save_char (tch, FALSE);

	if ( loaded )
		unload_pc (tch);

	send_to_char ("#1The specified number of points have been removed from their account.\n", ch);
	send_to_char ("Please be sure to leave a note explaining why on their pfile.#0\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "write %s Roleplay Point Deduction.", tch->tname);
	command_interpreter(ch, buf);

}

void do_award (CHAR_DATA *ch, char *argument, int cmd)
{
	CHAR_DATA		*tch = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	ACCOUNT_DATA	*account = NULL;
	bool			loaded = FALSE;

	if ( !*argument ) {
		send_to_char ("Who would you like to award?\n", ch);
		return;
	}

	if ( IS_NPC(ch) ) {
		send_to_char ("This is a PC-only command.\n", ch);
		return;
	}

	argument = one_argument(argument, buf);

	if ( !(tch = get_char_room_vis (ch, buf)) &&
			  !(tch = get_char_vis (ch, buf)) ) {
		if ( !(tch = load_pc (buf)) ) {
			send_to_char ("No PC with that name was found. Is it spelled correctly?\n", ch);
			return;
		}
		else loaded = TRUE;
	}

	if ( IS_NPC (tch) ) {
		send_to_char ("This command only works for player characters.\n", ch);
		return;
	}

	account = load_account (tch->pc->account);

	if ( !account ) {
		act ("Hmm... there seems to be a problem with that character's account. Please notify the staff.", FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT);
		return;
	}

	if ( !str_cmp (tch->pc->account, ch->pc->account) && port != TEST_PORT ) {
		send_to_char ("Adding roleplay points to your own account is against policy.\n", ch);
		return;
	}

	if ( tch->desc && tch->desc->account && IS_SET (tch->desc->account->flags, ACCOUNT_RPPDISPLAY) )
		send_to_char ("#6Congratulations, you've just been awarded a roleplay point!#0\n", tch);

	account->roleplay_points++;
	account->last_rpp = (int) time(0);
	save_account (account);

	tch->pc->last_rpp = (int) time(0);
	save_char (tch, FALSE);

	if ( loaded )
		unload_pc (tch);

	send_to_char ("#2A roleplay point has been added to that character's account.\n", ch);
	send_to_char ("Please be sure to leave a note explaining why on their pfile.#0\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "write %s Roleplay Point.", tch->tname);
	command_interpreter(ch, buf);

}

void post_email (DESCRIPTOR_DATA *d)
{
	ACCOUNT_DATA	*account = NULL;
	char		from [MAX_STRING_LENGTH] = {'\0'};
	char		buf [MAX_STRING_LENGTH] = {'\0'};

	if ( !*d->pending_message->message ) {
		send_to_char ("Email aborted.\n", d->character);
		d->pending_message = NULL;
		return;
	}

	snprintf (buf, MAX_STRING_LENGTH,  "%s", d->pending_message->message);
	d->pending_message = NULL;

	snprintf (from, MAX_STRING_LENGTH, "%s <%s>", d->character->tname, d->account->email);

	account = load_account (d->character->delay_who);

	send_email (account, d->account->email, from, d->character->delay_who2, buf);

	REMOVE_BIT (d->character->act, PLR_QUIET);

	send_to_char ("Your email has been sent out. It has been copied to your address for reference.\n", d->character);

	d->character->delay_who = NULL;
	d->character->delay_who2 = NULL;
}

void do_email (CHAR_DATA *ch, char *argument, int cmd)
{
	ACCOUNT_DATA	*account = NULL;
	CHAR_DATA		*tch = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};

	argument = one_argument (argument, buf);

	if ( !*buf ) {
		send_to_char ("To whom did you wish to send an email?\n", ch);
		return;
	}

	if ( !(tch = load_pc (buf)) ) {
		send_to_char ("That PC's file could not be loaded.\n", ch);
		return;
	}

	if ( !(account = load_account (tch->pc->account)) ) {
		send_to_char ("That character's account could not be loaded.\n", ch);
		unload_pc (tch);
		return;
	}

	ch->delay_who = str_dup (account->name);
	unload_pc (tch);

	if ( !*argument ) {
		send_to_char ("What would you like the subject-line of the email to be?\n", ch);
		return;
	}

	if ( IS_NPC (ch) ) {
		send_to_char ("Only PCs may use this command.\n", ch);
		return;
	}

	send_to_char ("\n#2Enter the message you'd like to email this player:#0\n", ch);

	CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
	ch->desc->str = &ch->desc->pending_message->message;
	ch->desc->max_str = MAX_STRING_LENGTH;
	ch->desc->proc = post_email;
	ch->delay_who2 = str_dup(argument);
	SET_BIT (ch->act, PLR_QUIET);

}

void do_unban (CHAR_DATA *ch, char *argument, int cmd)
{
	SITE_INFO	*site = NULL;
	SITE_INFO	*next_site;
	char		buf [MAX_STRING_LENGTH] = {'\0'};
	int		i = 0;

	if ( !*argument || !isdigit(*argument) ) {
		send_to_char ("You must specify the number of the site from the banned sitelist.\n", ch);
		return;
	}

	if ( !banned_site ) {
		send_to_char ("There are currently no sites to unban!\n", ch);
		return;
	}

	for ( i = 1, site = banned_site; site; i++, site = next_site ) {
		next_site = site->next;
		if ( strtol(argument, NULL, 10) == 1 && i == 1 ) {
			if ( GET_TRUST(ch) < 5 && str_cmp (site->banned_by, "Password Security System") && str_cmp (ch->tname, site->banned_by) ) {
				snprintf (buf, MAX_STRING_LENGTH,  "Sorry, but you'll need to get %s or a level 5 admin to do that.\n", site->banned_by);
				send_to_char (buf, ch);
				return;
			}
			unban_site (site);
			return;
		}
		else if ( i+1 == strtol(argument, NULL, 10) && site->next ) {
			if ( GET_TRUST(ch) < 5 && str_cmp (ch->tname, site->next->banned_by) ) {
				snprintf (buf, MAX_STRING_LENGTH,  "Sorry, but you'll need to get %s or a level 5 admin to do that.\n", site->banned_by);
				send_to_char (buf, ch);
				return;
			}
			unban_site (site->next);
			return;
		}
	}

	send_to_char ("That number is not on the banned site list.\n", ch);

}

void disconnect_banned_hosts()
{
	SITE_INFO	*site = NULL;
	DESCRIPTOR_DATA		*d = NULL;
	DESCRIPTOR_DATA		*next_desc = NULL;

	for ( site = banned_site; site; site = site->next ) {
       		for ( d = descriptor_list; d; d = next_desc ) {
        	        next_desc = d->next;
        	        if ( !d->account )
        	                continue;
        	        if ( !IS_SET(d->account->flags, ACCOUNT_NOBAN) ) {
        	                if ( strstr(d->host, site->name) ) {
        	                        close_socket(d);
        	                }
        	        }
        	}
	}
}

void ban_host (char *host, char *banned_by, int length)
{
	SITE_INFO	*site = NULL;
	SITE_INFO	*tmp_site = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};

	CREATE (site, SITE_INFO, 1);
	site->name = add_hash(host);
	site->banned_by = add_hash(banned_by);
	site->banned_on = time(0);
	if ( length != -1 && length != -2 )
		site->banned_until = time(0) + (60 * 60 * 24 * length);
	else if ( length == -2 )
		site->banned_until = time(0) + (60 * 60);
	else if ( length == -1 )
		site->banned_until = -1;

	if ( !banned_site )
		banned_site = site;
	else for ( tmp_site = banned_site; tmp_site; tmp_site = tmp_site->next ) {
		if ( !tmp_site->next ) {
			tmp_site->next = site;
			break;
		}
	}

	snprintf (buf, MAX_STRING_LENGTH,  "%s has sitebanned %s.\n", banned_by, host);
	send_to_gods (buf);

	save_banned_sites();
	
	return;
}

/*                                                                          *
 * funtion: do_ban                      < e.g.> ban [ <host> <duration> ]   *
 *                                                                          *
 *                                                                          */
void do_ban (CHAR_DATA *ch, char *argument, int cmd)
{
	SITE_INFO	*site = NULL;
    MYSQL_RES   *result = NULL;
    MYSQL_ROW   row;
	char		*start_date = NULL;
	char		*end_date = NULL;
	char		buf [MAX_STRING_LENGTH] = {'\0'};
	char		host [MAX_STRING_LENGTH] = {'\0'};
	char		length [MAX_STRING_LENGTH] = {'\0'};
	char		accounts [MAX_STRING_LENGTH] = {'\0'};
	int			i = 0;
	int			j = 0;
	time_t		ban_time, end_ban_time;

	if ( !*argument ) {
		snprintf (buf, MAX_STRING_LENGTH,  "\n#6Currently Banned Sites:#0\n\n");
		if ( !banned_site ) {
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   None.\n");
			send_to_char (buf, ch);
			return;
		}
		else for ( i = 1, site = banned_site; site; i++, site = site->next ) {
			*accounts = '\0';
			mysql_safe_query ("SELECT username,account_flags FROM forum_users WHERE user_last_ip LIKE '%%%s%%'", site->name);
			result = mysql_store_result (database);
			j = 1;
			if ( result ) {
				if ( mysql_num_rows(result) >= 10 )
					snprintf (accounts + strlen(accounts), MAX_STRING_LENGTH, " #110+ accounts affected#0");
				else while ( (row = mysql_fetch_row(result)) ) {
					if ( IS_SET (strtol(row[1], NULL, 10), ACCOUNT_NOBAN) )
						continue;
					if ( j != 1 )
						snprintf (accounts + strlen(accounts), MAX_STRING_LENGTH, ",");
					snprintf (accounts + strlen(accounts), MAX_STRING_LENGTH, " %s", row[0]);
					j++;
				}
				mysql_free_result (result);
			}
			if ( i != 1 )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   %d. #6%s#0 [%s]\n", i, site->name, site->banned_by);
			if ( i > 9 )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
			if ( *accounts )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "      #2Accounts:#0%s\n", accounts);
			else
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "      #2Accounts:#0 None Found\n");

			ban_time = site->banned_on;
			start_date = (char *) malloc (256) ;
			if ( asctime_r ( localtime ( &ban_time ), start_date ) != NULL ) {
			  start_date [ strlen ( start_date ) - 1 ] = '\0';
			}
			else {
			  start_date[0] = '\0';
			}

			if ( site->banned_until != -1 ) {
			  if ( i > 9 )
			    snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
			  snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "      #2Ban Period:#0 %s to ", start_date);

			  end_ban_time = site->banned_until;
			  end_date = (char *) malloc (256) ;
			  if ( asctime_r ( localtime ( &end_ban_time ), end_date ) != NULL ) {
			    end_date [ strlen ( end_date ) - 1 ] = '\0';
			  }
			  else {
			    end_date[0] = '\0';
			  }

			  snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "%s\n", end_date);
			  mem_free ( end_date ) ;
			  end_date = NULL;
			} 
			else {
			  if ( i > 9 )
			    snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
			  snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "      #2Permanently Banned On:#0 %s\n", start_date);
			}
			mem_free ( start_date );
			start_date = NULL;
		}
		page_string (ch->desc, buf);
		return;
	}

	argument = one_argument (argument, host);
	argument = one_argument (argument, length);

	for ( i = 0; i < strlen (host); i++ ) {
		if ( !isalpha (host [i]) && !isdigit (host[i]) &&
			host[i] != '.' && host[i] != '_' &&
			host[i] != '-' && host[i] != '*' ) {
			snprintf (buf, MAX_STRING_LENGTH,  "Illegal character '%c' in siteban entry.\n", host[i]);
			send_to_char (buf, ch);
			return;
		}
	}

	if ( !*length || (!isdigit (*length) && *length != '!') ) {
		send_to_char ("You need to specify a length of days; otherwise, '!' for a permanent ban.\n", ch);
		return;
	}

	if ( *length != '!' && strtol(length, NULL,10) < 1 ) {
		send_to_char ("The minimum ban period is 1 day.\n", ch);
		return;
	}

	if ( *length == '!' )
		ban_host (host, ch->tname, -1);
	else ban_host (host, ch->tname, strtol(length, NULL,10));

	disconnect_banned_hosts();
}

void do_echo(CHAR_DATA *ch, char *argument, int cmd)
{
	int 	i = 0;
	char 	buf[MAX_STRING_LENGTH] = {'\0'};

	for (i = 0; *(argument + i) == ' '; i++);

	if ( !*(argument + i) ) {
		send_to_char("That must be a mistake...\n", ch);
		return;
	}

	snprintf (buf, MAX_STRING_LENGTH,  "%s\n", argument + i);
	send_to_room (buf, ch->in_room);
}

void do_gecho(CHAR_DATA *ch, char *argument, int cmd)
{
	int 		i = 0;
	ROOM_DATA   *troom = NULL;

	for (i = 0; *(argument + i) == ' '; i++);

	if (!*(argument + i))
		send_to_char("That must be a mistake...\n", ch);

	else{
		snprintf (s_buf, MAX_STRING_LENGTH, "%s\n", argument + i);

		for (troom = full_room_list; troom; troom = troom->lnext){
			if ( troom->people ){
				send_to_room (s_buf, troom->virtual);
			}
		}
	}
	
	return;
}

void do_broadcast(CHAR_DATA *ch, char *argument, int cmd)
{
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	char			*p = NULL;
	int				i=0;
	DESCRIPTOR_DATA		*d = NULL;

	for (i = 0; *(argument + i) == ' '; i++);

	if (!*(argument + i))
		send_to_char("That must be a mistake...\n", ch);
	else
	{
		snprintf (s_buf, MAX_STRING_LENGTH, "%s\n", argument + i);
		snprintf (buf, MAX_STRING_LENGTH,  "\a\n#2Staff Announcement:#0\n\n");
		reformat_string (s_buf, &p);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "%s", p);

		for ( d = descriptor_list; d; d = d->next )
			SEND_TO_Q (buf, d);

	}
}

void do_zecho (CHAR_DATA *ch, char *argument, int cmd)
{
	int				zone = 0;
	ROOM_DATA		*room = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	
	strcpy (s_buf, argument);

	argument = one_argument (argument, buf);

	if ( !*buf || !strcmp (buf, "?") ) {
		send_to_char ("  zecho <zone> Message        send message to specific "
					  "zone.\n", ch);
		send_to_char ("  zecho Message               send message to zone you "
					  "are in.\n", ch);
		return;
	}

	while ( *argument == ' ' )
		argument++;

	if ( isdigit (*buf) && strtol(buf, NULL, 10) < 100 ) {
		zone = strtol(buf, NULL, 10);
		strcpy (s_buf, argument);
	} else
		zone = ch->in_room / 1000;

	strcat (s_buf, "\n");

	for ( room = full_room_list; room; room = room->lnext )
		if ( room->people && room->zone == zone )
			send_to_room (s_buf, room->virtual);

	snprintf (buf, MAX_STRING_LENGTH,  "(to zone %d): %s", zone, s_buf);
	send_to_char (buf, ch);
	
	return;
}

void do_pecho (CHAR_DATA *ch, char *argument, int cmd)
{
	CHAR_DATA	*vict = NULL;
	DESCRIPTOR_DATA 	*d = NULL;
	char		name [MAX_STRING_LENGTH] = {'\0'};
	char        message [MAX_STRING_LENGTH] = {'\0'};
	char        buf [MAX_STRING_LENGTH] = {'\0'};

	half_chop (argument, name, message);

	if ( !*name || !*message )
		send_to_char ("Who do you wish to pecho to and what??\n", ch);

	else if ( !(vict = get_char_nomask (name)) || IS_NPC (vict) ||
(!GET_TRUST (vict) && IS_SET (vict->flags, FLAG_WIZINVIS)) )
		send_to_char ("There is nobody playing the mud by that name.\n", ch);

	else if ( ch == vict )
		send_to_char ("You try to tell yourself something.\n", ch);

	else if ( IS_SET (vict->act, PLR_QUIET) ) {
		send_to_char ("That player is editing, try again later.\n", ch);
		return;
	}

	else {
		if ( IS_MORTAL (ch) && IS_SET (vict->flags, FLAG_ANON) ) {
			send_to_char ("There is nobody playing the mud by that name.\n", ch);
			return;
		}

		if ( !vict->desc && !IS_NPC (vict) ) {
			for ( d = descriptor_list; d; d = d->next ) {
				if ( d == vict->pc->owner ){
					break;
				}
			}

			if ( !d ) {
				send_to_char ("That player has disconnected.\n", ch);
				return;
			}
		}

		send_to_char (message, vict);
		snprintf (buf, MAX_STRING_LENGTH,  "You pecho to %s: '%s'\n",GET_NAME (vict), message);
		send_to_char (buf, ch);
	}
	
	return;
}


void do_transfer (CHAR_DATA *ch, char *argument, int cmd) 
{
	DESCRIPTOR_DATA	*i = NULL;
	CHAR_DATA		*victim = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	int				target = 0;

	argument = one_argument (argument, buf);
	
	if ( !*buf )
		send_to_char ("Who do you wish to transfer?\n", ch);
	
	else if ( str_cmp ("all", buf) ) {
		if (!(victim = get_char_vis(ch,buf)))
			send_to_char("No-one by that name around.\n",ch);
		else {
			act("$n disappears in a mushroom cloud.", FALSE, victim, 0, 0, TO_ROOM);
			target = ch->in_room;
			char_from_room(victim);
			char_to_room(victim,target);
			act("$n arrives from a puff of smoke.", FALSE, victim, 0, 0, TO_ROOM);
			act("$n has transferred you!",FALSE,ch,0,victim,TO_VICT);
			do_look(victim,"",15);
		}
	} 
	else { /* Trans All */
		if ( GET_TRUST (ch) < 5 ) {
			send_to_char ("Sorry, but TRANSFER ALL is a level 5-only command.\n", ch);
			return;
		}

		if ( !*argument || *argument != '!' ) {
			send_to_char ("Please type 'transfer all !' to confirm.\n", ch);
			return;
		}

	    for (i = descriptor_list; i; i = i->next) {
			if (i->character != ch && !i->connected) {
				victim = i->character;
				act("$n disappears in a mushroom cloud.", FALSE, victim, 0, 0, TO_ROOM);
				target = ch->in_room;
				char_from_room(victim);
				char_to_room(victim,target);
				act("$n arrives from a puff of smoke.", FALSE, victim, 0, 0, TO_ROOM);
				act("$n has transferred you!",FALSE,ch,0,victim,TO_VICT);
				do_look(victim,"",15);
			}
		}

		send_to_char ("All online PCs have been transferred to your location.\n", ch);
		return;
	}

	return;
}

void do_at (CHAR_DATA *ch, char *argument, int cmd)
{
	char			command [MAX_INPUT_LENGTH] = {'\0'};
	char			loc_str [MAX_INPUT_LENGTH] = {'\0'};
	int				location = 0;
	int				original_loc = 0;
	CHAR_DATA		*target_mob = NULL;
	OBJ_DATA		*target_obj = NULL;
	ROOM_DATA		*target_room = NULL;
	
	half_chop(argument, loc_str, command);

	if (!*loc_str) {
		send_to_char("You must supply a room number or a name.\n", ch);
		return;
	}

	
	if ( isdigit (*loc_str) ) {
		if ( !(target_room = vtor (strtol(loc_str, NULL,10))) ) {
			send_to_char("No room exists with that number.\n", ch);
			return;
		}
			
		location = target_room->virtual;
	}

	else if ((target_mob = get_char_vis (ch, loc_str)))
		location = target_mob->in_room;

	else if ((target_obj = get_obj_vis(ch, loc_str)))
		if (target_obj->in_room != NOWHERE)
			location = target_obj->in_room;
		else {
			send_to_char("The object is not available.\n", ch);
			return;
		}
	else{
		send_to_char("No such creature or object around.\n", ch);
		return;
	}

	/* a location has been found. */

	original_loc = ch->in_room;
	char_from_room(ch);
	char_to_room(ch, location);
	command_interpreter(ch, command);

	/* check if the guy's still there */

	for ( target_mob = vtor (location)->people;
		  target_mob;
		  target_mob = target_mob->next_in_room )
		if ( ch == target_mob ) {
			char_from_room (ch);
			char_to_room (ch, original_loc);
		}
	
	return;
}

void do_goto (CHAR_DATA *ch, char *argument, int cmd)
{
	char		buf [MAX_INPUT_LENGTH] = {'\0'};
	int			location;
	CHAR_DATA	*target_mob = NULL;
	CHAR_DATA	*tch = NULL;
	OBJ_DATA	*target_obj = NULL;
	ROOM_DATA	*troom = NULL;

	clear_pmote(ch);

	argument = one_argument(argument, buf);
	if (!*buf) {
		send_to_char("You must supply a room number or a name.\n", ch);
		return;
	}

	if (isdigit(*buf)) {

		if ( !(troom = vtor (strtol(buf, NULL, 10))) ) {
			send_to_char("No room exists with that number.\n", ch);
			return;
		}

		location = troom->virtual;
	}

	else if ( (target_mob = get_char_vis (ch, buf)) )
		location = target_mob->in_room;

	else if ( (target_obj = get_obj_vis (ch, buf)) ) {
		if ( target_obj->in_room != NOWHERE )
			location = target_obj->in_room;
		else {
			send_to_char ("The object is not available.\n", ch);
			return;
		}
	} else {
		send_to_char ("No such creature or object around.\n", ch);
		return;
	}

	/* a location has been found. */

	if ( ch->in_room == location ) {
		send_to_char ("You're already there.\n", ch);
		return;
	}

	if ( ch->pc ) {
		if ( !ch->pc->imm_leave || !strncmp (ch->pc->imm_leave, "(null)", 6) )
			ch->pc->imm_leave = str_dup ("");

		if ( !ch->pc->imm_enter || !strncmp (ch->pc->imm_enter, "(null)", 6) )
			ch->pc->imm_enter = str_dup ("");

		if ( *ch->pc->imm_leave )
			act (ch->pc->imm_leave, TRUE, ch, 0, 0, TO_ROOM | TO_ACT_FORMAT);
		else
			act ("$n quietly leaves.", TRUE, ch, 0, 0, TO_ROOM);
	} else
		act ("$n quietly leaves.", TRUE, ch, 0, 0, TO_ROOM);

	if ( !IS_SET (ch->flags, FLAG_WIZINVIS) && *argument != '!'  ) {

		troom = vtor(location);

		for ( tch = troom->people; tch; tch = tch->next_in_room ) {
			if ( !IS_NPC(tch) && IS_MORTAL(tch) ) {
				send_to_char ("You're currently visible to players. Use '!' to confirm the goto.\n", ch);
				return;
			}
		}
	}

	char_from_room (ch);
	char_to_room (ch, location);

	if ( ch->pc && *ch->pc->imm_enter )
		act (ch->pc->imm_enter, TRUE, ch, 0, 0, TO_ROOM | TO_ACT_FORMAT);
	else
		act ("$n suddenly appears.", TRUE, ch, 0, 0, TO_ROOM);

	do_look (ch, "", 15);
	
	return;
}

void pad_buffer (char *buf, int pad_stop)
{
	int		to_pad = 0;
	char	*p = NULL;

	p = ADDBUF;

	for ( to_pad = pad_stop - strlen (buf); to_pad > 0; to_pad--, p++ )
		*p = ' ';

	*p = 0;
}


void charstat (CHAR_DATA *ch, char *name)
{
	int				i = 0;
	int				j = 0;
	int				i2 = 0;
	int				loaded_char = 0;
	int				loads = 0;
	int				econ_zone = 0;
	int				instance = 1;
	int				time_diff = 0;
	int				hours_remaining = 0;
	int				days_remaining = 0;
	int				mins_remaining = 0;
	CHAR_DATA		*k = NULL;
	CHAR_DATA		*tch = NULL;
	AFFECTED_TYPE	*af = NULL;
	AFFECTED_TYPE	*next_affect = NULL;
	CHARM_DATA		*ench = NULL;
	char			buf [MAX_STRING_LENGTH] = {'\0'};

	if ( strtol(name, NULL,10) ) {
		if ( !(k = vtom (strtol(name, NULL,10))) ) {
			send_to_char ("No such mobile with that vnum.\n", ch);
			return;
		}
		instance = 0;
	}

	else if ( (k = load_pc (name)) )
		loaded_char = 1;

	else if ( !(k = get_char_room_vis (ch, name)) &&
			  !(k = get_char_vis (ch, name)) ) {
		send_to_char ("No player or mobile with that name found.\n", ch);
		return;
	}

	if ( !IS_NPC(k) )
		snprintf (buf, MAX_STRING_LENGTH,  "\n#2Name:#0   %s, a %s PC", k->tname, sex_types[(int)k->sex]);
	else
		snprintf (buf, MAX_STRING_LENGTH,  "\n#2VNUM:#0   %d, a %s %s", k->mob->virtual, sex_types[(int)k->sex],
			instance ? "[INSTANCE]" : "[PROTOTYPE]");

	if ( IS_NPC(k) ) {
		loads = 0;

		for ( tch = character_list; tch; tch = tch->next ) {
			if ( tch->deleted || !IS_NPC (tch) )
				continue;

			if ( tch->mob->virtual == k->mob->virtual )
				loads++;
		}
		snprintf (ADDBUF, MAX_STRING_LENGTH, " [Loaded Instances: %d]", loads);
	}
	else if ( k->pc && k->pc->account ) {
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", registered to account %s", k->pc->account);
	}

	snprintf (ADDBUF, MAX_STRING_LENGTH, " [id %d]\n", k->coldload_id);

	send_to_char (buf, ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Keys:#0   %s\n", GET_NAMES(k));

	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2SDesc:#0  %s\n", 
				  k->short_descr ? k->short_descr : "None");

	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2LDesc:#0  %s\n",
				  k->long_descr ? k->long_descr  : "None");

	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Str:#0 %d/%d", GET_STR (k), k->str);
	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2MaxHP:#0 %d", GET_MAX_HIT (k));
	pad_buffer (buf, 53);
	if ( instance ) 
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Moves:#0  %d/%d", GET_MOVE(k), GET_MAX_MOVE(k)); 
	else
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Moves:#0  N/A"); 
	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Dex:#0 %d/%d", GET_DEX (k), k->dex);
	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Race:#0  %s", db_race_table [k->race].name);
	pad_buffer (buf, 53);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Speak:#0  %s",skill_data[k->speaks].skill_name);
	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Con:#0 %d/%d", GET_CON (k), k->con);
	pad_buffer (buf, 25);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Age:#0   %dY %dM %dD %dH", 
	age (k).year, age (k).month, age (k).day, age (k).hour);
	pad_buffer (buf, 53);
	if ( instance )
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Ht/Wt:#0  %d/%d", k->height, get_weight (k) / 100);
	else
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Ht/Wt:#0  N/A");
	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Int:#0 %d/%d", GET_INT (k), k->intel);
	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Fight:#0 %s", fight_tab [k->fight_mode].name);
	pad_buffer (buf, 53);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Offns:#0  %d", k->offense);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "\n");
	send_to_char (buf, ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Wil:#0 %d/%d", GET_WIL (k), k->wil);
	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Hrnss:#0 %d", k->harness);
	pad_buffer (buf, 53);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2MHrnss:#0 %d", k->max_harness);
	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Aur:#0 %d/%d", GET_AUR (k), k->aur);
	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Armor:#0 %d", k->armor);
	pad_buffer (buf, 53);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Speed:#0  %s", speeds[k->speed]);
	send_to_char (buf, ch);
	send_to_char ("\n", ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Agi:#0 %d/%d", GET_AGI(k), k->agi);

	pad_buffer (buf, 25);
	snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Room:#0  %d", k->in_room);
	pad_buffer (buf, 53);
	if ( IS_NPC (k) ) {
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Spwn:#0   %d", k->mob->spawnpoint);
	} else {
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Cond:#0   %d,%d,%d", 
					  k->intoxication,
					  k->hunger,
					  k->thirst);
	}

	snprintf (ADDBUF, MAX_STRING_LENGTH, "\n");
	send_to_char (buf, ch);

	if ( IS_NPC (k) ) {
		*buf = '\0';
		snprintf (buf, MAX_STRING_LENGTH,  "#2Sum:#0 %d",
			k->str + k->dex + k->con + k->intel + k->wil +
			k->aur + k->agi);
		pad_buffer (buf, 25);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Carc:#0  %d", k->mob->carcass_vnum);
		pad_buffer (buf, 53);
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2Skin:#0   %d", k->mob->skinned_vnum);
	        snprintf (ADDBUF, MAX_STRING_LENGTH, "\n");
		send_to_char (buf, ch);
		*buf = '\0';
		pad_buffer (buf, 21);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Att:#0   %s", attack_names[k->nat_attack_type]);
		pad_buffer (buf, 49);
		snprintf (ADDBUF, MAX_STRING_LENGTH, "#2NDam:#0   %dd%d", k->mob->damnodice, k->mob->damsizedice);
	        snprintf (ADDBUF, MAX_STRING_LENGTH, "\n");
		send_to_char (buf, ch);
	}
	else if ( k->pc ) {
		*buf = '\0';
		snprintf (buf, MAX_STRING_LENGTH,  "#2Sum:#0 %d",
			k->str + k->dex + k->con + k->intel + k->wil +
			k->aur + k->agi);
		pad_buffer (buf, 25);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Level:#0 %d", k->pc->level);
	        snprintf (ADDBUF, MAX_STRING_LENGTH, "\n");
		send_to_char (buf, ch);
	}

	snprintf (buf, MAX_STRING_LENGTH,  "\n#2Clans:#0  [%s]\n", k->clans && *k->clans ? k->clans : "");
	send_to_char (buf, ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2States:#0 [%s", position_types [GET_POS (k)]);

	if ( k->intoxication > 0 )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", drunk");

	if ( !k->hunger )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", hungry");

	if ( !k->thirst )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", thirsty");
	
	if ( !IS_NPC (k) ) {
		switch ( k->pc->create_state ) {
			case STATE_REJECTED:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", REJECTED");
				break;
			case STATE_APPLYING:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", APPLYING");
				break;
			case STATE_SUBMITTED:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", SUBMITTED");
				break;
			case STATE_APPROVED:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", APPROVED");
				break;
			case STATE_SUSPENDED:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", SUSPENDED");
				break;
			case STATE_DIED:
				snprintf (ADDBUF, MAX_STRING_LENGTH, ", DIED");
				break;
		}
	}

	if ( GET_FLAG (k, FLAG_ENTERING) )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", ENTERING");

	if ( GET_FLAG (k, FLAG_LEAVING) )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", LEAVING");

	if ( GET_FLAG (k, FLAG_OSTLER) )
		snprintf (ADDBUF, MAX_STRING_LENGTH, ", OSTLER");

	snprintf (ADDBUF, MAX_STRING_LENGTH, "]\n");
	send_to_char (buf, ch);


	if ( k->mob && k->mob->access_flags ) {

		snprintf (buf, MAX_STRING_LENGTH,  "Access: [");

		for ( i = 0; *room_bits [i] != '\n'; i++ )
			if ( IS_SET (k->mob->access_flags, 1 << i) )
				snprintf (ADDBUF, MAX_STRING_LENGTH, "%s ", room_bits [i]);

		strcat (buf, "]\n");
		send_to_char (buf, ch);
	}

	if ( k->mob && k->mob->noaccess_flags ) {

		snprintf (buf, MAX_STRING_LENGTH,  "Noaccess: [");

		for ( i = 0; *room_bits [i] != '\n'; i++ )
			if ( IS_SET (k->mob->noaccess_flags, 1 << i) )
				snprintf (ADDBUF, MAX_STRING_LENGTH, "%s ", room_bits [i]);

		strcat (buf, "]\n");
		send_to_char (buf, ch);
	}

	snprintf (buf, MAX_STRING_LENGTH,  "#2Flags:#0  [");

	if ( !IS_NPC (k) ) {
		for( i = 0; *player_bits [i] != '\n'; i++ ) 
			if ( IS_SET (k->act, 1 << i) )
				snprintf (ADDBUF, MAX_STRING_LENGTH, " %s", player_bits [i]);

	} else {
		for( i = 0; *action_bits [i] != '\n'; i++ ) 
			if ( IS_SET (k->act, 1 << i) )
				snprintf (ADDBUF, MAX_STRING_LENGTH, " %s", action_bits [i]);

		if ( k->mob->vehicle_type == VEHICLE_BOAT )
			strcat (buf, " Boat");

		else if ( k->mob->vehicle_type == VEHICLE_HITCH )
			strcat (buf, " Hitch");
	}

	if ( GET_FLAG (k, FLAG_GUEST) )
		strcat (buf, " Guest");

	if ( IS_SET (k->plr_flags, NOPETITION) )
		strcat (buf, " NoPetition");

	if ( GET_FLAG (k, FLAG_BRIEF) )
		strcat (buf, " Brief");

	if ( GET_FLAG (k, FLAG_WIZINVIS) )
		strcat (buf, " Wizinvis");

	if ( GET_FLAG (k, FLAG_KILL) && k->fighting )
		strcat (buf, " Killing");
	else if ( !GET_FLAG (k, FLAG_KILL) && k->fighting )
		strcat (buf, " Hitting");

	if ( GET_FLAG (k, FLAG_FLEE) )
		strcat (buf, " Fleeing");

	if ( GET_FLAG (k, FLAG_BINDING) )
		strcat (buf, " Binding");

	if ( GET_FLAG (k, FLAG_VARIABLE) )
		strcat (buf, " Variable");
		
	if ( GET_FLAG (k, FLAG_PACIFIST) )
		strcat (buf, " Pacifist");

	if ( IS_SET (k->plr_flags, NEWBIE_HINTS) )
		strcat (buf, " Hints");

	if ( IS_SET (k->plr_flags, MENTOR) )
		strcat (buf, " Mentor");

	if ( IS_SET (k->plr_flags, NEWBIE) )
		strcat (buf, " Newbie");

	if ( IS_SET (k->act, ACT_NOBIND) )
		strcat (buf, " NoBind");

	if ( IS_SET (k->act, ACT_NOBLEED) )
		strcat (buf, " NoBleed");

	if ( IS_SET (k->act, ACT_FLYING) )
		strcat (buf, " Flying");

	if ( IS_SET (k->act, ACT_PHYSICIAN) )
		strcat (buf, " Physician");

	if ( GET_FLAG (k, FLAG_SEE_NAME) )
		strcat (buf, " See_name");

	if ( GET_FLAG (k, FLAG_AUTOFLEE) )
		strcat (buf, " Autoflee");

	if ( IS_SET (k->act, ACT_PREY) )
		strcat (buf, " Prey");

	if ( GET_FLAG (k, FLAG_NOPROMPT) )
		strcat (buf, " Noprompt");

	if ( GET_FLAG (k, FLAG_OSTLER) )
		strcat (buf, " Ostler");

	if ( GET_FLAG (k, FLAG_ISADMIN) )
		strcat (buf, " IsAdminPC");

	if ( !IS_NPC(k) && k->pc->is_guide )
		strcat (buf, " IsGuide");

	if ( IS_SET (k->plr_flags, NO_PLAYERPORT) )
		strcat (buf, " NoPlayerPort");

	if ( k->color )
		strcat (buf, " ANSI");

	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ]\n");
	send_to_char (buf, ch);

	if ( IS_NPC (k) && k->mob->owner ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Owner:#0  [%s]\n", k->mob->owner);
		send_to_char (buf, ch);
	}

	if ( IS_SET(k->act, ACT_JAILER) ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Jail Info:#0 [ Cell1: %d Cell2: %d Cell3: %d ].\n", k->cell_1, k->cell_2, k->cell_3);
		send_to_char (buf, ch);
	}

	
	if ( k->desc && k->desc->snoop.snooping &&
		 is_he_somewhere (k->desc->snoop.snooping) ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Snooping:#0  %s\n", GET_NAME (k->desc->snoop.snooping));
		send_to_char (buf, ch);
	}

	if ( k->desc && k->desc->snoop.snoop_by &&
		 is_he_somewhere (k->desc->snoop.snoop_by) ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Snooped by:#0  %s\n", GET_NAME (k->desc->snoop.snoop_by));
		send_to_char (buf, ch);
	}

	if ( k->following && is_he_somewhere (k->following) ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Following:#0 %s\n", GET_NAME (k->following));
		send_to_char (buf, ch);
	}

	if ( k->affected_by ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Affect:#0 [ ");
		for ( i = 0; *affected_bits [i] != '\n'; i++ )
			if ( IS_SET (k->affected_by, 1 << i) )
				snprintf (ADDBUF, MAX_STRING_LENGTH, "%s ", affected_bits [i]);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "]\n");
		send_to_char (buf, ch);
	}

	
	if ( k->charms ) {
		snprintf (buf, MAX_STRING_LENGTH,  "------------ CHARMs ------------\n");
		for ( ench = k->charms; ench; ench = ench->next )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "%s: %d hours remaining\n", ench->name, ench->current_hours);
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "--------------------------------------\n\n");
		send_to_char (buf, ch);
	}

	for ( af = k->hour_affects; af; af = next_affect ) {

		if ( af == k->hour_affects )
			send_to_char ("\n", ch);

		next_affect = af->next;		/* WatchX affect can delete af */

		if ( af->type == AFFECT_SHADOW ) {

			if ( !af->a.shadow.shadow && af->a.shadow.edge != -1 )
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Standing", af->type);

			else if ( !is_he_somewhere (af->a.shadow.shadow) )
				continue;

			else if ( IS_NPC (af->a.shadow.shadow) )
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Shadowing %s (%d)", af->type,
						af->a.shadow.shadow->short_descr,
						af->a.shadow.shadow->mob->virtual);
			else
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Shadowing PC %s", af->type,
						GET_NAME (af->a.shadow.shadow));

			if ( af->a.shadow.edge != -1 )
				snprintf (ADDBUF, MAX_STRING_LENGTH, " on %s edge.",
						dirs [af->a.shadow.edge]);

			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");

			send_to_char (buf, ch);

			continue;
		}

		if ( af->type == AFFECT_GUARD_DIR ) {

			if ( !af->a.shadow.shadow && af->a.shadow.edge != -1 )
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Guarding", af->type);

				snprintf (ADDBUF, MAX_STRING_LENGTH, " the %s exit.",
						dirs [af->a.shadow.edge]);

			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");

			send_to_char (buf, ch);

			continue;
		}

		else if ( af->type == MAGIC_SIT_TABLE ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Sitting at table.\n", af->type);
			send_to_char (buf, ch);
			continue;
		}

		else if ( af->type >= MAGIC_STABLING_PAID && af->type <= MAGIC_STABLING_LAST ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Stabling paid for ID %d, %d IC hours remaining.\n", af->type, af->a.spell.sn, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if (af->type == MUTE_EAVESDROP) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0    Muting Eavesdropping\n", 
						af->type);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type >= CRAFT_FIRST && af->type <= CRAFT_LAST ) {
/*
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Craft %s subcraft %s\n",
						  af->type,
						  af->a.craft->subcraft->craft_name,
						  af->a.craft->subcraft->subcraft_name);
			send_to_char (buf, ch);
*/
			continue;
		}

		if ( af->type >= JOB_1 && af->type <= JOB_3 ) {

			i = time_info.year * 12 * 30 + time_info.month * 30 + time_info.day;
			i = af->a.job.pay_date - i;

			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Job %d:  Pays %d coins (%d of %d days until "
						  "payday)\n"
						  "                 %d x vnum %s (%d)\n", af->type,
							af->type - JOB_1 + 1, af->a.job.cash,
							i, af->a.job.days,
							af->a.job.count,
							!vtoo (af->a.job.object_vnum) ?
								"UNDEFINED" : vtoo (af->a.job.object_vnum)->
											short_description,
							af->a.job.object_vnum);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_CRAFT_BRANCH_STOP ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   May branch a craft again in %d RL minutes.\n", af->type, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_PETITION_MESSAGE ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Will not receive petition message again for %d RL minutes.\n", af->type, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == AFFECT_LOST_CON ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Will regain %d CON points in %d in-game hours.\n", af->type, af->a.spell.sn, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == AFFECT_HOLDING_BREATH ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Can hold breath for %d more RL seconds.\n", af->type, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_CRAFT_DELAY ) {
			if ( time(0) >= af->a.spell.modifier )
				continue;
	                time_diff = af->a.spell.modifier - time(0);
        	        days_remaining = time_diff / (60 * 60 * 24);
                	time_diff %= 60 * 60 * 24;
                	hours_remaining = time_diff / (60 * 60);
			time_diff %= 60 * 60;
			mins_remaining = time_diff / 60;
			time_diff %= 60;
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   OOC craft delay timer engaged. [%dd %dh %dm %ds remaining]\n", af->type, days_remaining, hours_remaining, mins_remaining, time_diff);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type >= MAGIC_SKILL_GAIN_STOP && af->type < MAGIC_SPELL_GAIN_STOP ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   May improve %s again in %d RL minutes.\n", 
			af->type, 
			skill_data[af->type - MAGIC_SKILL_GAIN_STOP].skill_name,
			af->a.spell.duration);
			
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type >= MAGIC_FLAG_NOGAIN && af->type <= MAGIC_FLAG_NOGAIN + LAST_SKILL ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Skill gain in %s has been halted by an administrator.\n", af->type, skill_data[af->type-6000].skill_name);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_RAISED_HOOD ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Mob has raised hood due to inclement weather.\n", af->type);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type >= MAGIC_CRIM_BASE &&
			 af->type <= MAGIC_CRIM_BASE + 100 ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Wanted in zone %d for %d hours.\n", af->type,
						  af->type - MAGIC_CRIM_BASE, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_NOTIFY ) {
			if ( is_he_somewhere ((CHAR_DATA *) af->a.spell.t) ) {
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Notify pending on %s for %d hours.\n",
					af->type,
					GET_NAME ((CHAR_DATA *) af->a.spell.t), af->a.spell.duration);
				send_to_char (buf, ch);
			}

			continue;
		}

		if ( af->type == MAGIC_CLAN_NOTIFY ) {
			if ( is_he_somewhere ((CHAR_DATA *) af->a.spell.t) ) {
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   CLAN Notify pending on %s for %d hours.\n",
					af->type,
					GET_NAME ((CHAR_DATA *) af->a.spell.t), af->a.spell.duration);
				send_to_char (buf, ch);
			}

			continue;
		}

		if ( af->type == MAGIC_GUARD ) {
			if ( is_he_somewhere ((CHAR_DATA *) af->a.spell.t) ) {
				snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Guarding %s.\n", af->type,
					GET_NAME ((CHAR_DATA *) af->a.spell.t));
				send_to_char (buf, ch);
			} else
				send_to_char ("   Guarding someone who's left the game.\n", ch);

			continue;
		}

		if ( af->type >= MAGIC_CRIM_HOODED &&
			 af->type < MAGIC_CRIM_HOODED + 100 ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Hooded criminal charge in zone %d for %d RL seconds.\n",
					 af->type, af->type - MAGIC_CRIM_HOODED, 
					 af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_STARED ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Studied by an enforcer.  Won't be studied for "
						  "%d RL seconds.\n",
					 af->type, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_WARNED ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Warned by an enforcer.  Won't be warned for "
						  "%d RL seconds.\n",
					 af->type, af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_HIDDEN ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Hidden.\n", af->type);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_SNEAK ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Currently trying to sneak.\n", af->type);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_TOLL ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   TOLL:  Collecting %d for going %s.\n",
						  af->type,
						  af->a.toll.charge,
						  dirs [af->a.toll.dir]);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type >= MAGIC_AFFECT_FIRST && af->type <= MAGIC_AFFECT_LAST ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   Spell effect, %d RL minutes remaining.\n",
						  af->type,
						  af->a.spell.duration);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_TOLL_PAID ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2%5d#0   TOLL PAID to travel %s.\n",
						  af->type,
						  dirs [af->a.toll.dir]);
			send_to_char (buf, ch);
			continue;
		}

		if ( af->type == MAGIC_WATCH1 ||
		     af->type == MAGIC_WATCH2 ||
		     af->type == MAGIC_WATCH3 )
			continue;

		if ( af->type >= MAGIC_FIRST_SOMA && af->type <= MAGIC_LAST_SOMA ) {
			soma_stat(ch, af);
			continue;
		}

		
	}

	send_to_char ("\n", ch);

	if ( k->shop && IS_SET (k->flags, FLAG_KEEPER) ) {
		snprintf (buf, MAX_STRING_LENGTH,  "  #2Shop Rm:#0  %5d\n",
					  k->shop->shop_vnum);
		send_to_char (buf, ch);

		snprintf (buf, MAX_STRING_LENGTH,  "  #2Store Rm:#0 %5d\n",
					  k->shop->store_vnum);
		send_to_char (buf, ch);

		snprintf (buf, MAX_STRING_LENGTH,  "  #2Markup:#0    %2.2f                \n",
					  k->shop->markup);
		send_to_char (buf, ch);

		if ( IS_SET (k->act, ACT_ECONZONE) ) {
			send_to_char ("   #3NOTE:#0  #5ECONZONE flag overrides standard "
						  "markups and discounts.#0\n", ch);

			econ_zone = zone_to_econ_zone (ch->room->zone);

			if ( econ_zone != -1 ) {

				snprintf (buf, MAX_STRING_LENGTH,  "          Markup/Discounts are those paid in "
							  "your zone:  %d (%s)\n",
							  ch->room->zone,
							  default_econ_info [econ_zone].flag_name);
				send_to_char (buf, ch);

				*buf = '\0';

				for ( i = 0; *default_econ_info [i].flag_name != '\n'; i++ ) {

					if ( (i % 3) == 0 ) {
						if ( *buf ) {
							send_to_char (buf, ch);
							send_to_char ("\n", ch);
						}
						strcpy (buf, "     ");
					}

					else if ( (i % 3) == 1 )
						pad_buffer (buf, 28);

					else
						pad_buffer (buf, 53);

					snprintf (ADDBUF, MAX_STRING_LENGTH, "  %-10.10s: %1.2f/%1.2f",
					  default_econ_info [i].flag_name,
					  default_econ_info [i].obj_econ_info [econ_zone].markup,
					  default_econ_info [i].obj_econ_info [econ_zone].discount);
				}

				if ( *buf ) {
					send_to_char (buf, ch);
					send_to_char ("\n", ch);
				}
			}
		}

		else {
			snprintf (buf, MAX_STRING_LENGTH,  "  #2Discount:#0  %2.2f\n", k->shop->discount);
			send_to_char (buf, ch);

			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup1:#0 %2.2f", k->shop->econ_markup1);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount1:#0 %2.2f", k->shop->econ_discount1);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ1:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags1, 1 << i) ) {
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "%s", econ_flags [i]);
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "]");

			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
			send_to_char (buf, ch);

			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup2:#0 %2.2f", k->shop->econ_markup2);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount2:#0 %2.2f", k->shop->econ_discount2);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ2:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags2, 1 << i) ) {
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "%s",  econ_flags [i]);
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "]");

			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
			send_to_char (buf, ch);

			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup3:#0 %2.2f", k->shop->econ_markup3);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount3:#0 %2.2f", k->shop->econ_discount3);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ3:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags3, 1 << i) ) {
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "%s",  econ_flags [i]);
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				strcat (buf, "]");

			strcat (buf, "\n");
			send_to_char (buf, ch);

			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup4:#0 %2.2f", k->shop->econ_markup4);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount4:#0 %2.2f", k->shop->econ_discount4);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ4:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags4, 1 << i) ) {
					strcat (buf, econ_flags [i]);
					strcat (buf, " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				strcat (buf, "]");

			strcat (buf, "\n");
			send_to_char (buf, ch);


			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup5:#0 %2.2f", k->shop->econ_markup5);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount5:#0 %2.2f", k->shop->econ_discount5);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ5:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags5, 1 << i) ) {
					strcat (buf, econ_flags [i]);
					strcat (buf, " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				strcat (buf, "]");

			strcat (buf, "\n");
			send_to_char (buf, ch);


			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup6:#0 %2.2f", k->shop->econ_markup6);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount6:#0 %2.2f", k->shop->econ_discount6);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ6:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags6, 1 << i) ) {
					strcat (buf, econ_flags [i]);
					strcat (buf, " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				strcat (buf, "]");

			strcat (buf, "\n");
			send_to_char (buf, ch);


			snprintf (buf, MAX_STRING_LENGTH,  "  #2Econ Markup7:#0 %2.2f", k->shop->econ_markup7);
			pad_buffer (buf, 23);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "   #2Discount7:#0 %2.2f", k->shop->econ_discount7);
			pad_buffer (buf, 40);
			snprintf (ADDBUF, MAX_STRING_LENGTH, "  #2Econ7:#0 [");

			for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
				if ( IS_SET (k->shop->econ_flags7, 1 << i) ) {
					strcat (buf, econ_flags [i]);
					strcat (buf, " ");
				}
			}

			if ( buf [strlen (buf) - 1] != '[' )
				buf [strlen (buf) - 1] = ']';
			else
				strcat (buf, "]");

			strcat (buf, "\n");
			send_to_char (buf, ch);

		}

		snprintf (buf, MAX_STRING_LENGTH,  "  #2NoBuy Flags:#0  [");

		for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
			if ( IS_SET (k->shop->nobuy_flags, 1 << i) ) {
				strcat (buf, econ_flags [i]);
				strcat (buf, " ");
			}
		}

		if ( buf [strlen (buf) - 1] != '[' )
			buf [strlen (buf) - 1] = ']';
		else
			strcat (buf, "]");

		strcat (buf, "\n");
		send_to_char (buf, ch);

		snprintf (buf, MAX_STRING_LENGTH,  "  #2Trades in:#0    [");

		for ( i = 0; i < MAX_TRADES_IN; i++ )
			if ( k->shop->trades_in [i] )
				snprintf (ADDBUF, MAX_STRING_LENGTH, "%s ", item_types [k->shop->trades_in [i]]);

		snprintf (ADDBUF, MAX_STRING_LENGTH, "]\n\n");
		send_to_char (buf, ch);

		if ( k->shop->delivery [0] ) {
			snprintf (buf, MAX_STRING_LENGTH,  "#2Deliveries:#0\n   ");
			j = 1;
			for ( i = 0; i <= MAX_DELIVERIES; i++ ) {
				if ( !k->shop->delivery[i] )
					break;
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2%d:#0 %-8d ", i, k->shop->delivery[i]);
				if ( !(j % 6) )
					strcat (buf, "\n   ");
				j++;
			}
			strcat (buf, "\n\n");
			send_to_char (buf, ch);
		}
 	}

	i2 = 1;
        snprintf (buf, MAX_STRING_LENGTH,  "#2%8.8s:#0 %03d/%03d  %s", "Offense", k->offense,
        	k->offense, i2 % 4 ? "" : "\n"); 
	send_to_char (buf, ch);

	for ( i = 0; i < MAX_SKILLS; i++ ) {
		if ( k->skills [i] && real_skill (k, i) ) {
			i2++;
			snprintf (buf, MAX_STRING_LENGTH,  "#2%8.8s:#0 %03d/%03d  %s", skill_data[i].skill_name, k->skills [i],
						  real_skill (k, i), i2 % 4 ? "" : "\n");
			send_to_char (buf, ch);
		}
	}

	if ( buf [strlen(buf)-1] != '\n' )
		send_to_char ("\n", ch);

	if ( loaded_char )
		unload_pc (k);
}

void roomstat (CHAR_DATA *ch, char *name)
{
	char				buf [MAX_STRING_LENGTH] = {'\0'};
	char				buf2 [MAX_STRING_LENGTH] = {'\0'};
	ROOM_DATA			*rm = NULL;
	CHAR_DATA			*k = NULL;
	OBJ_DATA			*j = NULL;
	XTRA_DESCR_DATA		*desc = NULL;
	int					i = 0;
	AFFECTED_TYPE		*herbed = NULL;


	rm = vtor (ch->in_room);
	snprintf (buf, MAX_STRING_LENGTH,  "[%4d]: %s\n", rm->virtual, rm->name);
	send_to_char(buf, ch);

	sprinttype (rm->sector_type, *sector_types, buf2);
	snprintf (buf, MAX_STRING_LENGTH,  "Sector type[%s] ", buf2);
	send_to_char(buf, ch);
			
	sprintbit ((long) rm->room_flags,room_bits,buf2);
	snprintf (buf, MAX_STRING_LENGTH,  "Rflags[%s]\n",buf2);
	send_to_char (buf,ch);

	send_to_char("Description:\n", ch);
	send_to_char(rm->description, ch);
	send_to_char("\n",ch);	
	if(rm->ex_description) {
		send_to_char("Ex-desc keyword(s)[",ch);
		for (desc = rm->ex_description; desc; desc = desc->next) {
			send_to_char(desc->keyword,ch);
			send_to_char(" ",ch);
		}
		send_to_char("]\n",ch);
	}

	herbed = is_room_affected(rm->affects, HERBED_COUNT);

	if(!herbed) 
	    send_to_char("\nThis room has not been herbed.\n\n", ch);
	else {
	    snprintf (buf2, MAX_STRING_LENGTH, "This room has been herbed %d times (Duration = %d)\n\n",
		    herbed->a.herbed.timesHerbed, herbed->a.herbed.duration);
	    send_to_char(buf2, ch);
	}
	    
	send_to_char ("------- Chars present -------\n", ch);
	for (k = rm->people; k; k = k->next_in_room) {
		if ( IS_NPC (k) )
			act ("NPC: $N", FALSE, ch, 0, k, TO_CHAR);
		else
			act ("PC:  $N", FALSE, ch, 0, k, TO_CHAR);
	}
	strcat(buf, "\n");
	send_to_char(buf, ch);

	strcpy(buf, "--------- Contents ---------\n");
	for (j = rm->contents; j; j = j->next_content)
	{
		strcat(buf, j->name);
		strcat(buf, "\n");
	}
	strcat(buf, "\n");
	send_to_char(buf, ch);

	send_to_char("------- Exits defined -------\n", ch);
	for (i = 0; i <= 5; i++) {
		if (rm->dir_option[i]) {
			snprintf (buf, MAX_STRING_LENGTH, "Direction %s . Keyword : %s\n",
			        dirs[i], rm->dir_option[i]->keyword);
			send_to_char(buf, ch);
			strcpy(buf, "Description:\n  ");
			if(rm->dir_option[i]->general_description)
		  	strcat(buf, rm->dir_option[i]->general_description);
			else
				strcat(buf,"UNDEFINED\n");
			send_to_char(buf, ch);
			sprintbit(rm->dir_option[i]->exit_info,exit_bits,buf2);
			snprintf (buf, MAX_STRING_LENGTH,  "Exit flag: %s \nKey no: %d  (pick penalty %d)\nTo room (Virtual: %d)\n",
			        buf2, rm->dir_option[i]->key, rm->dir_option [i]->pick_penalty,
					rm->dir_option[i]->to_room);
			send_to_char(buf, ch);
		}
	}
	
	send_to_char("------- Extra descriptions -------\n", ch);
	if ( rm->extra ) {
		for ( i = 0; i < WR_DESCRIPTIONS; i++ ){
			if (rm->extra->weather_desc [i]){
				snprintf (buf, MAX_STRING_LENGTH, "%s:  %s", weather_room [i], rm->extra->weather_desc [i]);
				send_to_char(buf, ch);
			}
		}
		
		send_to_char("\n", ch);
		
		for ( i = 0; i < 6; i++ ){
			if (rm->extra->alas [i]){
				snprintf (buf, MAX_STRING_LENGTH,"%s alas:  %s", dirs[i], rm->extra->alas [i] );
				send_to_char(buf, ch);
			}
		}
	}
}

/*                                                                          *
 * funtion: acctstat                    < e.g.> stat acct traithe           *
 *                                                                          *
 *                                                                          */
void acctstat (CHAR_DATA *ch, char *name)
{
	ACCOUNT_DATA	*account = NULL;
	STORED_PC_DATA	*pc = NULL;
	char			*date = NULL;
	time_t			account_time;
	char			buf [MAX_STRING_LENGTH] = {'\0'};
	char			line [MAX_STRING_LENGTH] = {'\0'};
	MYSQL_RES		*result = NULL;
	MYSQL_ROW		row = NULL;
	int				messages = 0;

	if ( !*name || strtol(name, NULL,10) ) {
		send_to_char ("Please specify an account name.\n", ch);
		return;
	}
	if ( !(account = load_account(name)) ) {
		send_to_char ("That account does not exist.\n", ch);
		return;
	}
	

	*buf = '\0';
	*line = '\0';

	snprintf (buf, MAX_STRING_LENGTH, "\n   #2Account Name:#0            %s\n", account->name);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Registered Email:#0        %s\n", account->email);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Last Logged In From:#0     %s\n", account->last_ip);
	
	/* Retreive a list of other users from this IP ( default = no-op )*/
	mysql_safe_query ("SELECT username FROM forum_users WHERE user_last_ip = '%s' AND username != '%s'", account->last_ip, account->name);
	if( ( result = mysql_store_result( database ) ) != NULL ) {
	  if ( !IS_SET (account->flags, ACCOUNT_IPSHARER) && mysql_num_rows (result) > 0  
	       && str_cmp( account->name, "Guest" ) 
	       && str_cmp( account->last_ip, "(null)" )
	       && !strstr( account->last_ip, "www.yourmud.org" ) ) {
	    snprintf ( buf + strlen( buf ), MAX_STRING_LENGTH, "   #1Accounts Sharing IP:#0    " );
	    while ( ( row = mysql_fetch_row( result ) ) ) {
	      snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " %s", row[0]);
	    }
	    snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "#0\n");
	  }	
	  mysql_free_result (result);
	  result = NULL;
	}
	else {
	  system_log("Warning: MySql returned a NULL result in staff.c::acctstat() while fetching account sharing info.", TRUE);
	}

	/* Retreive the timestamp for Last Activity ( default = "" ) */
	date = (char *) malloc ( 256) ; 
	date[0] = '\0' ;
	mysql_safe_query ( "SELECT lastlogon FROM %s.pfiles WHERE account = '%s' ORDER BY lastlogon DESC LIMIT 1", PFILES_DATABASE, account->name ) ;
	if ( ( result = mysql_store_result ( database ) ) != NULL ) {
	  row = mysql_fetch_row( result ) ;
	  
	  if ( row && *row[0] ) {
	    account_time = (time_t) strtol(row[0], NULL, 10);
	    if ( asctime_r( localtime( &account_time ), date ) != NULL ) { 
	      date [strlen(date)-1] = '\0' ; /* chop the newline asctime_r tacks on */
	    }
	  }
	  
	  mysql_free_result ( result );
	  result = NULL;
	}
	else {
	  system_log("Warning: MySql returned a NULL result in staff.c::acctstat() while fetching lastlogin info.", TRUE);
	}
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Last PC Activity On:#0     %s\n", ( date[0] ) ? date : "None Recorded") ;     
	mem_free (date);

	/* Account Registration Date ( default = "None Recorded" ) */
	date = (char *) malloc (256) ; 
	date[0] = '\0' ;
	account_time = account->created_on;
	asctime_r( localtime( &account_time ), date ) ;
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Account Registered On:#0   %s", ( date[0] ) ? date : "None Recorded") ;
	mem_free (date);

	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Accrued Roleplay Points:#0 %d\n", account->roleplay_points);

	if ( account->last_rpp > 0 ) {
		account_time = (time_t) account->last_rpp;
		date = (char *) malloc (256) ; 
		date[0] = '\0' ;
		asctime_r( localtime( &account_time ), date ) ;
		date[strlen(date)-1] = '\0';
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Last RPP Award On:#0       %s\n", account->last_rpp > 0 ? date : "None Recorded");
		mem_free (date);
	}

	/* Retreive the number of stored Hobbitmails ( default = 0 ) */
	messages = 0 ;
	mysql_safe_query ("SELECT COUNT(*) FROM hobbitmail WHERE account = '%s'", account->name);
	if ( ( result = mysql_store_result(database) ) != NULL ) {
	  messages = ( ( row = mysql_fetch_row( result ) ) != NULL ) 
	    ? strtol( row[0], NULL,10 ) 
	    : 0 ;
	  mysql_free_result ( result ) ;
	  result = NULL;
	}
	else {
	  system_log("Warning: MySql returned a NULL result in staff.c::acctstat() while fetching hmail count", TRUE);
	}
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Stored Hobbitmails:#0      %d\n", messages);

	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Web Forum Posts:#0         %d\n", account->forum_posts);

	if ( account->flags ) {
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Account Flags Set:#0      ");
		if ( IS_SET (account->flags, ACCOUNT_NOPETITION) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoPetition");
		if ( IS_SET (account->flags, ACCOUNT_NOGUEST) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoGuest");
		if ( IS_SET (account->flags, ACCOUNT_NOPSI) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoPsi");
		if ( IS_SET (account->flags, ACCOUNT_NOBAN) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoBan");
		if ( IS_SET (account->flags, ACCOUNT_NORETIRE) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoRetire");
		if ( IS_SET (account->flags, ACCOUNT_NOVOTE) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " NoVoteReminder");
		if ( IS_SET (account->flags, ACCOUNT_IPSHARER) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " IPSharingOK");
		if ( IS_SET (account->flags, ACCOUNT_RPPDISPLAY) )
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " RPPDisplay");
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
	}
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2ANSI Color Setting:#0      %s\n", account->color ? "On" : "Off");
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Downloaded Sourcecode:#0   %s\n", account->code ? "Yes" : "No");  
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   #2Newsletter Status:#0       %s\n", account->newsletter ? "Subscribed" : "Opted Out");

	if ( account->pc ) {
		snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
		for ( pc = account->pc; pc; pc = pc->next ) {
			if ( strlen(buf) + strlen(line) >= MAX_STRING_LENGTH )
				break;
			snprintf (line, MAX_STRING_LENGTH, "   #2Registered Character:#0    %s\n", pc->name);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "%s", line);
		}
	}

	if ( account != NULL )
		free_account (account);

	page_string (ch->desc, buf);
}

void objstat (CHAR_DATA *ch, char *name)
{
	OBJ_DATA			*j = NULL;
	OBJ_DATA			*j2 = NULL;
	char				buf [MAX_STRING_LENGTH] = {'\0'};
	char				buf2 [MAX_STRING_LENGTH] = {'\0'};
	char				copper_buf [MAX_STRING_LENGTH] = {'\0'};
	char *bow_type[] = { "Longbow", "Shortbow", "Crossbow", "Sling" };
	int					i =0 ;
	int					instance = 0;
	float				cost = 0;
	AFFECTED_TYPE		*af  = NULL;
	char				*temp_arg = NULL;
	


	
	if ( !*name && !strtol(name, NULL,10) ) {
		send_to_char ("Please specifiy an object name or vnum.\n", ch);
		return;
	}

	if ( just_a_number (name) && vtoo (strtol(name, NULL,10)) )
		j = vtoo (strtol(name, NULL,10));

	else if ( (j = get_obj_in_list_vis (ch, name, ch->right_hand)) ||
			(j = get_obj_in_list_vis (ch, name, ch->left_hand)) ||
			  (j = get_obj_in_list_vis (ch, name, ch->room->contents)) )
		instance = 1;

	else if ( !IS_NPC (ch) && !*name )
		j = vtoo (ch->pc->edit_obj);

	if ( !j ) {
		send_to_char ("No such object.\n", ch);
		return;
	}

	snprintf (buf, MAX_STRING_LENGTH,  "\n#2VNUM:#0  %d [%s] [#2%s#0] [id %d]\n", j->virtual,
		instance ? "#2Instance#0" : "#2Prototype#0",
		item_types[(int)GET_ITEM_TYPE(j)], j->coldload_id);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Keys: #0 %s\n", j->name);
	send_to_char (buf, ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2SDesc:#0 %s\n#2LDesc:#0 %s\n\n", j->short_description,
		j->description);
	send_to_char(buf, ch);

	if ( j->obj_flags.type_flag == ITEM_INK ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Ink String:#0  %s\n", j->ink_color);
		send_to_char (buf, ch);
	}

	if ( j->obj_flags.wear_flags ) {
		snprintf (buf, MAX_STRING_LENGTH, "#2Wearbits:#0    ");
		for(i=0;(*wear_bits[i] != '\n');i++)
			if(IS_SET(j->obj_flags.wear_flags,(1<<i)))
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,"%s ",wear_bits[i]);
		strcat(buf,"\n");
		send_to_char(buf, ch);
	}

	if ( j->obj_flags.bitvector ) {
		snprintf (buf, MAX_STRING_LENGTH, "#2Bitvector:#0   ");
		for(i=0;(*affected_bits[i] != '\n');i++)
			if(IS_SET(j->obj_flags.bitvector,(1<<i)))
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,"%s ",affected_bits[i]);
		strcat(buf,"\n");
		send_to_char(buf, ch);
	}

	if ( j->obj_flags.extra_flags ) {
		snprintf (buf, MAX_STRING_LENGTH, "#2Extra Flags:#0 ");
		for(i=0;(*extra_bits[i] != '\n');i++)
			if(IS_SET(j->obj_flags.extra_flags,(1<<i)))
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,"%s ",extra_bits[i]);
		strcat(buf,"\n");
		send_to_char(buf,ch);
	}

	if ( j->econ_flags ) {
		snprintf (buf, MAX_STRING_LENGTH,  "#2Econ Flags:#0  ");
		for ( i = 0; str_cmp (econ_flags [i], "\n"); i++ ) {
			if ( IS_SET (j->econ_flags, 1 << i) ) {
				strcat (buf, econ_flags [i]);
				strcat (buf, " ");
			}
		}
		strcat (buf, "\n");
		send_to_char (buf, ch);
	}

	*buf = 0;

	if ( j->size ) {
		if ( IS_WEARABLE (j) )
			snprintf (buf, MAX_STRING_LENGTH,  "#2Size:#0 %s (%s)\n",
							sizes_named [j->size], sizes [j->size]);
		else
			snprintf (buf, MAX_STRING_LENGTH,  "#2Size:#0 %s (%s) #1[N/A]#0\n",
							sizes_named [j->size], sizes [j->size]);
	}

	else if ( IS_WEARABLE (j) )
		snprintf (buf, MAX_STRING_LENGTH,  "#2Size:#0 Any\n");

	if ( *buf )
		send_to_char (buf, ch);

	if ( GET_ITEM_TYPE (j) == ITEM_FLUID )
		snprintf (copper_buf, MAX_STRING_LENGTH, "%d.%02df (%d)", (int)j->coppers / 100, (int)j->coppers % 100, (int)j->coppers);
	else
		snprintf (copper_buf, MAX_STRING_LENGTH, "%df", (int)j->coppers);

	cost = j->coppers;

	snprintf (buf, MAX_STRING_LENGTH,  "#2Weight:#0      %d.%02d", j->obj_flags.weight/100, j->obj_flags.weight % 100);
	pad_buffer (buf, 32);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Full Weight:#0  %d.%02d", OBJ_MASS(j)/100, OBJ_MASS(j)%100);
	pad_buffer (buf, 61);
        snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Timer:#0  %d\n", j->obj_timer);
	send_to_char (buf, ch);

	snprintf (buf, MAX_STRING_LENGTH,  "#2Cost:#0        %.02f cp", cost);
	pad_buffer (buf, 32);
	snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Quality:#0 %d", j->quality);
	pad_buffer (buf, 61);
        snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Cond.:#0  %d%%\n\n", j->item_wear);

	send_to_char (buf, ch);

	switch (j->obj_flags.type_flag) {
		case ITEM_FLUID:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Alcohol:#0 %d per sip\n"
						  "#2Oval1 - Water:#0   %d per sip\n"
						  "#2Oval2 - Food:#0    %d per sip\n",
						  j->o.fluid.alcohol,
						  j->o.fluid.water,
						  j->o.fluid.food);
			break;

		case ITEM_LIGHT: 

			if ( (j2 = vtoo (j->o.light.liquid)) ) {
				snprintf (buf2, MAX_STRING_LENGTH,  "%d (%s)", j2->virtual, j2->short_description);
				if ( GET_ITEM_TYPE (j2) != ITEM_LIQUID_FUEL )
					snprintf (buf2 + strlen (buf2), MAX_STRING_LENGTH, " [Need %s; this is %s]\n",
							 item_types [ITEM_LIQUID_FUEL],
							 item_types [(int) GET_ITEM_TYPE (j2)]);
			}

			else if ( j->o.light.v4 < 33 ) {
				sprinttype (j->o.light.v4, *drinks, buf2);
				strcat (buf2, " [NEEDS OBJECT ASSIGNED]");
			}

			else
				snprintf (buf2, MAX_STRING_LENGTH,  "%d (NO SUCH OBJECT EXISTS)",
							   j->o.light.liquid);

			snprintf (buf, MAX_STRING_LENGTH,              "#2Oval0 - Capacity:#0 %d\n"
						  "#2Oval1 - Hours:#0    %d\n"
						  "#2Oval2 - Liquid:#0   %s\n"
						  "#2Oval3 - On:#0       %d (0 is no, 1 is yes)\n",
						  j->o.light.capacity,
						  j->o.light.hours,
						  buf2,
						  j->o.light.on);
			break;

		case ITEM_FOOD :
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Food Value:#0 %d\n"
						  "#2Oval5 - Bites:#0 %3d\n",
					j->o.od.value [0],
					j->o.od.value [5]);
			break;
		
		case ITEM_WORN :
			snprintf (buf, MAX_STRING_LENGTH,  "#2MKeys:#0 %s\n", j->desc_keys);
			break;

		case ITEM_POTION:
		case ITEM_SCROLL:
		case ITEM_SALVE:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Dormancy 1:#0 %d IC Hours%s\n", j->o.od.value[0], !j->o.od.value[0] ? " (Instantaneous)" : "");
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval1 - Duration 1:#0 %d IC Hours%s\n", j->o.od.value[1], !j->o.od.value[1] ? " (Instantaneous)" : "");
			
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval3 - Dormancy 2:#0 %d IC Hours%s\n", j->o.od.value[3], !j->o.od.value[3] ? " (Instantaneous)" : "");
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval4 - Duration 2:#0 %d IC Hours%s\n", j->o.od.value[4], !j->o.od.value[4] ? " (Instantaneous)" : "");
			send_to_char (buf, ch);

			*buf = '\0';

			break;

		case ITEM_WEAPON :
			if ( j->o.weapon.use_skill != SKILL_SHORTBOW && j->o.weapon.use_skill != SKILL_LONGBOW 
			     && j->o.weapon.use_skill != SKILL_CROSSBOW && j->o.weapon.use_skill != SKILL_SLING )  {
			        snprintf (buf, MAX_STRING_LENGTH,  "#2Hands (Oval0):#0 #1[DEPRECATED - BASED ON WEAPON SKILL]#0\n");
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Damage (Oval1/2):#0 %dd%d\n", j->o.od.value[1], j->o.od.value[2]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Weapon Type (Type):#0 %s\n", skill_data[j->o.od.value[3]].skill_name);
				if ( j->o.od.value[4] >= 0 && j->o.od.value[4] <= 4 )
					snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Hit Theme (Oval4):#0 %d (%s)\n", j->o.od.value[4], weapon_theme[j->o.od.value[4]]);
				else snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Hit Theme (Oval4):#0 %d (None!)", j->o.od.value[4]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Delay (Oval5):#0 %d\n", j->o.od.value[5]);
			}
			else {
				snprintf (buf, MAX_STRING_LENGTH,  "#2Hands (Oval0):#0 %d\n", j->o.od.value[0]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Bow Type (Oval1):#0 %s\n", bow_type[j->o.od.value[1]]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Accuracy Modifier (Oval2):#0 %d\n", j->o.od.value[2]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Skill Used (Oval3):#0 %s [skill number %d]\n", skill_data[j->o.od.value[3]].skill_name, j->o.od.value[3]);
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Damage Modifier (Oval4):#0 %d\n", j->o.od.value[4]);
			}
			break;

		case ITEM_ARMOR :
			snprintf (buf, MAX_STRING_LENGTH,  "#2AC-Apply:#0 [%d]\n#2Type:#0 [%d: %s]\n#2MKeys:#0 %s\n",
		 		j->o.od.value [0],j->o.od.value[1], armor_types[j->o.od.value[1]], j->desc_keys);
			break;

		case ITEM_NPC_OBJECT :
			snprintf (buf, MAX_STRING_LENGTH,  "#2NPC VNUM:#0 %d [#5%s#0]\n", j->o.od.value [0], j->o.od.value[0] > 0 ? vtom(j->o.od.value[0])->short_descr : "none");
			break;

		case ITEM_CONTAINER :
			if ( !IS_SET (j->obj_flags.extra_flags, ITEM_TABLE))
			snprintf (buf, MAX_STRING_LENGTH,              "#2Oval0 - Capacity:#0  %d  (%d.%.2d lbs)\n"
						 "#2Oval1 - Lockflags:#0 %d\n"
						 "#2Oval2 - Key#0:       %d\n"
						 "#2Oval3 - Pick Penl:#0 %d\n"
						 "#2Oval4 - N/A:#0       %d\n"
						 "#2Oval5 - Corpse:#0    %s\n",
					j->o.container.capacity,
					j->o.container.capacity / 100,
					j->o.container.capacity % 100,
					j->o.container.flags,
					j->o.container.key,
					j->o.container.pick_penalty,
					j->o.container.v4,
					j->virtual == VNUM_CORPSE ? "Yes" : "No");
			else
			snprintf (buf, MAX_STRING_LENGTH,              "#2Oval0 - Capacity:#0    %d  (%d.%.2d lbs)\n"
						 "#2Oval1 - Lockflags:#0   %d\n"
						 "#2Oval2 - Key:#0         %d\n"
						 "#2Oval3 - Pick Penl:#0   %d\n"
						 "#2Oval4 - N/A:#0         %d\n"
						 "#2Oval5 - Seating Cap:#0 %d\n",
					j->o.container.capacity,
					j->o.container.capacity / 100,
					j->o.container.capacity % 100,
					j->o.container.flags,
					j->o.container.key,
					j->o.container.pick_penalty,
					j->o.container.v4,
					j->o.container.table_max_sitting);

			break;

		case ITEM_DRINKCON:
		case ITEM_FOUNTAIN:

			if ( (j2 = vtoo (j->o.drinkcon.liquid)) ) {
				snprintf (buf2, MAX_STRING_LENGTH,  "%d (%s)", j2->virtual, j2->short_description);
				if ( GET_ITEM_TYPE (j2) != ITEM_FLUID )
					snprintf (buf2 + strlen (buf2), MAX_STRING_LENGTH, " [Need %s; this is %s]\n",
							 item_types [ITEM_FLUID],
							 item_types [(int) GET_ITEM_TYPE (j2)]);
			}

			else if ( j->o.drinkcon.liquid )
				strcat (buf2, " [None set]");

			else if ( j->o.drinkcon.liquid < 33 ) {
				sprinttype (j->o.drinkcon.liquid, *drinks, buf2);
				strcat (buf2, " [NEEDS OBJECT ASSIGNED]");
			}

			else
				snprintf (buf2, MAX_STRING_LENGTH,  "%d (NO SUCH OBJECT EXISTS)",
							   j->o.drinkcon.liquid);

			snprintf (buf, MAX_STRING_LENGTH,              "#2Oval0 - Capacity:#0 %d\n"
						  "#2Oval1 - Contains:#0 %d\n"
						  "#2Oval2 - Liquid:#0   %s\n",
						j->o.drinkcon.capacity,
						j->o.drinkcon.volume,
						buf2);
			break;

		case ITEM_KEY :
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Keytype:#0  %d\n", j->o.od.value[0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval1 - Keyed To:#0 %d\n", j->o.od.value[1]);
			break;

		case ITEM_TICKET:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Ticket Number:#0 %d\n"
				      "#2Oval1 - Keeper VNUM:#0   %d\n",
						  j->o.ticket.ticket_num,
						  j->o.ticket.keeper_vnum);
			break;

		case ITEM_PERFUME:
			snprintf (buf, MAX_STRING_LENGTH,              "#2Oval0 - Perfume Type:#0 %d\n"
						  "#2Oval1 - Duration:#0     %d\n"
						  "#2Oval2 - Aroma Str:#0    %d\n"
						  "#2Oval3 - Doses:#0        %d\n",
							j->o.perfume.type,
							j->o.perfume.duration,
							j->o.perfume.aroma_strength,
							j->o.perfume.doses);
			break;

		case ITEM_QUIVER:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Missile Capacity:#0 %d\n",
							j->o.od.value[0]);
			break;

		case ITEM_KEYRING:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Key Capacity:#0 %d\n", j->o.od.value[0]);
			break;

		case ITEM_SHEATH:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval0 - Capacity:#0 %d (%d lbs.)\n", j->o.od.value[0], j->o.od.value[0]/100);
			break;

		case ITEM_MISSILE:
		case ITEM_BULLET:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Base Damage:#0 %dd%d\n", j->o.od.value[0], j->o.od.value[1]);
			break;

		case ITEM_INK:
	                snprintf (buf, MAX_STRING_LENGTH,  "#2Oval 0 -  Dips Left:#0  %d\n", j->o.od.value [0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 1 -  Capacity:#0   %d\n", j->o.od.value[1]);
			break;

		case ITEM_HEALER_KIT:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval 0 -  Uses Remaining:#0  %d\n", j->o.od.value[0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 1 -  Healing Bonus:#0   %d\n", j->o.od.value[1]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 2 -  Required Skill:#0  %d\n", j->o.od.value[2]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 3 -  Immediate Regen:#0 %d\n", j->o.od.value[3]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Treats These Wound Types:#0 ");
			if ( !j->o.od.value[5] || IS_SET (j->o.od.value[5], TREAT_ALL) ) {
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " All\n");
				break;
			}
			if ( IS_SET (j->o.od.value[5], TREAT_BLUNT) )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " Contusion");
			if ( IS_SET (j->o.od.value[5], TREAT_SLASH) )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " Slash");
			if ( IS_SET (j->o.od.value[5], TREAT_PUNCTURE) )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " Puncture");
			if ( IS_SET (j->o.od.value[5], TREAT_BURN) )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " Burn");
			if ( IS_SET (j->o.od.value[5], TREAT_FROST) )
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  " Frost");
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
			break;

		case ITEM_REPAIR_KIT:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval 0 -  Uses Remaining:#0  %d\n", j->o.od.value[0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 1 -  Mending Bonus:#0   %d\n", j->o.od.value[1]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 2 -  Required Skill:#0  %d\n", j->o.od.value[2]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Skill needed to use kit:#0   %s\n", 
				 (j->o.od.value[3] > 0) ? skill_data[(j->o.od.value[3])].skill_name : (j->o.od.value[3] < 0) ? "#1None#0" : "#1Any#0");
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Repairs This Item Types:#0   ");
			if ( j->o.od.value[5] == 0 ) {
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#1All#0\n");
				break;
			}
			else if ( j->o.od.value[5] < 0 ) {
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#1None#0\n");
				break;
			}
			else {
				snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "%s\n", item_types[(j->o.od.value[5])]);
				break;
			}

			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "\n");
			break;

		case ITEM_TENT:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval 0 -  Destination Room:#0 %d\n", j->o.od.value[0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 1 -  Max Occupancy:#0    %d\n", j->o.od.value[1]);
			break;

		case ITEM_DWELLING:
			snprintf (buf, MAX_STRING_LENGTH,  "#2Oval 0 -  Destination Room:#0 %d\n", j->o.od.value[0]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 1 -  Max Occupancy:#0    %d\n", j->o.od.value[1]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 2 -  Lockflags:#0        %d\n", j->o.od.value[2]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 3 -  Key:#0              %d\n", j->o.od.value[3]);
			snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "#2Oval 4 -  Pick Penalty:#0     %d\n", j->o.od.value[4]);
			break;

		default :
			if ( j->virtual == 666 )
				snprintf (buf, MAX_STRING_LENGTH,  "#2Original Object VNUM:#0 %d\n", j->o.od.value[0]);
			else snprintf (buf, MAX_STRING_LENGTH, "#2Values 0-5:#0 [%d] [%d] [%d] [%d] [%d] [%d]\n",
				j->o.od.value [0],
				j->o.od.value [1],
				j->o.od.value [2],
				j->o.od.value [3],
				j->o.od.value [4],
				j->o.od.value [5]);
			break;
		}

	send_to_char(buf, ch);

	if ( j->contains ) {
		strcpy(buf, "\n#2Contains#0[ ");
		
		for(j2=j->contains;j2;j2 = j2->next_conte

Showing the first 100 KB of 233.1 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571