Re: [CODE] Restring...

From: Christoffer Lundberg (avatar@orion.boden.se)
Date: 04/05/99


I have now tried to copy the code for storing a character when
storing an object for the purposes of restringing objects, but
problems have occured. Whenever someone saves, the MUD crashes.
The .core tells me nothing...
    I will distribute my code so that any problems can be found.

---CODE---
struct obj_file_elem {
   obj_num item_number;
   char *name;
   char *short_desc;
   char *long_desc;
   ...
   ..
   .
};

int Obj_to_store_from(struct obj_data * obj, FILE * fl, int locate)
{
  int j;
  struct obj_file_elem object;

  object.item_number = GET_OBJ_VNUM(obj);
  if (obj->name)
    strcpy(object.name, obj->name);
  else
    *object.name = '\0';

  if (obj->short_description)
    strcpy(object.short_desc, obj->short_description);
  else
    *object.short_desc = '\0';

  if (obj->description)
    strcpy(object.long_desc, obj->description);
  else
    *object.long_desc = '\0';

  ...
  ..
  .
}

struct obj_data *Obj_from_store_to(struct obj_file_elem object, int
*locate)
{
  struct obj_data *obj;
  int j;

  if (real_object(object.item_number) > -1) {
    obj = read_object(object.item_number, VIRTUAL);
    *locate = (int) object.locate;
    GET_OBJ_VAL(obj, 0) = object.value[0];
    GET_OBJ_VAL(obj, 1) = object.value[1];
    GET_OBJ_VAL(obj, 2) = object.value[2];
    GET_OBJ_VAL(obj, 3) = object.value[3];
    GET_OBJ_EXTRA(obj) = object.extra_flags;
    GET_OBJ_WEIGHT(obj) = object.weight;
    GET_OBJ_TIMER(obj) = object.timer;
    GET_OBJ_LEVEL(obj) = object.level;
    OBJ_SIZE(obj) = object.size;
    obj->name = str_dup(object.name);
    obj->short_description = str_dup(object.short_desc);
    obj->description = str_dup(object.long_desc);
    ...
    ..
    .
}

---END OF CODE---

What can be wrong?

Thanks on forehand!

()CHRISTOFFER:>......


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



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