… | |
… | |
61 | |
61 | |
62 | switch (decor_option) |
62 | switch (decor_option) |
63 | { |
63 | { |
64 | case 0: |
64 | case 0: |
65 | break; |
65 | break; |
|
|
66 | |
66 | case 1: |
67 | case 1: |
67 | { /* random placement of decor objects. */ |
68 | { /* random placement of decor objects. */ |
68 | int number_to_place = rndm (RP->Xsize * RP->Ysize / 5); |
69 | int number_to_place = rndm (RP->Xsize * RP->Ysize / 5); |
69 | int failures = 0; |
70 | int failures = 0; |
70 | object *new_decor_object; |
|
|
71 | |
71 | |
72 | while (failures < 100 && number_to_place > 0) |
72 | while (failures < 100 && number_to_place > 0) |
73 | { |
73 | { |
74 | int x, y; |
74 | int x = rndm (RP->Xsize - 2) + 1; |
|
|
75 | int y = rndm (RP->Ysize - 2) + 1; |
75 | |
76 | |
76 | x = rndm (RP->Xsize - 2) + 1; |
|
|
77 | y = rndm (RP->Ysize - 2) + 1; |
|
|
78 | if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) |
77 | if (maze[x][y] == 0 && obj_count_in_map (map, x, y) < 2) |
79 | { /* empty */ |
78 | { |
80 | object *this_object; |
79 | object *this_object = decor_map->pick_random_object ()->clone (); |
81 | |
80 | |
82 | new_decor_object = decor_map->pick_random_object (); |
|
|
83 | this_object = arch_to_object (new_decor_object->arch); |
|
|
84 | new_decor_object->copy_to (this_object); |
|
|
85 | this_object->x = x; |
81 | this_object->x = x; |
86 | this_object->y = y; |
82 | this_object->y = y; |
87 | /* it screws things up if decor can stop people */ |
83 | /* it screws things up if decor can stop people */ |
88 | this_object->move_block = 0; |
84 | this_object->move_block = 0; |
|
|
85 | |
89 | insert_ob_in_map (this_object, map, NULL, 0); |
86 | insert_ob_in_map (this_object, map, NULL, 0); |
90 | number_to_place--; |
87 | number_to_place--; |
91 | } |
88 | } |
92 | else |
89 | else |
93 | failures++; |
90 | failures++; |
94 | } |
91 | } |
95 | break; |
92 | break; |
96 | } |
93 | } |
|
|
94 | |
97 | default: |
95 | default: |
98 | { /* place decor objects everywhere: tile the map. */ |
96 | { /* place decor objects everywhere: tile the map. */ |
99 | int i, j; |
97 | int i, j; |
100 | |
98 | |
101 | for (i = 1; i < RP->Xsize - 1; i++) |
99 | for (i = 1; i < RP->Xsize - 1; i++) |
102 | for (j = 1; j < RP->Ysize - 1; j++) |
100 | for (j = 1; j < RP->Ysize - 1; j++) |
103 | { |
101 | { |
104 | if (maze[i][j] == 0) |
102 | if (maze[i][j] == 0) |
105 | { |
103 | { |
106 | object *new_decor_object, *this_object; |
104 | object *this_object = decor_map->pick_random_object ()->clone (); |
107 | |
105 | |
108 | new_decor_object = decor_map->pick_random_object (); |
|
|
109 | this_object = arch_to_object (new_decor_object->arch); |
|
|
110 | new_decor_object->copy_to (this_object); |
|
|
111 | this_object->x = i; |
106 | this_object->x = i; |
112 | this_object->y = j; |
107 | this_object->y = j; |
113 | /* it screws things up if decor can stop people */ |
108 | /* it screws things up if decor can stop people */ |
114 | this_object->move_block = 0; |
109 | this_object->move_block = 0; |
|
|
110 | |
115 | insert_ob_in_map (this_object, map, NULL, 0); |
111 | insert_ob_in_map (this_object, map, NULL, 0); |
116 | } |
112 | } |
117 | } |
113 | } |
118 | break; |
114 | break; |
119 | } |
115 | } |
120 | } |
116 | } |
121 | } |
117 | } |
|
|
118 | |