interp.c

Mor/Mor/src/interp.c · 40.4 KB

From the archive Mor.zip

Download the archive   « Back to the archive contents

/***************************************************************************
 *  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			   *
***************************************************************************/

#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "interp.h"

char    last_command[MAX_STRING_LENGTH];

bool 	check_disabled (const struct cmd_type *command);
DISABLED_DATA *disabled_first;
 
#define END_MARKER	"END" /* for load_disabled() and save_disabled() */

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

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



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



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

    /*
     * Common other commands.
     * Placed here so one and two letter abbreviations work.
     */
    { "at",             do_at,          POS_DEAD,       L6,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "cast",		do_cast,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "auction",        do_auction,     POS_SLEEPING,    0,  LOG_NORMAL, 1,0,0 },
    { "buy",		do_buy,		POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "channels",       do_channels,    POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "exits",		do_exits,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "get",		do_get,		POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "goto",           do_goto,        POS_DEAD,       L8,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "group",          do_group,       POS_SLEEPING,    0,  LOG_NORMAL, 1,0 ,0},
    { "guild",		do_guild,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
    { "hit",		do_kill,	POS_FIGHTING,	 0,  LOG_NORMAL, 0,0,0 },
    { "inventory",	do_inventory,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "kill",		do_kill,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "look",		do_look,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "clan",		do_clantalk,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "music",          do_music,   	POS_SLEEPING,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0}, 
    { "order",		do_order,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "practice",       do_practice,	POS_SLEEPING,    0,  LOG_NORMAL, 1,0 ,0},
	{ "quest",          do_quest,       POS_RESTING,     0,  LOG_NORMAL, 1,0,0 },
    { "rest",		do_rest,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,0,0 },
    { "sit",		do_sit,		POS_SLEEPING,    0,  LOG_NORMAL, 1,0 ,0},
    { "sockets",        do_sockets,	POS_DEAD,       L4,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "stand",		do_stand,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "tell",		do_tell,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "unlock",         do_unlock,      POS_RESTING,     0,  LOG_NORMAL, 1,0,0 },
    { "wield",		do_wear,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "wizhelp",	do_wizhelp,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},

    /*
     * Informational commands.
     */
    { "affects",	do_affects,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "areas",		do_areas,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "bug",		do_bug,		POS_DEAD,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "changes",	do_changes,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "commands",	do_commands,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "compare",	do_compare,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "consider",	do_consider,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "count",		do_count,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "credits",	do_credits,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM},
    { "equipment",	do_equipment,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "examine",	do_examine,	POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },
/*  { "groups",		do_groups,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 }, */
    { "help",		do_help,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "idea",		do_idea,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "info",           do_groups,      POS_SLEEPING,    0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "motd",		do_motd,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM},
    { "news",		do_news,	POS_DEAD,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "read",		do_read,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "report",		do_report,	POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "rules",		do_rules,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
	{ "score",		do_score,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "skills",		do_skills,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "socials",	do_socials,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "show",		do_show,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "spells",		do_spells,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "story",		do_story,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "time",		do_time,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "typo",		do_typo,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "weather",	do_weather,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "who",		do_who,		POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "whois",		do_whois,	POS_DEAD,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "wizlist",	do_wizlist,	POS_DEAD,        0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "worth",		do_worth,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},

    /*
     * Configuration commands.
     */
    { "alia",		do_alia,	POS_DEAD,	 0,  LOG_NORMAL, 0,KEEP_HIDE,OK_CHARM },
    { "alias",		do_alias,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
	{ "autoall",    do_autoall,     POS_DEAD,0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "autolist",	do_autolist,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "autoassist",	do_autoassist,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "autoexit",	do_autoexit,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "autogold",	do_autogold,	POS_DEAD,        0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "autoloot",	do_autoloot,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "autosac",	do_autosac,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "autosplit",	do_autosplit,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "brief",		do_brief,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
/*  { "channels",	do_channels,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM }, */
	{ "colour",		do_colour,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "combine",	do_combine,	POS_DEAD,        0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "compact",	do_compact,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "description",	do_description,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "delet",		do_delet,	POS_DEAD,	 0,  LOG_ALWAYS, 0,KEEP_HIDE,0 },
    { "delete",		do_delete,	POS_STANDING,	 0,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "nofollow",	do_nofollow,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "noloot",		do_noloot,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "nosummon",	do_nosummon,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "outfit",		do_outfit,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0},
    { "password",	do_password,	POS_DEAD,	 0,  LOG_NEVER,  1,KEEP_HIDE,OK_CHARM},
    { "prompt",		do_prompt,	POS_DEAD,        0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "scroll",		do_scroll,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "title",		do_title,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "unalias",	do_unalias,	POS_DEAD,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,OK_CHARM},
    { "wimpy",		do_wimpy,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},

    /*
     * Communication commands.
     */
    { "afk",		do_afk,		POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "answer",		do_answer,	POS_SLEEPING,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
/*  { "auction",	do_auction,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0}, */
    { "deaf",		do_deaf,	POS_DEAD,	 0,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "emote",		do_emote,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "pmote",		do_pmote,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { ".",		do_gossip,	POS_SLEEPING,	 0,  LOG_NORMAL, 0,KEEP_HIDE ,0},
    { "gossip",		do_gossip,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { ",",		do_emote,	POS_RESTING,	 0,  LOG_NORMAL, 0,KEEP_HIDE,0 },
    { "grats",		do_grats,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "gtell",		do_gtell,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { ";",		do_gtell,	POS_DEAD,	 0,  LOG_NORMAL, 0,KEEP_HIDE ,0},
/*  { "music",		do_music,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 }, */
    { "note",		do_note,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "pose",		do_pose,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "question",	do_question,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "quote",		do_quote,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "quiet",		do_quiet,	POS_SLEEPING, 	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "reply",		do_reply,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "replay",		do_replay,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "say",		do_say,		POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "'",		do_say,		POS_RESTING,	 0,  LOG_NORMAL, 0,0,0 },
    { "shout",		do_shout,	POS_RESTING,	 3,  LOG_NORMAL, 1,0,0 },
    { "unread",		do_unread,	POS_SLEEPING,    0,  LOG_NORMAL, 1,KEEP_HIDE,OK_CHARM },
    { "yell",		do_yell,	POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },

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

    /*
     * Combat commands.
     */
    { "backstab",	do_backstab,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "bash",		do_bash,	POS_FIGHTING,    0,  LOG_NORMAL, 1,0 ,0},
    { "berserk",	do_berserk,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "dirt",		do_dirt,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "disarm",		do_disarm,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "flee",		do_flee,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "kick",		do_kick,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "murde",		do_murde,	POS_FIGHTING,	 0,  LOG_NORMAL, 0,KEEP_HIDE,OK_CHARM },
    { "murder",		do_murder,	POS_FIGHTING,	 5,  LOG_ALWAYS, 1,0,0 },
    { "rescue",		do_rescue,	POS_FIGHTING,	 0,  LOG_NORMAL, 0,0 ,0},
    { "surrender",	do_surrender,	POS_FIGHTING,    0,  LOG_NORMAL, 1,0,0 },
    { "trip",		do_trip,	POS_FIGHTING,    0,  LOG_NORMAL, 1,0,0 },

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

    /*
     * Miscellaneous commands.
     */
    { "enter", 		do_enter, 	POS_STANDING,	 0,  LOG_NORMAL, 1,0,0 },
    { "follow",		do_follow,	POS_RESTING,	 0,  LOG_NORMAL, 1,0,0 },
    { "gain",		do_gain,	POS_STANDING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "go",		do_enter,	POS_STANDING,	 0,  LOG_NORMAL, 0,0,0},
/*  { "group",		do_group,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 }, */
    { "groups",		do_groups,	POS_SLEEPING,    0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "hide",		do_hide,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "play",		do_play,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
/*  { "practice",	do_practice,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0}, */
    { "qui",		do_qui,		POS_DEAD,	 0,  LOG_NORMAL, 0,KEEP_HIDE,OK_CHARM },
    { "quit",		do_quit,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "recall",		do_recall,	POS_FIGHTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "/",		do_recall,	POS_FIGHTING,	 0,  LOG_NORMAL, 0,0 ,0},
    { "rent",		do_rent,	POS_DEAD,	 0,  LOG_NORMAL, 0,0 ,0},
    { "save",		do_save,	POS_DEAD,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "sleep",		do_sleep,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "sneak",		do_sneak,	POS_STANDING,	 0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "split",		do_split,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "steal",		do_steal,	POS_STANDING,	 0,  LOG_NORMAL, 1,0,0},
    { "train",		do_train,	POS_RESTING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "visible",	do_visible,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "wake",		do_wake,	POS_SLEEPING,	 0,  LOG_NORMAL, 1,0 ,0},
    { "where",		do_where,	POS_RESTING,	 0,  LOG_NORMAL, 1,KEEP_HIDE ,0},



    /*
     * Immortal commands.
     */
	{ "losereply",	do_losereply,POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "vlist",		do_vlist,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "exlist",		do_exlist,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "pload",		do_pload,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "punload",	do_punload,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "backup",		do_backup,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
	{ "bonus",		do_bonus,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
    { "advance",	do_advance,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE ,OK_CHARM},
	{ "disable",	do_disable,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE ,OK_CHARM},
    { "dump",		do_dump,	POS_DEAD,	ML,  LOG_ALWAYS, 0,KEEP_HIDE,0 },
	{ "doas",		do_doas,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "trust",		do_trust,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
    { "violate",	do_violate,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
	{ "nuke",		do_nuke,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE ,0},

    { "allow",		do_allow,	POS_DEAD,	L2,  LOG_ALWAYS, 1,KEEP_HIDE ,OK_CHARM},
    { "ban",		do_ban,		POS_DEAD,	L2,  LOG_ALWAYS, 1,KEEP_HIDE ,OK_CHARM},
    { "deny",		do_deny,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE ,OK_CHARM},
    { "disconnect",	do_disconnect,	POS_DEAD,	L3,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "flag",		do_flag,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "freeze",		do_freeze,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
	{ "noaffect",	do_noaffect,	POS_DEAD,	ML,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "permban",	do_permban,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
    { "protect",	do_protect,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "reboo",		do_reboo,	POS_DEAD,	L1,  LOG_NORMAL, 0,KEEP_HIDE,OK_CHARM },
    { "reboot",		do_reboot,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
	{ "rename",		do_rename,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
    { "set",		do_set,		POS_DEAD,	L2,  LOG_ALWAYS, 1,KEEP_HIDE,OK_CHARM },
    { "shutdow",	do_shutdow,	POS_DEAD,	L1,  LOG_NORMAL, 0,KEEP_HIDE,0 },
    { "shutdown",	do_shutdown,	POS_DEAD,	L1,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
/*  { "sockets",	do_sockets,	POS_DEAD,	L4,  LOG_NORMAL, 1,KEEP_HIDE,0 }, */
    { "wizlock",	do_wizlock,	POS_DEAD,	L2,  LOG_ALWAYS, 1,KEEP_HIDE,0 },

    { "force",		do_force,	POS_DEAD,	L7,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "load",		do_load,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "newlock",	do_newlock,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "nochannels",	do_nochannels,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "noemote",	do_noemote,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "noshout",	do_noshout,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "notell",		do_notell,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "pecho",		do_pecho,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 }, 
    { "pardon",		do_pardon,	POS_DEAD,	L3,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "purge",		do_purge,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "restore",	do_restore,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "sla",		do_sla,		POS_DEAD,	L3,  LOG_NORMAL, 0,KEEP_HIDE,0 },
    { "slay",		do_slay,	POS_DEAD,	L3,  LOG_ALWAYS, 1,KEEP_HIDE,0 },
    { "teleport",	do_transfer,    POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },	
    { "transfer",	do_transfer,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE ,0},

/*  { "at",		do_at,		POS_DEAD,	L6,  LOG_NORMAL, 1,KEEP_HIDE,0 }, */
    { "poofin",		do_bamfin,	POS_DEAD,	L8,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "poofout",	do_bamfout,	POS_DEAD,	L8,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "gecho",		do_echo,	POS_DEAD,	L4,  LOG_ALWAYS, 1 ,KEEP_HIDE,0},
/*  { "goto",		do_goto,	POS_DEAD,	L8,  LOG_NORMAL, 1 ,KEEP_HIDE,0}, */
    { "holylight",	do_holylight,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "incognito",	do_incognito,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "invis",		do_invis,	POS_DEAD,	IM,  LOG_NORMAL, 0,KEEP_HIDE,0 },
    { "log",		do_log,		POS_DEAD,	L1,  LOG_ALWAYS, 1 ,KEEP_HIDE,0},
    { "memory",		do_memory,	POS_DEAD,	IM,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "mwhere",		do_mwhere,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "owhere",		do_owhere,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "peace",		do_peace,	POS_DEAD,	L5,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "penalty",	do_penalty,	POS_DEAD,	L7,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "echo",		do_recho,	POS_DEAD,	L6,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
    { "return",         do_return,      POS_DEAD,       L6,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "snoop",		do_snoop,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
    { "stat",		do_stat,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "string",		do_string,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
    { "switch",		do_switch,	POS_DEAD,	L6,  LOG_ALWAYS, 1,KEEP_HIDE ,0},
    { "wizinvis",	do_invis,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "vnum",		do_vnum,	POS_DEAD,	L4,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "zecho",		do_zecho,	POS_DEAD,	L4,  LOG_ALWAYS, 1,KEEP_HIDE ,0},

    { "clone",		do_clone,	POS_DEAD,	L5,  LOG_ALWAYS, 1,KEEP_HIDE,0 },

    { "wiznet",		do_wiznet,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "immtalk",	do_immtalk,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,OK_CHARM},
    { "imotd",          do_imotd,       POS_DEAD,       IM,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { ":",		do_immtalk,	POS_DEAD,	IM,  LOG_NORMAL, 0 ,KEEP_HIDE,OK_CHARM},
    { "smote",		do_smote,	POS_DEAD,	IM,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "prefi",		do_prefi,	POS_DEAD,	IM,  LOG_NORMAL, 0 ,KEEP_HIDE,0},
    { "prefix",		do_prefix,	POS_DEAD,	IM,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "mpdump",		do_mpdump,	POS_DEAD,	IM,  LOG_NEVER,  1,KEEP_HIDE,0 },
    { "mpstat",		do_mpstat,	POS_DEAD,	IM,  LOG_NEVER,  1,KEEP_HIDE,0 },

    /*
     * OLC
     */
    { "edit",		do_olc,		POS_DEAD,    0,  LOG_NORMAL, 1 ,KEEP_HIDE,0},
    { "asave",          do_asave,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "alist",		do_alist,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "resets",		do_resets,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "redit",		do_redit,	POS_DEAD,    0,	 LOG_NORMAL, 1,KEEP_HIDE,0 },
    { "medit",		do_medit,	POS_DEAD,    0,	 LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "aedit",		do_aedit,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "oedit",		do_oedit,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "mpedit",		do_mpedit,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0},
    { "hedit",		do_hedit,	POS_DEAD,    0,  LOG_NORMAL, 1,KEEP_HIDE ,0},

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




/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, char *argument , bool is_order)
{
    extern int nAllocString;
	extern int nAllocPerm;
	char command[MAX_INPUT_LENGTH];
	char buf[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;
	int string_count = nAllocString ;
	int perm_count = nAllocPerm ;
	char cmd_copy[MAX_INPUT_LENGTH] ;
	char buf2[MAX_STRING_LENGTH] ;

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

    /*
     * Implement freeze command.
     */
    if ( !IS_NPC(ch) && IS_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 );

    /*Lets see who is doing what? LAST COMMAND  -Ferric*/
    strcpy( buf, argument);
    sprintf(last_command,"%s in room[%d]: %s.",ch->name,ch->in_room->vnum,buf);

    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 )
		{
			found = TRUE;
			break;
		}
    }

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

    if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
		||   fLogAll
		||   cmd_table[cmd].log == LOG_ALWAYS )
    {
		sprintf( log_buf, "Log %s: %s", ch->name, logline );
		wiznet(log_buf,ch,NULL,WIZ_SECURE,0,get_trust(ch));
		log_string( log_buf );
    }

    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 );
    }

    /*
     * Some commands stops hiding
     */
	if( (!cmd_table[cmd].okay & OK_CHARM) && (IS_AFFECTED(ch, AFF_CHARM)) && !is_order)
	{
		send_to_char("First ask to your beloved master.\n\r", ch);
		return;
	}

    /*
     * Some commands stops hiding
     */
	if( (!cmd_table[cmd].keep & KEEP_HIDE) && (IS_AFFECTED(ch, AFF_HIDE)) )
	{
		REMOVE_BIT( ch->affected_by, AFF_HIDE );
		send_to_char("You step out of the shadows.\n\r", ch);
		act("$n steps out of the shadows.", ch, NULL, NULL, TO_ROOM);
	}

    if ( !found )
    {
	/*
	 * Look for command in socials table.
	 */
		if ( !check_social( ch, command, argument ) )
			send_to_char( "Huh?\n\r", ch );
			return;
    }
	else if (check_disabled (&cmd_table[cmd]))
	{
		send_to_char ("This command has been temporarily disabled.\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;
    }
	strcpy(cmd_copy, argument) ;
    /*
     * Dispatch the command.
     */
    (*cmd_table[cmd].do_fun) ( ch, argument );

    tail_chain( );

	if (string_count < nAllocString)
	{
		sprintf(buf2,
		"Memcheck : Increase in strings :: %s : %s", ch->name, cmd_copy) ;
		wiznet(buf2, NULL, NULL, WIZ_MEMCHECK,0,0) ;
	}

	if (perm_count < nAllocPerm)
	{
		sprintf(buf2,
		"Increase in perms :: %s : %s", ch->name, cmd_copy) ;
		wiznet(buf2, NULL, NULL, WIZ_MEMCHECK, 0,0) ;
	}
    return;
}

/* function to keep argument safe in all commands -- no static strings */
void do_function (CHAR_DATA *ch, DO_FUN *do_fun, char *argument)
{
    char *command_string;
    
    /* copy the string */
    command_string = str_dup(argument);
    
    /* dispatch the command */
    (*do_fun) (ch, command_string);
    
    /* free the string */
    free_string(command_string);
}
    
bool check_social( CHAR_DATA *ch, char *command, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    int cmd;
    bool found;

    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_NOEMOTE) )
    {
	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 bad 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( social_table[cmd].name, "snore" ) )
	    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( social_table[cmd].others_no_arg, ch, NULL, victim, TO_ROOM    );
	act( social_table[cmd].char_no_arg,   ch, NULL, victim, TO_CHAR    );
    }
    else if ( ( victim = get_char_room( ch, arg ) ) == NULL )
    {
	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( social_table[cmd].char_auto,     ch, NULL, victim, TO_CHAR    );
    }
    else
    {
	act( social_table[cmd].others_found,  ch, NULL, victim, TO_NOTVICT );
	act( social_table[cmd].char_found,    ch, NULL, victim, TO_CHAR    );
	act( social_table[cmd].vict_found,    ch, NULL, victim, TO_VICT    );

	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( social_table[cmd].char_found,
		    victim, NULL, ch, TO_CHAR    );
		act( social_table[cmd].vict_found,
		    victim, NULL, ch, TO_VICT    );
		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;
}



/*
 * 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;
}

/*
 * Contributed by Alander.
 */
void do_commands( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    int cmd;
    int col;
 
    col = 0;
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
        if ( cmd_table[cmd].level <  LEVEL_HERO
        &&   cmd_table[cmd].level <= get_trust( ch ) 
	&&   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;
}
/* eski do_wizhelp
void do_wizhelp( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    int cmd;
    int col;
 
    col = 0;
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
        if ( cmd_table[cmd].level >= LEVEL_HERO
        &&   cmd_table[cmd].level <= get_trust( ch ) 
        &&   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;
}
*/

/*
 * New wizhelp command written by Pallock from RotL
 * You may use this with no credit but keeping my name
 * tagged to the code itself.
 */

void do_wizhelp( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    int cmd;
    int col;
    int clevel;
    col = 0;

    for( clevel = LEVEL_HERO + 1; clevel < MAX_LEVEL + 1; clevel++ )
    {
        for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
        {
            if ( cmd_table[cmd].level >= LEVEL_HERO
            &&   cmd_table[cmd].level <= get_trust( ch ) 
            &&   cmd_table[cmd].show
            &&   cmd_table[cmd].level == clevel)
            {
                sprintf( buf, "[%-3d] %-13s", cmd_table[cmd].level, cmd_table[cmd].name);
                send_to_char( buf, ch );
                if ( ++col % 4 == 0 )
                    send_to_char( "\n\r", ch );
            }
        }
    }

    if ( col % 4 != 0 )
        send_to_char( "\n\r", ch );
    return;
}

void do_doas (CHAR_DATA *ch, char *argument)
{
	CHAR_DATA *victim;
	DESCRIPTOR_DATA *orig;
	char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
	//char buf[MAX_STRING_LENGTH];

	//const char *allowed_commands = "score inventory skills spells auto";


	if ( argument[0] == '\0' )
    {
	send_to_char( "doas <victim> <command>\n\r", ch );
	return;
    }
	argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

	if ( arg2[0] == '\0' )
    {
	send_to_char( "Doas what for whom?\n\r", ch );
	return;
    }

	if ( ( victim = get_char_world( ch, arg1 ) ) == NULL )
    {
	send_to_char( "The victim is not connected.\n\r", ch );
	return;
    }
/* Burada komut kontrolü yapýlabilir.
	if (!is_full_name(arg2, allowed_commands))
	{
		sprintf(buf, "You can only execute following commands: %s.\n",allowed_commands);
		send_to_char(buf,ch);
		return;
	}
	*/
	orig = victim->desc;
	
	victim->desc = ch->desc;
	ch->desc = NULL;
	
	interpret (victim, arg2,TRUE);

	ch->desc = victim->desc;	
	victim->desc = orig;
}

/* Syntax is:
disable - shows disabled commands
disable <command> - toggles disable status of command
*/

void do_disable (CHAR_DATA *ch, char *argument)
{
	int i;
	DISABLED_DATA *p,*q;
	char buf[100];
	
	if (IS_NPC(ch))
	{
		send_to_char ("RETURN first.\n\r",ch);
		return;
	}
	
	if (!argument[0]) /* Nothing specified. Show disabled commands. */
	{
		if (!disabled_first) /* Any disabled at all ? */
		{
			send_to_char ("There are no commands disabled.\n\r",ch);
			return;
		}

		send_to_char ("Disabled commands:\n\r"
		              "Command      Level   Disabled by\n\r",ch);
		                
		for (p = disabled_first; p; p = p->next)
		{
			sprintf (buf, "%-12s %5d   %-12s\n\r",p->command->name, p->level, p->disabled_by);
			send_to_char (buf,ch);
		}
		return;
	}
	
	/* command given */

	/* First check if it is one of the disabled commands */
	for (p = disabled_first; p ; p = p->next)
		if (!str_cmp(argument, p->command->name))
			break;
			
	if (p) /* this command is disabled */
	{
	/* Optional: The level of the imm to enable the command must equal or exceed level
	   of the one that disabled it */
	
		if (get_trust(ch) < p->level)
		{
			send_to_char ("This command was disabled by a higher power.\n\r",ch);
			return;
		}
		
		/* Remove */
		
		if (disabled_first == p) /* node to be removed == head ? */
			disabled_first = p->next;
		else /* Find the node before this one */
		{
			for (q = disabled_first; q->next != p; q = q->next); /* empty for */
			q->next = p->next;
		}
		
		free_string (p->disabled_by); /* free name of disabler */
		free_mem (p,sizeof(DISABLED_DATA)); /* free node */
		save_disabled(); /* save to disk */
		send_to_char ("Command enabled.\n\r",ch);
	}
	else /* not a disabled command, check if that command exists */
	{
		/* IQ test */
		if (!str_cmp(argument,"disable"))
		{
			send_to_char ("You cannot disable the disable command.\n\r",ch);
			return;
		}

		/* Search for the command */
		for (i = 0; cmd_table[i].name[0] != '\0'; i++)
			if (!str_cmp(cmd_table[i].name, argument))
				break;

		/* Found? */				
		if (cmd_table[i].name[0] == '\0')
		{
			send_to_char ("No such command.\n\r",ch);
			return;
		}

		/* Can the imm use this command at all ? */				
		if (cmd_table[i].level > get_trust(ch))
		{
			send_to_char ("You dot have access to that command; you cannot disable it.\n\r",ch);
			return;
		}
		
		/* Disable the command */
		
		p = alloc_mem (sizeof(DISABLED_DATA));

		p->command = &cmd_table[i];
		p->disabled_by = str_dup (ch->name); /* save name of disabler */
		p->level = get_trust(ch); /* save trust */
		p->next = disabled_first;
		disabled_first = p; /* add before the current first element */
		
		send_to_char ("Command disabled.\n\r",ch);
		save_disabled(); /* save to disk */
	}
}

/* Check if that command is disabled 
   Note that we check for equivalence of the do_fun pointers; this means
   that disabling 'chat' will also disable the '.' command
*/   
bool check_disabled (const struct cmd_type *command)
{
	DISABLED_DATA *p;
	
	for (p = disabled_first; p ; p = p->next)
		if (p->command->do_fun == command->do_fun)
			return TRUE;

	return FALSE;
}

/* Load disabled commands */
void load_disabled()
{
	FILE *fp;
	DISABLED_DATA *p;
	char *name;
	int i;
	
	disabled_first = NULL;
	
	if( (fp = fopen (DISABLED_FILE, "r"))==NULL)/* No disabled file.. no disabled commands : */
		return;
		
	name = fread_word (fp);
	
	while (str_cmp(name, END_MARKER)) /* as long as name is NOT END_MARKER :) */
	{
		/* Find the command in the table */
		for (i = 0; cmd_table[i].name[0] ; i++)
			if (!str_cmp(cmd_table[i].name, name))
				break;
				
		if (!cmd_table[i].name[0]) /* command does not exist? */
		{
			bug ("Skipping uknown command in  DISABLED_FILE  file.",0);
			fread_number(fp); /* level */
			fread_word(fp); /* disabled_by */
		}
		else /* add new disabled command */
		{
			p = alloc_mem(sizeof(DISABLED_DATA));
			p->command = &cmd_table[i];
			p->level = fread_number(fp);
			p->disabled_by = str_dup(fread_word(fp)); 
			p->next = disabled_first;
			
			disabled_first = p;

		}
		
		name = fread_word(fp);
	}

	fclose (fp);		
}

/* Save disabled commands */
void save_disabled()
{
	FILE *fp;
	DISABLED_DATA *p;
	
	if (!disabled_first) /* delete file if no commands are disabled */
	{
		unlink (DISABLED_FILE);
		return;
	}
	
	fp = fopen (DISABLED_FILE, "w");
	
	if (!fp)
	{
		bug ("Could not open DISABLED_FILE for writing",0);
		return;
	}
	
	for (p = disabled_first; p ; p = p->next)
		fprintf (fp, "%s %d %s\n", p->command->name, p->level, p->disabled_by);
		
	fprintf (fp, "%s\n",END_MARKER);
		
	fclose (fp);
}

Site Stats

Snippets: 1791
Codebases: 571