OSDN Git Service

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