/
rogue24b3/
rogue24b3/data/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  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.                                                  *
 ***************************************************************************/

/***************************************************************************
*	ROM 2.4 is copyright 1993-1998 Russ Taylor			   *
*	ROM has been brought to you by the ROM consortium		   *
*	    Russ Taylor (rtaylor@hypercube.org)				   *
*	    Gabrielle Taylor (gtaylor@hypercube.org)			   *
*	    Brian Moore (zump@rom.org)					   *
*	By using this code, you have agreed to follow the terms of the	   *
*	ROM license, in the file Rom24/doc/rom.license			   *
***************************************************************************/

#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "staffcmds.h"

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


/*
 * Log-all switch.
 */
bool				fLogAll		= FALSE;



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

    /*
     * Common other commands.
     * Placed here so one and two letter abbreviations work.
     */
    { "at",             do_at,          POS_DEAD,       -1, 1, STAFF_GEN },
    { "areas",		do_areas,	POS_DEAD,	 0, 1 },
    { "ask",		do_spec_comm,	POS_RESTING,	 0, 1, 0, SCMD_ASK },
    { "attributes",	do_attributes,	POS_DEAD,	 0, 1 },
    { "cast",		do_cast,	POS_FIGHTING,	 0, 1 },
    { "category",	do_category,	POS_DEAD,	-1, 1, STAFF_ADMIN },
    { "cname",		do_cname,	POS_SLEEPING,	 0, 1 },
    { "buy",		do_buy,		POS_RESTING,	 0, 1 },
    { "channels",       do_channels,    POS_DEAD,        0, 1 },
    { "exits",		do_exits,	POS_RESTING,	 0, 1 },
    { "get",		do_get,		POS_RESTING,	 0, 1 },
    { "goto",           do_goto,        POS_DEAD,       -1, 1, STAFF_GEN | STAFF_TRAINEE | STAFF_ASSOCIATE },
    { "group",          do_group,       POS_SLEEPING,    0, 1 },
    { "guild",		do_guild,	POS_DEAD,	-1, 1, STAFF_CLANS },
    { "hit",		do_kill,	POS_FIGHTING,	 0, 0 },
    { "inventory",	do_inventory,	POS_DEAD,	 0, 1 },
    { "kill",		do_kill,	POS_FIGHTING,	 0, 1 },
    { "look",		do_look,	POS_RESTING,	 0, 1 },
    { "clan",		do_gen_comm,	POS_SLEEPING,	 0, 1, 0, SCMD_CLAN },
    { "cpromote",	do_promote,	POS_SLEEPING,	 0, 1 },
    { "clans",		do_clanlist,	POS_SLEEPING,	 0, 1 },
    { "msp",		do_gen_tog,	POS_DEAD,	 0, 1, 0, SCMD_MSP },
    { "music",          do_gen_comm,   	POS_SLEEPING,    0, 1, 0, SCMD_MUSIC }, 
    { "order",		do_order,	POS_RESTING,	 0, 1 },
    { "practice",       do_practice,	POS_SLEEPING,    0, 1 },
    { "rest",		do_rest,	POS_SLEEPING,	 0, 1 },
    { "shapeshift",	do_shapeshift,	POS_STANDING,	 0, 1 },
    { "sit",		do_sit,		POS_SLEEPING,    0, 1 },
    { "sockets",        do_users,	POS_DEAD,       -1, 0, STAFF_GEN },
    { "stand",		do_stand,	POS_SLEEPING,	 0, 1 },
    { "tell",		do_tell,	POS_RESTING,	 0, 1 },
    { "unlock",         do_unlock,      POS_RESTING,     0, 1 },
    { "unread",		do_checknote,	POS_DEAD,	 0, 1 },
    { "users",		do_users,	POS_DEAD,	-1, 1, STAFF_GEN },
    { "wield",		do_wear,	POS_RESTING,	 0, 1 },
    { "wizhelp",	do_wizhelp,	POS_DEAD,	-1, 0, STAFF_GEN | STAFF_TRAINEE | STAFF_ASSOCIATE },

    /*
     * Informational commands.
     */
    { "affects",	do_affects,	POS_DEAD,	 0, 1 },
    { "bug",		do_bug,		POS_DEAD,	 0, 1 },
    { "clear",		do_gen_ps,	POS_DEAD,	 0, 1, 0, SCMD_CLEAR },
    { "commands",	do_commands,	POS_DEAD,	 0, 1 },
    { "compare",	do_compare,	POS_RESTING,	 0, 1 },
    { "consider",	do_consider,	POS_RESTING,	 0, 1 },
    { "count",		do_count,	POS_SLEEPING,	 0, 1 },
    { "credits",	do_credits,	POS_DEAD,	 0, 1 },
    { "equipment",	do_equipment,	POS_DEAD,	 0, 1 },
    { "examine",	do_examine,	POS_RESTING,	 0, 1 },
    { "help",		do_help,	POS_DEAD,	 0, 1 },
    { "info",           do_groups,      POS_SLEEPING,    0, 1 },
    { "idea",		do_idea,	POS_DEAD,	 0, 1 },
    { "motd",		do_gen_ps,	POS_DEAD,        0, 1, 0, SCMD_MOTD },
    { "policy",		do_gen_ps,	POS_DEAD,	 0, 1, 0, SCMD_POLICY },
    { "read",		do_read,	POS_RESTING,	 0, 1 },
    { "rules",		do_gen_ps,	POS_DEAD,	 0, 1, 0, SCMD_RULES },
    { "score",		do_score,	POS_DEAD,	 0, 1 },
    { "scan",           do_scan,        POS_RESTING,     0, 1 },
    { "skills",		do_skills,	POS_DEAD,	 0, 1 },
    { "socials",	do_socials,	POS_DEAD,	 0, 1 },
    { "show",		do_gen_tog,	POS_DEAD,	 0, 1, 0, SCMD_SHOW },
    { "spells",		do_spells,	POS_DEAD,	 0, 1 },
    { "story",		do_gen_ps,	POS_DEAD,	 0, 1, 0, SCMD_STORY },
    { "time",		do_time,	POS_DEAD,	 0, 1 },
    { "toggle",		do_toggle,	POS_DEAD,	 0, 1 },
    { "typo",		do_typo,	POS_DEAD,	 0, 1 },
    { "version",	do_gen_ps,	POS_DEAD,	 0, 1, 0, SCMD_VERSION },
    { "weather",	do_weather,	POS_RESTING,	 0, 1 },
    { "who",		do_who,		POS_DEAD,	 0, 1 },
    { "whisper",	do_spec_comm,	POS_RESTING,	 0, 1, 0, SCMD_WHISPER },
    { "wizlist",	do_wizlist,	POS_DEAD,        0, 1 },
    { "worth",		do_worth,	POS_SLEEPING,	 0, 1 },
    { "gold",		do_worth,	POS_SLEEPING,	 0, 1 },

    /*
     * Configuration commands.
     */
    { "alias",		do_alias,	POS_DEAD,	 0, 1 },
    { "autolist",	do_autolist,	POS_DEAD,	 0, 1 },
    { "autoall",	do_autoall,	POS_DEAD,	 0, 1 },
    { "autoassist",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOASSIST },
    { "autodamage",	do_gen_tog,	POS_DEAD,	 0, 1, 0, SCMD_AUTODAMAGE },
    { "automap",	do_gen_tog,	POS_DEAD,	 0, 1, 0, SCMD_AUTOMAP },
    { "autoexit",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOEXIT },
    { "autogold",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOGOLD },
    { "autoloot",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOLOOT },
    { "autosac",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOSAC },
    { "autosplit",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_AUTOSPLIT },
    { "brief",		do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_BRIEF },
    { "broadcast",	do_gen_comm,	POS_DEAD,	-1, 1, STAFF_GAME, SCMD_BROADCAST },
    { "color",		do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_COLOR },
    { "combine",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_COMBINE },
    { "compact",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_COMPACT },
    { "description",	do_gen_menu,	POS_DEAD,	 0, 1 },
    { "delete",		do_olc_delete,	POS_DEAD,	-1, 1, STAFF_OLCADMIN },
    { "donate",		do_donate,	POS_RESTING,	 0, 1 },
    { "nofollow",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_NOFOLLOW },
    { "nopueblo",	do_gen_tog,	POS_DEAD,	 0, 1, 0, SCMD_NOPUEBLO },
    { "noloot",		do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_NOLOOT },
    { "nosummon",	do_gen_tog,	POS_DEAD,        0, 1, 0, SCMD_NOSUMMON },
    { "outfit",		do_outfit,	POS_RESTING,	 0, 1 },
    { "password",	do_gen_menu,	POS_DEAD,	 0, 1 },
    { "prompt",		do_prompt,	POS_DEAD,        0, 1 },
    { "play",		do_play,	POS_RESTING,	 0, 1 },
    { "songs",		do_songs,	POS_DEAD,	 0, 1 },
    { "scroll",		do_scroll,	POS_DEAD,	 0, 1 },
    { "title",		do_title,	POS_DEAD,	 0, 1 },
    { "unalias",	do_unalias,	POS_DEAD,	 0, 1 },
    { "wimpy",		do_wimpy,	POS_DEAD,	 0, 1 },
    { "display",	do_display,	POS_DEAD,	 0, 1 },
    { "map",		do_mapper,	POS_DEAD,	 0, 1 },
    { "menu",		do_gen_menu,	POS_DEAD,	 0, 1 },

    /*
     * Communication commands.
     */
    { "afk",		do_afk,		POS_SLEEPING,	 0, 1 },
    { "board",		do_board,	POS_SLEEPING,	 0, 1 },
    { "deaf",		do_gen_tog,	POS_DEAD,	 0, 1 },
    { "emote",		do_emote,	POS_RESTING,	 0, 1 },
    { "pmote",		do_pmote,	POS_RESTING,	 0, 1 },
    { "chat",		do_gen_comm,	POS_SLEEPING,	 0, 1, 0, SCMD_CHAT },
    { "gossip",		do_gen_comm,	POS_SLEEPING,	 0, 0, 0, SCMD_CHAT },
    { ",",		do_gocial,	POS_SLEEPING,	 0, 0 },
    { "gocial",         do_gocial,      POS_SLEEPING,    0, 1 },
    { "grats",		do_gen_comm,	POS_SLEEPING,	 0, 1, 0, SCMD_GRATS },
    { "gtell",		do_gtell,	POS_DEAD,	 0, 1 },
    { "note",		do_note,	POS_SLEEPING,	 0, 1 },
    { "pose",		do_pose,	POS_RESTING,	 0, 1 },
    { "quest",          do_quest,       POS_RESTING,     0, 1 },
    { "qtalk",		do_gen_comm,	POS_SLEEPING,	0,  0, 0, SCMD_QUEST },
    { "questalk",	do_gen_comm,	POS_SLEEPING,	0,  1, 0, SCMD_QUEST },
    { "quiet",		do_gen_tog,	POS_SLEEPING, 	 0, 1, 0, SCMD_QUIET },
    { "reply",		do_reply,	POS_SLEEPING,	 0, 1 },
    { "report",         do_report,      POS_RESTING,     0, 1 },
    { "replay",		do_replay,	POS_SLEEPING,	 0, 1 },
    { "say",		do_say,		POS_RESTING,	 0, 1 },
    { "'",		do_say,		POS_RESTING,	 0, 0 },
    { "shout",		do_gen_comm,	POS_RESTING,	 3, 1, 0, SCMD_SHOUT },

    /*
     * Object manipulation commands.
     */
    { "brandish",	do_brandish,	POS_RESTING,	 0, 1 },
    { "close",		do_close,	POS_RESTING,	 0, 1 },
    { "drink",		do_drink,	POS_RESTING,	 0, 1 },
    { "drive",		do_drive,	POS_RESTING,	 0, 1 },
    { "drop",		do_drop,	POS_RESTING,	 0, 1 },
    { "eat",		do_eat,		POS_RESTING,	 0, 1 },
    { "envenom",	do_envenom,	POS_RESTING,	 0, 1 },
    { "fill",		do_fill,	POS_RESTING,	 0, 1 },
    { "finger",		do_finger,	POS_RESTING,	 0, 1 },
    { "give",		do_give,	POS_RESTING,	 0, 1 },
    { "heal",		do_heal,	POS_RESTING,	 0, 1 }, 
    { "hold",		do_wear,	POS_RESTING,	 0, 1 },
    { "list",		do_list,	POS_RESTING,	 0, 1 },
    { "lock",		do_lock,	POS_RESTING,	 0, 1 },
    { "open",		do_open,	POS_RESTING,	 0, 1 },
    { "pick",		do_pick,	POS_RESTING,	 0, 1 },
    { "pour",		do_pour,	POS_RESTING,	 0, 1 },
    { "put",		do_put,		POS_RESTING,	 0, 1 },
    { "quaff",		do_quaff,	POS_RESTING,	 0, 1 },
    { "recite",		do_recite,	POS_RESTING,	 0, 1 },
    { "remove",		do_remove,	POS_RESTING,	 0, 1 },
    { "sell",		do_sell,	POS_RESTING,	 0, 1 },
    { "take",		do_get,		POS_RESTING,	 0, 1 },
    { "sacrifice",	do_sacrifice,	POS_RESTING,	 0, 1 },
    { "junk",           do_sacrifice,   POS_RESTING,     0, 0 },
    { "value",		do_value,	POS_RESTING,	 0, 1 },
    { "volume",		do_volume,	POS_DEAD,	 0, 1 },
    { "wear",		do_wear,	POS_RESTING,	 0, 1 },
    { "zap",		do_zap,		POS_RESTING,	 0, 1 },

    /*
     * Pueblo Commands.
     */
    { "pmusic",		do_pmusic,	POS_DEAD,	 0, 1 },
    { "pstop",		do_pstop,	POS_DEAD,	 0, 1 },

    /*
     * Combat commands.
     */
    { "backstab",	do_backstab,	POS_FIGHTING,	 0, 1 },
    { "bash",		do_bash,	POS_FIGHTING,    0, 1 },
    { "bs",		do_backstab,	POS_FIGHTING,	 0, 0 },
    { "berserk",	do_berserk,	POS_FIGHTING,	 0, 1 },
    { "dirt",		do_dirt,	POS_FIGHTING,	 0, 1 },
    { "disarm",		do_disarm,	POS_FIGHTING,	 0, 1 },
    { "flee",		do_flee,	POS_FIGHTING,	 0, 1 },
    { "kick",		do_kick,	POS_FIGHTING,	 0, 1 },
    { "lore",		do_lore,	POS_FIGHTING,	 0, 1 },
    { "murder",		do_murder,	POS_FIGHTING,	 5, 1 },
    { "rescue",		do_rescue,	POS_FIGHTING,	 0, 0 },
    { "surrender",	do_surrender,	POS_FIGHTING,    0, 1 },
    { "trip",		do_trip,	POS_FIGHTING,    0, 1 },
    { "spellbane",	do_spellbane,	POS_STANDING,	 0, 0 },

    /*
     * Mob command interpreter (placed here for faster scan...)
     */
    { "mob",		do_mob,		POS_DEAD,	 0, 0 },

    /*
     * Miscellaneous commands.
     */
    { "enter", 		do_enter, 	POS_STANDING,	 0, 1 },
    { "leave",		do_leave,	POS_STANDING,	 0, 1 },
    { "mount",		do_mount,	POS_STANDING,	 0, 1 },
    { "unmount",	do_unmount,	POS_SITTING,	 0, 1 },
    { "follow",		do_follow,	POS_RESTING,	 0, 1 },
    { "gain",		do_gain,	POS_STANDING,	 0, 1 },
    { "go",		do_enter,	POS_STANDING,	 0, 0 },
    { "groups",		do_groups,	POS_SLEEPING,    0, 1 },
    { "hide",		do_hide,	POS_RESTING,	 0, 1 },
    { "juke",		do_juke,	POS_RESTING,	 0, 1 },
    { "quit",		do_quit,	POS_DEAD,	 0, 1 },
    { "recall",		do_recall,	POS_FIGHTING,	 0, 1 },
    { "/",		do_recall,	POS_FIGHTING,	 0, 0 },
    { "save",		do_save,	POS_DEAD,	 0, 1 },
    { "sleep",		do_sleep,	POS_SLEEPING,	 0, 1 },
    { "sneak",		do_sneak,	POS_STANDING,	 0, 1 },
    { "split",		do_split,	POS_RESTING,	 0, 1 },
    { "steal",		do_steal,	POS_STANDING,	 0, 1 },
    { "train",		do_train,	POS_RESTING,	 0, 1 },
    { "visible",	do_visible,	POS_SLEEPING,	 0, 1 },
    { "wake",		do_wake,	POS_SLEEPING,	 0, 1 },
    { "watch",		do_watch,	POS_RESTING,	 0, 1 },
    { "where",		do_where,	POS_RESTING,	 0, 1 },

    /*
     * Immortal commands.
     */
    { "for",		do_for,		POS_DEAD,	-1, 1, STAFF_ADMIN },
    { "rename",		do_rename, 	POS_DEAD,	-1, 1, STAFF_SECADMIN },
    { "pload",		do_pload,	POS_DEAD,	-1, 1, STAFF_SECADMIN },
    { "punload",	do_punload,	POS_DEAD,	-1, 1, STAFF_SECADMIN },
    { "advance",	do_advance,	POS_DEAD,	-1, 1, STAFF_ADMIN },
    { "copyover",	do_copyover,	POS_DEAD,	-1, 1, STAFF_ADMIN },
    { "dump",		do_dump,	POS_DEAD,	-1, 1, STAFF_CODER },
    { "trust",		do_trust,	POS_DEAD,	-1, 1, STAFF_ADMIN },
    { "violate",	do_violate,	POS_DEAD,	-1, 1, STAFF_SECADMIN },
    { "vape",		do_vape,	POS_DEAD,	-1, 1, STAFF_SECADMIN },

    { "allow",		do_allow,	POS_DEAD,	IM,  1, 0, SCMD_ALLOW },
    { "deny",		do_allow,	POS_DEAD,	IM,  1, 0, SCMD_DENY },
    { "unban",		do_unban,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "ban",		do_ban,		POS_DEAD,	-1,  1, STAFF_SECURITY, SCMD_TEMPBAN },
    { "disconnect",	do_disconnect,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "dc",		do_disconnect,	POS_DEAD,	-1,  0, STAFF_SECURITY },
    { "flag",		do_flag,	POS_DEAD,	-1,  1, STAFF_ADMIN },
    { "freeze",		do_freeze,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "permban",	do_ban,		POS_DEAD,	-1,  1, STAFF_SECADMIN, SCMD_PERMBAN },
    { "protect",	do_protect,	POS_DEAD,	-1,  1, STAFF_ADMIN },
    { "reboot",		do_reboot,	POS_DEAD,	-1,  1, STAFF_ADMIN },
    { "set",		do_set,		POS_DEAD,	-1,  1, STAFF_GEN },
    { "oset",		do_oset,	POS_DEAD,	-1,  1, STAFF_CHAR },
    { "skillset",	do_sset,	POS_DEAD,	-1,  0, STAFF_CHAR },
    { "setskill",	do_sset,	POS_DEAD,	-1,  1, STAFF_CHAR },
    { "shutdown",	do_shutdown,	POS_DEAD,	-1,  1, STAFF_ADMIN },
    { "wizlock",	do_wizlock,	POS_DEAD,	-1,  1, STAFF_ADMIN },
    { "force",		do_force,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "last",		do_last,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "load",		do_load,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "newlock",	do_newlock,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "nochat",         do_gen_tog,	POS_DEAD,        0,  1, 0, SCMD_NOCHAT },
    { "noquest",	do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOQUEST },
    { "noclan",         do_gen_tog,	POS_DEAD,        0,  1, 0, SCMD_NOCLAN },
    { "noinfo",		do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOINFO },
    { "nomusic",	do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOMUSIC },
    { "nograts",	do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOGRATS },
    { "notell",		do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOTELL },
    { "noshout",	do_gen_tog,	POS_DEAD,	 0,  1, 0, SCMD_NOSHOUT },
    { "mute",		do_mute,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "send",		do_pecho,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "pardon",		do_pardon,	POS_DEAD,	-1,  1, STAFF_CHAR },
    { "purge",		do_purge,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "restore",	do_restore,	POS_DEAD,	-1,  1, STAFF_CHAR },
    { "slay",		do_slay,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "teleport",	do_transfer,    POS_DEAD,	-1,  1, STAFF_GEN },
    { "transfer",	do_transfer,	POS_DEAD,	-1,  1, STAFF_GEN },

    { "poofin",		do_bamfin,	POS_DEAD,	-1,  1, STAFF_GEN | STAFF_ASSOCIATE },
    { "poofout",	do_bamfout,	POS_DEAD,	-1,  1, STAFF_GEN | STAFF_ASSOCIATE },
    { "rmessage",	do_rmsg,	POS_DEAD,	-1,  1, STAFF_CHAR },
    { "gecho",		do_echo,	POS_DEAD,	-1,  1, STAFF_GAME },
    { "holylight",	do_gen_tog,	POS_DEAD,	-1,  1, STAFF_GEN | STAFF_ASSOCIATE | STAFF_TRAINEE, SCMD_HOLYLIGHT },
    { "nohassle",	do_gen_tog,	POS_DEAD,	-1,  1, STAFF_GEN, SCMD_NOHASSLE },
    { "incognito",	do_incognito,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "invis",		do_invis,	POS_DEAD,	-1,  0, STAFF_GEN | STAFF_ASSOCIATE | STAFF_TRAINEE },
    { "log",		do_log,		POS_DEAD,	-1,  1, STAFF_SECADMIN },
    { "memory",		do_memory,	POS_DEAD,	-1,  1, STAFF_CODER },
    { "mwhere",		do_mwhere,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "owhere",		do_owhere,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "peace",		do_peace,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "echo",		do_recho,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "return",         do_return,      POS_DEAD,       IM,  0 },
    { "snoop",		do_snoop,	POS_DEAD,	-1,  1, STAFF_SECURITY },
    { "stat",		do_stat,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "string",		do_string,	POS_DEAD,	-1,  1, STAFF_GAME },
    { "switch",		do_switch,	POS_DEAD,	-1,  1, STAFF_GAME },
    { "syslog",		do_syslog,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "wiznet",		do_syslog,	POS_DEAD,	-1,  0, STAFF_GEN },
    { "wizinvis",	do_invis,	POS_DEAD,	-1,  1, STAFF_GEN | STAFF_ASSOCIATE | STAFF_TRAINEE},
    { "vnum",		do_vnum,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "zallow",		do_zallow,	POS_DEAD,	-1,  1, STAFF_OLCADMIN, SCMD_ZALLOW },
    { "zdeny",		do_zallow,	POS_DEAD,	-1,  1, STAFF_OLCADMIN, SCMD_ZDENY },
    { "zecho",		do_zecho,	POS_DEAD,	-1,  1, STAFF_GAME },
    { "clone",		do_clone,	POS_DEAD,	-1,  1, STAFF_GEN },

    { "immtalk",	do_immtalk,	POS_DEAD,	-1,  1, STAFF_GEN | STAFF_ASSOCIATE | STAFF_TRAINEE},
    { "imotd",          do_gen_ps,       POS_DEAD,      -1,  1, STAFF_GEN, SCMD_IMOTD },
    { ";",		do_immtalk,	POS_DEAD,	-1,  0, STAFF_GEN | STAFF_TRAINEE | STAFF_ASSOCIATE},
    { "smote",		do_smote,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "prefix",		do_prefix,	POS_DEAD,	-1,  1, STAFF_GEN },
    { "mpdump",		do_mpdump,	POS_DEAD,	-1,  1, STAFF_SCRIPT },
    { "mpstat",		do_mpstat,	POS_DEAD,	-1,  1, STAFF_SCRIPT },
    { "sound",		do_sound,	POS_DEAD,	-1,  1, STAFF_GAME },

    /*
     * OLC
     */
    { "olc",		do_olclist,	POS_DEAD,  -1, 1, STAFF_OLC },
    { "path",		do_path,	POS_DEAD,  -1, 1, STAFF_GAME },
    { "immtitle",	do_immtitle,	POS_DEAD,  -1, 1, STAFF_ADMIN },
    { "immcurse",	do_immcurse,	POS_DEAD,  -1, 1, STAFF_ADMIN },
    { "edit",		do_olc,		POS_DEAD,  -1, 0, STAFF_OLC },
    { "asave",          do_asave,	POS_DEAD,  -1, 1, STAFF_OLC | STAFF_TRAINEE},
    { "alist",		do_alist,	POS_DEAD,  -1, 1, STAFF_GEN },
    { "mlist",		do_liblist,	POS_DEAD,  -1, 1, STAFF_GEN, SCMD_MLIST },
    { "olist",		do_liblist,	POS_DEAD,  -1, 1, STAFF_GEN, SCMD_OLIST },
    { "rlist",		do_liblist,	POS_DEAD,  -1, 1, STAFF_GEN, SCMD_RLIST },
    { "tlist",		do_liblist,	POS_DEAD,  -1, 1, STAFF_GEN, SCMD_TLIST },
    { "resets",		do_resets,	POS_DEAD,  -1, 1, STAFF_OLC },
    { "redit",		do_redit,	POS_DEAD,  -1, 1, STAFF_OLC | STAFF_TRAINEE },
    { "medit",		do_medit,	POS_DEAD,  -1, 1, STAFF_OLC | STAFF_TRAINEE },
    { "aedit",		do_aedit,	POS_DEAD,  -1, 1, STAFF_OLCADMIN },
    { "oedit",		do_oedit,	POS_DEAD,  -1, 1, STAFF_OLC | STAFF_TRAINEE },
    { "mpedit",		do_mpedit,	POS_DEAD,  -1, 1, STAFF_SCRIPT },
    { "hedit",		do_hedit,	POS_DEAD,  -1, 1, STAFF_HELP },
    { "gedit",		do_gedit,	POS_DEAD,  -1, 1, STAFF_CLANS },
    { "sedit",		do_sedit,	POS_DEAD,  -1, 1, STAFF_SOCIALS },
    /*
     * End of list.
     */
    { "",		0,		POS_DEAD,	 0,  0 }
};




/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, 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.
     */
    REMOVE_BIT( ch->affected_by, AFF_HIDE );

    /*
     * Implement freeze command.
     */
    if (PLR_FLAGGED(ch, 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]) )
    {
	command[0] = argument[0];
	command[1] = '\0';
	argument++;
	while ( isspace(*argument) )
	    argument++;
    }
    else
    {
	argument = one_argument( argument, command );
    }

    /*
     * 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)
	&& (!IS_STAFFCMD(cmd) || (cmd_table[cmd].staffcmd & STF_FLAGS(ch))))
	{
	    found = TRUE;
	    break;
	}
    }

    if (PLR_FLAGGED(ch, PLR_LOG) || fLogAll)
	log("Log %s: %s", ch->name, logline);

    if ( ch->desc != NULL && ch->desc->snoop_by != NULL )
    {
	write_to_buffer( ch->desc->snoop_by, "% ",    2 );
	write_to_buffer( ch->desc->snoop_by, logline, 0 );
	write_to_buffer( ch->desc->snoop_by, "\n\r",  2 );
    }

    if ( !found )
    {
	/*
	 * Look for command in socials table.
	 */
	if ( !check_social( ch, command, argument ) )
	    send_to_char( "Huh?\n\r", 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_RESTING:
	    send_to_char( "Nah... You feel too relaxed...\n\r", ch);
	    break;

	case POS_SITTING:
	    send_to_char( "Better stand up first.\n\r",ch);
	    break;

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

	}
	return;
    }

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

    tail_chain( );
    return;
}

/* function to keep argument safe in all commands -- no static strings */
void do_function (CHAR_DATA *ch, DO_FUN *do_fun, char *argument, SInt32 subcmd)
{
    char *command_string;
    
    /* copy the string */
    command_string = str_dup(argument);
    
    /* dispatch the command */
    (*do_fun) (ch, command_string, subcmd);

    /* free the string */
    free_string(command_string);
}
    
bool check_social( CHAR_DATA *ch, char *command, char *argument )
{
    int cmd, min_pos;
    bool found;
    OBJ_DATA *obj;
    CHAR_DATA *victim;
    char arg[MAX_INPUT_LENGTH];

    found = FALSE;
    for (cmd = 0; social_table[cmd].name[0] != '\0'; cmd++)
    {
	if (command[0] == social_table[cmd].name[0]
	&&  !str_prefix( command, social_table[cmd].name)) {
	    found = TRUE;
	    break;
	}
    }

    if (!found)
	return FALSE;

    if (!IS_NPC(ch) && IS_SET(ch->comm, COMM_MUTED)) {
	send_to_char( "You are anti-social!\n\r", ch );
	return TRUE;
    }
    if (GET_POS(ch) < (min_pos = social_table[cmd].min_pos)) {
	switch (ch->position) {
	case POS_DEAD:
		ch->Send("Lie still; you are DEAD.\n\r");
		return TRUE;
	case POS_INCAP:
	case POS_MORTAL:
		ch->Send("You are hurt far too bad for that.\n\r");
		return TRUE;
	case POS_STUNNED:
		ch->Send("You are too stunned to do that.\n\r");
		return TRUE;
	case POS_SLEEPING:
		ch->Send("In your dreams, or what?\n\r");
		return TRUE;
	case POS_RESTING:
		ch->Send("Nah... You feel too relaxed to do that..\n\r");
		return TRUE;
	case POS_SITTING:
		ch->Send("Maybe you should get on your feet?\n\r");
		return TRUE;
	case POS_FIGHTING:
		ch->Send("No way!  You're fighting for your life!\n\r");
		return TRUE;
	default:
		ch->Send("Ahh, you seem to be bugged, inform staff.\n\r");
		return TRUE;
	}
    }

    one_argument( argument, arg );
    victim = NULL;
    if ( arg[0] == '\0' )
    {
	act(social_table[cmd].others_no_arg, ch, NULL, victim, TO_ROOM);
	act_new(social_table[cmd].char_no_arg, ch, NULL, victim, TO_CHAR, min_pos, TRUE, FALSE);
    }
    else if (!(victim = get_char_room(ch, arg)))
    {
	if (*(social_table[cmd].char_obj_found) &&
	((obj = get_obj_list(ch, arg, IN_ROOM(ch)->contents)) ||
	(obj = get_obj_carry(ch, arg, ch)))) {
		act(social_table[cmd].others_obj_found, ch, obj, obj, TO_ROOM);
		act_new(social_table[cmd].char_obj_found, ch, obj, obj, TO_CHAR, min_pos, TRUE, FALSE);
	} else
		send_to_char( "They aren't here.\n\r", ch );
    }
    else if ( victim == ch )
    {
	act(social_table[cmd].others_auto, ch, NULL, victim, TO_ROOM);
	act_new(social_table[cmd].char_auto, ch, NULL, victim, TO_CHAR, min_pos, TRUE, FALSE);
    }
    else
    {
	act(social_table[cmd].others_found, ch, NULL, victim, TO_NOTVICT);
	act_new(social_table[cmd].char_found, ch, NULL, victim, TO_CHAR, min_pos, TRUE, FALSE);
	act_new(social_table[cmd].vict_found, ch, NULL, victim, TO_VICT, min_pos, TRUE, FALSE);
/*
	if ( !IS_NPC(ch) && IS_NPC(victim)
	&&   !IS_AFFECTED(victim, AFF_CHARM)
	&&   IS_AWAKE(victim) 
	&&   victim->desc == NULL)
	{
	    switch ( number_bits( 4 ) )
	    {
	    case 0:
	    case 1: case 2: case 3: case 4:
	    case 5: case 6: case 7: case 8:
		act(social_table[cmd].others_found,
		    victim, NULL, ch, TO_NOTVICT);
		act_new(social_table[cmd].char_found,
		    victim, NULL, ch, TO_CHAR, min_pos, TRUE, FALSE);
		act_new(social_table[cmd].vict_found,
		    victim, NULL, ch, TO_VICT, min_pos, TRUE, FALSE);
		break;

	    case 9: case 10: case 11: case 12:
		act( "$n slaps $N.",  victim, NULL, ch, TO_NOTVICT );
		act( "You slap $N.",  victim, NULL, ch, TO_CHAR    );
		act( "$n slaps you.", victim, NULL, ch, TO_VICT    );
		break;
	    }
	}
*/
    }
    return TRUE;
}



/*
 * Return true if an argument is completely numeric.
 */
bool is_number ( char *arg )
{
 
    if ( *arg == '\0' )
        return FALSE;
 
    if ( *arg == '+' || *arg == '-' )
        arg++;
 
    for ( ; *arg != '\0'; arg++ )
    {
        if ( !isdigit( *arg ) )
            return FALSE;
    }
 
    return TRUE;
}



/*
 * Given a string like 14.foo, return 14 and 'foo'
 */
int number_argument( char *argument, char *arg )
{
    char *pdot;
    int number;
    
    for ( pdot = argument; *pdot != '\0'; pdot++ )
    {
	if ( *pdot == '.' )
	{
	    *pdot = '\0';
	    number = atoi( argument );
	    *pdot = '.';
	    strcpy( arg, pdot+1 );
	    return number;
	}
    }

    strcpy( arg, argument );
    return 1;
}

/* 
 * Given a string like 14*foo, return 14 and 'foo'
*/
int mult_argument(char *argument, char *arg)
{
    char *pdot;
    int number;

    for ( pdot = argument; *pdot != '\0'; pdot++ )
    {
        if ( *pdot == '*' )
        {
            *pdot = '\0';
            number = atoi( argument );
            *pdot = '*';
            strcpy( arg, pdot+1 );
            return number;
        }
    }
 
    strcpy( arg, argument );
    return 1;
}

bool is_abbrev(const char *arg1, const char *arg2) {
        if (!*arg1 || !*arg2)
                return false;

        for (; *arg1 && *arg2; arg1++, arg2++)
                if (LOWER(*arg1) != LOWER(*arg2))
                        return false;

        if (!*arg1)     return true;
        else            return false;
}

char *any_one_arg(const char *argument, char *first_arg)
{
  skip_spaces(argument);

  while (*argument && !isspace(*argument)) {
    *(first_arg++) = LOWER(*argument);
    argument++;
  }

  *first_arg = '\0';

  return const_cast<char *>(argument);
}

void half_chop(const char *string, char *arg1, char *arg2)
{
  char *temp;

  temp = any_one_arg(string, arg1);
  skip_spaces(temp);
  strcpy(arg2, temp);
}

/*
 * Pick off one argument from a string and return the rest.
 * Understands quotes.
 */
char *one_argument( char *argument, char *arg_first )
{
    char cEnd;

    while ( isspace(*argument) )
	argument++;

    cEnd = ' ';
    if ( *argument == '\'' || *argument == '"' )
	cEnd = *argument++;

    while ( *argument != '\0' )
    {
	if ( *argument == cEnd )
	{
	    argument++;
	    break;
	}
	*arg_first = LOWER(*argument);
	arg_first++;
	argument++;
    }
    *arg_first = '\0';

    while ( isspace(*argument) )
	argument++;

    return argument;
}

void skip_spaces(const char *&string) {
	while (*string && isspace(*string))	string++;
}

char *two_arguments(char *argument, char *first_arg, char *second_arg) {
        return one_argument(one_argument(argument, first_arg), second_arg);
}

/*
 * Contributed by Alander.
 */
ACMD(do_commands) {
    int cmd, col;
    BUFFER *output=new_buf();
    char buf[MAX_STRING_LENGTH];
 
    col = 0;
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
        if ( cmd_table[cmd].level <  LEVEL_IMMORTAL && !IS_STAFFCMD(cmd)
	&&   cmd_table[cmd].level <= get_trust( ch ) 
	&&   cmd_table[cmd].show)
	{
	    sprintf( buf, "%-12s", cmd_table[cmd].name );
	    add_buf(output, buf);
	    if ( ++col % 6 == 0 )
		add_buf(output, "\n\r");
	}
    }
 
    if ( col % 6 != 0 )
	add_buf(output, "\n\r");
    page_to_char(buf_string(output), ch);
    free_buf(output);
    return;
}

ACMD(do_wizhelp) {
    CHAR_DATA *vict;
    char buf[MAX_STRING_LENGTH], arg[MIL];
    int cmd;
    int col;
 
    col = 0;
    argument = one_argument(argument, arg);

    if (arg[0] == '\0') vict = ch;
    else if (IS_IMMORTAL(ch)) {
	vict = get_char_world(ch, arg);
		if (!vict) {
			send_to_char("No such player.\r\n",ch);
			return;
		}
		if (get_trust(vict) > get_trust(ch))
		vict = ch;
	} else
		vict = ch;
	if (vict == NULL || IS_NPC(vict)) return;

    send_to_char("The following commands are allowed to you:\r\n",ch);
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
	if (((IS_STAFFCMD(cmd) && STF_FLAGGED(vict,cmd_table[cmd].staffcmd))
	|| (!IS_STAFFCMD(cmd) && (cmd_table[cmd].level >= LEVEL_IMMORTAL)
	&& (get_trust(vict) >= cmd_table[cmd].level)))
	&& cmd_table[cmd].show)
	{
	    sprintf( buf, "%-12s", cmd_table[cmd].name );
	    send_to_char( buf, ch );
	    if ( ++col % 6 == 0 )
		send_to_char( "\n\r", ch );
	}
    }
 
    if ( col % 6 != 0 )
	send_to_char( "\n\r", ch );
    return;
}