--- deliantra/server/random_maps/decor.C 2006/12/30 18:45:28 1.7 +++ deliantra/server/random_maps/decor.C 2006/12/31 19:02:23 1.8 @@ -1,3 +1,4 @@ + /* CrossFire, A Multiplayer game for X-windows @@ -44,7 +45,7 @@ /* put the decor into the map. Right now, it's very primitive. */ void -put_decor (maptile *map, char **maze, char *decorstyle, int decor_option, random_map_params * RP) +put_decor (maptile *map, char **maze, char *decorstyle, int decor_option, random_map_params *RP) { maptile *decor_map; char style_name[256]; @@ -59,61 +60,61 @@ decor_option = RANDOM () % NR_DECOR_OPTIONS + 1; switch (decor_option) { - case 0: + case 0: + break; + case 1: + { /* random placement of decor objects. */ + int number_to_place = RANDOM () % ((RP->Xsize * RP->Ysize) / 5); + int failures = 0; + object *new_decor_object; + + while (failures < 100 && number_to_place > 0) + { + int x, y; + + x = RANDOM () % (RP->Xsize - 2) + 1; + y = RANDOM () % (RP->Ysize - 2) + 1; + if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) + { /* empty */ + object *this_object; + + new_decor_object = pick_random_object (decor_map); + this_object = arch_to_object (new_decor_object->arch); + new_decor_object->copy_to (this_object); + this_object->x = x; + this_object->y = y; + /* it screws things up if decor can stop people */ + this_object->move_block = MOVE_BLOCK_DEFAULT; + insert_ob_in_map (this_object, map, NULL, 0); + number_to_place--; + } + else + failures++; + } break; - case 1: - { /* random placement of decor objects. */ - int number_to_place = RANDOM () % ((RP->Xsize * RP->Ysize) / 5); - int failures = 0; - object *new_decor_object; + } + default: + { /* place decor objects everywhere: tile the map. */ + int i, j; - while (failures < 100 && number_to_place > 0) + for (i = 1; i < RP->Xsize - 1; i++) + for (j = 1; j < RP->Ysize - 1; j++) { - int x, y; - - x = RANDOM () % (RP->Xsize - 2) + 1; - y = RANDOM () % (RP->Ysize - 2) + 1; - if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) - { /* empty */ - object *this_object; + if (maze[i][j] == 0) + { + object *new_decor_object, *this_object; new_decor_object = pick_random_object (decor_map); this_object = arch_to_object (new_decor_object->arch); new_decor_object->copy_to (this_object); - this_object->x = x; - this_object->y = y; + this_object->x = i; + this_object->y = j; /* it screws things up if decor can stop people */ this_object->move_block = MOVE_BLOCK_DEFAULT; insert_ob_in_map (this_object, map, NULL, 0); - number_to_place--; } - else - failures++; } - break; - } - default: - { /* place decor objects everywhere: tile the map. */ - int i, j; - - for (i = 1; i < RP->Xsize - 1; i++) - for (j = 1; j < RP->Ysize - 1; j++) - { - if (maze[i][j] == 0) - { - object *new_decor_object, *this_object; - - new_decor_object = pick_random_object (decor_map); - this_object = arch_to_object (new_decor_object->arch); - new_decor_object->copy_to (this_object); - this_object->x = i; - this_object->y = j; - /* it screws things up if decor can stop people */ - this_object->move_block = MOVE_BLOCK_DEFAULT; - insert_ob_in_map (this_object, map, NULL, 0); - } - } - break; - } + break; + } } }