Difference for common/object.c from version 1.55 to 1.56


version 1.55 version 1.56
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_object_c =   * static char *rcsid_object_c =
  *   "$Id: object.c,v 1.55 2002/05/31 04:18:33 mwedel Exp $";   *   "$Id: object.c,v 1.56 2002/07/15 04:57:12 mwedel Exp $";
  */   */
   
 /*  /*
Line 515
 
Line 515
  */   */
   
 void clear_object(object *op) {  void clear_object(object *op) {
    int tmp;  
   
   if(op->name!=NULL) {      /* the memset will clear all these values for us, but we need
        * to reduce the refcount on them.
        */
       if(op->name!=NULL)
     free_string(op->name);      free_string(op->name);
     op->name=NULL;      if(op->name_pl!=NULL)
   }  
   if(op->name_pl!=NULL) {  
     free_string(op->name_pl);      free_string(op->name_pl);
     op->name_pl=NULL;      if(op->title != NULL)
   }  
   if(op->title != NULL) {  
     free_string(op->title);      free_string(op->title);
     op->title = NULL;      if(op->race!=NULL)
   }  
   if(op->race!=NULL) {  
     free_string(op->race);      free_string(op->race);
     op->race=NULL;      if(op->slaying!=NULL)
   }  
   if(op->slaying!=NULL) {  
     free_string(op->slaying);      free_string(op->slaying);
     op->slaying=NULL;      if(op->msg!=NULL)
   }  
   if(op->msg!=NULL) {  
     free_string(op->msg);      free_string(op->msg);
     op->msg=NULL;  
   }      /* Using this memset is a lot easier (and probably faster)
   for (tmp=0; tmp<=(NUM_FLAGS/32); tmp++)       * than explicitly clearing the fields.
  op->flags[tmp] = 0;       */
       memset((void*)((char*)op + offsetof(object, name)),
       0, sizeof(object)-offsetof(object, name));
        /* Below here, we clear things that are not done by the memset,
        * or set default values that are not zero.
        */
   
   /* This is more or less true */    /* This is more or less true */
   SET_FLAG(op, FLAG_REMOVED);    SET_FLAG(op, FLAG_REMOVED);
   op->map=NULL;  
       op->contr = NULL;
   op->below=NULL;    op->below=NULL;
   op->above=NULL;    op->above=NULL;
   op->owner=NULL;  
   op->refcount=0;  
   op->inv=NULL;    op->inv=NULL;
   op->env=NULL;  
   op->container=NULL;    op->container=NULL;
       op->env=NULL;
   op->more=NULL;    op->more=NULL;
   op->head=NULL;    op->head=NULL;
   op->arch=NULL;      op->map=NULL;
   op->other_arch=NULL;      op->refcount=0;
   op->enemy=NULL;      /* What is not cleared is next, prev, active_next, active_prev, and count */
   op->contr = NULL;  
   op->weight=0,op->carrying=0,op->weight_limit=0;  
   op->anim_speed=0;  
   op->level=0;  
   op->value=op->run_away=0;  
   op->invisible=0;  
   op->last_heal=0,op->last_sp=0,op->last_grace=0,op->last_eat=0;  
   op->nrof=0;  
   op->ownercount=0;  
   op->attacktype=0;  
   memset(&op->resist, 0, sizeof(op->resist));  
   op->stats.exp=0;  
   op->x=0; op->y=0; op->ox=0; op->oy=0;  
   op->stats.dam=0,op->stats.wc=0,op->stats.ac=0;  
   op->stats.luck=0;  
   op->stats.food=0;  
   op->stats.sp=op->stats.maxsp=op->stats.hp=op->stats.maxhp=0;  
   op->stats.grace=op->stats.maxgrace=0;  
   op->expmul=1.0;    op->expmul=1.0;
   op->direction=0;  
   op->glow_radius=0;  
   op->stats.Str=op->stats.Dex=op->stats.Con=0;  
   op->stats.Wis=op->stats.Cha=op->stats.Int=op->stats.Pow=0;  
   op->material=op->magic=op->state=op->type=0;  
   op->face = blank_face;    op->face = blank_face;
   
   op->attacked_by = NULL;  
   op->attacked_by_count= -1;    op->attacked_by_count= -1;
   op->type=0;  
   op->casting_speed = (float)0;  
   
   /* The object should already have been removed from the speed list  
    * before this function is called  
    */  
   op->speed=op->speed_left=0;  
   op->pick_up=0;  
   op->can_apply=0;  
   op->will_apply=0;  
   op->move_status = 0;  
   op->move_type = 0;  
   op->path_repelled = 0;  
   op->path_attuned = 0;  
   op->path_denied = 0;  
 #ifdef CASTING_TIME  #ifdef CASTING_TIME
   op->casting = -1;    op->casting = -1;
   op->spelltype = 0;  
   op->spell = NULL;  
 #endif  #endif
   op->randomitems=NULL;  
   op->spellitem = NULL;  
   op->animation_id=0;  
   op->weapontype=0;  
   op->client_type=0;  
 }  }
   
 /*  /*


Legend:
line(s) removed in v.1.55 
line(s) changed
 line(s) added in v.1.56

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:15