OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.git] / src / rooms-fractal.c
1 #include "angband.h"
2 #include "grid.h"
3 #include "generate.h"
4 #include "rooms.h"
5 #include "rooms-normal.h"
6
7 /*!
8 * @brief タイプ9の部屋…フラクタルカーブによる洞窟生成 / Type 9 -- Driver routine to create fractal cave system
9 * @return なし
10 */
11 bool build_type9(void)
12 {
13         int grd, roug, cutoff;
14         POSITION xsize, ysize, y0, x0;
15
16         bool done, light, room;
17
18         /* get size: note 'Evenness'*/
19         xsize = randint1(22) * 2 + 6;
20         ysize = randint1(15) * 2 + 6;
21
22         /* Find and reserve some space in the dungeon.  Get center of room. */
23         if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
24         {
25                 /* Limit to the minimum room size, and retry */
26                 xsize = 8;
27                 ysize = 8;
28
29                 /* Find and reserve some space in the dungeon.  Get center of room. */
30                 if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
31                 {
32                         /*
33                         * Still no space?!
34                         * Try normal room
35                         */
36                         return build_type1();
37                 }
38         }
39
40         light = done = FALSE;
41         room = TRUE;
42
43         if ((dun_level <= randint1(25)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) light = TRUE;
44
45         while (!done)
46         {
47                 /* Note: size must be even or there are rounding problems
48                 * This causes the tunnels not to connect properly to the room */
49
50                 /* testing values for these parameters feel free to adjust */
51                 grd = 1 << (randint0(4));
52
53                 /* want average of about 16 */
54                 roug = randint1(8) * randint1(4);
55
56                 /* about size/2 */
57                 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
58                         randint1(xsize / 4) + randint1(ysize / 4);
59
60                 /* make it */
61                 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
62
63                 /* Convert to normal format + clean up */
64                 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
65         }
66
67         return TRUE;
68 }