Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: one more patch for out-of-map objects (spell_effect.c)



Guess what?  Yet another bug fix!  This is a complement to what I
sent on Wednesday for all spells and skills trying to access objects
out of the map.

This patch fixes the spells "light", "drain magic", "charm monsters"
and "charm undead".  All of them could crash the game if they were
used near the edges of the map, especially by high-level players or
monsters.  Now these problems should be solved.  This should make the
game much more stable and get rid of the frequent crashes caused by
monsters reading scrolls or using wands.

Maybe it will soon be time for 0.92.5?  My version of Crossfire is now
rather stable (I applied all the patches from Brian Thomas as well as
the ones I sent to this list, of course).  The only major bug that I
can still see is the one that I described on Wednesday about dragons
or other monsters being killed by a wall of thorns, a pool of chaos or
other objects on which they walk.

-Raphael

---------- cut here ---------- cut here ---------- cut here ----------
*** server/spell_effect.c~	Fri Jul 19 12:14:42 1996
--- server/spell_effect.c	Fri Jul 19 15:57:44 1996
***************
*** 732,743 ****
  
    x=op->x+freearr_x[dir],y=op->y+freearr_y[dir];
  
!   for(target=get_map_ob(op->map,x,y);target;target=target->above)
!      if(QUERY_FLAG(target,FLAG_MONSTER)) {
          /* coky doky. got a target monster. Lets make a blinding attack */ 
!          if(target->head) target = target->head; 
!          (void) hit_player(target,dam,op,(AT_BLIND|AT_MAGIC));
!          return 1; /* one success only! */
        }
  
    /* no live target, perhaps a wall is in the way? */
--- 732,744 ----
  
    x=op->x+freearr_x[dir],y=op->y+freearr_y[dir];
  
!   if (!out_of_map(op->map,x,y))
!     for(target=get_map_ob(op->map,x,y);target;target=target->above)
!       if(QUERY_FLAG(target,FLAG_MONSTER)) {
          /* coky doky. got a target monster. Lets make a blinding attack */ 
! 	if(target->head) target = target->head; 
! 	(void) hit_player(target,dam,op,(AT_BLIND|AT_MAGIC));
! 	return 1; /* one success only! */
        }
  
    /* no live target, perhaps a wall is in the way? */
***************
*** 2055,2067 ****
  /*  drain_magic:  peterm  */
  /*  drains all the magic out of the victim.  */
  int drain_magic(object *op,int dir) {
!     object *tmp;
  
!      for(tmp=get_map_ob(op->map,op->x+freearr_x[dir],op->y+freearr_y[dir]);
!          tmp!=NULL;
!          tmp=tmp->above)
          if(QUERY_FLAG(tmp, FLAG_ALIVE))
!         break;
       /*  If we did not find a player in the specified direction, transfer
  	to anyone on top of us. */
  
--- 2056,2069 ----
  /*  drain_magic:  peterm  */
  /*  drains all the magic out of the victim.  */
  int drain_magic(object *op,int dir) {
!     object *tmp = NULL;
  
!     if (!out_of_map(op->map,op->x+freearr_x[dir],op->y+freearr_y[dir]))
!       for(tmp=get_map_ob(op->map,op->x+freearr_x[dir],op->y+freearr_y[dir]);
! 	  tmp!=NULL;
! 	  tmp=tmp->above)
          if(QUERY_FLAG(tmp, FLAG_ALIVE))
! 	  break;
       /*  If we did not find a player in the specified direction, transfer
  	to anyone on top of us. */
  
***************
*** 2153,2158 ****
--- 2155,2162 ----
    object *tmp,*effect;
    
    for(i=1;i<MIN(9+SP_level_strength_adjust(op,spellnum),SIZEOFFREE);i++) {
+         if (out_of_map(op->map,op->x+freearr_x[i],op->y+freearr_y[i]))
+ 	  continue;
  	for(tmp=get_map_ob(op->map,op->x+freearr_x[i],op->y+freearr_y[i]);
  	    tmp&&(!QUERY_FLAG(tmp,FLAG_MONSTER));tmp=tmp->above);
  	if(!tmp) continue;
***************
*** 2183,2188 ****
--- 2187,2194 ----
    object *tmp,*effect;
   
    for(i=1;i<MIN(9+SP_level_strength_adjust(op,spellnum),SIZEOFFREE);i++) {
+         if (out_of_map(op->map,op->x+freearr_x[i],op->y+freearr_y[i]))
+ 	  continue;
          for(tmp=get_map_ob(op->map,op->x+freearr_x[i],op->y+freearr_y[i]);
              tmp&&(!QUERY_FLAG(tmp,FLAG_MONSTER));tmp=tmp->above);
          if(!tmp) continue;
---------- cut here ---------- cut here ---------- cut here ----------