Re: [ASCII PFILES] remove_player

From: Alexander Decker (ahdbn4@umr.edu)
Date: 08/05/02


> The problem is with the use of unlink up there, because it takes
> pfile_name
> as argument, and I'm quite sure pfile_name is an empty string
> when unlink is
> called. I think this function is made to remove the pfile of a
> deleted char,
> but here, it doesn't.

You are right.. the relased function does seem to be incomplete. I
didnt recognize this for a while, but here is my fixed function.
Note that I have player variables installed so you may not need
that part. You could also add the rentfile compilation to
get_filename() (probably should), but I havent gotten around to it
yet.

void remove_player(int pfilepos)
{
  char pfile_name[128], rent_name[128], var_name[128];

  if (!*player_table[pfilepos].name)
    return;

  sprintf(pfile_name, "%s%s%c%s%s%s", PLR_PREFIX, SLASH,
      *player_table[pfilepos].name, SLASH, player_table[pfilepos].name,
      PLR_SUFFIX);

  if (get_filename(player_table[pfilepos].name, var_name, SCRIPT_VARS_FILE))
    if (!unlink(var_name))
      mudlog(CMP, LVL_GOD, TRUE, "Player Variable file for %c%s removed",
          UPPER(*player_table[pfilepos].name),
player_table[pfilepos].name + 1);

  if (get_filename(player_table[pfilepos].name, rent_name, CRASH_FILE))
    if (!unlink(rent_name))
      mudlog(CMP, LVL_GOD, TRUE, "Rent file for %c%s removed",
          UPPER(*player_table[pfilepos].name),
player_table[pfilepos].name + 1);

  if (!unlink(pfile_name))
    mudlog(CMP, LVL_GOD, TRUE, "Player file for %c%s removed",
        UPPER(*player_table[pfilepos].name), player_table[pfilepos].name
+ 1);

  /* Unlink any other player-owned files here if you have them  */

  log("PCLEAN: %s Lev: %d Last: %s",
      player_table[pfilepos].name,
      player_table[pfilepos].level,
      asctime(localtime(&player_table[pfilepos].last)));
  player_table[pfilepos].name[0] = '\0';
  save_player_index();
}

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT