Re: [CODE] Crashing

From: peter hartman (wart@KUNTRYNET.COM)
Date: 03/31/98

Thanks for the help.  I checked my buffer, and it was using something
strange and odd so I added one in.  The player file was overriding the
buffer (I think).  Here is the finished code for a do_players command that
allows you to search for specific player levels and it'll list 'em
(without crashing).

  FILE *fl;
  struct char_file_u player;
  int done=FALSE;
  char buf[MAX_STRING_LENGTH];
  int lowl, highl;

  two_arguments(argument, arg1, arg2);
  if (!*arg1 || !*arg2)
  { send_to_char("Must provide low and high levels.\r\n", ch);
    lowl = atoi(arg1);
    highl = atoi(arg2);
  if (!(fl = fopen(PLAYER_FILE, "r+")))
  { send_to_char("Can't open player file.  Uh oh.", ch);
  sprintf(buf, "Player Name             Player Level\r\n");
  while (!done)
  { fread(&player, sizeof(struct char_file_u), 1, fl);
    if (feof(fl))
    { fclose(fl);
      done = TRUE;
    if (!done)
      if (player.level >= lowl && player.level <= highl)
        sprintf(buf, "%s%-20s %-2i\r\n", buf,, player.level);
  send_to_char(buf, ch);


Wart || ||

"You did all the talking and me"
 -- Laurie Anderson

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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