ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/server/random_maps/random_map.C
Revision: 1.58
Committed: Wed Jun 30 23:15:56 2010 UTC (16 years, 3 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.57: +15 -18 lines
Log Message:
temp check-in

File Contents

# User Rev Content
1 elmex 1.1 /*
2 root 1.31 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 pippijn 1.20 *
4 root 1.47 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.46 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992 Frank Tore Johansen
7 pippijn 1.20 *
8 root 1.42 * Deliantra is free software: you can redistribute it and/or modify it under
9     * the terms of the Affero GNU General Public License as published by the
10     * Free Software Foundation, either version 3 of the License, or (at your
11     * option) any later version.
12 pippijn 1.20 *
13     * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 root 1.30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 pippijn 1.20 * GNU General Public License for more details.
17     *
18 root 1.42 * You should have received a copy of the Affero GNU General Public License
19     * and the GNU General Public License along with this program. If not, see
20     * <http://www.gnu.org/licenses/>.
21 root 1.30 *
22 root 1.31 * The authors can be reached via e-mail to <support@deliantra.net>
23 pippijn 1.20 */
24 elmex 1.1
25     #include <time.h>
26     #include <stdio.h>
27     #include <global.h>
28     #include <random_map.h>
29     #include <rproto.h>
30     #include <sproto.h>
31    
32 root 1.39 #define CEDE coroapi::cede_to_tick ()
33 root 1.22
34 root 1.34 static void symmetrize_layout (Layout maze, random_map_params *RP);
35     static void rotate_layout (Layout maze, int rotation);
36 root 1.33
37 root 1.55 noinline SV *
38     random_map_params::get_sv (const char *option) const
39 root 1.51 {
40     SV **he = hv_fetch (hv, option, strlen (option), 0);
41    
42 root 1.55 return he ? *he : 0;
43 root 1.51 }
44    
45 root 1.55 noinline const_utf8_string
46     random_map_params::get_str (const char *option, const_utf8_string fallback) const
47     {
48     SV *sv = get_sv (option);
49     return sv ? cfSvPVutf8_nolen (sv) : fallback;
50     }
51    
52     noinline IV
53 root 1.51 random_map_params::get_iv (const char *option, IV fallback) const
54     {
55 root 1.55 SV *sv = get_sv (option);
56     return sv ? SvIV (sv) : fallback;
57     }
58    
59     noinline UV
60     random_map_params::get_uv (const char *option, UV fallback) const
61     {
62     SV *sv = get_sv (option);
63     return sv ? SvUV (sv) : fallback;
64     }
65    
66     noinline NV
67     random_map_params::get_nv (const char *option, NV fallback) const
68     {
69     SV *sv = get_sv (option);
70     return sv ? SvNV (sv) : fallback;
71     }
72    
73     noinline void
74     random_map_params::set (const char *option, SV *value) const
75     {
76     int len = strlen (option);
77    
78     if (value)
79     hv_store (hv, option, len, value, 0);
80     else
81     hv_delete (hv, option, len, G_DISCARD);
82     }
83    
84     noinline void
85     random_map_params::set (const char *option, const_utf8_string value) const
86     {
87     set (option, value && *value ? newSVpvn_utf8 (value, strlen (value), 1) : 0);
88     }
89    
90     void
91     random_map_params::set (const char *option, IV value) const
92     {
93     set (option, newSViv (value));
94     }
95    
96     void
97     random_map_params::set (const char *option, UV value) const
98     {
99     set (option, newSVuv (value));
100     }
101    
102     void
103     random_map_params::set (const char *option, NV value) const
104     {
105     set (option, newSVnv (value));
106     }
107    
108     void
109     random_map_params::hv_clone ()
110     {
111     HV *copy = newHV ();
112    
113     hv_iterinit (hv);
114    
115     // does not work for utf-8 keys
116     while (HE *he = hv_iternext (hv))
117     {
118     STRLEN klen; const char *key = HePV (he, klen);
119     hv_store (copy, key, klen, newSVsv (HeVAL (he)), HeHASH (he));
120     }
121    
122     SvREFCNT_dec (hv);
123     hv = copy;
124     }
125    
126     shstr_tmp
127     random_map_params::as_shstr () const
128     {
129     set ("xsize" , xsize);
130     set ("ysize" , ysize);
131     set ("monsterstyle" , monsterstyle);
132     set ("exit_on_final_map" , exit_on_final_map);
133     set ("layoutstyle" , layoutstyle);
134     set ("doorstyle" , doorstyle);
135     set ("final_map" , final_map);
136     set ("this_map" , this_map);
137     set ("expand2x" , expand2x);
138     set ("layoutoptions1" , layoutoptions1);
139     set ("layoutoptions2" , layoutoptions2);
140     set ("layoutoptions3" , layoutoptions3);
141     set ("symmetry" , symmetry);
142     set ("dungeon_depth" , dungeon_depth);
143     set ("orientation" , orientation);
144     set ("origin_x" , origin_x);
145     set ("origin_y" , origin_y);
146     set ("random_seed" , (UV)random_seed);
147     set ("difficulty" , difficulty && difficulty_given ? difficulty : 0);
148     set ("difficulty_increase", difficulty_increase);
149     set ("dungeon_level" , dungeon_level);
150    
151     dynbuf_text buf;
152     hv_iterinit (hv);
153    
154     // does not work for utf-8 keys
155     while (HE *he = hv_iternext (hv))
156     {
157     STRLEN klen; const char *key = HePV (he, klen);
158     STRLEN vlen; const char *value = SvPVutf8 (HeVAL (he), vlen);
159    
160     buf.fadd (key, klen);
161     buf << ' ';
162     buf.fadd (value, vlen);
163     buf << '\n';
164     }
165 root 1.51
166 root 1.55 return shstr (buf);
167 root 1.51 }
168    
169     random_map_params::~random_map_params ()
170     {
171     SvREFCNT_dec (hv);
172     }
173    
174 root 1.34 /* takes a map and makes it symmetric: adjusts Xsize and
175     * Ysize to produce a symmetric map.
176     */
177 root 1.33 static void
178 root 1.34 symmetrize_layout (Layout layout, random_map_params *RP)
179 root 1.3 {
180 root 1.33 if (RP->symmetry_used == SYMMETRY_NONE)
181     return;
182 root 1.32
183 root 1.34 Layout sym_layout (
184     RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY ? layout->w * 2 - 3 : layout->w,
185     RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY ? layout->h * 2 - 3 : layout->h
186 root 1.33 );
187 root 1.32
188 root 1.33 if (RP->symmetry_used == SYMMETRY_X)
189 root 1.34 for (int i = 0; i < sym_layout->w / 2 + 1; i++)
190     for (int j = 0; j < sym_layout->h; j++)
191 root 1.3 {
192 root 1.34 sym_layout[i ][j] =
193     sym_layout[sym_layout->w - i - 1][j] = layout[i][j];
194 root 1.32 }
195    
196 root 1.33 if (RP->symmetry_used == SYMMETRY_Y)
197 root 1.34 for (int i = 0; i < sym_layout->w; i++)
198     for (int j = 0; j < sym_layout->h / 2 + 1; j++)
199 root 1.3 {
200 root 1.34 sym_layout[i][j ] =
201     sym_layout[i][sym_layout->h - j - 1] = layout[i][j];
202 root 1.3 }
203 root 1.32
204 root 1.33 if (RP->symmetry_used == SYMMETRY_XY)
205 root 1.34 for (int i = 0; i < sym_layout->w / 2 + 1; i++)
206     for (int j = 0; j < sym_layout->h / 2 + 1; j++)
207 root 1.3 {
208 root 1.34 sym_layout[i ][j ] =
209     sym_layout[i ][sym_layout->h - j - 1] =
210     sym_layout[sym_layout->w - i - 1][j ] =
211     sym_layout[sym_layout->w - i - 1][sym_layout->h - j - 1] = layout[i][j];
212 root 1.3 }
213 root 1.32
214 root 1.34 layout.swap (sym_layout);
215     sym_layout.free ();
216 root 1.32
217 elmex 1.1 /* reconnect disjointed spirals */
218 root 1.34 /* reconnect disjointed nethacklayouts: the routine for
219 root 1.3 spirals will do the trick? */
220 root 1.33 if (RP->map_layout_style == LAYOUT_SPIRAL
221     || RP->map_layout_style == LAYOUT_ROGUELIKE)
222 root 1.34 connect_spirals (layout->w, layout->h, RP->symmetry_used, layout);
223 elmex 1.1 }
224    
225     /* takes a map and rotates it. This completes the
226     onion layouts, making them possibly centered on any wall.
227     It'll modify Xsize and Ysize if they're swapped.
228     */
229 root 1.33 static void
230 root 1.34 rotate_layout (Layout layout, int rotation)
231 root 1.3 {
232 root 1.34 int w = layout->w;
233     int h = layout->h;
234    
235 root 1.3 switch (rotation)
236     {
237 root 1.13 case 2: /* a reflection */
238 root 1.11 {
239 root 1.58 LayoutData new_layout (w, h);
240 root 1.32
241 root 1.34 for (int i = 0; i < w; i++) /* copy a reflection back */
242     for (int j = 0; j < h; j++)
243     new_layout[i][j] = layout[w - i - 1][h - j - 1];
244 root 1.11
245 root 1.58 layout->swap (new_layout);
246 root 1.11 }
247 root 1.34 break;
248 root 1.32
249 root 1.11 case 1:
250     case 3:
251     {
252 root 1.58 LayoutData new_layout (h, w);
253 root 1.32
254 root 1.13 if (rotation == 1) /* swap x and y */
255 root 1.34 for (int i = 0; i < w; i++)
256     for (int j = 0; j < h; j++)
257     new_layout[j][i] = layout[i][j];
258 root 1.3
259 root 1.32 if (rotation == 3) /* swap x and y */
260 root 1.34 for (int i = 0; i < w; i++)
261     for (int j = 0; j < h; j++)
262     new_layout[j][i] = layout[w - i - 1][h - j - 1];
263 root 1.33
264 root 1.58 layout->swap (new_layout);
265 root 1.11 }
266 root 1.34 break;
267 elmex 1.1 }
268     }
269    
270     /* checks the layout to see if I can stick a horizontal(dir = 0) wall
271     (or vertical, dir == 1)
272     here which ends up on other walls sensibly. */
273 root 1.44 static int
274 root 1.13 can_make_wall (char **maze, int dx, int dy, int dir, random_map_params *RP)
275 root 1.3 {
276 elmex 1.1 int i1;
277 root 1.3 int length = 0;
278 elmex 1.1
279     /* dont make walls if we're on the edge. */
280 root 1.3 if (dx == 0 || dx == (RP->Xsize - 1) || dy == 0 || dy == (RP->Ysize - 1))
281     return -1;
282 elmex 1.1
283     /* don't make walls if we're ON a wall. */
284 root 1.3 if (maze[dx][dy] != 0)
285     return -1;
286 elmex 1.1
287 root 1.3 if (dir == 0) /* horizontal */
288 elmex 1.1 {
289     int y = dy;
290 root 1.3
291     for (i1 = dx - 1; i1 > 0; i1--)
292     {
293     int sindex = surround_flag2 (maze, i1, y, RP);
294    
295     if (sindex == 1)
296     break;
297     if (sindex != 0)
298     return -1; /* can't make horiz. wall here */
299     if (maze[i1][y] != 0)
300     return -1; /* can't make horiz. wall here */
301     length++;
302     }
303    
304     for (i1 = dx + 1; i1 < RP->Xsize - 1; i1++)
305     {
306     int sindex = surround_flag2 (maze, i1, y, RP);
307    
308     if (sindex == 2)
309     break;
310     if (sindex != 0)
311     return -1; /* can't make horiz. wall here */
312     if (maze[i1][y] != 0)
313     return -1; /* can't make horiz. wall here */
314     length++;
315     }
316 elmex 1.1 return length;
317     }
318 root 1.3 else
319     { /* vertical */
320     int x = dx;
321    
322     for (i1 = dy - 1; i1 > 0; i1--)
323     {
324     int sindex = surround_flag2 (maze, x, i1, RP);
325    
326     if (sindex == 4)
327     break;
328     if (sindex != 0)
329     return -1; /* can't make vert. wall here */
330     if (maze[x][i1] != 0)
331     return -1; /* can't make horiz. wall here */
332     length++;
333     }
334    
335     for (i1 = dy + 1; i1 < RP->Ysize - 1; i1++)
336     {
337 root 1.43 int sindex = surround_flag2 (maze, x, i1, RP);
338    
339     if (sindex == 8)
340     break;
341     if (sindex != 0)
342     return -1; /* can't make verti. wall here */
343     if (maze[x][i1] != 0)
344     return -1; /* can't make horiz. wall here */
345     length++;
346     }
347    
348     return length;
349     }
350    
351     return -1;
352     }
353    
354     /* take a layout and make some rooms in it.
355     --works best on onions.*/
356 root 1.44 static void
357 root 1.43 roomify_layout (char **maze, random_map_params *RP)
358     {
359     int tries = RP->Xsize * RP->Ysize / 30;
360    
361 root 1.50 for (int ti = 0; ti < tries; ti++)
362 root 1.43 {
363 root 1.50 /* starting location for looking at creating a door */
364     int dx = rmg_rndm (RP->Xsize);
365     int dy = rmg_rndm (RP->Ysize);
366    
367     /* results of checking on creating walls. */
368     int cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */
369     int cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */
370 root 1.43
371     if (cx == -1)
372     {
373     if (cy != -1)
374     make_wall (maze, dx, dy, 1);
375    
376     continue;
377     }
378    
379     if (cy == -1)
380     {
381     make_wall (maze, dx, dy, 0);
382     continue;
383     }
384 root 1.3
385 root 1.43 if (cx < cy)
386     make_wall (maze, dx, dy, 0);
387     else
388     make_wall (maze, dx, dy, 1);
389 elmex 1.1 }
390     }
391    
392 root 1.3 int
393     make_wall (char **maze, int x, int y, int dir)
394     {
395     maze[x][y] = 'D'; /* mark a door */
396 root 1.50
397 root 1.3 switch (dir)
398 elmex 1.1 {
399 root 1.13 case 0: /* horizontal */
400     {
401 root 1.50 for (int i1 = x - 1; maze[i1][y] == 0; --i1) maze[i1][y] = '#';
402     for (int i1 = x + 1; maze[i1][y] == 0; ++i1) maze[i1][y] = '#';
403 root 1.13 break;
404     }
405     case 1: /* vertical */
406     {
407 root 1.50 for (int i1 = y - 1; maze[x][i1] == 0; --i1) maze[x][i1] = '#';
408     for (int i1 = y + 1; maze[x][i1] == 0; ++i1) maze[x][i1] = '#';
409 root 1.13 break;
410     }
411 elmex 1.1 }
412    
413     return 0;
414     }
415    
416     /* puts doors at appropriate locations in a layout. */
417 root 1.44 static void
418 root 1.13 doorify_layout (char **maze, random_map_params *RP)
419 root 1.3 {
420     int ndoors = RP->Xsize * RP->Ysize / 60; /* reasonable number of doors. */
421     int doorlocs = 0; /* # of available doorlocations */
422    
423 root 1.41 uint16 *doorlist_x = salloc<uint16> (RP->Xsize * RP->Ysize);
424     uint16 *doorlist_y = salloc<uint16> (RP->Xsize * RP->Ysize);
425 elmex 1.1
426     /* make a list of possible door locations */
427 root 1.41 for (int i = 1; i < RP->Xsize - 1; i++)
428     for (int j = 1; j < RP->Ysize - 1; j++)
429 root 1.3 {
430     int sindex = surround_flag (maze, i, j, RP);
431    
432     if (sindex == 3 || sindex == 12) /* these are possible door sindex */
433     {
434     doorlist_x[doorlocs] = i;
435     doorlist_y[doorlocs] = j;
436     doorlocs++;
437     }
438     }
439 root 1.12
440 root 1.3 while (ndoors > 0 && doorlocs > 0)
441     {
442 root 1.41 int di = rmg_rndm (doorlocs);
443     int i = doorlist_x[di];
444     int j = doorlist_y[di];
445     int sindex = surround_flag (maze, i, j, RP);
446 root 1.27
447 root 1.3 if (sindex == 3 || sindex == 12) /* these are possible door sindex */
448     {
449     maze[i][j] = 'D';
450     ndoors--;
451 elmex 1.1 }
452 root 1.27
453 root 1.3 /* reduce the size of the list */
454     doorlocs--;
455     doorlist_x[di] = doorlist_x[doorlocs];
456     doorlist_y[di] = doorlist_y[doorlocs];
457 elmex 1.1 }
458 root 1.12
459 root 1.32 sfree (doorlist_x, RP->Xsize * RP->Ysize);
460     sfree (doorlist_y, RP->Xsize * RP->Ysize);
461 elmex 1.1 }
462    
463 root 1.43 /* function selects the layout function and gives it whatever
464     arguments it needs. */
465 root 1.44 static Layout
466 root 1.43 layoutgen (random_map_params *RP)
467     {
468     Layout layout (RP);
469    
470     switch (RP->map_layout_style)
471     {
472     case LAYOUT_ONION:
473     map_gen_onion (layout, RP->layoutoptions1, RP->layoutoptions2);
474    
475 root 1.50 if (!(rmg_rndm (3)) && !(RP->layoutoptions1 & (RMOPT_WALLS_ONLY | RMOPT_WALL_OFF)))
476 root 1.43 roomify_layout (layout, RP);
477    
478     break;
479    
480     case LAYOUT_MAZE:
481 root 1.54 maze_gen (layout, RP->get_iv ("maze_type", rmg_rndm (4)));
482 root 1.43
483     if (!(rmg_rndm (2)))
484     doorify_layout (layout, RP);
485    
486     break;
487    
488     case LAYOUT_SPIRAL:
489     map_gen_spiral (layout, RP->layoutoptions1);
490    
491     if (!(rmg_rndm (2)))
492     doorify_layout (layout, RP);
493    
494     break;
495    
496     case LAYOUT_ROGUELIKE:
497     /* Don't put symmetry in rogue maps. There isn't much reason to
498     * do so in the first place (doesn't make it any more interesting),
499     * but more importantly, the symmetry code presumes we are symmetrizing
500     * spirals, or maps with lots of passages - making a symmetric rogue
501     * map fails because its likely that the passages the symmetry process
502     * creates may not connect the rooms.
503     */
504     RP->symmetry_used = SYMMETRY_NONE;
505     roguelike_layout_gen (layout, RP->layoutoptions1);
506     /* no doorifying... done already */
507     break;
508    
509     case LAYOUT_SNAKE:
510     make_snake_layout (layout, RP->layoutoptions1);
511    
512     if (rmg_rndm (2))
513     roomify_layout (layout, RP);
514    
515     break;
516    
517     case LAYOUT_SQUARE_SPIRAL:
518     make_square_spiral_layout (layout, RP->layoutoptions1);
519    
520     if (rmg_rndm (2))
521     roomify_layout (layout, RP);
522    
523     break;
524    
525 root 1.57 case LAYOUT_CAVE:
526     layout->gen_cave (RP->get_iv ("cave_type", rmg_rndm (4)));
527    
528     if (!(rmg_rndm (2)))
529     doorify_layout (layout, RP);
530    
531     break;
532    
533 root 1.43 default:
534     abort ();
535     }
536    
537 root 1.58 layout->print ();
538    
539 root 1.43 /* rotate the layout randomly */
540     rotate_layout (layout, rmg_rndm (4));
541    
542 root 1.58 layout->print ();
543    
544 root 1.43 symmetrize_layout (layout, RP);
545    
546 root 1.58 #if 1
547     layout->print ();
548 root 1.43 #endif
549    
550     if (RP->expand2x)
551     expand2x (layout);
552    
553     return layout;
554     }
555    
556     bool
557     maptile::generate_random_map (random_map_params *RP)
558     {
559     RP->Xsize = RP->xsize;
560     RP->Ysize = RP->ysize;
561    
562     /* pick a random seed, or use the one from the input file */
563     RP->random_seed = RP->random_seed
564     ? RP->random_seed + RP->dungeon_level
565     : time (0);
566    
567     // we run "single-threaded"
568     rmg_rndm.seed (RP->random_seed);
569    
570 root 1.55 shstr buf = RP->as_shstr ();
571 root 1.43
572     if (RP->difficulty == 0)
573     {
574     RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */
575    
576     if (RP->difficulty_increase > 0.001)
577     RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase);
578    
579     if (RP->difficulty < 1)
580     RP->difficulty = 1;
581     }
582     else
583     RP->difficulty_given = 1;
584    
585     if (RP->Xsize < MIN_RANDOM_MAP_SIZE)
586     RP->Xsize = MIN_RANDOM_MAP_SIZE + rmg_rndm (25) + 5;
587    
588     if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
589     RP->Ysize = MIN_RANDOM_MAP_SIZE + rmg_rndm (25) + 5;
590    
591 root 1.58 min_it (RP->Xsize, MAX_RANDOM_MAP_SIZE);
592     min_it (RP->Ysize, MAX_RANDOM_MAP_SIZE);
593    
594 root 1.43 if (RP->symmetry == SYMMETRY_RANDOM)
595     RP->symmetry_used = rmg_rndm (SYMMETRY_XY) + 1;
596     else
597     RP->symmetry_used = RP->symmetry;
598    
599     if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY)
600     RP->Ysize = RP->Ysize / 2 + 1;
601    
602     if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY)
603     RP->Xsize = RP->Xsize / 2 + 1;
604    
605     if (RP->expand2x > 0)
606     {
607     RP->Xsize /= 2;
608     RP->Ysize /= 2;
609     }
610    
611     if (strstr (RP->layoutstyle, "onion"))
612     RP->map_layout_style = LAYOUT_ONION;
613     else if (strstr (RP->layoutstyle, "maze"))
614     RP->map_layout_style = LAYOUT_MAZE;
615     else if (strstr (RP->layoutstyle, "spiral"))
616     RP->map_layout_style = LAYOUT_SPIRAL;
617     else if (strstr (RP->layoutstyle, "rogue"))
618     RP->map_layout_style = LAYOUT_ROGUELIKE;
619     else if (strstr (RP->layoutstyle, "snake"))
620     RP->map_layout_style = LAYOUT_SNAKE;
621     else if (strstr (RP->layoutstyle, "squarespiral"))
622     RP->map_layout_style = LAYOUT_SQUARE_SPIRAL;
623 root 1.57 else if (strstr (RP->layoutstyle, "cave"))
624     RP->map_layout_style = LAYOUT_CAVE;
625 root 1.43 else
626 root 1.58 RP->map_layout_style = LAYOUT_CAVE;//D
627     //RP->map_layout_style = rmg_rndm (NROFLAYOUTS - 1) + 1; /* No style found - choose one randomly */
628 root 1.43
629     Layout layout = layoutgen (RP);
630    
631     #ifdef RMAP_DEBUG
632     dump_layout (layout);
633     #endif
634    
635     /* increment these for the current map */
636     ++RP->dungeon_level;
637    
638     // need to patch RP becasue following code doesn't use the Layout object
639     RP->Xsize = layout->w;
640     RP->Ysize = layout->h;
641    
642     /* allocate the map and set the floor */
643 root 1.51 make_map_floor (layout, RP->get_str ("floorstyle", ""), RP);
644 root 1.43
645     /* set region */
646     default_region = RP->region;
647    
648     CEDE;
649    
650     place_specials_in_map (this, layout, RP);
651    
652     CEDE;
653    
654 root 1.51 const char *wallstyle = RP->get_str ("wallstyle", 0);
655    
656 root 1.43 /* create walls unless the wallstyle is "none" */
657 root 1.51 if (strcmp (wallstyle, "none"))
658 root 1.43 {
659 root 1.51 make_map_walls (this, layout, wallstyle, RP->get_str ("miningstyle", ""), RP);
660 root 1.43
661     /* place doors unless doorstyle or wallstyle is "none" */
662     if (strcmp (RP->doorstyle, "none"))
663     put_doors (this, layout, RP->doorstyle, RP);
664     }
665    
666     CEDE;
667    
668 root 1.51 const char *exitstyle = RP->get_str ("exitstyle", "");
669    
670 root 1.43 /* create exits unless the exitstyle is "none" */
671 root 1.51 if (strcmp (exitstyle, "none"))
672     place_exits (this, layout, exitstyle, RP->orientation, RP);
673 root 1.43
674     CEDE;
675    
676     /* create monsters unless the monsterstyle is "none" */
677     if (strcmp (RP->monsterstyle, "none"))
678     place_monsters (this, RP->monsterstyle, RP->difficulty, RP);
679    
680     CEDE;
681    
682     /* treasures needs to have a proper difficulty set for the map. */
683     difficulty = estimate_difficulty ();
684    
685     CEDE;
686    
687 root 1.55 const char *treasurestyle = RP->get_str ("treasurestyle", "");
688    
689 root 1.43 /* create treasure unless the treasurestyle is "none" */
690 root 1.55 place_treasure (this, layout, treasurestyle, RP->get_iv ("treasureoptions"), RP);
691 root 1.43
692     CEDE;
693    
694 root 1.55 const char *decorstyle = RP->get_str ("treasurestyle", "");
695    
696 root 1.43 /* create decor unless the decorstyle is "none" */
697 root 1.55 if (strcmp (decorstyle, "none"))
698     put_decor (this, layout, decorstyle, RP->get_iv ("decoroptions"), RP);
699 root 1.43
700     CEDE;
701    
702     /* generate treasures, etc. */
703     fix_auto_apply ();
704    
705     CEDE;
706    
707     unblock_exits (this, layout, RP);
708    
709 root 1.51 msg = buf;
710 root 1.43 in_memory = MAP_ACTIVE;
711    
712     CEDE;
713    
714     return 1;
715     }
716