version 1.8 | | version 1.9 |
---|
| | |
/* | | /* |
* static char *rcsid_decor_ = | | * static char *rcsid_decor_ = |
* "$Id: decor.c,v 1.8 2005/11/16 08:16:08 mwedel Exp $"; | | * "$Id: decor.c,v 1.9 2006/02/25 19:46:12 qal21 Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
decor_map = find_style(style_name,decorstyle,-1); | | decor_map = find_style(style_name,decorstyle,-1); |
if(decor_map == NULL) return; | | if(decor_map == NULL) return; |
/* pick a random option, only 1 option right now. */ | | /* pick a random option, only 1 option right now. */ |
if(decor_option==0) { | | if(decor_option==0) |
decor_option = RANDOM() % NR_DECOR_OPTIONS +1; | | decor_option = RANDOM() % NR_DECOR_OPTIONS +1; |
}; | | |
switch(decor_option) { | | switch(decor_option) { |
case 0: break; | | case 0: break; |
case 1: /* random placement of decor objects. */ | | case 1: { /* random placement of decor objects. */ |
{ | | |
int number_to_place = RANDOM() % ( (RP->Xsize *RP->Ysize) / 5); | | int number_to_place = RANDOM() % ( (RP->Xsize *RP->Ysize) / 5); |
int failures=0; | | int failures=0; |
object *new_decor_object; | | object *new_decor_object; |
| | |
int x,y; | | int x,y; |
x = RANDOM() % (RP->Xsize-2) +1; | | x = RANDOM() % (RP->Xsize-2) +1; |
y = RANDOM() % (RP->Ysize-2) +1; | | y = RANDOM() % (RP->Ysize-2) +1; |
if(maze[x][y]==0 && obj_count_in_map(map,x,y)<2) /* empty */ | | if(maze[x][y]==0 && obj_count_in_map(map,x,y)<2) { /* empty */ |
{ | | |
object *this_object; | | object *this_object; |
new_decor_object = pick_random_object(decor_map); | | new_decor_object = pick_random_object(decor_map); |
this_object = arch_to_object(new_decor_object->arch); | | this_object = arch_to_object(new_decor_object->arch); |
| | |
insert_ob_in_map(this_object,map,NULL,0); | | insert_ob_in_map(this_object,map,NULL,0); |
number_to_place--; | | number_to_place--; |
} | | } |
else failures++; | | else |
| | failures++; |
} | | } |
break; | | break; |
default: /* place decor objects everywhere: tile the map. */ | | } |
{ | | default: { /* place decor objects everywhere: tile the map. */ |
int i,j; | | int i,j; |
for(i=1;i<RP->Xsize-1;i++) for(j=1;j<RP->Ysize-1;j++) { | | for(i=1;i<RP->Xsize-1;i++) for(j=1;j<RP->Ysize-1;j++) { |
if(maze[i][j]==0) { | | if(maze[i][j]==0) { |
| | |
insert_ob_in_map(this_object,map,NULL,0); | | insert_ob_in_map(this_object,map,NULL,0); |
} | | } |
} | | } |
| | |
} | | |
break; | | break; |
| | |
} | | } |
} | | } |
} | | } |