SMAUG: "Disable Commands" snippet by Zeno
=======================================

Description
-----------
This snippet for SMAUG allows Immortals to enable and disable any command
on the fly through the use of one command in the MUD. Disabled commands
persist over hotboots/reboots/crashes since they use command flags.
Once disabled, no one (not even the highest Immortal) can use the command.
The 'disable' command toggles the command being disabled/enabled.

Support
-------
All support for this snippet (and any of my snippets) must be posted on
MudBytes (mudbytes.net) under the appropriate code. Find this snippet
on MudBytes, post a new comment, and I will reply as soon as possible.

Sharing
-------
All of my released code can be distributed anywhere as long as credit
is given when due. Please do not claim my code as your own. If you
do distribute my code to other places, I'd like it if you notify me.
My email address is zenomcdohl-AT-gmail-DOT-com, but please do not
use this for support.

Background
----------
This code was originally released at MudBytes (mudbytes.net). Most
(if not all) of my released code originated from the MUD I run
(InuYasha Galaxy: iyg.arthmoor.com) which is a modified version of
SmaugFUSS. Therefor all code I release has been tested and is currently
running on a MUD open to the public. Everything should work as intended,
but since I wrote most of this code years ago, improvements can probably
be made to the code to make it more efficient. I'd appreciate it if you
improve any of the code, that you would post the changes on MudBytes. You
can find contact information and details about myself at the following URL:
http://en.wikipedia.org/wiki/User:Zeno_McDohl

Syntax
------
Disable <command>  -- Toggles the command from disabled or enabled.
Disable -- Views list of disabled commands

Installation
------------
1.) Copy the following code (do_disable) into your source (preferably act_wiz.c):
void do_disable( CHAR_DATA *ch, char *argument )
{
    CMDTYPE *command;
    CMDTYPE *cmd;
    char arg1[MAX_INPUT_LENGTH];
    int hash, cnt;

    smash_tilde( argument );
    argument = one_argument( argument, arg1 );

    set_char_color( AT_IMMORT, ch );

    if ( arg1[0] == '\0' )
    {
        send_to_char( "Disable what command?\n\r&WCommands currently disabled:&D\n\r", ch );
        for ( cnt = hash = 0; hash < 126; hash++ )
           for ( cmd = command_hash[hash]; cmd; cmd = cmd->next )
		       {
		          if ( IS_SET( cmd->flags, CMD_FLAG_DISABLED ) )
			           ch_printf(ch, "&w%s&D\n\r", cmd->name );
		       }
        return;
    }

    command = find_command( arg1 );

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

    if ( !str_cmp( command->name, "disable" ) )
    {
        send_to_char( "Ha! No.\n\r", ch );
        return;
    }

    if ( command->level > get_trust(ch) )
    {
	      send_to_char( "You cannot touch this command.\n\r", ch );
	      return;
    }

    if ( IS_SET( command->flags, CMD_FLAG_DISABLED ) )
    {
	      ch_printf( ch, "The command '%s' is no longer disabled.\n\r", command->name );
	      REMOVE_BIT( command->flags, CMD_FLAG_DISABLED );
	      save_commands();
	      return;
    }
    else if ( !IS_SET( command->flags, CMD_FLAG_DISABLED ) )
    {
        ch_printf( ch, "The command '%s' is now disabled.\n\r", command->name );
        SET_BIT( command->flags, CMD_FLAG_DISABLED );
	      save_commands();
        return;
    }

}

2.) In mud.h, find these lines:
#define	CMD_FLAG_POSSESS	BV00
#define CMD_FLAG_POLYMORPHED	BV01
#define CMD_WATCH		BV02	/* FB */

And below them, add this:
#define CMD_FLAG_DISABLED       BV03

3.) In interp.c, find this line:
buf = check_cmd_flags ( ch, cmd );

Before that, add these lines:
if ( IS_SET( cmd->flags, CMD_FLAG_DISABLED ) )
{
      send_to_char( "That command is currently disabled.\n\r", ch );
      return;
}

4.) Add the appropriate line to mud.h for do_pecho and the 2 lines to tables.c. 

5.) Make clean, make and hotboot/reboot the MUD. Use cedit to create the command.