OSDN Git Service

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