ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/server/random_maps/random_map.C
Revision: 1.59
Committed: Thu Jul 1 01:22:44 2010 UTC (16 years, 3 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.58: +65 -71 lines
Log Message:
got rid of Layout, better memory management etc.

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.59 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.59 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 root 1.59 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.59 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.59 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.59 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.59 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.59 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.59 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.59 /* need to run the isolation remover for some layouts */
215     switch (RP->map_layout_style)
216     {
217     case LAYOUT_ONION:
218     case LAYOUT_SNAKE:
219     case LAYOUT_SQUARE_SPIRAL:
220     // safe
221     break;
222    
223     default:
224     sym_layout.isolation_remover ();
225     break;
226     }
227    
228 root 1.34 layout.swap (sym_layout);
229 elmex 1.1 }
230    
231     /* takes a map and rotates it. This completes the
232     onion layouts, making them possibly centered on any wall.
233     It'll modify Xsize and Ysize if they're swapped.
234     */
235 root 1.33 static void
236 root 1.59 rotate_layout (Layout &layout, int rotation)
237 root 1.3 {
238 root 1.59 int w = layout.w;
239     int h = layout.h;
240 root 1.34
241 root 1.3 switch (rotation)
242     {
243 root 1.13 case 2: /* a reflection */
244 root 1.11 {
245 root 1.59 Layout new_layout (w, h);
246 root 1.32
247 root 1.34 for (int i = 0; i < w; i++) /* copy a reflection back */
248     for (int j = 0; j < h; j++)
249     new_layout[i][j] = layout[w - i - 1][h - j - 1];
250 root 1.11
251 root 1.59 layout.swap (new_layout);
252 root 1.11 }
253 root 1.34 break;
254 root 1.32
255 root 1.11 case 1:
256     case 3:
257     {
258 root 1.59 Layout new_layout (h, w);
259 root 1.32
260 root 1.13 if (rotation == 1) /* swap x and y */
261 root 1.34 for (int i = 0; i < w; i++)
262     for (int j = 0; j < h; j++)
263     new_layout[j][i] = layout[i][j];
264 root 1.3
265 root 1.32 if (rotation == 3) /* swap x and y */
266 root 1.34 for (int i = 0; i < w; i++)
267     for (int j = 0; j < h; j++)
268     new_layout[j][i] = layout[w - i - 1][h - j - 1];
269 root 1.33
270 root 1.59 layout.swap (new_layout);
271 root 1.11 }
272 root 1.34 break;
273 elmex 1.1 }
274     }
275    
276     /* checks the layout to see if I can stick a horizontal(dir = 0) wall
277     (or vertical, dir == 1)
278     here which ends up on other walls sensibly. */
279 root 1.44 static int
280 root 1.13 can_make_wall (char **maze, int dx, int dy, int dir, random_map_params *RP)
281 root 1.3 {
282 elmex 1.1 int i1;
283 root 1.3 int length = 0;
284 elmex 1.1
285     /* dont make walls if we're on the edge. */
286 root 1.3 if (dx == 0 || dx == (RP->Xsize - 1) || dy == 0 || dy == (RP->Ysize - 1))
287     return -1;
288 elmex 1.1
289     /* don't make walls if we're ON a wall. */
290 root 1.3 if (maze[dx][dy] != 0)
291     return -1;
292 elmex 1.1
293 root 1.3 if (dir == 0) /* horizontal */
294 elmex 1.1 {
295     int y = dy;
296 root 1.3
297     for (i1 = dx - 1; i1 > 0; i1--)
298     {
299     int sindex = surround_flag2 (maze, i1, y, RP);
300    
301     if (sindex == 1)
302     break;
303     if (sindex != 0)
304     return -1; /* can't make horiz. wall here */
305     if (maze[i1][y] != 0)
306     return -1; /* can't make horiz. wall here */
307     length++;
308     }
309    
310     for (i1 = dx + 1; i1 < RP->Xsize - 1; i1++)
311     {
312     int sindex = surround_flag2 (maze, i1, y, RP);
313    
314     if (sindex == 2)
315     break;
316     if (sindex != 0)
317     return -1; /* can't make horiz. wall here */
318     if (maze[i1][y] != 0)
319     return -1; /* can't make horiz. wall here */
320     length++;
321     }
322 elmex 1.1 return length;
323     }
324 root 1.3 else
325     { /* vertical */
326     int x = dx;
327    
328     for (i1 = dy - 1; i1 > 0; i1--)
329     {
330     int sindex = surround_flag2 (maze, x, i1, RP);
331    
332     if (sindex == 4)
333     break;
334     if (sindex != 0)
335     return -1; /* can't make vert. wall here */
336     if (maze[x][i1] != 0)
337     return -1; /* can't make horiz. wall here */
338     length++;
339     }
340    
341     for (i1 = dy + 1; i1 < RP->Ysize - 1; i1++)
342     {
343 root 1.43 int sindex = surround_flag2 (maze, x, i1, RP);
344    
345     if (sindex == 8)
346     break;
347     if (sindex != 0)
348     return -1; /* can't make verti. wall here */
349     if (maze[x][i1] != 0)
350     return -1; /* can't make horiz. wall here */
351     length++;
352     }
353    
354     return length;
355     }
356    
357     return -1;
358     }
359    
360     /* take a layout and make some rooms in it.
361     --works best on onions.*/
362 root 1.44 static void
363 root 1.43 roomify_layout (char **maze, random_map_params *RP)
364     {
365     int tries = RP->Xsize * RP->Ysize / 30;
366    
367 root 1.50 for (int ti = 0; ti < tries; ti++)
368 root 1.43 {
369 root 1.50 /* starting location for looking at creating a door */
370     int dx = rmg_rndm (RP->Xsize);
371     int dy = rmg_rndm (RP->Ysize);
372    
373     /* results of checking on creating walls. */
374     int cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */
375     int cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */
376 root 1.43
377     if (cx == -1)
378     {
379     if (cy != -1)
380     make_wall (maze, dx, dy, 1);
381    
382     continue;
383     }
384    
385     if (cy == -1)
386     {
387     make_wall (maze, dx, dy, 0);
388     continue;
389     }
390 root 1.3
391 root 1.43 if (cx < cy)
392     make_wall (maze, dx, dy, 0);
393     else
394     make_wall (maze, dx, dy, 1);
395 elmex 1.1 }
396     }
397    
398 root 1.3 int
399     make_wall (char **maze, int x, int y, int dir)
400     {
401     maze[x][y] = 'D'; /* mark a door */
402 root 1.50
403 root 1.3 switch (dir)
404 elmex 1.1 {
405 root 1.13 case 0: /* horizontal */
406     {
407 root 1.50 for (int i1 = x - 1; maze[i1][y] == 0; --i1) maze[i1][y] = '#';
408     for (int i1 = x + 1; maze[i1][y] == 0; ++i1) maze[i1][y] = '#';
409 root 1.13 break;
410     }
411     case 1: /* vertical */
412     {
413 root 1.50 for (int i1 = y - 1; maze[x][i1] == 0; --i1) maze[x][i1] = '#';
414     for (int i1 = y + 1; maze[x][i1] == 0; ++i1) maze[x][i1] = '#';
415 root 1.13 break;
416     }
417 elmex 1.1 }
418    
419     return 0;
420     }
421    
422     /* puts doors at appropriate locations in a layout. */
423 root 1.44 static void
424 root 1.13 doorify_layout (char **maze, random_map_params *RP)
425 root 1.3 {
426     int ndoors = RP->Xsize * RP->Ysize / 60; /* reasonable number of doors. */
427     int doorlocs = 0; /* # of available doorlocations */
428    
429 root 1.41 uint16 *doorlist_x = salloc<uint16> (RP->Xsize * RP->Ysize);
430     uint16 *doorlist_y = salloc<uint16> (RP->Xsize * RP->Ysize);
431 elmex 1.1
432     /* make a list of possible door locations */
433 root 1.41 for (int i = 1; i < RP->Xsize - 1; i++)
434     for (int j = 1; j < RP->Ysize - 1; j++)
435 root 1.3 {
436     int sindex = surround_flag (maze, i, j, RP);
437    
438     if (sindex == 3 || sindex == 12) /* these are possible door sindex */
439     {
440     doorlist_x[doorlocs] = i;
441     doorlist_y[doorlocs] = j;
442     doorlocs++;
443     }
444     }
445 root 1.12
446 root 1.3 while (ndoors > 0 && doorlocs > 0)
447     {
448 root 1.41 int di = rmg_rndm (doorlocs);
449     int i = doorlist_x[di];
450     int j = doorlist_y[di];
451     int sindex = surround_flag (maze, i, j, RP);
452 root 1.27
453 root 1.3 if (sindex == 3 || sindex == 12) /* these are possible door sindex */
454     {
455     maze[i][j] = 'D';
456     ndoors--;
457 elmex 1.1 }
458 root 1.27
459 root 1.3 /* reduce the size of the list */
460     doorlocs--;
461     doorlist_x[di] = doorlist_x[doorlocs];
462     doorlist_y[di] = doorlist_y[doorlocs];
463 elmex 1.1 }
464 root 1.12
465 root 1.32 sfree (doorlist_x, RP->Xsize * RP->Ysize);
466     sfree (doorlist_y, RP->Xsize * RP->Ysize);
467 elmex 1.1 }
468    
469 root 1.43 /* function selects the layout function and gives it whatever
470     arguments it needs. */
471 root 1.59 void
472     Layout::generate (random_map_params *RP)
473 root 1.43 {
474     switch (RP->map_layout_style)
475     {
476     case LAYOUT_ONION:
477 root 1.59 map_gen_onion (*this, RP->layoutoptions1, RP->layoutoptions2);
478 root 1.43
479 root 1.50 if (!(rmg_rndm (3)) && !(RP->layoutoptions1 & (RMOPT_WALLS_ONLY | RMOPT_WALL_OFF)))
480 root 1.59 roomify_layout (*this, RP);
481 root 1.43
482     break;
483    
484     case LAYOUT_MAZE:
485 root 1.59 maze_gen (*this, RP->get_iv ("maze_type", rmg_rndm (4)));
486 root 1.43
487     if (!(rmg_rndm (2)))
488 root 1.59 doorify_layout (*this, RP);
489 root 1.43
490     break;
491    
492     case LAYOUT_SPIRAL:
493 root 1.59 map_gen_spiral (*this, RP->layoutoptions1);
494 root 1.43
495     if (!(rmg_rndm (2)))
496 root 1.59 doorify_layout (*this, RP);
497 root 1.43
498     break;
499    
500     case LAYOUT_ROGUELIKE:
501     /* Don't put symmetry in rogue maps. There isn't much reason to
502     * do so in the first place (doesn't make it any more interesting),
503     * but more importantly, the symmetry code presumes we are symmetrizing
504     * spirals, or maps with lots of passages - making a symmetric rogue
505     * map fails because its likely that the passages the symmetry process
506     * creates may not connect the rooms.
507     */
508     RP->symmetry_used = SYMMETRY_NONE;
509 root 1.59 roguelike_layout_gen (*this, RP->layoutoptions1);
510 root 1.43 /* no doorifying... done already */
511     break;
512    
513     case LAYOUT_SNAKE:
514 root 1.59 make_snake_layout (*this, RP->layoutoptions1);
515 root 1.43
516     if (rmg_rndm (2))
517 root 1.59 roomify_layout (*this, RP);
518 root 1.43
519     break;
520    
521     case LAYOUT_SQUARE_SPIRAL:
522 root 1.59 make_square_spiral_layout (*this, RP->layoutoptions1);
523 root 1.43
524     if (rmg_rndm (2))
525 root 1.59 roomify_layout (*this, RP);
526 root 1.43
527     break;
528    
529 root 1.57 case LAYOUT_CAVE:
530 root 1.59 gen_cave (RP->get_iv ("cave_type", rmg_rndm (4)));
531 root 1.57
532     if (!(rmg_rndm (2)))
533 root 1.59 doorify_layout (*this, RP);
534 root 1.57
535     break;
536    
537 root 1.43 default:
538     abort ();
539     }
540    
541     /* rotate the layout randomly */
542 root 1.59 rotate_layout (*this, rmg_rndm (4));
543 root 1.43
544 root 1.59 symmetrize_layout (*this, RP);
545 root 1.58
546 root 1.59 #if 0
547     print ();//D
548 root 1.43 #endif
549    
550     if (RP->expand2x)
551 root 1.59 expand2x (*this);
552 root 1.43 }
553    
554     bool
555     maptile::generate_random_map (random_map_params *RP)
556     {
557     RP->Xsize = RP->xsize;
558     RP->Ysize = RP->ysize;
559    
560     /* pick a random seed, or use the one from the input file */
561     RP->random_seed = RP->random_seed
562     ? RP->random_seed + RP->dungeon_level
563     : time (0);
564    
565     // we run "single-threaded"
566     rmg_rndm.seed (RP->random_seed);
567    
568 root 1.55 shstr buf = RP->as_shstr ();
569 root 1.43
570     if (RP->difficulty == 0)
571     {
572     RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */
573    
574     if (RP->difficulty_increase > 0.001)
575     RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase);
576    
577     if (RP->difficulty < 1)
578     RP->difficulty = 1;
579     }
580     else
581     RP->difficulty_given = 1;
582    
583     if (RP->Xsize < MIN_RANDOM_MAP_SIZE)
584     RP->Xsize = MIN_RANDOM_MAP_SIZE + rmg_rndm (25) + 5;
585    
586     if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
587     RP->Ysize = MIN_RANDOM_MAP_SIZE + rmg_rndm (25) + 5;
588    
589 root 1.58 min_it (RP->Xsize, MAX_RANDOM_MAP_SIZE);
590     min_it (RP->Ysize, MAX_RANDOM_MAP_SIZE);
591    
592 root 1.43 if (RP->symmetry == SYMMETRY_RANDOM)
593     RP->symmetry_used = rmg_rndm (SYMMETRY_XY) + 1;
594     else
595     RP->symmetry_used = RP->symmetry;
596    
597     if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY)
598     RP->Ysize = RP->Ysize / 2 + 1;
599    
600     if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY)
601     RP->Xsize = RP->Xsize / 2 + 1;
602    
603     if (RP->expand2x > 0)
604     {
605     RP->Xsize /= 2;
606     RP->Ysize /= 2;
607     }
608    
609     if (strstr (RP->layoutstyle, "onion"))
610     RP->map_layout_style = LAYOUT_ONION;
611     else if (strstr (RP->layoutstyle, "maze"))
612     RP->map_layout_style = LAYOUT_MAZE;
613     else if (strstr (RP->layoutstyle, "spiral"))
614     RP->map_layout_style = LAYOUT_SPIRAL;
615     else if (strstr (RP->layoutstyle, "rogue"))
616     RP->map_layout_style = LAYOUT_ROGUELIKE;
617     else if (strstr (RP->layoutstyle, "snake"))
618     RP->map_layout_style = LAYOUT_SNAKE;
619     else if (strstr (RP->layoutstyle, "squarespiral"))
620     RP->map_layout_style = LAYOUT_SQUARE_SPIRAL;
621 root 1.57 else if (strstr (RP->layoutstyle, "cave"))
622     RP->map_layout_style = LAYOUT_CAVE;
623 root 1.43 else
624 root 1.59 RP->map_layout_style = rmg_rndm (NROFLAYOUTS - 1) + 1; /* No style found - choose one randomly */
625 root 1.43
626 root 1.59 Layout layout (RP->Xsize, RP->Ysize);
627     layout.generate (RP);
628 root 1.43
629     /* increment these for the current map */
630     ++RP->dungeon_level;
631    
632     // need to patch RP becasue following code doesn't use the Layout object
633 root 1.59 RP->Xsize = layout.w;
634     RP->Ysize = layout.h;
635 root 1.43
636     /* allocate the map and set the floor */
637 root 1.51 make_map_floor (layout, RP->get_str ("floorstyle", ""), RP);
638 root 1.43
639     /* set region */
640     default_region = RP->region;
641    
642     CEDE;
643    
644     place_specials_in_map (this, layout, RP);
645    
646     CEDE;
647    
648 root 1.51 const char *wallstyle = RP->get_str ("wallstyle", 0);
649    
650 root 1.43 /* create walls unless the wallstyle is "none" */
651 root 1.51 if (strcmp (wallstyle, "none"))
652 root 1.43 {
653 root 1.51 make_map_walls (this, layout, wallstyle, RP->get_str ("miningstyle", ""), RP);
654 root 1.43
655     /* place doors unless doorstyle or wallstyle is "none" */
656     if (strcmp (RP->doorstyle, "none"))
657     put_doors (this, layout, RP->doorstyle, RP);
658     }
659    
660     CEDE;
661    
662 root 1.51 const char *exitstyle = RP->get_str ("exitstyle", "");
663    
664 root 1.43 /* create exits unless the exitstyle is "none" */
665 root 1.51 if (strcmp (exitstyle, "none"))
666     place_exits (this, layout, exitstyle, RP->orientation, RP);
667 root 1.43
668     CEDE;
669    
670     /* create monsters unless the monsterstyle is "none" */
671     if (strcmp (RP->monsterstyle, "none"))
672     place_monsters (this, RP->monsterstyle, RP->difficulty, RP);
673    
674     CEDE;
675    
676     /* treasures needs to have a proper difficulty set for the map. */
677     difficulty = estimate_difficulty ();
678    
679     CEDE;
680    
681 root 1.55 const char *treasurestyle = RP->get_str ("treasurestyle", "");
682    
683 root 1.43 /* create treasure unless the treasurestyle is "none" */
684 root 1.55 place_treasure (this, layout, treasurestyle, RP->get_iv ("treasureoptions"), RP);
685 root 1.43
686     CEDE;
687    
688 root 1.55 const char *decorstyle = RP->get_str ("treasurestyle", "");
689    
690 root 1.43 /* create decor unless the decorstyle is "none" */
691 root 1.55 if (strcmp (decorstyle, "none"))
692     put_decor (this, layout, decorstyle, RP->get_iv ("decoroptions"), RP);
693 root 1.43
694     CEDE;
695    
696     /* generate treasures, etc. */
697     fix_auto_apply ();
698    
699     CEDE;
700    
701     unblock_exits (this, layout, RP);
702    
703 root 1.51 msg = buf;
704 root 1.43 in_memory = MAP_ACTIVE;
705    
706     CEDE;
707    
708     return 1;
709     }
710