Difference for common/object.c from version 1.133 to 1.134


version 1.133 version 1.134
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_object_c =   * static char *rcsid_object_c =
  *   "$Id: object.c,v 1.133 2006/06/24 10:41:44 ryo_saeba Exp $";   *   "$Id: object.c,v 1.134 2006/07/02 15:32:34 tchize Exp $";
  */   */
   
 /*  /*
Line 289
 
Line 289
  * or find a player.   * or find a player.
  */   */
 /*TODO this function is badly named*/  /*TODO this function is badly named*/
 object *is_player_inv (object *op) {   object *get_player_container(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 */        /*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)
Line 1282
 
Line 1282
  *   the previous environment.   *   the previous environment.
  *   Beware: This function is called from the editor as well!   *   Beware: This function is called from the editor as well!
  */   */
   /* TODO this function is a piece of overbloated crap or at lest
    * look like need cleanup it does to much different things.
    */
 void remove_ob(object *op) {  void remove_ob(object *op) {
     object *tmp,*last=NULL;      object *tmp,*last=NULL;
     object *otmp;      object *otmp;
Line 1291
 
Line 1293
     mapstruct *m;      mapstruct *m;
     sint16 x,y;      sint16 x,y;
          
   
     if(QUERY_FLAG(op,FLAG_REMOVED)) {      if(QUERY_FLAG(op,FLAG_REMOVED)) {
  dump_object(op);   dump_object(op);
  LOG(llevError,"Trying to remove removed object.\n%s\n",errmsg);   LOG(llevError,"Trying to remove removed object.\n%s\n",errmsg);
   
  /* Changed it to always dump core in this case.  As has been learned  
  * in the past, trying to recover from errors almost always  
  * make things worse, and this is a real error here - something  
  * that should not happen.  
  * Yes, if this was a mission critical app, trying to do something  
  * to recover may make sense, but that is because failure of the app      
  * may have other disastrous problems.  Cf runs out of a script  
  * so is easily enough restarted without any real problems.  
  * MSW 2001-07-01  
  */  
  abort();   abort();
     }      }
     if(op->more!=NULL)      if(op->more!=NULL)
Line 1317
 
Line 1307
      * In this case, the object to be removed is in someones       * In this case, the object to be removed is in someones
      * inventory.       * inventory.
      */       */
     /* TODO try to call a generic inventory weight adjusting function like sub_weight */
     if(op->env!=NULL) {      if(op->env!=NULL) {
  if(op->nrof)   if(op->nrof)
      sub_weight(op->env, op->weight*op->nrof);       sub_weight(op->env, op->weight*op->nrof);
Line 1327
 
Line 1318
  * made to players inventory.  If set, avoiding the call   * made to players inventory.  If set, avoiding the call
  * to save cpu time.   * to save cpu time.
  */   */
  if ((otmp=is_player_inv(op->env))!=NULL && otmp->contr &&       if ((otmp=get_player_container(op->env))!=NULL && otmp->contr &&
      !QUERY_FLAG(otmp,FLAG_NO_FIX_PLAYER))       !QUERY_FLAG(otmp,FLAG_NO_FIX_PLAYER))
      fix_player(otmp);       fix_player(otmp);
   
Line 1343
 
Line 1334
  * the map, but we don't actually do that - it is up   * the map, but we don't actually do that - it is up
  * to the caller to decide what we want to do.   * to the caller to decide what we want to do.
  */   */
  op->x=op->env->x,op->y=op->env->y;      op->x=op->env->x;
  op->ox=op->x,op->oy=op->y;      op->y=op->env->y;
       op->ox=op->x;
       op->oy=op->y;
  op->map=op->env->map;   op->map=op->env->map;
  op->above=NULL,op->below=NULL;      op->above=NULL;
       op->below=NULL;
  op->env=NULL;   op->env=NULL;
  return;   return;
     }      }
Line 1361
 
Line 1355
     if (!m) {      if (!m) {
  LOG(llevError,"remove_ob called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n",   LOG(llevError,"remove_ob called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n",
      op->map->path, op->x, op->y);       op->map->path, op->x, op->y);
  /* in old days, we used to set x and y to 0 and continue.  
  * it seems if we get into this case, something is probablye  
  * screwed up and should be fixed.  
  */  
  abort();   abort();
     }      }
     if (op->map != m) {      if (op->map != m) {
  LOG(llevDebug,"remove_ob: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n",      LOG(llevError,"remove_ob: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n",
      op->map->path, m->path, op->x, op->y, x, y);       op->map->path, m->path, op->x, op->y, x, y);
     }      }
   
     /* Re did the following section of code - it looks like it had  
      * lots of logic for things we no longer care about  
      */  
   
     /* link the object above us */      /* link the object above us */
     if (op->above)      if (op->above)
  op->above->below=op->below;   op->above->below=op->below;
Line 1390
 
Line 1376
  * use translated coordinates in case some oddness with map tiling is   * use translated coordinates in case some oddness with map tiling is
  * evident   * evident
  */   */
       /*TODO is this check really needed?*/
  if(GET_MAP_OB(m,x,y)!=op) {   if(GET_MAP_OB(m,x,y)!=op) {
      dump_object(op);       dump_object(op);
      LOG(llevError,"remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", errmsg);       LOG(llevError,"remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", errmsg);
Line 1439
 
Line 1426
      tmp->above = NULL;       tmp->above = NULL;
  last=tmp;   last=tmp;
     }      }
     /* last == NULL of there are no objects on this space */    /* last == NULL or there are no objects on this space */
     if (last==NULL) {      if (last==NULL) {
  /* set P_NEED_UPDATE, otherwise update_position will complain.  In theory,   /* set P_NEED_UPDATE, otherwise update_position will complain.  In theory,
  * we could preserve the flags (GET_MAP_FLAGS), but update_position figures   * we could preserve the flags (GET_MAP_FLAGS), but update_position figures
Line 1454
 
Line 1441
   
     if(QUERY_FLAG(op,FLAG_BLOCKSVIEW)|| (op->glow_radius != 0))       if(QUERY_FLAG(op,FLAG_BLOCKSVIEW)|| (op->glow_radius != 0))
  update_all_los(op->map, op->x, op->y);   update_all_los(op->map, op->x, op->y);
   
 }  }
   
 /**  /**
Line 1475
 
Line 1461
     if (can_merge(op,top))      if (can_merge(op,top))
     {      {
       top->nrof+=op->nrof;        top->nrof+=op->nrof;
 /*      CLEAR_FLAG(top,FLAG_STARTEQUIP);*/  
       op->weight = 0; /* Don't want any adjustements now */        op->weight = 0; /* Don't want any adjustements now */
       remove_ob(op);        remove_ob(op);
       free_object(op);        free_object(op);
Line 1860
 
Line 1845
  /* is this object in the players inventory, or sub container   /* is this object in the players inventory, or sub container
  * therein?   * therein?
  */   */
         tmp = is_player_inv (op->env);          tmp = get_player_container (op->env);
  /* nope.  Is this a container the player has opened?   /* nope.  Is this a container the player has opened?
  * If so, set tmp to that player.   * If so, set tmp to that player.
  * IMO, searching through all the players will mostly   * IMO, searching through all the players will mostly
Line 1998
 
Line 1983
   } else    } else
     add_weight (where, (op->weight+op->carrying));      add_weight (where, (op->weight+op->carrying));
   
   otmp=is_player_inv(where);    otmp=get_player_container(where);
   if (otmp&&otmp->contr!=NULL) {    if (otmp&&otmp->contr!=NULL) {
     if (!QUERY_FLAG(otmp,FLAG_NO_FIX_PLAYER))      if (!QUERY_FLAG(otmp,FLAG_NO_FIX_PLAYER))
       fix_player(otmp);        fix_player(otmp);


Legend:
line(s) removed in v.1.133 
line(s) changed
 line(s) added in v.1.134

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