ascii object files

From: ;P (siv@CYBERENET.NET)
Date: 08/08/97


greetings...been attempting to change the object files from binary to ascii..
for some reason the object file is fine (well..mostly) if the player just
saves....but if the player quits the  file is deleted...here is my
objsave code:


void objsave(struct char_data * ch, bool quit)
{
  char buf[MAX_INPUT_LENGTH];
  int j;
  FILE *fp;

  if (IS_NPC(ch))
    return;

  if (!get_filename(GET_NAME(ch), buf, OBJECT_FILE))
    return;
  if (!(fp = fopen(buf, "wb")))
    return;

  for (j = 0; j < NUM_WEARS; j++) {
    if (GET_EQ(ch,j)) {
      if (!write_obj_file(GET_EQ(ch,j), fp, j+1)) {
        fclose(fp);
        return;
      }
      restore_weight(GET_EQ(ch,j));
   if (quit)
      extract_saved_objs(GET_EQ(ch,j));
    }
  }

  if (!write_obj_file(ch->carrying, fp, 0)) {
    fprintf(fp, "$~\n");
    fclose(fp);
    return;
  }
  /* write final line, close */
  fprintf(fp, "$~\n");
  fclose(fp);


  if (quit)
    extract_saved_objs(ch->carrying);
}


so...if the player is saving without quiting then the objects are not
extracted..but if the player quits, it does extract them...it appears
that the objs are being extracted, then cause there aren't any objs..it
deletes the file...but i can't see why....since the objects are extracted
after the file has been written...

so..does anyone see any problems here?

thanks
siv

"Killing the bad stupid people, so the good stupid people may thrive."
        The Scorched Earth Party -


     +------------------------------------------------------------+
     | 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