version 1.24 | | version 1.25 |
---|
| | |
/* | | /* |
* static char *rcsid_treasure_c = | | * static char *rcsid_treasure_c = |
* "$Id: treasure.c,v 1.24 2006/01/08 23:12:26 qal21 Exp $"; | | * "$Id: treasure.c,v 1.25 2006/03/04 17:37:19 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
lx=x+freearr_x[i]; | | lx=x+freearr_x[i]; |
ly=y+freearr_y[i]; | | ly=y+freearr_y[i]; |
/* boundscheck */ | | /* boundscheck */ |
if(lx > 0 && ly > 0 && lx < RP->Xsize && ly < RP->Ysize) | | if(lx >= 0 && ly >= 0 && lx < RP->Xsize && ly < RP->Ysize) |
/* don't bother searching this square unless the map says life exists.*/ | | /* don't bother searching this square unless the map says life exists.*/ |
if(GET_MAP_FLAGS(map,lx,ly) & P_IS_ALIVE) { | | if(GET_MAP_FLAGS(map,lx,ly) & P_IS_ALIVE) { |
object *the_monster=get_map_ob(map,lx,ly); | | object *the_monster=get_map_ob(map,lx,ly); |
| | |
int i; | | int i; |
x = *cx;y=*cy; | | x = *cx;y=*cy; |
| | |
for(i=0;i<SIZEOFFREE;i++) { | | for(i=0;i<=SIZEOFFREE1;i++) { |
int lx,ly,sindex; | | int lx,ly,sindex; |
lx = x +freearr_x[i]; | | lx = x +freearr_x[i]; |
ly = y +freearr_y[i]; | | ly = y +freearr_y[i]; |
| | |
| | |
/* OK, if we got here, we're obviously someplace where there's no enclosed | | /* OK, if we got here, we're obviously someplace where there's no enclosed |
spots--try to find someplace which is 2x enclosed. */ | | spots--try to find someplace which is 2x enclosed. */ |
for(i=0;i<SIZEOFFREE;i++) { | | for(i=0;i<=SIZEOFFREE1;i++) { |
int lx,ly,sindex; | | int lx,ly,sindex; |
lx = x +freearr_x[i]; | | lx = x +freearr_x[i]; |
ly = y +freearr_y[i]; | | ly = y +freearr_y[i]; |
| | |
} | | } |
| | |
/* settle for one surround point */ | | /* settle for one surround point */ |
for(i=0;i<SIZEOFFREE;i++) { | | for(i=0;i<=SIZEOFFREE1;i++) { |
int lx,ly,sindex; | | int lx,ly,sindex; |
lx = x +freearr_x[i]; | | lx = x +freearr_x[i]; |
ly = y +freearr_y[i]; | | ly = y +freearr_y[i]; |
| | |
} | | } |
/* give up and return the closest free spot. */ | | /* give up and return the closest free spot. */ |
i = find_first_free_spot(&find_archetype("chest")->clone,map,x,y); | | i = find_first_free_spot(&find_archetype("chest")->clone,map,x,y); |
if(i!=-1&&i<SIZEOFFREE) { | | if(i!=-1&&i<=SIZEOFFREE1) { |
*cx = x +freearr_x[i]; | | *cx = x +freearr_x[i]; |
*cy = y +freearr_y[i]; | | *cy = y +freearr_y[i]; |
| | return; |
} | | } |
/* indicate failure */ | | /* indicate failure */ |
*cx=*cy=-1; | | *cx=*cy=-1; |