Difference for server/apply.c from version 1.127 to 1.128


version 1.127 version 1.128
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_apply_c =   * static char *rcsid_apply_c =
  *   "$Id: apply.c,v 1.127 2005/05/21 19:33:10 akirschbaum Exp $";   *   "$Id: apply.c,v 1.128 2005/07/17 09:44:30 akirschbaum Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 752
 
Line 752
   
   
 /*  /*
  * convert_item() returns 1 if anything was converted, otherwise 0   * convert_item() returns 1 if anything was converted, 0 if the item was not
    * what the converter wants, -1 if the converter is broken.
  */   */
 #define CONV_FROM(xyz) xyz->slaying  #define CONV_FROM(xyz) xyz->slaying
 #define CONV_TO(xyz) xyz->other_arch  #define CONV_TO(xyz) xyz->other_arch
Line 767
 
Line 768
 int convert_item(object *item, object *converter) {  int convert_item(object *item, object *converter) {
     int nr=0;      int nr=0;
     object *tmp;      object *tmp;
       int is_in_shop;
       int price_in;
       int price_out;
   
       for(tmp = get_map_ob(converter->map, converter->x, converter->y);
    tmp != NULL;
    tmp = tmp->above) {
    if(tmp->type == SHOP_FLOOR)
        break;
       }
       is_in_shop = (tmp != NULL);
   
     /* We make some assumptions - we assume if it takes money as it type,      /* We make some assumptions - we assume if it takes money as it type,
      * it wants some amount.  We don't make change (ie, if something costs       * it wants some amount.  We don't make change (ie, if something costs
Line 784
 
Line 796
  /* take into account rounding errors */   /* take into account rounding errors */
  if (nr*CONV_NEED(converter)%item->value) cost++;   if (nr*CONV_NEED(converter)%item->value) cost++;
  decrease_ob_nr(item, cost);   decrease_ob_nr(item, cost);
   
    price_in = cost*item->value;
     }      }
     else {      else {
  if(item->type==PLAYER||CONV_FROM(converter)!=item->arch->name||   if(item->type==PLAYER||CONV_FROM(converter)!=item->arch->name||
Line 793
 
Line 807
  if(CONV_NEED(converter)) {   if(CONV_NEED(converter)) {
      nr=item->nrof/CONV_NEED(converter);       nr=item->nrof/CONV_NEED(converter);
      decrease_ob_nr(item,nr*CONV_NEED(converter));       decrease_ob_nr(item,nr*CONV_NEED(converter));
        price_in = nr*CONV_NEED(converter)*item->value;
  } else {   } else {
        price_in = item->value;
      remove_ob(item);       remove_ob(item);
      free_object(item);       free_object(item);
  }   }
Line 809
 
Line 825
  item->nrof=CONV_NR(converter);   item->nrof=CONV_NR(converter);
     if(nr)      if(nr)
  item->nrof*=nr;   item->nrof*=nr;
     for(tmp=get_map_ob(converter->map,converter->x,converter->y);      if(is_in_shop)
  tmp!=NULL;  
  tmp=tmp->above) {  
  if(tmp->type==SHOP_FLOOR)  
      break;  
     }  
     if(tmp!=NULL)  
  SET_FLAG(item,FLAG_UNPAID);   SET_FLAG(item,FLAG_UNPAID);
       else if(price_in < item->nrof*item->value) {
    LOG(llevError, "Broken converter %s at %s (%d, %d) in value %d, out value %d\n",
        converter->name, converter->map->path, converter->x, converter->y, price_in,
        item->nrof*item->value);
    free_object(item);
    return -1;
       }
     item->x=converter->x;      item->x=converter->x;
     item->y=converter->y;      item->y=converter->y;
     insert_ob_in_map(item,converter->map,converter,0);      insert_ob_in_map(item,converter->map,converter,0);
Line 1399
 
Line 1416
     }      }
   
   case CONVERTER:    case CONVERTER:
     convert_item (victim, trap);      if (convert_item (victim, trap) < 0) {
    object *op;
   
    new_draw_info_format(NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name(trap));
   
    op = get_archetype("burnout");
    if (op != NULL) {
        op->x = trap->x;
        op->y = trap->y;
        insert_ob_in_map(op, trap->map, trap, 0);
    }
       }
     goto leave;      goto leave;
   
   case TRIGGER_BUTTON:    case TRIGGER_BUTTON:


Legend:
line(s) removed in v.1.127 
line(s) changed
 line(s) added in v.1.128

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