Re: ascii pfile player deletion

From: Sammy (samedi@DHC.NET)
Date: 07/31/97


On Thu, 31 Jul 1997, Crimson Wizard wrote:

> If you are using autorun, then "shutdown die" should do it.  On a side
> note, I've got the ascii patch in and tweaked to my liking, but I noticed
> than when a character self deletes, it doesn't remove their entry from the
> index file, nor does it remove the actual pfile... hrm hrm.

That's something I left unchanged from stock circle.  You can either
leave it the way it is to keep your ability to undelete players, or add
another 2 or 3 lines of code to remove them from the index and wipe their
file.

Here's the function I use to remove all files associated with a player:

void remove_player(long id, byte stomp)
{
  long i;

  for(i = 0; i < top_of_p_table; i++)
    if(player_table[i].id > 0 && player_table[i].id == id)
      break;

  if(player_table[i].id != id || !*player_table[i].name)
    return;

  sprintf(buf, "%s/%c/%s", PLR_PREFIX, *player_table[i].name,
    player_table[i].name);
  chmod(buf, S_IREAD | S_IWRITE); /* I don't think this is in the public
                                     patch.  It's a little extra security
                                     and requires inclusion of another
                                     system include. */
  unlink(buf);

  sprintf(buf, "%s/%c/%s", RENT_PREFIX, *player_table[i].name,
    player_table[i].name);        /* This assumes rent files similar to
                                     the ascii pfiles (ie: all files in
                                     the same directory).  If using the
                                     stock system, you'll need to use
                                     get_filename() as below. */
  chmod(buf, S_IREAD | S_IWRITE);
  unlink(buf);

  get_filename(player_table[i].name, buf, SAVES_FILE);
                                  /* This is a file with poofs, aliases,
                                     and other ascii data in a stock-type
                                     dir structure.  Use this as an
                                     example for removing alias files or
                                     stock rent files. */
  unlink(buf);

  update_mail_index(id, NULL);    /* *shrug*  This is an ascii mail thing.
                                     I have no idea how you'd remove a
                                     player's mail from the binary plrmail
                                     file. */

  if(stomp)
    *player_table[i].name = '\0'; /* Sorry I don't remember why this is
                                     here, but I know it was necessary
                                     for this routine to work correctly
                                     with something else I did.  The idea
                                     is that to remove a player from the
                                     index, "stomp" on the first letter
                                     of their name, then call the index
                                     save routine, which should be modded
                                     to skip the stomped entries. */
}

Sam


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST