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

/***************************************************************************
* Written by Joseph Benfield, aka Diablos of End of Time.  No credit as    *
* this was a quick and easy thing to write.  A few of my immortal staff,   *
* including me, have accidentally deleted our characters because of it not *
* requiring a password.  This simple replacement fixes that.  This is my   *
* first snippet, but it's simple enough to where it should work without    *
* problems.  Aside from requiring a password, it has also been modified to *
* log within the command itself rather than interp.c so that any failed    *
* attempts to login, any typos, or the actual successful deletion itself   *
* will not any arguments.  For example, this the delete command with no    *
* arguments: Log Diablos: delete    This is when an argument supplied      *
* does not match the password: FAILED DELETE: Diablos!   This will show    *
* when the deletion is successful: Diablos has deleted!  To install this,  *
* it is rather simple.  First going into interp.c and find the delete      *
* command, then replace 'LOG_ALWAYS' with 'LOG_NORMAL'.  This will prevent *
* the logging of arguments as mentioned before.  The command itself,       *
* however, is designed to emulate the command as if logged.  It will show  *
* over wiznet and in the logs, but again, without any arguments, passwords *
* etc.  Find your delete command in probably act_comm.c and replace it     *
* with the following:                                                      *
***************************************************************************/






/* Improved to require a password to use.  Useful for preventing things like
   Immortals forcing people to "delete, delete" or any possible loopholes involving
   things like charm. */

void do_delete( CHAR_DATA * ch, char *argument )
{
   char strsave[MAX_INPUT_LENGTH];
   char buf[MAX_STRING_LENGTH];
   DESCRIPTOR_DATA *d, *d_next;
   int id;

   if ( IS_NPC( ch ) )
      return;

   if ( argument[0] == '\0' ) {
      send_to_char( "Syntax: delete <password>\n\rThis will delete your character permanently!\n\r", ch );
      wiznet( "Log $N: delete", ch, NULL, 0, 0, 0 );
      sprintf( log_buf, "Log %s: delete", ch->name );
      log_string( log_buf );
      return;
   }

   if ( strcmp( crypt( argument, ch->pcdata->pwd ), ch->pcdata->pwd ))
   {
      send_to_char( "{RWrong password.{x\n\r", ch );
      sprintf( log_buf, "FAILED DELETE: %s!", ch->name );
      log_string( log_buf );
      wiznet( "Log $N: FAILED DELETE!", ch, NULL, 0, 0, 0 );
      return;
   }

   send_to_char( "Your character has been deleted.\n\r", ch );
   act( "$n has deleted $mself.", ch, NULL, NULL, TO_ROOM );
   sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( ch->name ) );
   wiznet( "$N has deleted $Mself.", ch, NULL, 0, 0, 0 );
   stop_fighting( ch, TRUE );
   sprintf( log_buf, "%s has deleted!", ch->name );
   log_string( log_buf );
   unlink( strsave );

   id = ch->id;
   d = ch->desc;
   extract_char( ch, TRUE );
   if ( d != NULL )
      close_socket( d );

   for ( d = descriptor_list; d != NULL; d = d_next )
   {
      CHAR_DATA *tch;
      d_next = d->next;
      tch = d->original ? d->original : d->character;
      if ( tch && tch->id == id )
      {
         extract_char( tch, TRUE );
         close_socket( d );
      }
   }
   return;
}