[code] Oedit.c

From: Drago's (creed@I-55.COM)
Date: 11/18/97


I have had a recent discovery of not being able to save objects after a reboot.
I use OasisOLCv1.5 and have had a real pain in the ass time with this.  I
know thatyou have to save internally and then oedit save ##, but upon
rebooting, those objects just aren't there.  I don't want to send the my
entire oedit.c file to everyone, so I am going to send the
oedit_save_to_disk() with this (as I am guessing the problem is here).

void oedit_save_to_disk(int zone_num)
{
  int counter, counter2, realcounter;
  FILE *fp;
  struct obj_data *obj;
  struct extra_descr_data *ex_desc;

  sprintf(buf, "%s/%d.new", OBJ_PREFIX, zone_table[zone_num].number);
  if (!(fp = fopen(buf, "w+"))) {
    mudlog("SYSERR: OLC: Cannot open objects file!", BRF, LVL_BUILDER, TRUE);
}
  /*
   * Start running through all objects in this zone.
   */
  for (counter = zone_table[zone_num].number * 100;
       counter <= zone_table[zone_num].top; counter++) {
    if ((realcounter = real_object(counter)) >= 0) {
      if ((obj = (obj_proto + realcounter))->action_description) {
        strcpy(buf1, obj->action_description);
        strip_string(buf1);
      } else
        *buf1 = '\0';

      fprintf(fp,
              "#%d\n"
              "%s~\n"
 "%s~\n"
              "%s~\n"
              "%s~\n"
              "%d %d %d\n"
              "%d %d %d %d\n"
              "%d %d %d\n",

              GET_OBJ_VNUM(obj),
              (obj->name && *obj->name) ? obj->name : "undefined",
              (obj->short_description && *obj->short_description) ?
                        obj->short_description : "undefined",
              (obj->description && *obj->description) ?
                        obj->description : "undefined",
              buf1, GET_OBJ_TYPE(obj), GET_OBJ_EXTRA(obj), GET_OBJ_WEAR(obj),
              GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 2),
              GET_OBJ_VAL(obj, 3), GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj),
              GET_OBJ_RENT(obj)
            );

      /*
       * Do we have extra descriptions?
       */
      if (obj->ex_description) {        /* Yes, save them too. */
        for (ex_desc = obj->ex_description; ex_desc; ex_desc = ex_desc->next) {
          /*
           * Sanity check to prevent nasty protection faults.
           */
          if (!*ex_desc->keyword || !*ex_desc->description) {
            mudlog("SYSERR: OLC: oedit_save_to_disk: Corrupt ex_desc!", BRF, LV$
            continue;
          }
          strcpy(buf1, ex_desc->description);
          strip_string(buf1);
          fprintf(fp, "E\n"
              "%s~\n"
                  "%s~\n", ex_desc->keyword, buf1);
        }
      }
      /*
       * Do we have affects?
       */
      for (counter2 = 0; counter2 < MAX_OBJ_AFFECT; counter2++)
        if (obj->affected[counter2].modifier)
          fprintf(fp, "A\n"
                  "%d %d\n", obj->affected[counter2].location,
                  obj->affected[counter2].modifier);
    }
  }

  /*
   * Write the final line, close the file.
   */
  fprintf(fp, "$~\n");
  fclose(fp);
  sprintf(buf2, "%s/%d.obj", OBJ_PREFIX, zone_table[zone_num].number);
  /*
   * We're fubar'd if we crash between the two lines below.
   */
  remove(buf2);
  rename(buf, buf2);

  olc_remove_from_save_list(zone_table[zone_num].number, OLC_SAVE_OBJ);
}


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