[Circle] [CODE] Objsave patch

MAALEXAN@am.pnu.com
Date: 11/01/96


I'm trying to put in the objsave save patch by Jeremy Hess, from the ftp 
site.  It compiles just fine but I get a segmentation fault when I log on.  
Anyone familiar with this patch?  

I am using patch 11 circle it may be that the patch was written for an 
earlier version.  The reason I think this is Mr. Hess refers to a file 
called act.obj.c which I don't have.  I do have a file act.item.c that 
contains the relevant functions.  But I wonder if other stuff has changed 
with additional patches that makes this patch no longer work correctly.

Here is a gdb backtrace.  

gdb trace:
#0  0x30818 in perform_put (ch=0x2f8c10, obj=0x2fbca8, cont=0x0)
    at act.item.c:34
#1  0x7ca94 in read_obj_pos (ch=0x2f8c10) at objsave.c:928
#2  0x70084 in nanny (d=0x2f7f40, arg=0xeffff750 "1") at interpreter.c:1573 
#3  0x19d9c in game_loop (mother_desc=3) at comm.c:595
#4  0x18f60 in init_game (port=6666) at comm.c:242
#5  0x18eac in main (argc=3, argv=0xeffffdec) at comm.c:212

The error occurs when the function perform_put is called 
from read_obj_pos (a new function for the patch now in  objsave.c).

CRASH LOCATION IS AT ARROW  

void perform_put(struct char_data * ch, struct obj_data * obj,
                      struct obj_data * cont)
{
  extern int read_obj;
  if (GET_OBJ_WEIGHT(cont) + GET_OBJ_WEIGHT(obj) > GET_OBJ_VAL(cont, 0)) <-
    act("$p won't fit in $P.", FALSE, ch, obj, cont, TO_CHAR);      
  else {
    obj_from_char(obj);

Here is the code that called the above function: 
(read_obj_pos was called by nanny at startup)

PERFORM_PUT CALLED AT ARROW

void read_obj_pos(struct char_data *ch) 
{
  char fn[40];
  FILE *obj_file;
  struct objpos_data op;
  struct obj_data *obj,*obj2,*obj3;
  int container,found;

  int perform_wear(struct char_data *ch,struct obj_data *obj, int where);  
  void perform_put(struct char_data *ch,struct obj_data *obj, struct 
obj_data   *cont);
  read_obj = TRUE;
  if(!get_filename(GET_NAME(ch), fn, OBJPOS_FILE)){
    sprintf(buf2, "Cannot get file for PLAYER %s in read_obj_pos()", 
GET_NAME(ch));
    log(buf2);
    send_to_char("There is a problem loading your ITEMS IN PLACE.\r\n"
                 "Please contact a god and report this.\r\n", ch);
    read_obj = FALSE;
    return;   
  }

  if(!(obj_file = fopen(fn, "rb"))){
    read_obj = FALSE; 
    return;
  }

  fread((char *)&op, 1, sizeof(struct objpos_data), obj_file); 
  obj = ch->carrying;

  /* Handle Equipment */
  while((!(feof(obj_file)) && (op.position > INVENTORY)) && 
(!op.in_object)){
    perform_wear( ch, obj, op.position ); 
    obj = obj->next;
    fread((char *)&op, 1, sizeof(struct objpos_data), obj_file);  

  while(!(feof(obj_file))){
    if( op.in_object) {
      if( op.position > INVENTORY ) 
--->  perform_put( ch, obj, ch->equipment[op.position]);  <-- here
      else{
        container = 0;
        found = FALSE;
for( obj2 = ch->carrying; obj2 && !found; obj2 = obj2->next_content)
          if( GET_OBJ_TYPE(obj2) == ITEM_CONTAINER ){
            container++;
            if(container == op.container)
              found = TRUE;
            obj3 = obj2;
          }
        perform_put( ch, obj, obj3);
      }

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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