Difference for common/object.c from version 1.130 to 1.131


version 1.130 version 1.131
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_object_c =   * static char *rcsid_object_c =
  *   "$Id: object.c,v 1.130 2006/06/07 07:10:46 mwedel Exp $";   *   "$Id: object.c,v 1.131 2006/06/07 21:44:05 tchize Exp $";
  */   */
   
 /*  /*
Line 146
 
Line 146
      * be animated or have a very low speed.  Is this an attempted monster       * be animated or have a very low speed.  Is this an attempted monster
      * check?       * check?
      */       */
       /*TODO is this check really needed?*/
     if (!QUERY_FLAG(ob1,FLAG_ANIMATE) && FABS((ob1)->speed) > MIN_ACTIVE_SPEED)      if (!QUERY_FLAG(ob1,FLAG_ANIMATE) && FABS((ob1)->speed) > MIN_ACTIVE_SPEED)
  return 0;   return 0;
   
Line 159
 
Line 160
     /* This is really a spellbook check - really, we should      /* This is really a spellbook check - really, we should
      * check all objects in the inventory.       * check all objects in the inventory.
      */       */
       /*TODO is this check really needed?*/
     if (ob1->inv || ob2->inv) {      if (ob1->inv || ob2->inv) {
  /* if one object has inventory but the other doesn't, not equiv */   /* if one object has inventory but the other doesn't, not equiv */
  if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) return 0;   if ((ob1->inv && !ob2->inv) || (ob2->inv && !ob1->inv)) return 0;
Line 177
 
Line 179
      * are not equal - just if it has been identified, the been_applied       * are not equal - just if it has been identified, the been_applied
      * flags lose any meaning.       * flags lose any meaning.
      */       */
      
       /*TODO is this hack on BEEN_APPLIED really needed? */
     if (QUERY_FLAG(ob1, FLAG_IDENTIFIED))      if (QUERY_FLAG(ob1, FLAG_IDENTIFIED))
  SET_FLAG(ob1, FLAG_BEEN_APPLIED);   SET_FLAG(ob1, FLAG_BEEN_APPLIED);
   
Line 234
 
Line 238
         }          }
     }      }
   
       /*TODO should this really be limited to scrolls?*/
     switch (ob1->type) {      switch (ob1->type) {
  case SCROLL:   case SCROLL:
      if (ob1->level != ob2->level) return 0;       if (ob1->level != ob2->level) return 0;
Line 253
 
Line 258
  * an object is carrying.  It goes through in figures out how much   * an object is carrying.  It goes through in figures out how much
  * containers are carrying, and sums it up.   * containers are carrying, and sums it up.
  */   */
    /* TODO should check call this this are made a place where we really need reevaluaton of whole tree */
 signed long sum_weight(object *op) {  signed long sum_weight(object *op) {
   signed long sum;    signed long sum;
   object *inv;    object *inv;
Line 263
 
Line 269
   }    }
   if (op->type == CONTAINER && op->stats.Str)    if (op->type == CONTAINER && op->stats.Str)
     sum = (sum * (100 - op->stats.Str))/100;      sum = (sum * (100 - op->stats.Str))/100;
   if(op->carrying != sum)  
     op->carrying = sum;      op->carrying = sum;
   return sum;    return sum;
 }  }
Line 283
 
Line 288
  * a better check.  We basically keeping traversing up until we can't   * a better check.  We basically keeping traversing up until we can't
  * or find a player.   * or find a player.
  */   */
   /*TODO this function is badly named*/
 object *is_player_inv (object *op) {   object *is_player_inv (object *op) {
     for (;op!=NULL&&op->type!=PLAYER; op=op->env)      for (;op!=NULL&&op->type!=PLAYER; op=op->env)
         /*TODO this is patching the structure on the flight as side effect. Shoudln't be needed in clean code */
       if (op->env==op)        if (op->env==op)
  op->env = NULL;   op->env = NULL;
     return op;      return op;
Line 480
 
Line 486
  * anything - once an object is removed, it is basically dead anyways.   * anything - once an object is removed, it is basically dead anyways.
  */   */
   
   /* TODO a side effect of this function is to clean owner chain for not existing anymore owner.
    * This is not the place to do such a cleaning
    */
 object *get_owner(object *op) {  object *get_owner(object *op) {
     if(op->owner==NULL)      if(op->owner==NULL)
  return NULL;   return NULL;
Line 487
 
Line 496
     if (!QUERY_FLAG(op->owner,FLAG_FREED) && !QUERY_FLAG(op->owner, FLAG_REMOVED) &&      if (!QUERY_FLAG(op->owner,FLAG_FREED) && !QUERY_FLAG(op->owner, FLAG_REMOVED) &&
  op->owner->count==op->ownercount)   op->owner->count==op->ownercount)
  return op->owner;   return op->owner;
       LOG(llevError,"I had to clean an owner when in get_owner, this isn't my job.\n");
     op->owner=NULL;      op->owner=NULL;
     op->ownercount=0;      op->ownercount=0;
     return NULL;      return NULL;
Line 528
 
Line 537
     /* IF the owner still has an owner, we did not resolve to a final owner.      /* IF the owner still has an owner, we did not resolve to a final owner.
      * so lets not add to that.       * so lets not add to that.
      */       */
     if (owner->owner) return;      if (owner->owner){
         LOG(llevError,"owner id %d could not be resolved to a parent owner sin set_owner(). This is bad!"
             "owner=%p owner->owner=%p owner->ownercount=%d owner->owner->count=%d ",
             owner,owner->owner,owner->ownercount, owner->owner->count);
         return;
       }
   
     op->owner=owner;      op->owner=owner;
   
Line 555
 
Line 569
  /* players don't have owners - they own themselves.  Update   /* players don't have owners - they own themselves.  Update
  * as appropriate.   * as appropriate.
  */   */
         /*TODO owner=self is dangerous and should be avoided*/
  if (clone->type == PLAYER) owner=clone;   if (clone->type == PLAYER) owner=clone;
  else return;   else return;
     }      }
Line 615
 
Line 630
     event *evt;      event *evt;
     event *evt2;      event *evt2;
   
       /*TODO this comment must be investigated*/
     /* redo this to be simpler/more efficient. Was also seeing      /* redo this to be simpler/more efficient. Was also seeing
      * crashes in the old code.  Move this to the top - am       * crashes in the old code.  Move this to the top - am
      * seeing periodic crashes in this code, and would like to have       * seeing periodic crashes in this code, and would like to have


Legend:
line(s) removed in v.1.130 
line(s) changed
 line(s) added in v.1.131

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