Difference for server/time.c from version 1.78 to 1.79


version 1.78 version 1.79
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_time_c =   * static char *rcsid_time_c =
  *    "$Id: time.c,v 1.78 2005/10/28 23:43:31 akirschbaum Exp $";   *    "$Id: time.c,v 1.79 2005/11/16 08:16:09 mwedel Exp $";
  */   */
   
 /*  /*
Line 109
 
Line 109
     qty=rndm(0,qty-1);      qty=rndm(0,qty-1);
     for (op=gen->inv;qty;qty--)      for (op=gen->inv;qty;qty--)
         op=op->below;          op=op->below;
     i=find_free_spot(op->arch,gen->map,gen->x,gen->y,1,9);      i=find_free_spot(op,gen->map,gen->x,gen->y,1,9);
     if (i==-1)      if (i==-1)
         return;          return;
     head=object_create_clone(op);      head=object_create_clone(op);
Line 141
 
Line 141
  LOG(llevError,"Generator (%s) not on a map?\n", gen->name);   LOG(llevError,"Generator (%s) not on a map?\n", gen->name);
  return;   return;
     }      }
     i=find_free_spot(at,gen->map,gen->x,gen->y,1,9);      i=find_free_spot(&at->clone,gen->map,gen->x,gen->y,1,9);
     if (i==-1) return;      if (i==-1) return;
     while(at!=NULL) {      while(at!=NULL) {
  op=arch_to_object(at);   op=arch_to_object(at);
Line 260
 
Line 260
      }       }
  }   }
  if((int)op->stats.wc < (NUM_ANIMATIONS(op)/2+1)) {   if((int)op->stats.wc < (NUM_ANIMATIONS(op)/2+1)) {
      CLEAR_FLAG(op, FLAG_NO_PASS);       op->move_block = 0;
      CLEAR_FLAG(op, FLAG_BLOCKSVIEW);       CLEAR_FLAG(op, FLAG_BLOCKSVIEW);
      update_all_los(op->map, op->x, op->y);       update_all_los(op->map, op->x, op->y);
  }   }
Line 331
 
Line 331
  && (!QUERY_FLAG(tmp, FLAG_NO_PICK)   && (!QUERY_FLAG(tmp, FLAG_NO_PICK)
     ||QUERY_FLAG(tmp,FLAG_CAN_ROLL))) {      ||QUERY_FLAG(tmp,FLAG_CAN_ROLL))) {
      /* If it has speed, it should move itself, otherwise: */       /* If it has speed, it should move itself, otherwise: */
      int i=find_free_spot(tmp->arch,op->map,op->x,op->y,1,9);       int i=find_free_spot(tmp,op->map,op->x,op->y,1,9);
   
      /* If there is a free spot, move the object someplace */       /* If there is a free spot, move the object someplace */
      if (i!=-1) {       if (i!=-1) {
Line 353
 
Line 353
      if(tmp) {       if(tmp) {
      op->stats.food=1;       op->stats.food=1;
      } else {       } else {
  SET_FLAG(op, FLAG_NO_PASS);    /* The coast is clear, block the way */   op->move_block = MOVE_ALL;
  if(!op->arch->clone.stats.ac)   if(!op->arch->clone.stats.ac)
      SET_FLAG(op, FLAG_BLOCKSVIEW);       SET_FLAG(op, FLAG_BLOCKSVIEW);
  update_all_los(op->map, op->x, op->y);   update_all_los(op->map, op->x, op->y);
Line 460
 
Line 460
      op->stats.wc=0;       op->stats.wc=0;
      op->speed = 0;       op->speed = 0;
      update_ob_speed(op);       update_ob_speed(op);
      SET_FLAG(op, FLAG_WALK_ON);  
        /* Hard coding this makes sense for holes I suppose */
        op->move_on = MOVE_WALK;
      for (tmp=op->above; tmp!=NULL; tmp=next) {       for (tmp=op->above; tmp!=NULL; tmp=next) {
  next=tmp->above;   next=tmp->above;
  move_apply(op,tmp,tmp);   move_apply(op,tmp,tmp);
Line 471
 
Line 473
  return;   return;
     }      }
     /* We're closing */      /* We're closing */
     CLEAR_FLAG(op, FLAG_WALK_ON);      op->move_on = 0;
   
     op->stats.wc++;      op->stats.wc++;
     if((int)op->stats.wc >= NUM_ANIMATIONS(op))      if((int)op->stats.wc >= NUM_ANIMATIONS(op))
  op->stats.wc=NUM_ANIMATIONS(op)-1;   op->stats.wc=NUM_ANIMATIONS(op)-1;
Line 551
 
Line 554
     }      }
   
     op->direction=0;      op->direction=0;
     CLEAR_FLAG(op, FLAG_WALK_ON);      op->move_on=0;
     CLEAR_FLAG(op, FLAG_FLY_ON);      op->move_type=0;
     CLEAR_FLAG(op, FLAG_FLYING);  
     op->speed = 0;      op->speed = 0;
     update_ob_speed(op);      update_ob_speed(op);
     op->stats.wc = op->stats.sp;      op->stats.wc = op->stats.sp;
Line 709
 
Line 711
     } /* if there is something alive on this space */      } /* if there is something alive on this space */
   
   
     if (mflags & P_WALL) {      if (OB_TYPE_MOVE_BLOCK(op, GET_MAP_MOVE_BLOCK(m, new_x, new_y))) {
    int retry=0;
   
  /* if the object doesn't reflect, stop the arrow from moving   /* if the object doesn't reflect, stop the arrow from moving
  * note that this code will now catch cases where a monster is   * note that this code will now catch cases where a monster is
  * on a wall but has reflecting - the arrow won't reflect.   * on a wall but has reflecting - the arrow won't reflect.
Line 719
 
Line 723
  if(!QUERY_FLAG(op, FLAG_REFLECTING) || !(rndm(0, 19))) {   if(!QUERY_FLAG(op, FLAG_REFLECTING) || !(rndm(0, 19))) {
      stop_arrow (op);       stop_arrow (op);
      return;       return;
  } else {    /* object is reflected */   } else {
      /* If one of the major directions (n,s,e,w), just reverse it */       /* If one of the major directions (n,s,e,w), just reverse it */
      if(op->direction&1) {       if(op->direction&1) {
  op->direction=absdir(op->direction+4);   op->direction=absdir(op->direction+4);
      } else {   retry=1;
  /* The below is just logic for figuring out what direction       }
  * the object should now take.       /* There were two blocks with identical code -
  */        * use this retry here to make this one block
          * that did the same thing.
  int left, right;        */
        while (retry<2) {
    int left, right, mflags;
  left= get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction-1)],   mapstruct *m1;
         op->y+freearr_y[absdir(op->direction-1)], NULL, NULL) & P_WALL;   sint16 x1, y1;
  right=get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction+1)],  
     op->y+freearr_y[absdir(op->direction+1)], NULL, NULL) & P_WALL;   retry++;
   
    get_map_flags(op->map,&m1, op->x+freearr_x[absdir(op->direction-1)],
           op->y+freearr_y[absdir(op->direction-1)], &x1, &y1);
    left = OB_TYPE_MOVE_BLOCK(op, (GET_MAP_MOVE_BLOCK(m1, x1, y1)));
   
    get_map_flags(op->map,&m1, op->x+freearr_x[absdir(op->direction+1)],
       op->y+freearr_y[absdir(op->direction+1)], &x1, &y1);
    right = OB_TYPE_MOVE_BLOCK(op, (GET_MAP_MOVE_BLOCK(m1, x1, y1)));
   
  if(left==right)   if(left==right)
      op->direction=absdir(op->direction+4);       op->direction=absdir(op->direction+4);
Line 742
 
Line 754
      op->direction=absdir(op->direction+2);       op->direction=absdir(op->direction+2);
  else if(right)   else if(right)
      op->direction=absdir(op->direction-2);       op->direction=absdir(op->direction-2);
   
    mflags = get_map_flags(op->map,&m1, op->x+DIRX(op),op->y+DIRY(op), &x1, &y1);
   
    /* If this space is not out of the map and not blocked, valid space -
    * don't need to retry again.
    */
    if (!(mflags & P_OUT_OF_MAP) &&
      !OB_TYPE_MOVE_BLOCK(op, GET_MAP_MOVE_BLOCK(m1, x1, y1))) break;
   
      }       }
      /* Is the new direction also a wall?  If show, shuffle again */       /* Couldn't find a direction to move the arrow to - just
      if(get_map_flags(op->map,NULL, op->x+DIRX(op),op->y+DIRY(op), NULL, NULL) & P_WALL) {        * top it from moving.
  int left, right;        */
        if (retry==2) {
  left= get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction-1)],  
  op->y+freearr_y[absdir(op->direction-1)], NULL, NULL) & P_WALL;  
  right = get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction+1)],  
       op->y+freearr_y[absdir(op->direction+1)], NULL, NULL) & P_WALL;  
   
  if(!left)  
      op->direction=absdir(op->direction-1);  
  else if(!right)  
      op->direction=absdir(op->direction+1);  
  else { /* is this possible? */  
      stop_arrow (op);       stop_arrow (op);
      return;       return;
  }   }
      }  
      /* update object image for new facing */       /* update object image for new facing */
      /* many thrown objects *don't* have more than one face */       /* many thrown objects *don't* have more than one face */
      if(GET_ANIM_ID(op))       if(GET_ANIM_ID(op))
Line 817
 
Line 827
      esrv_send_item(pl, tmp);       esrv_send_item(pl, tmp);
  }   }
     } else {      } else {
         j=find_first_free_spot(tmp->arch,op->map,op->x,op->y);          j=find_first_free_spot(tmp,op->map,op->x,op->y);
  if (j==-1)  /* No free spot */   if (j==-1)  /* No free spot */
      free_object(tmp);       free_object(tmp);
  else {   else {
Line 951
 
Line 961
   
 /*  move_player_mover:  this function takes a "player mover" as an  /*  move_player_mover:  this function takes a "player mover" as an
  * argument, and performs the function of a player mover, which is:   * argument, and performs the function of a player mover, which is:
    *
  * a player mover finds any players that are sitting on it.  It   * a player mover finds any players that are sitting on it.  It
  * moves them in the op->stats.sp direction.  speed is how often it'll move.   * moves them in the op->stats.sp direction.  speed is how often it'll move.
  * If attacktype is nonzero it will paralyze the player.  If lifesave is set,   * If attacktype is nonzero it will paralyze the player.  If lifesave is set,
  * it'll dissapear after hp+1 moves.  If hp is set and attacktype is set,   * it'll dissapear after hp+1 moves.  If hp is set and attacktype is set,
  * it'll paralyze the victim for hp*his speed/op->speed   * it'll paralyze the victim for hp*his speed/op->speed
   
 */  */
 void move_player_mover(object *op) {  void move_player_mover(object *op) {
     object *victim, *nextmover;      object *victim, *nextmover;
Line 969
 
Line 978
     if (!dir) dir=rndm(1, 8);      if (!dir) dir=rndm(1, 8);
   
     for(victim=get_map_ob(op->map,op->x,op->y); victim !=NULL; victim=victim->above) {      for(victim=get_map_ob(op->map,op->x,op->y); victim !=NULL; victim=victim->above) {
  if(QUERY_FLAG(victim, FLAG_ALIVE)&& (!(QUERY_FLAG(victim,FLAG_FLYING))||op->stats.maxhp)) {   if(QUERY_FLAG(victim, FLAG_ALIVE) && (victim->move_type & op->move_type)) {
   
      if (victim->head) victim = victim->head;       if (victim->head) victim = victim->head;
   
Line 1087
 
Line 1096
  return;   return;
     }      }
     /* Make sure this multipart object fits */      /* Make sure this multipart object fits */
     if (at->more && arch_blocked(at, op->map, op->x, op->y))      if (at->more && ob_blocked(&at->clone, op->map, op->x, op->y))
  return;   return;
   
     while(at!=NULL) {      while(at!=NULL) {


Legend:
line(s) removed in v.1.78 
line(s) changed
 line(s) added in v.1.79

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