version 1.10 | | version 1.11 |
---|
| | |
/* | | /* |
* static char *rcsid_special_c = | | * static char *rcsid_special_c = |
* "$Id: special.c,v 1.10 2000/12/15 03:09:19 peterm Exp $"; | | * "$Id: special.c,v 1.11 2000/12/18 06:15:05 peterm Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
| | |
void place_fountain_with_specials(mapstruct *map) { | | void place_fountain_with_specials(mapstruct *map) { |
int ix,iy,i=-1; | | int ix,iy,i=-1,tries=0; |
mapstruct *fountain_style=find_style("/styles/misc","fountains",-1); | | mapstruct *fountain_style=find_style("/styles/misc","fountains",-1); |
object *fountain=get_archetype("fountain"); | | object *fountain=get_archetype("fountain"); |
object *potion=get_object(); | | object *potion=get_object(); |
copy_object(pick_random_object(fountain_style),potion); | | copy_object(pick_random_object(fountain_style),potion); |
while(i<0) { | | while(i<0 && tries<10) { |
ix = RANDOM() % (map->mapx -2) +1; | | ix = RANDOM() % (map->mapx -2) +1; |
iy = RANDOM() % (map->mapx -2) +1; | | iy = RANDOM() % (map->mapx -2) +1; |
i = find_first_free_spot(fountain->arch,map,ix,iy); | | i = find_first_free_spot(fountain->arch,map,ix,iy); |
| | tries++; |
}; | | }; |
| | if(i==-1) { /* can't place fountain */ |
| | free_object(fountain); |
| | free_object(potion); |
| | return; |
| | } |
ix += freearr_x[i]; | | ix += freearr_x[i]; |
iy += freearr_y[i]; | | iy += freearr_y[i]; |
potion->face=fountain->face; | | potion->face=fountain->face; |