daleken/
daleken/data/notes/
daleken/data/player/
daleken/data/system/poses/
daleken/doc/Homepage/images/
daleken/log/
/*___________________________________________________________________________*
   )()(			  DalekenMUD 1.12 (C) 2000			)()(
   `]['		       by Martin Thomson, Lee Brooks,			`]['
    ||		       Ken Herbert and David Jacques			 ||
    || ----------------------------------------------------------------- ||
    || Envy Diku Mud improvements copyright (C) 1994 by Michael Quan,	 ||
    || David Love, Guilherme 'Willie' Arnold, and Mitchell Tse.		 ||
    || Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael	 ||
    || Chastain, Michael Quan, and Mitchell Tse.			 ||
    || Original Diku Mud copyright (C) 1990, 1991			 ||
    || by Sebastian Hammer, Michael Seifert, Hans Henrik St{rfeldt,	 ||
    || Tom Madsen, and Katja Nyboe.					 ||
    || ----------------------------------------------------------------- ||
    || Any use of this software must follow the licenses of the		 ||
    || creators.  Much time and thought has gone into this software and	 ||
    || you are benefitting. We hope that you share your changes too.	 ||
    || What goes around, comes around.					 ||
    || ----------------------------------------------------------------- ||
    ||                              interp.c                             ||
    || Command interpreter plus socials and poses code.                  ||
 *_/<>\_________________________________________________________________/<>\_*/

#include "mud.h"
#include "olc.h"
#include "db.h"

bool check_social args( ( CHAR_DATA *ch, char *command,
			  const char *argument ) );

/*
 * Command logging types.
 */
#define LOG_NORMAL		0
#define LOG_ALWAYS		1
#define LOG_NEVER		2

/*
 * Log-all switch.
 */
char last_command[MAX_INPUT_LENGTH * 2];
/*
 * For poses, reintroduced for Daleken 1.10.
 */
struct pose_index_data pose_table [ MAX_CLASS ];
int top_pose;

char const message_colours[] = {
    'w', 'b', 'r', 'g', 'y', 'm'
};

/*
 * Command table.
 * What a monstrosity!
 */
const struct cmd_type cmd_table[] =
{
    /*
     * Common movement commands.
     */
    { "north",		do_north,	POS_STANDING,	0,	LOG_NORMAL },
    { "east",		do_east,	POS_STANDING,	0,	LOG_NORMAL },
    { "south",		do_south,	POS_STANDING,	0,	LOG_NORMAL },
    { "west",		do_west,	POS_STANDING,	0,	LOG_NORMAL },
    { "up",		do_up,		POS_STANDING,	0,	LOG_NORMAL },
    { "down",		do_down,	POS_STANDING,	0,	LOG_NORMAL },

    /*
     * Common other commands.
     * Placed here so one and two letter abbreviations work.
     */
    { "affects",	do_affects,	POS_STUNNED,	0,	LOG_NORMAL },
    { "buy",		do_buy,		POS_SITTING,	0,	LOG_NORMAL },
    { "cast",		do_cast,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "exits",		do_exits,	POS_RESTING,	0,	LOG_NORMAL },
    { "get",		do_get,		POS_RESTING,	0,	LOG_NORMAL },
    { "group",		do_group,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "holypower",	do_holypower,	POS_FIGHTING,	5,	LOG_NORMAL },
    { "inventory",	do_inventory,	POS_DEAD,	0,	LOG_NORMAL },
    { "immtalk",	do_immtalk,	POS_DEAD,	L_ANG,	LOG_NORMAL },
    { "kill",		do_kill,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "look",		do_look,	POS_RESTING,	0,	LOG_NORMAL },
    { "open",		do_open,	POS_RESTING,	0,	LOG_NORMAL },
    { "order",		do_order,	POS_RESTING,	0,	LOG_ALWAYS },
    { "quaff",		do_quaff,	POS_RESTING,	0,	LOG_NORMAL },
    { "racial",		do_racial,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "rest",		do_rest,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "recall",		do_recall,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "/",		do_recall,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "seniortalk",	do_seniortalk,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "sit",		do_sit,		POS_SLEEPING,	0,	LOG_NORMAL },
    { "sleep",		do_sleep,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "stand",		do_stand,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "tell",		do_tell,	POS_RESTING,	0,	LOG_NORMAL },
    { "wake",		do_wake,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "wear",		do_wear,	POS_RESTING,	0,	LOG_NORMAL },
    { "wield",		do_wear,	POS_RESTING,	0,	LOG_NORMAL },
    { "wizhelp",	do_wizhelp,	POS_DEAD,	L_ANG,	LOG_NORMAL },

    /*
     * Informational commands.
     */
    { "areas",		do_areas,	POS_DEAD,	0,	LOG_NORMAL },
    { "bug",		do_bug,		POS_DEAD,	0,	LOG_NORMAL },
    { "color",		do_colour,	POS_DEAD,	0,	LOG_NORMAL },
    { "colour",		do_colour,	POS_DEAD,	0,	LOG_NORMAL },
    { "commands",	do_commands,	POS_DEAD,	0,	LOG_NORMAL },
    { "compare",	do_compare,	POS_RESTING,	0,	LOG_NORMAL },
    { "consider",	do_consider,	POS_RESTING,	0,	LOG_NORMAL },
    { "credits",	do_credits,	POS_DEAD,	0,	LOG_NORMAL },
    { "equipment",	do_equipment,	POS_DEAD,	0,	LOG_NORMAL },
    { "examine",	do_examine,	POS_RESTING,	0,	LOG_NORMAL },
    { "help",		do_help,	POS_DEAD,	0,	LOG_NORMAL },
    { "highest",	do_highest,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "idea",		do_idea,	POS_DEAD,	0,	LOG_NORMAL },
    { "magic",		do_magic,	POS_DEAD,	0,	LOG_NORMAL },
    { "pagelength",	do_pagelen,	POS_DEAD,	0,	LOG_NORMAL },
    { "quest",		do_quest,	POS_RESTING,	0,	LOG_NORMAL },
    { "raceinfo",	do_raceinfo,	POS_DEAD,	0,	LOG_NORMAL },
    { "report",		do_report,	POS_DEAD,	0,	LOG_NORMAL },
    { "read",		do_look,	POS_RESTING,	0,	LOG_NORMAL },
    { "scan",		do_scan,	POS_RESTING,	0,	LOG_NORMAL },
    { "score",		do_score,	POS_DEAD,	0,	LOG_NORMAL },
    { "slist",		do_slist,	POS_DEAD,	0,	LOG_NORMAL },
    { "socials",	do_socials,	POS_DEAD,	0,	LOG_NORMAL },
    { "spells",		do_spells,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "time",		do_time,	POS_DEAD,	0,	LOG_NORMAL },
    { "typo",		do_typo,	POS_DEAD,	0,	LOG_NORMAL },
    { "weather",	do_weather,	POS_RESTING,	0,	LOG_NORMAL },
    { "who",		do_who,		POS_DEAD,	0,	LOG_NORMAL },
    { "whois",		do_whois,	POS_DEAD,	0,	LOG_NORMAL },
    { "wizlist",	do_wizlist,	POS_DEAD,	0,	LOG_NORMAL },

    /*
     * Combat commands.
     */
    { "backstab",	do_backstab,	POS_STANDING,	0,	LOG_NORMAL },
    { "berserk",	do_berserk,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "bs",		do_backstab,	POS_STANDING,	0,	LOG_NORMAL },
    { "charge",		do_charge,	POS_STANDING,	0,	LOG_NORMAL },
    { "circle",		do_circle,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "combo",		do_combo,	POS_FIGHTING,	10,	LOG_NORMAL },
    { "disarm",		do_disarm,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "fee",		do_fee,		POS_FIGHTING,	0,	LOG_NORMAL },
    { "feed",		do_feed,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "flee",		do_flee,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "headbutt",	do_headbutt,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "impale",		do_impale,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "kick",		do_kick,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "ram",		do_ram,		POS_FIGHTING,	0,	LOG_NORMAL },
    { "rescue",		do_rescue,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "quicken",	do_quicken,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "slit",		do_slit_throat,	POS_STANDING,	0,	LOG_NORMAL },
    { "smash",		do_smash,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "snapkick",	do_snapkick,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "stake",		do_stake,	POS_STANDING,	0,	LOG_NORMAL },
    { "stomp",		do_stomp,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "strangle",	do_strangle,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "surge",		do_surge,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "throw",		do_throw,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "trip",		do_trip,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "whirlwind",	do_whirlwind,	POS_FIGHTING,	0,	LOG_NORMAL },

    /*
     * Communication commands.
     */
    { "answer",		do_answer,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "auction",	do_auction,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "beep",		do_beep,	POS_RESTING,	20,	LOG_NORMAL },
    { "board",		do_board,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "busy",		do_busy,	POS_SLEEPING,	20,	LOG_NORMAL },
    { "chat",		do_chat,	POS_SLEEPING,	0,	LOG_NORMAL },
    { ".",		do_chat,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "congratulate",	do_gratz,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "deaf",		do_deaf,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "emote",		do_emote,	POS_RESTING,	0,	LOG_NORMAL },
    { ",",		do_emote,	POS_RESTING,	0,	LOG_NORMAL },
    { "grtz",		do_gratz,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "$",		do_gratz,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "gtell",		do_gtell,	POS_DEAD,	0,	LOG_NORMAL },
    { ";",		do_gtell,	POS_DEAD,	0,	LOG_NORMAL },
    { "music",		do_music,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "note",		do_note,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "question",	do_question,	POS_SLEEPING,	3,	LOG_NORMAL },
    { "reply",		do_reply,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "say",		do_say,		POS_SLEEPING,	0,	LOG_NORMAL },
    { "'",		do_say,		POS_SLEEPING,	0,	LOG_NORMAL },
    { "shout",		do_shout,	POS_RESTING,	3,	LOG_NORMAL },
    { "yell",		do_yell,	POS_RESTING,	3,	LOG_NORMAL },

    /*
     * Object manipulation commands.
     */
    { "brandish",	do_brandish,	POS_RESTING,	0,	LOG_NORMAL },
    { "brew",		do_brew,	POS_SITTING,	0,	LOG_NORMAL },
    { "bury",		do_bury,	POS_STANDING,	0,	LOG_NORMAL },
    { "carve",		do_carve,	POS_STANDING,	0,	LOG_NORMAL },
    { "close",		do_close,	POS_RESTING,	0,	LOG_NORMAL },
    { "dig",		do_dig,		POS_STANDING,	0,	LOG_NORMAL },
    { "disable",	do_disable,	POS_STANDING,	0,	LOG_NORMAL },
    { "donate",		do_donate,	POS_RESTING,	0,	LOG_NORMAL },
    { "drink",		do_drink,	POS_RESTING,	0,	LOG_NORMAL },
    { "drop",		do_drop,	POS_RESTING,	0,	LOG_NORMAL },
    { "eat",		do_eat,		POS_RESTING,	0,	LOG_NORMAL },
    { "embalm",		do_embalm,	POS_STANDING,	0,	LOG_NORMAL },
    { "fill",		do_fill,	POS_RESTING,	0,	LOG_NORMAL },
    { "give",		do_give,	POS_RESTING,	0,	LOG_NORMAL },
    { "harvest",	do_harvest,	POS_RESTING,	0,	LOG_NORMAL },
    { "hold",		do_wear,	POS_RESTING,	0,	LOG_NORMAL },
    { "juggle",		do_juggle,	POS_STANDING,	0,	LOG_NORMAL },
    { "list",		do_list,	POS_SITTING,	0,	LOG_NORMAL },
    { "lock",		do_lock,	POS_RESTING,	0,	LOG_NORMAL },
    { "modify",		do_modify_armour, POS_SITTING,	0,	LOG_NORMAL },
    { "pick",		do_pick,	POS_RESTING,	0,	LOG_NORMAL },
    { "prepare",	do_prepare,	POS_RESTING,	0,	LOG_NORMAL },
    { "put",		do_put,		POS_RESTING,	0,	LOG_NORMAL },
    { "quaff",		do_quaff,	POS_RESTING,	0,	LOG_NORMAL },
    { "recite",		do_recite,	POS_RESTING,	0,	LOG_NORMAL },
    { "repair",		do_repair,	POS_SITTING,	0,	LOG_NORMAL },
    { "remove",		do_remove,	POS_RESTING,	0,	LOG_NORMAL },
    { "sell",		do_sell,	POS_SITTING,	0,	LOG_NORMAL },
    { "take",		do_get,		POS_RESTING,	0,	LOG_NORMAL },
    { "sacrifice",	do_sacrifice,	POS_RESTING,	0,	LOG_NORMAL },
    { "scribe",		do_scribe,	POS_SITTING,	0,	LOG_NORMAL },
    { "sharpen",	do_sharpen,	POS_STANDING,	0,	LOG_NORMAL },
    { "unlock",		do_unlock,	POS_RESTING,	0,	LOG_NORMAL },
    { "value",		do_value,	POS_SITTING,	0,	LOG_NORMAL },
    { "zap",		do_zap,		POS_RESTING,	0,	LOG_NORMAL },

    /*
     * Configuration commands.
     */
    { "auto",		do_auto,	POS_DEAD,	0,	LOG_NORMAL },
    { "autoexit",	do_autoexit,	POS_DEAD,	0,	LOG_NORMAL },
    { "autogold",	do_autogold,	POS_DEAD,	0,	LOG_NORMAL },
    { "autoloot",	do_autoloot,	POS_DEAD,	0,	LOG_NORMAL },
    { "autosac",	do_autosac,	POS_DEAD,	0,	LOG_NORMAL },
    { "autosplit",	do_autosplit,	POS_DEAD,	0,	LOG_NORMAL },
    { "blank",		do_blank,	POS_DEAD,	0,	LOG_NORMAL },
    { "brief",		do_brief,	POS_DEAD,	0,	LOG_NORMAL },
    { "channels",	do_channels,	POS_DEAD,	0,	LOG_NORMAL },
    { "combine",	do_combine,	POS_DEAD,	0,	LOG_NORMAL },
    { "config",		do_config,	POS_DEAD,	0,	LOG_NORMAL },
    { "description",	do_description,	POS_DEAD,	0,	LOG_NORMAL },
    { "password",	do_password,	POS_DEAD,	0,	LOG_NEVER  },
    { "prompt",		do_prompt,	POS_DEAD,	0,	LOG_NORMAL },
    { "setmin",		do_setmin,	POS_DEAD,	0,	LOG_NORMAL },
    { "setmout",	do_setmout,	POS_DEAD,	0,	LOG_NORMAL },
    { "setname",	do_setname,	POS_DEAD,	0,	LOG_NORMAL },
    { "title",		do_title,	POS_DEAD,	0,	LOG_NORMAL },
    { "wimpy",		do_wimpy,	POS_DEAD,	0,	LOG_NORMAL },

    /*
     * Clan and religion commands.
     */
    { "clan",		do_clan,	POS_STANDING,	10,	LOG_NORMAL },
    { "clans",		do_clans,	POS_STANDING,	10,	LOG_NORMAL },
    { "clantalk",	do_clantalk,	POS_SLEEPING,	10,	LOG_NORMAL },
    { ")",		do_clantalk,	POS_SLEEPING,	10,	LOG_NORMAL },
    { "guild",		do_clan,	POS_STANDING,	10,	LOG_NORMAL },
    { "guilds",		do_guilds,	POS_SLEEPING,	10,	LOG_NORMAL },
    { "leave",		do_leave,	POS_DEAD,	10,	LOG_ALWAYS },
    { "order",		do_clan,	POS_STANDING,	10,	LOG_NORMAL },
    { "orders",		do_orders,	POS_SLEEPING,	10,	LOG_NORMAL },
    { "religion",	do_religion,	POS_DEAD,	10,	LOG_NORMAL },

    /*
     * Miscellaneous commands.
     */
    { "afk",		do_afk,		POS_SLEEPING,	0,	LOG_NORMAL },
    { "aliases",	do_aliases,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "appraise",	do_appraise,	POS_SITTING,	0,	LOG_NORMAL },
    { "arena",		do_arena,	POS_STANDING,	0,	LOG_NORMAL },
    { "bank",		do_bank,	POS_STANDING,	0,	LOG_NORMAL },
    { "bashdoor",	do_bash,	POS_STANDING,	0,	LOG_NORMAL },
    { "battle",		do_battle,	POS_STANDING,	0,	LOG_ALWAYS },
    { "battle",		do_battle,	POS_STANDING,	L_SEN,	LOG_ALWAYS },
    { "become",		do_become,	POS_SLEEPING,	10,	LOG_ALWAYS },
    { "blink",		do_blink,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "bounty",		do_bounty,	POS_SITTING,	10,	LOG_NORMAL },
    { "call",		do_call,	POS_SITTING,	0,	LOG_NORMAL },
    { "chameleon power", do_chameleon,	POS_STANDING,	0,	LOG_NORMAL },
#if defined( MCCP )
    { "compress",	do_compress,	POS_DEAD,	0,	LOG_NORMAL },
#endif
    { "condition",	do_condition,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "count",		do_sysinfo,	POS_DEAD,	20,	LOG_NORMAL },
    { "drag",		do_drag,	POS_STANDING,	5,	LOG_NORMAL },
    { "delet",		do_delet,	POS_STANDING,	2,	LOG_NEVER },
    { "delete",		do_delete,	POS_STANDING,	2,	LOG_NEVER },
    { "enter",		do_enter,	POS_STANDING,	0,	LOG_NORMAL },
    { "engrave",	do_engrave,	POS_STANDING,	0,	LOG_NORMAL },
    { "focus",		do_meditate,	POS_RESTING,	5,	LOG_NORMAL },
    { "follow",		do_follow,	POS_RESTING,	0,	LOG_NORMAL },
    { "forage",		do_forage,	POS_STANDING,	0,	LOG_NORMAL },
    { "heal",		do_heal,	POS_RESTING,	0,	LOG_NORMAL },
    { "heighten senses", do_heighten,	POS_STANDING,	0,	LOG_NORMAL },
    { "hide",		do_hide,	POS_RESTING,	0,	LOG_NORMAL },
    { "hire",		do_hire,	POS_SITTING,	0,	LOG_NORMAL },
    { "ispell",		do_ispell,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "last",		do_last,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "lighten",	do_lighten,	POS_SITTING,	0,	LOG_NORMAL },
    { "mobdeath",	do_mobdeath,	POS_SLEEPING,	20,	LOG_NORMAL },
    { "movehidden",	do_move_hidden,	POS_STANDING,	0,	LOG_NORMAL },
    { "multiclas",	do_multi_clas,	POS_SLEEPING,	50,	LOG_NORMAL },
    { "multiclass",	do_multi_class,	POS_SLEEPING,	50,	LOG_NORMAL },
    { "poison weapon",	do_poison_weapon, POS_SLEEPING,	0,	LOG_NORMAL },
    { "pose",		do_pose,	POS_STANDING,	2,	LOG_NORMAL },
    { "practice",	do_practice,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "pray",		do_pray,	POS_STANDING,	5,	LOG_NORMAL },
    { "push",		do_push,	POS_STANDING,	5,	LOG_NORMAL },
    { "qui",		do_qui,		POS_DEAD,	0,	LOG_NORMAL },
    { "quit",		do_quit,	POS_DEAD,	0,	LOG_NORMAL },
    { "random",		do_random,	POS_RESTING,	0,	LOG_NORMAL },
    { "save",		do_save,	POS_DEAD,	0,	LOG_NORMAL },
    { "sleep",		do_sleep,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "smith",		do_smith,	POS_STANDING,	0,	LOG_NORMAL },
    { "snare",		do_snare,	POS_FIGHTING,	0,	LOG_NORMAL },
    { "sneak",		do_sneak,	POS_STANDING,	0,	LOG_NORMAL },
    { "speak",		do_speak,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "split",		do_split,	POS_RESTING,	0,	LOG_NORMAL },
    { "statistics",	do_sysinfo,	POS_DEAD,	20,	LOG_NORMAL },
    { "steal",		do_steal,	POS_STANDING,	0,	LOG_NORMAL },
    { "study",		do_study,	POS_STANDING,	0,	LOG_NORMAL },
    { "sysinfo",	do_sysinfo,	POS_DEAD,	20,	LOG_NORMAL },
    { "taunt",		do_taunt,	POS_STANDING,	0,	LOG_NORMAL },
    { "tend",		do_tend,	POS_SITTING,	0,	LOG_NORMAL },
    { "track",		do_track,	POS_STANDING,	0,	LOG_NORMAL },
    { "trade",		do_trade,	POS_RESTING,	0,	LOG_NORMAL },
    { "train",		do_train,	POS_RESTING,	0,	LOG_NORMAL },
    { "untangle",	do_untangle,	POS_SITTING,	0,	LOG_NORMAL },
    { "uptime",		do_sysinfo,	POS_DEAD,	20,	LOG_NORMAL },
    { "visible",	do_visible,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "wake",		do_wake,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "where",		do_where,	POS_RESTING,	0,	LOG_NORMAL },
    { "worth",		do_worth,	POS_SLEEPING,	0,	LOG_NORMAL },
    { "mpcomm",		do_mpcomm,	POS_DEAD,	0,	LOG_NORMAL },

    /*
     * Immortal commands.
     */
    { "fileoutput",	do_fileoutput,	POS_DEAD,	L_OVL,	LOG_ALWAYS },
    { "<",		do_fileoutput,	POS_DEAD,	L_OVL,	LOG_ALWAYS },
    { "imtlset",	do_imtlset,	POS_DEAD,	L_OVL,	LOG_ALWAYS },
    { "test",		do_test,	POS_DEAD,	L_OVL,	LOG_ALWAYS },

    { "aestat",		do_aestat,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "advance",	do_advance,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "cedit",		do_cedit,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "confiscate",	do_confiscate,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "copyove",	do_copyove,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "copyover",	do_copyover,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "force",		do_force,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "grant",		do_grant,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "log",		do_log,		POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "mestat",		do_mestat,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "mset",		do_mset,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "numlock",	do_numlock,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "oestat",		do_oestat,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "pestat",		do_pestat,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "pledit",		do_pledit,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "pload",		do_pload,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "punload",	do_punload,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "reboo",		do_reboo,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "reboot",		do_reboot,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "reledit",	do_reledit,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "repeat",		do_repeat,	POS_STANDING,	L_MAS,	LOG_ALWAYS },
    { "restat",		do_restat,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "shutdow",	do_shutdow,	POS_DEAD,	L_MAS,	LOG_NORMAL },
    { "shutdown",	do_shutdown,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "sstime",		do_sstime,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "toad",		do_toad,	POS_DEAD,	L_MAS,	LOG_ALWAYS },
    { "wizlock",	do_wizlock,	POS_DEAD,	L_MAS,	LOG_ALWAYS },

    { "builder",	do_builder,	POS_DEAD,	L_MBLD,	LOG_ALWAYS },
    { "hedit",		do_hedit,	POS_DEAD,	L_MBLD,	LOG_NORMAL },
    { "slookup",	do_slookup,	POS_DEAD,	L_MBLD,	LOG_NORMAL },
    { "sset",		do_sset,	POS_DEAD,	L_MBLD,	LOG_ALWAYS },
    { "trust",		do_trust,	POS_DEAD,	L_MBLD,	LOG_ALWAYS },
    { "wizify",		do_wizify,	POS_DEAD,	L_MBLD,	LOG_ALWAYS },
    { "wsave",		do_wsave,	POS_DEAD,	L_MBLD,	LOG_ALWAYS },

    { "allow",		do_allow,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "badname",	do_badname,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "deny",		do_deny,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "disconnect",	do_disconnect,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "dupefind",	do_dupefind,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "echo",		do_echo,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "freeze",		do_freeze,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "immname",	do_immname,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "ispell",		do_ispell,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "keylock",	do_keylock,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "masscast",	do_masscast,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "memory",		do_memory,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "mload",		do_mload,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "newlock",	do_newlock,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "noemote",	do_noemote,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "nofight",	do_nofight,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "nolag",		do_nolag,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "notell",		do_notell,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "oload",		do_oload,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "pardon",		do_pardon,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "poseset",	do_poseset,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "quote",		do_quote,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "return",		do_return,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "sedit",		do_sedit,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "silence",	do_silence,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "siteban",	do_ban,		POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "snoop",		do_snoop,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "sstat",		do_sstat,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "switch",		do_switch,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "transfer",	do_transfer,	POS_DEAD,	L_SEN,	LOG_ALWAYS },
    { "users",		do_users,	POS_DEAD,	L_SEN,	LOG_NORMAL },
    { "]",		do_seniortalk,	POS_DEAD,	L_SEN,	LOG_NORMAL },

    { "avatar",		do_avatar,	POS_SLEEPING,	L_JUN,	LOG_ALWAYS },
    { "mfind",		do_mfind,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "mpstat",		do_mpstat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "mstat",		do_mstat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "mwhere",		do_mwhere,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "ofind",		do_ofind,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "opstat",		do_opstat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "oset",		do_oset,	POS_DEAD,	L_JUN,	LOG_ALWAYS },
    { "ostat",		do_ostat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "owhere",		do_owhere,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "recho",		do_recho,	POS_DEAD,	L_JUN,	LOG_ALWAYS },
    { "restore",	do_restore,	POS_DEAD,	L_JUN,	LOG_ALWAYS },
    { "rpstat",		do_rpstat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "rstat",		do_rstat,	POS_DEAD,	L_JUN,	LOG_NORMAL },
    { "send",		do_send,	POS_DEAD,	L_JUN,	LOG_ALWAYS },
    { "unaffect",	do_unaffect,	POS_DEAD,	L_JUN,	LOG_ALWAYS },

    { "info",		do_info,	POS_DEAD,	L_ARCH,	LOG_NORMAL },
    { "peace",		do_peace,	POS_DEAD,	L_ARCH,	LOG_NORMAL },
    { "sla",		do_sla,		POS_DEAD,	L_ARCH,	LOG_NORMAL },
    { "slay",		do_slay,	POS_DEAD,	L_ARCH,	LOG_ALWAYS },
    { "wizinvis",	do_invis,	POS_DEAD,	L_ARCH,	LOG_NORMAL },

    { "at",		do_at,		POS_DEAD,	L_APP,	LOG_NORMAL },
    { "bamfin",		do_bamfin,	POS_DEAD,	L_APP,	LOG_NORMAL },
    { "bamfout",	do_bamfout,	POS_DEAD,	L_APP,	LOG_NORMAL },

    /*
     * OLC, builder commands
     */
    { "aedit",		do_aedit,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "alist",		do_alist,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "asave",		do_asave,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "exlist",		do_exlist,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "flaglookup",	do_flaglookup,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "?",		do_flaglookup,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "gmpedit",	do_gmpedit,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "goto",		do_goto,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "medit",		do_medit,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "oedit",		do_oedit,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "purge",		do_purge,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "redit",		do_redit,	POS_DEAD,	L_BLD,	LOG_NORMAL },
    { "resets",		do_resets,	POS_DEAD,	L_BLD,	LOG_NORMAL },

    { "holylight",	do_holylight,	POS_DEAD,	L_ANG,	LOG_NORMAL },
    { "wiznet",		do_wiznet,	POS_DEAD,	L_ANG,	LOG_NORMAL },
    { ":",		do_immtalk,	POS_DEAD,	L_ANG,	LOG_NORMAL },

    /*
     * End of list.
     */
    { "", 0,	POS_DEAD,	0, LOG_NORMAL }
};


/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, const char *argument )
{
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;

    /*
     * Strip leading spaces.
     */
    while( isspace( *argument ) )
	argument++;
    if( argument[0] == '\0' )
	return;

    /*
     * No hiding and remove AFK
     */
    if( ch->position == POS_MEDITATING )
	ch->position = POS_RESTING;
    if( IS_AFFECTED( ch, AFF_HIDE ) && !is_affected( ch, gsn_move_hidden ) )
	xREMOVE_BIT( ch->affected_by, AFF_HIDE );
    if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_AFK ) )
    {
	xREMOVE_BIT( ch->act, PLR_AFK );
	act( "&b$n has returned to $s keyboard.", ch, NULL, NULL, TO_ROOM );
    }

    /*
     * Implement freeze command.
     */
    if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_FREEZE ) )
    {
	send_to_char( "You're totally frozen!\n\r", ch );
	return;
    }

    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     *	 also no spaces needed after punctuation.
     */
    strcpy( logline, argument );
    if( !isalpha( argument[0] ) && !isdigit( argument[0] )
	&& argument[0] != '"' )
    {
	command[0] = argument[0];
	command[1] = '\0';
	argument++;
	while( isspace( *argument ) )
	    argument++;
    }
    else
    {
	argument = one_argument( argument, command );
    }

    /*
     * MUD Programs trigger.
     */
    if( command_trigger( ch, command, argument ) )
    {
	if( ( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_LOG ) )
	    || IS_SET( SysInfo->flags, SYSINFO_LOGALL ) )
	{
	    sprintf( log_buf, "LOG %s: %s %s", ch->name, command, argument );
	    log_string( log_buf );
	    wiznet( ch, WIZ_COMMANDS, UMAX( get_trust( ch ), L_SEN ),
		    log_buf );
	}
	return;
    }

    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust( ch );
    for( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
	if( command[0] == cmd_table[cmd].name[0]
	    && !str_prefix( command, cmd_table[cmd].name )
	    && ( cmd_table[cmd].level <= trust ) )
	{
	    found = TRUE;
	    break;
	}
    }

    /*
     * Log and snoop.
     */
    if( cmd_table[cmd].log == LOG_NEVER )
	strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX" );

    if( ( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_LOG ) )
	|| IS_SET( SysInfo->flags, SYSINFO_LOGALL )
	|| cmd_table[cmd].log == LOG_ALWAYS )
    {
	sprintf( log_buf, "LOG %s: %s", ch->name, logline );
	log_string( log_buf );
	wiznet( ch, WIZ_COMMANDS, UMAX( get_trust( ch ), L_SEN ), logline );
    }

    if( ch->desc && ch->desc->snoop_by )
    {
	sprintf( log_buf, "&c<%%%s:%s%%>\n\r", ch->name, logline );
	write_to_buffer( ch->desc->snoop_by, log_buf );
    }

    if( !found )
    {
	/*
	 * Look for command in socials table.
	 */
	if( !check_social( ch, command, argument ) )
	    bad_command( ch );
	return;
    }

    /*
     * Character not in position for command?
     */
    if( ch->position < cmd_table[cmd].position )
    {
	switch( ch->position )
	{
	case POS_DEAD:
	    send_to_char( "Lie still; you are DEAD.\n\r", ch );
	    break;

	case POS_MORTAL:
	case POS_INCAP:
	    send_to_char( "You are hurt far too bad for that.\n\r", ch );
	    break;

	case POS_STUNNED:
	    send_to_char( "You are too stunned to do that.\n\r", ch );
	    break;

	case POS_SLEEPING:
	    send_to_char( "In your dreams, or what?\n\r", ch );
	    break;

	case POS_GETTING_UP:
	case POS_SMASHED:
	case POS_RESTING:
	    send_to_char( "Nah... You feel too relaxed...\n\r", ch );
	    break;

	case POS_FIGHTING:
	    send_to_char( "No way!  You are still fighting!\n\r", ch );
	    break;
	}
	return;
    }

    sprintf( last_command, "[%5d] %s in [%5d] %s: %s",
	     IS_NPC( ch ) ? ch->pIndexData->vnum : 0,
	     IS_NPC( ch ) ? ch->short_descr : ch->name,
	     ch->in_room ? ch->in_room->vnum : 0,
	     ch->in_room ? ch->in_room->name : "(not in a room)",
	     logline );

    /*
     * Dispatch the command.
     */
    ( *cmd_table[cmd].do_fun ) ( ch, argument );

    strcat( last_command, " (Finished)" );
    return;
}


SOCIAL_DATA *find_social( const char *command )
{
    SOCIAL_DATA *social;
    int hash;

    if( LOWER( command[0] ) < 'a' || LOWER( command[0] ) > 'z' )
	hash = 0;
    else
	hash = ( LOWER( command[0] ) - 'a' ) + 1;

    for( social = social_table[hash]; social; social = social->next )
	if( !str_prefix( command, social->name ) )
	    return social;

    return NULL;
}


bool check_social( CHAR_DATA *ch, char *command, const char *argument )
{
    CHAR_DATA *victim;
    char arg[MAX_INPUT_LENGTH];
    SOCIAL_DATA *cmd;

    cmd = find_social( command );

    if( !cmd )
	return FALSE;

    if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_NO_EMOTE ) )
    {
	send_to_char( "You are anti-social!\n\r", ch );
	return TRUE;
    }

    switch( ch->position )
    {
    case POS_DEAD:
	send_to_char( "Lie still; you are DEAD.\n\r", ch );
	return TRUE;

    case POS_INCAP:
    case POS_MORTAL:
	send_to_char( "You are hurt far too badly for that.\n\r", ch );
	return TRUE;

    case POS_STUNNED:
	send_to_char( "You are too stunned to do that.\n\r", ch );
	return TRUE;

    case POS_SLEEPING:
	/*
	 * I just know this is the path to a 12" 'if' statement.  :(
	 * But two players asked for it already!  -- Furey
	 */
	if( !str_cmp( cmd->name, "snore" ) )
	{
	    send_to_char( "You snore, zzzzZZZZzzzz.\n\r", ch );
	    break;
	}
	send_to_char( "In your dreams, or what?\n\r", ch );
	return TRUE;

    }

    one_argument( argument, arg );
    victim = NULL;
    if( arg[0] == '\0' )
    {
	act( cmd->char_no_arg, ch, NULL, victim, TO_CHAR );
	act( cmd->others_no_arg, ch, NULL, victim, TO_ROOM );
    }
    else if( !( victim = get_char_world( ch, arg ) ) )
    {
	send_to_char( "They aren't here.\n\r", ch );
    }
    else if( victim == ch )
    {
	act( cmd->char_auto, ch, NULL, victim, TO_CHAR );
	act( cmd->others_auto, ch, NULL, victim, TO_ROOM );
    }
    else if( !get_char_room( ch, arg ) && can_see( ch, victim ) )
    {
	if( !IS_NPC( victim ) )
	{
	    ROOM_INDEX_DATA *original;
	    const char *ldbase = "From far away, ";
	    char ldmsg[MAX_STRING_LENGTH];

	    original = ch->in_room;
	    char_from_room( ch );
	    char_to_room( ch, victim->in_room );

	    strcpy( ldmsg, ldbase );
	    strcat( ldmsg, cmd->char_found );
	    act( ldmsg, ch, NULL, victim, TO_CHAR );

	    strcpy( ldmsg, ldbase );
	    strcat( ldmsg, cmd->vict_found );
	    act( ldmsg, ch, NULL, victim, TO_VICT );

	    char_from_room( ch );
	    char_to_room( ch, original );
	}
	else
	{
	    send_to_char( "They aren't here.\n\r", ch );
	}
    }
    else
    {
	act( cmd->char_found, ch, NULL, victim, TO_CHAR );
	act( cmd->vict_found, ch, NULL, victim, TO_VICT );
	act( cmd->others_found, ch, NULL, victim, TO_NOTVICT );

	if( !IS_NPC( ch )
	    && IS_NPC( victim )
	    && !IS_AFFECTED( victim, AFF_CHARM )
	    && IS_AWAKE( victim ) )
	{
	    switch( number_bits( 4 ) )
	    {
	    case 0:
		if( ( victim->level < ch->level )
		    && !( victim->fighting ) )
		    multi_hit( victim, ch, TYPE_UNDEFINED );
		break;

	    case 1:	    case 2:
	    case 3:	    case 4:
	    case 5:	    case 6:
	    case 7:
		act( cmd->char_found, victim, NULL, ch, TO_CHAR );
		act( cmd->vict_found, victim, NULL, ch, TO_VICT );
		act( cmd->others_found, victim, NULL, ch, TO_NOTVICT );
		break;

	    case 8:	    case 9:
	    case 10:	    case 11:
		act( "$n slap$% $N.", victim, NULL, ch, TO_ALL );
		break;
	    case 12:	    case 13:
		act( "$n laugh$% in $O face.", victim, NULL, ch, TO_ALL );
	    }
	}
    }

    return TRUE;
}


/*
 * Return true if an argument is completely numeric.
 */
bool is_number( const char *arg )
{
    if( *arg == '\0' )
	return FALSE;

    if( *arg == '+' || *arg == '-' )
	arg++;

    for( ; *arg != '\0'; arg++ )
    {
	if( !isdigit( *arg ) )
	    return FALSE;
    }

    return TRUE;
}


/*
 * Same as is_number but allows numbers of the form "x.yK" or "x.yM"
 */
bool is_number_special( const char *arg )
{
    bool point = FALSE;
    bool end = FALSE;
    const char *multiples = "kKmMbBtT";

    if( *arg == '\0' )
	return FALSE;

    if( *arg == '+' || *arg == '-' )
	arg++;

    for( ; *arg != '\0'; arg++ )
    {
	if( *arg == '.' )
	{
	    if( !point )
		point = TRUE;
	    else
		return FALSE;
	}
	else if( end || !isdigit( *arg ) )
	{
	    if( strchr( multiples, *arg ) )
	    {
		if( !end )
		    end = TRUE;
		else
		    return FALSE;
	    }
	    else
		return FALSE;
	}
    }
    return TRUE;
}


/*
 * Given a string like 14.foo, return 14 and 'foo'
 */
int number_argument( const char *argument, char *arg )
{
    char buf[MAX_INPUT_LENGTH];
    char *pdot;
    int number;

    strcpy( buf, argument );
    for( pdot = &buf[0]; *pdot != '\0'; pdot++ )
    {
	if( *pdot == '.' )
	{
	    *pdot = '\0';
	    if( !is_number( buf ) )
	    {
		*pdot = '.';
		break;
	    }
	    number = atoi( buf );
	    *pdot = '.';
	    strcpy( arg, pdot + 1 );
	    return number;
	}
    }

    strcpy( arg, buf );
    return 1;
}


bool isvowel( char ch )
{
    ch = LOWER( ch );
    if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
	return TRUE;
    return FALSE;
}


/*
 * Aliases by Symposium
 */
void do_aliases( CHAR_DATA *ch, const char *argument )
{
    ALIAS_DATA *jim;
    ALIAS_DATA *prev;
    char alname[MAX_INPUT_LENGTH];
    char alcontent[MAX_INPUT_LENGTH];
    char *p, *q;
    int i;
    char directions[] = "neswudNESWUD";

    if( IS_NPC( ch ) )
    {
	send_to_char( "You cant!\n\r", ch );
	return;
    }

    /*
     * standard output of alias list
     */
    if( argument[0] == '\0' )
    {
	send_to_char( "&gYour aliases:&n\n\r", ch );
	if( !ch->pcdata->aliases )
	{
	    send_to_char( "None.\n\r", ch );
	    return;
	}
	send_to_char( LINE_SEPARATOR, ch );
	for( jim = ch->pcdata->aliases; jim; jim = jim->next )
	{
	    charprintf( ch, "  &g%s&b : &y\"%s\"&n\n\r",
			jim->name, jim->command );
	}
	send_to_char( LINE_SEPARATOR, ch );
	return;
    }

    argument = one_argument( argument, alname );
    strcpy( alcontent, argument );

    /*
     * remove an alias
     */
    if( alcontent[0] == '\0' )
    {
	for( jim = ch->pcdata->aliases; jim; jim = jim->next )
	{
	    if( !str_cmp( jim->name, alname ) )
	    {
		if( jim == ch->pcdata->aliases )
		{
		    ch->pcdata->aliases = jim->next;
		}
		else
		{
		    for( prev = ch->pcdata->aliases; prev && prev->next != jim; )
			prev = prev->next;
		    prev->next = jim->next;
		}
		free_alias( jim );
		charprintf( ch, "&gAlias &c%s&g removed.&n\n\r", alname );
		return;
	    }
	}
	charprintf( ch, "&gNo alias &c%s&g defined.&n\n\r", alname );
	return;
    }

    /*
     * check if alias is allready used
     */
    for( jim = ch->pcdata->aliases; jim; jim = jim->next )
    {
	if( !str_cmp( jim->name, alname ) )
	{
	    send_to_char( "That alias is allready used.\n\r", ch );
	    return;
	}
    }

    /*
     * check for recursion in the alias.
     */
    if( !strcmp( alname, "!" ) || !strcmp( alname, "end_of_aliases" ) )
    {
	send_to_char( "Not allowed.\n\r", ch );
	return;
    }

    i = strlen( alname );
    q = alcontent;
    while( ( p = str_str( q, alname ) ) )
    {
	q = p + 1;
	if( !isspace( p[i] ) && p[i] != '=' )
	    continue;
	do
	    p--;
	while( p >= alcontent && isspace( *p ) );
	if( p < alcontent || *p == '=' )
	{
	    send_to_char( "Watch for recursion in your aliases.\n\r", ch );
	    return;
	}
    }

    /*
     * finally make the new alias
     */
    jim = new_alias( );

    jim->name = str_dup( alname );
    jim->command = str_dup( alcontent );
    if( strchr( alcontent, '%' ) )
	jim->complex = ALIAS_COMPLEX;
    else if( strchr( alcontent, '=' ) )
	jim->complex = ALIAS_MULTIPLE;
    else
    {
	jim->complex = ALIAS_MULTIPLE;
	for( p = alcontent; *p; p++ )
	{
	    if( !strchr( directions, *p ) )
	    {
		jim->complex = ALIAS_SIMPLE;
		break;
	    }
	}
    }

    jim->next = ch->pcdata->aliases;
    ch->pcdata->aliases = jim;

    charprintf( ch, "&gAlias &c%s&g added successfully.&n\n\r", jim->name );
    return;
}


/* aliases by Symposium */
bool perform_alias( DESCRIPTOR_DATA * d )
{
    CHAR_DATA *ch;
    ALIAS_DATA *jim;
    char *all_args;
    char *ptr;
    char *write_to;
    char *args[10];
    char buf[MAX_INPUT_LENGTH * 4];
    char outcomm[MAX_INPUT_LENGTH * 2];
    char temp[MAX_INPUT_LENGTH];
    int i, num;
    bool running = TRUE;
    const char directions[] = "neswudNESWUD";

    if( !( ch = CH( d ) ) )
	return FALSE;

    if( d->incomm[0] == '|' )
    {
	strcpy( d->incomm, d->incomm + 1 );
	return FALSE;
    }

    if( strchr( d->incomm, '|' ) )
    {
	for( i = 0; d->incomm[i] != '\0'; i++ )
	{
	    if( d->incomm[i] == '|' )
		buf[i] = '\n';
	    else
		buf[i] = d->incomm[i];
	}
	buf[i++] = '\n';
	strncpy( &buf[i], d->inbuf, MAX_INPUT_LENGTH * 4 - i );
	buf[MAX_INPUT_LENGTH * 4 - 1] = '\0';
	strcpy( d->inbuf, buf );
	d->incomm[0] = '\0';
	return TRUE;
    }

    /* determine if running */
    for( ptr = d->incomm; *ptr; ptr++ )
    {
	if( !strchr( directions, *ptr ) )
	{
	    running = FALSE;
	    break;
	}
    }

    /* is it an alias */
    outcomm[0] = '\0';
    all_args = (char *)one_argument( d->incomm, buf );
    strcpy( temp, all_args );
    args[0] = &temp[0];

    for( jim = ch->pcdata->aliases; jim; jim = jim->next )
    {
	if( !str_cmp( buf, jim->name ) )
	{
	    strcpy( outcomm, jim->command );
	    break;
	}
    }
    if( outcomm[0] == '\0' )	/* This is where the most traffic will be */
    {
	if( running && d->incomm[1] != '\0' )
	{
	    i = 0;
	    for( ptr = d->incomm; *ptr; ptr++ )
	    {
		buf[i++] = *ptr;
		buf[i++] = '\n';
	    }
	    strncpy( &buf[i], d->inbuf, MAX_INPUT_LENGTH * 4 - i );
	    buf[MAX_INPUT_LENGTH * 4 - 1] = '\0';
	    strcpy( d->inbuf, buf );
	    d->incomm[0] = '\0';
	    return TRUE;
	}
	return FALSE;
    }

    if( jim->complex == ALIAS_SIMPLE )
    {
	if( !strcmp( d->inlast, buf ) && ++d->repeat >= 20 )
	{
	    sprintf( temp, "%s input spamming!", d->host );
	    log_string( temp );
	    write_to_buffer( d, "\n\r*** PUT A LID ON IT!!! ***\n\r" );
	    strcpy( d->incomm, "quit" );
	}
	else
	{
	    strcpy( d->incomm, jim->command );
	}
	return TRUE;
    }

    /* fill with carriage returns instead of "="'s */
    for( i = 0; outcomm[i] != '\0'; i++ )
    {
	if( outcomm[i] == '=' )
	    outcomm[i] = '\n';
    }
    outcomm[i++] = '\n';
    outcomm[i] = '\0';

    if( jim->complex == ALIAS_MULTIPLE )
    {
	strcpy( buf, outcomm );
	strncpy( &buf[i], d->inbuf, MAX_INPUT_LENGTH * 4 - i );
	buf[MAX_INPUT_LENGTH * 4 - 1] = '\0';
	strcpy( d->inbuf, buf );
	d->incomm[0] = '\0';
	return TRUE;
    }

    /* make arguments seperate */
    for( i = 1; i < 9; ++i )
    {
	args[i] = (char *)one_argument( args[i - 1], temp );
	strcpy( args[i - 1], temp );
	if( args[i][0] == '\0' )
	    break;
    }

    write_to = &buf[0];
    for( ptr = &outcomm[0]; *ptr; ++ptr )
    {
	if( *ptr == '%' )
	{
	    num = *( ++ptr ) - '1';
	    if( num < i && num >= 0 )	/* parameters,	*/
		/* i will be the number of arguments that are valid */
	    {
		strncpy( write_to, args[num], strlen( args[num] ) );
		write_to += strlen( args[num] );
	    }
	    else if( *ptr == '*' )	/* all parameters */
	    {
		strcpy( write_to, all_args );
		write_to += strlen( all_args );
	    }
	    else if( *ptr == '%' )	/* %age sign */
	    {
		*( write_to++ ) = '%';
	    }
	}
	else			/* normal letter */
	    *( write_to++ ) = *ptr;
    }
    i = write_to - &buf[0];
    strncpy( &buf[i], d->inbuf, MAX_INPUT_LENGTH * 4 - i );
    buf[MAX_INPUT_LENGTH * 4 - 1] = '\0';
    strcpy( d->inbuf, buf );
    d->incomm[0] = '\0';
    return TRUE;
}


/*
 * Messages you get when you type something wrong.
 * Make up your own, they are here for fun really.
 */
void bad_command( CHAR_DATA *ch )
{
    int count;
    const char * const comm[] =
    {
	"Beg yours?",
	"Pardon me but I do not understand.",
	"Sorry are you speaking my language?",
	"Well, well, well, I never thought of it THAT way.",
	"WOW! Thats so obscure I've never heard of it.",
	"Would you like to rephrase that?",
	"Would you like fries with that?",
	"That particular command is a little outdated.",
	"Perhaps this time in English?",
	"Have you got your head screwed on the right way?",
	"Hang on, it will come to me any moment now...",
	"I am impressed by your ingenuity, that one stumps me completely!",
	"Perhaps if you typed it in BACKWARDS I might understand!",
	"Hey loser stop punching my button, I'll get REAL angry soon!",
	"I'm warning you, this is getting more than a little tiring.",
	"Have you been smoking some of that weed man?",
	"ARRGGHH! I'm a computer trapped inside the body of a computer!",
	"Oh No! The Blue Meanies are coming, the Blue Meanies!",
	"Oh well that's done it, you've ruined my concentration.",
	"WTF?!?",
	"I dont wish to know that!",
	"Yea... right!",
	"That was pure giberish.",
	"You can spank that monkey.",
	"&f&RFLOOB.&n",
	"Oh my god... he's wacked.",
	"You really have to get out more often.",
	"Oohh, about half past thirty.",
	"Mah nah mah nah! Do doo do do doo.",
	"And I thought these things smelt bad... from the outside.",
	"You want to do WHAT with a jar of cream and an armadillo?",
	"Your flubber is where?",
	"I can do that too... well i can!",
	"Lovely Spam.\n\rWonderfull Spam!\n\rLovely.\n\rLovely.\n\rLovely.",
	"Spam\n\rSpam\n\rSpam\n\rSpam\n\rSpam\n\rSpam\n\rSpam\n\rSpam",
	"And exactly WHY did the chicken cross the road then?",
	"Nurse, this man needs 100g adrenaline, STAT!",
	"If you saw what I see from here, you wouldn't be smiling.",
	"Did you see that pink elephant too?",
	"Are you offering me surrender?",
	"Hmm... exactly what to do with these loaves and fishes.",
	"Did you catch the number of that donkey cart?",
	"Who said that?",
	"Stop it! I can't take it anymore!",
	"She cannae take anymore cap'n!",
	"Ahem!  None of us are getting any younger here mate.",
	"I wonder where I put my Hindi translation dictionary...",
	"You seem depressed, here's a smiley face to brighten your day &k&3:)",
	"Do you know what 'loofnmad' means?\n\rWell neither do I, speak ENGLISH loser!",
	"Yes, isn't it terrible.  And how do you feel about that?",
	"No need to take it out on the computer!",
	"I'm warning you, if you keep this up I might loose my temper.",
	"No.  I don't think that is the meaning of life, keep trying.",
	"Are you related to that monkey who wrote the complete works of Shakespeare?",
	"Bob.",
	"Checkmate!",
	"And?",
	"                              ?",
	"?",
	"Huh?",
	"D'oh!",
	"M'kay?",
	"Whazzat then?",
	"&MExqueeeeeeze Me?!?!?",
	NULL
    };

    for( count = 0; comm[count]; count++ )
	;
    charprintf( ch, "&%c%s&n\n\r", message_colours[number_range( 0, 5 )],
		comm[number_range( 0, count - 1 )] );
}


void do_pose( CHAR_DATA *ch, const char *argument )
{
    int i;
    POSE_DATA *pose;
    char buf[MAX_INPUT_LENGTH];

    if( IS_NPC( ch ) || ch->class < 0 || ch->class > MAX_CLASS )
	return;
    i = pose_table[ch->class].size;
    if( get_first_class( ch ) != CLASS_NONE )
	i += pose_table[get_first_class( ch )].size;
    if( get_second_class( ch ) != CLASS_NONE )
	i += pose_table[get_second_class( ch )].size;
    i = number_range( 1, i );
    for( pose = pose_table[ch->class].first; pose; pose = pose->next )
	if( --i <= 0 )
	    break;
    if( i > 0 && get_first_class( ch ) != CLASS_NONE )
	for( pose = pose_table[get_first_class( ch )].first;
	     pose; pose = pose->next )
	    if( --i <= 0 )
		break;
    if( i > 0 && get_second_class( ch ) != CLASS_NONE )
	for( pose = pose_table[get_second_class( ch )].first;
	     pose; pose = pose->next )
	    if( --i <= 0 )
		break;
    if( pose )
    {
	int col = number_range( 0, 5 );
	sprintf( buf, "&%c%s", message_colours[col], pose->to_char );
	act( buf, ch, NULL, NULL, TO_CHAR );
	sprintf( buf, "&%c%s", message_colours[col], pose->to_room );
	act( buf, ch, NULL, NULL, TO_ROOM );
    }
    else
	send_to_char( "You pose for camera, no-one's looking.\n\r", ch );
    return;
}