… | |
… | |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <random_map.h> |
25 | #include <random_map.h> |
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | #include <rproto.h> |
27 | #include <rproto.h> |
28 | |
|
|
29 | |
28 | |
30 | /* find a character in the layout. fx and fy are pointers to |
29 | /* find a character in the layout. fx and fy are pointers to |
31 | where to find the char. fx,fy = -1 if not found. */ |
30 | where to find the char. fx,fy = -1 if not found. */ |
32 | void |
31 | void |
33 | find_in_layout (int mode, char target, int *fx, int *fy, char **layout, random_map_params * RP) |
32 | find_in_layout (int mode, char target, int *fx, int *fy, char **layout, random_map_params * RP) |
… | |
… | |
140 | if (orientation == 0) |
139 | if (orientation == 0) |
141 | orientation = RANDOM () % 6 + 1; |
140 | orientation = RANDOM () % 6 + 1; |
142 | |
141 | |
143 | switch (orientation) |
142 | switch (orientation) |
144 | { |
143 | { |
145 | case 1: |
144 | case 1: |
146 | { |
145 | { |
147 | sprintf (styledirname, "/styles/exitstyles/up"); |
146 | sprintf (styledirname, "/styles/exitstyles/up"); |
148 | style_map_up = find_style (styledirname, exitstyle, -1); |
147 | style_map_up = find_style (styledirname, exitstyle, -1); |
149 | sprintf (styledirname, "/styles/exitstyles/down"); |
148 | sprintf (styledirname, "/styles/exitstyles/down"); |
150 | style_map_down = find_style (styledirname, exitstyle, -1); |
149 | style_map_down = find_style (styledirname, exitstyle, -1); |
151 | break; |
150 | break; |
152 | } |
151 | } |
|
|
152 | |
153 | case 2: |
153 | case 2: |
154 | { |
154 | { |
155 | sprintf (styledirname, "/styles/exitstyles/down"); |
155 | sprintf (styledirname, "/styles/exitstyles/down"); |
156 | style_map_up = find_style (styledirname, exitstyle, -1); |
156 | style_map_up = find_style (styledirname, exitstyle, -1); |
157 | sprintf (styledirname, "/styles/exitstyles/up"); |
157 | sprintf (styledirname, "/styles/exitstyles/up"); |
158 | style_map_down = find_style (styledirname, exitstyle, -1); |
158 | style_map_down = find_style (styledirname, exitstyle, -1); |
159 | break; |
159 | break; |
160 | } |
160 | } |
|
|
161 | |
161 | default: |
162 | default: |
162 | { |
163 | { |
163 | sprintf (styledirname, "/styles/exitstyles/generic"); |
164 | sprintf (styledirname, "/styles/exitstyles/generic"); |
164 | style_map_up = find_style (styledirname, exitstyle, -1); |
165 | style_map_up = find_style (styledirname, exitstyle, -1); |
165 | style_map_down = style_map_up; |
166 | style_map_down = style_map_up; |
166 | break; |
167 | break; |
167 | } |
168 | } |
168 | } |
169 | } |
|
|
170 | |
169 | if (style_map_up == 0) |
171 | if (style_map_up == 0) |
170 | the_exit_up = arch_to_object (archetype::find ("exit")); |
172 | the_exit_up = arch_to_object (archetype::find ("exit")); |
171 | else |
173 | else |
172 | { |
174 | { |
173 | object *tmp; |
175 | object *tmp; |
… | |
… | |
191 | the_exit_down = 0; |
193 | the_exit_down = 0; |
192 | |
194 | |
193 | /* set up the up exit */ |
195 | /* set up the up exit */ |
194 | the_exit_up->stats.hp = RP->origin_x; |
196 | the_exit_up->stats.hp = RP->origin_x; |
195 | the_exit_up->stats.sp = RP->origin_y; |
197 | the_exit_up->stats.sp = RP->origin_y; |
196 | the_exit_up->slaying = RP->origin_map; |
198 | the_exit_up->slaying = RP->origin_map; |
197 | |
199 | |
198 | /* figure out where to put the entrance */ |
200 | /* figure out where to put the entrance */ |
199 | /* begin a logical block */ |
201 | /* begin a logical block */ |
200 | { |
202 | { |
201 | int i, j; |
203 | int i, j; |
… | |
… | |
325 | /* give the final map a name */ |
327 | /* give the final map a name */ |
326 | sprintf (new_map_name, "%sfinal_map", RP->final_map); |
328 | sprintf (new_map_name, "%sfinal_map", RP->final_map); |
327 | /* set the exit down. */ |
329 | /* set the exit down. */ |
328 | #endif |
330 | #endif |
329 | /* load it */ |
331 | /* load it */ |
330 | if (!(new_map = maptile::find_map (RP->final_map, 0))) |
332 | if (!(new_map = maptile::load_map_sync (RP->final_map))) |
331 | return; |
333 | return; |
332 | |
|
|
333 | new_map->load (); |
|
|
334 | |
334 | |
335 | the_exit_down->slaying = RP->final_map; |
335 | the_exit_down->slaying = RP->final_map; |
336 | |
336 | |
337 | for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above) |
337 | for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above) |
338 | /* Remove exit back to previous random map. There should only be one |
338 | /* Remove exit back to previous random map. There should only be one |