… | |
… | |
49 | object *tmp; |
49 | object *tmp; |
50 | |
50 | |
51 | for (i = xstart; i < xstart + xsize; i++) |
51 | for (i = xstart; i < xstart + xsize; i++) |
52 | for (j = ystart; j < ystart + ysize; j++) |
52 | for (j = ystart; j < ystart + ysize; j++) |
53 | { |
53 | { |
54 | for (tmp = get_map_ob (map, i, j); tmp != NULL; tmp = tmp->above) |
54 | for (tmp = GET_MAP_OB (map, i, j); tmp != NULL; tmp = tmp->above) |
55 | { |
55 | { |
56 | if (!QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
56 | if (!QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
57 | { |
57 | { |
58 | if (tmp->head) |
58 | if (tmp->head) |
59 | tmp = tmp->head; |
59 | tmp = tmp->head; |
60 | remove_ob (tmp); |
60 | tmp->remove (); |
61 | free_object (tmp); |
61 | tmp->destroy (); |
62 | tmp = get_map_ob (map, i, j); |
62 | tmp = GET_MAP_OB (map, i, j); |
63 | } |
63 | } |
64 | if (tmp == NULL) |
64 | if (tmp == NULL) |
65 | break; |
65 | break; |
66 | } |
66 | } |
67 | } |
67 | } |
… | |
… | |
78 | int i, j; |
78 | int i, j; |
79 | object *tmp; |
79 | object *tmp; |
80 | object *new_ob; |
80 | object *new_ob; |
81 | |
81 | |
82 | /* First, splatter everything in the dest map at the location */ |
82 | /* First, splatter everything in the dest map at the location */ |
83 | nuke_map_region (dest_map, x, y, MAP_WIDTH (in_map), MAP_HEIGHT (in_map)); |
83 | nuke_map_region (dest_map, x, y, in_map->width, in_map->height); |
84 | |
84 | |
85 | for (i = 0; i < MAP_WIDTH (in_map); i++) |
85 | for (i = 0; i < in_map->width; i++) |
86 | for (j = 0; j < MAP_HEIGHT (in_map); j++) |
86 | for (j = 0; j < in_map->height; j++) |
87 | { |
87 | { |
88 | for (tmp = get_map_ob (in_map, i, j); tmp != NULL; tmp = tmp->above) |
88 | for (tmp = GET_MAP_OB (in_map, i, j); tmp != NULL; tmp = tmp->above) |
89 | { |
89 | { |
90 | /* don't copy things with multiple squares: must be dealt with |
90 | /* don't copy things with multiple squares: must be dealt with |
91 | specially. */ |
91 | specially. */ |
92 | if (tmp->head != NULL) |
92 | if (tmp->head != NULL) |
93 | continue; |
93 | continue; |
… | |
… | |
110 | int is_occupied = 0; |
110 | int is_occupied = 0; |
111 | int l, m; |
111 | int l, m; |
112 | |
112 | |
113 | /* don't even try to place a submap into a map if the big map isn't |
113 | /* don't even try to place a submap into a map if the big map isn't |
114 | sufficiently large. */ |
114 | sufficiently large. */ |
115 | if (2 * xsize > MAP_WIDTH (map) || 2 * ysize > MAP_HEIGHT (map)) |
115 | if (2 * xsize > map->width || 2 * ysize > map->height) |
116 | return 0; |
116 | return 0; |
117 | |
117 | |
118 | /* search a bit for a completely free spot. */ |
118 | /* search a bit for a completely free spot. */ |
119 | for (tries = 0; tries < 20; tries++) |
119 | for (tries = 0; tries < 20; tries++) |
120 | { |
120 | { |
121 | /* pick a random location in the layout */ |
121 | /* pick a random location in the layout */ |
122 | i = RANDOM () % (MAP_WIDTH (map) - xsize - 2) + 1; |
122 | i = RANDOM () % (map->width - xsize - 2) + 1; |
123 | j = RANDOM () % (MAP_HEIGHT (map) - ysize - 2) + 1; |
123 | j = RANDOM () % (map->height - ysize - 2) + 1; |
124 | is_occupied = 0; |
124 | is_occupied = 0; |
125 | for (l = i; l < i + xsize; l++) |
125 | for (l = i; l < i + xsize; l++) |
126 | for (m = j; m < j + ysize; m++) |
126 | for (m = j; m < j + ysize; m++) |
127 | is_occupied |= layout[l][m]; |
127 | is_occupied |= layout[l][m]; |
128 | if (!is_occupied) |
128 | if (!is_occupied) |
… | |
… | |
135 | if (is_occupied) |
135 | if (is_occupied) |
136 | { /* failure, try a relaxed placer. */ |
136 | { /* failure, try a relaxed placer. */ |
137 | /* pick a random location in the layout */ |
137 | /* pick a random location in the layout */ |
138 | for (tries = 0; tries < 10; tries++) |
138 | for (tries = 0; tries < 10; tries++) |
139 | { |
139 | { |
140 | i = RANDOM () % (MAP_WIDTH (map) - xsize - 2) + 1; |
140 | i = RANDOM () % (map->width - xsize - 2) + 1; |
141 | j = RANDOM () % (MAP_HEIGHT (map) - ysize - 2) + 1; |
141 | j = RANDOM () % (map->height - ysize - 2) + 1; |
142 | is_occupied = 0; |
142 | is_occupied = 0; |
143 | for (l = i; l < i + xsize; l++) |
143 | for (l = i; l < i + xsize; l++) |
144 | for (m = j; m < j + ysize; m++) |
144 | for (m = j; m < j + ysize; m++) |
145 | if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') |
145 | if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') |
146 | is_occupied |= 1; |
146 | is_occupied |= 1; |
… | |
… | |
158 | place_fountain_with_specials (maptile *map) |
158 | place_fountain_with_specials (maptile *map) |
159 | { |
159 | { |
160 | int ix, iy, i = -1, tries = 0; |
160 | int ix, iy, i = -1, tries = 0; |
161 | maptile *fountain_style = find_style ("/styles/misc", "fountains", -1); |
161 | maptile *fountain_style = find_style ("/styles/misc", "fountains", -1); |
162 | object *fountain = get_archetype ("fountain"); |
162 | object *fountain = get_archetype ("fountain"); |
163 | object *potion = get_object (); |
163 | object *potion = object::create (); |
164 | |
164 | |
165 | copy_object (pick_random_object (fountain_style), potion); |
165 | pick_random_object (fountain_style)->copy_to (potion); |
|
|
166 | |
166 | while (i < 0 && tries < 10) |
167 | while (i < 0 && tries < 10) |
167 | { |
168 | { |
168 | ix = RANDOM () % (MAP_WIDTH (map) - 2) + 1; |
169 | ix = RANDOM () % (map->width - 2) + 1; |
169 | iy = RANDOM () % (MAP_HEIGHT (map) - 2) + 1; |
170 | iy = RANDOM () % (map->height - 2) + 1; |
170 | i = find_first_free_spot (fountain, map, ix, iy); |
171 | i = find_first_free_spot (fountain, map, ix, iy); |
171 | tries++; |
172 | tries++; |
172 | }; |
173 | } |
|
|
174 | |
173 | if (i == -1) |
175 | if (i == -1) |
174 | { /* can't place fountain */ |
176 | { /* can't place fountain */ |
175 | free_object (fountain); |
177 | fountain->destroy (); |
176 | free_object (potion); |
178 | potion->destroy (); |
177 | return; |
179 | return; |
178 | } |
180 | } |
|
|
181 | |
179 | ix += freearr_x[i]; |
182 | ix += freearr_x[i]; |
180 | iy += freearr_y[i]; |
183 | iy += freearr_y[i]; |
181 | potion->face = fountain->face; |
184 | potion->face = fountain->face; |
182 | SET_FLAG (potion, FLAG_NO_PICK); |
185 | SET_FLAG (potion, FLAG_NO_PICK); |
183 | SET_FLAG (potion, FLAG_IDENTIFIED); |
186 | SET_FLAG (potion, FLAG_IDENTIFIED); |
… | |
… | |
198 | int ix, iy, i = -1; |
201 | int ix, iy, i = -1; |
199 | char buf[HUGE_BUF], *style, *decor, *mon; |
202 | char buf[HUGE_BUF], *style, *decor, *mon; |
200 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
203 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
201 | int g_xsize, g_ysize; |
204 | int g_xsize, g_ysize; |
202 | |
205 | |
203 | object *the_exit = get_object (); |
206 | object *the_exit = object::create (); |
204 | |
207 | |
205 | if (!exit_style) |
208 | if (!exit_style) |
206 | return; |
209 | return; |
207 | |
210 | |
208 | copy_object (pick_random_object (exit_style), the_exit); |
211 | pick_random_object (exit_style)->copy_to (the_exit); |
209 | |
212 | |
210 | while (i < 0) |
213 | while (i < 0) |
211 | { |
214 | { |
212 | ix = RANDOM () % (MAP_WIDTH (map) - 2) + 1; |
215 | ix = RANDOM () % (map->width - 2) + 1; |
213 | iy = RANDOM () % (MAP_HEIGHT (map) - 2) + 1; |
216 | iy = RANDOM () % (map->height - 2) + 1; |
214 | i = find_first_free_spot (the_exit, map, ix, iy); |
217 | i = find_first_free_spot (the_exit, map, ix, iy); |
215 | } |
218 | } |
216 | |
219 | |
217 | ix += freearr_x[i]; |
220 | ix += freearr_x[i]; |
218 | iy += freearr_y[i]; |
221 | iy += freearr_y[i]; |
… | |
… | |
296 | { |
299 | { |
297 | special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); |
300 | special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); |
298 | if (special_map == NULL) |
301 | if (special_map == NULL) |
299 | return; |
302 | return; |
300 | |
303 | |
301 | if (find_spot_for_submap (map, layout, &ix, &iy, MAP_WIDTH (special_map), MAP_HEIGHT (special_map))) |
304 | if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height)) |
302 | include_map_in_map (map, special_map, ix, iy); |
305 | include_map_in_map (map, special_map, ix, iy); |
303 | break; |
306 | break; |
304 | } |
307 | } |
305 | |
308 | |
306 | /* Make a special fountain: an unpickable potion disguised as |
309 | /* Make a special fountain: an unpickable potion disguised as |