OSDN Git Service

[Refactor] #40570 Separated dungeon-data-definition.c/h from floor-generate.h and...
authorHourier <hourier@users.sourceforge.jp>
Fri, 24 Jul 2020 03:09:37 +0000 (12:09 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 26 Jul 2020 08:04:20 +0000 (17:04 +0900)
12 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/floor/floor-generate.c
src/floor/floor-generate.h
src/floor/floor-streams.c
src/floor/geometry.h
src/room/room-generator.c
src/room/rooms-vault.c
src/room/rooms.c
src/system/dungeon-data-definition.c [new file with mode: 0644]
src/system/dungeon-data-definition.h [new file with mode: 0644]

index e2aff6c..dd319cc 100644 (file)
     <ClCompile Include="..\..\src\store\purchase-order.c" />\r
     <ClCompile Include="..\..\src\store\sell-order.c" />\r
     <ClCompile Include="..\..\src\store\service-checker.c" />\r
+    <ClCompile Include="..\..\src\system\dungeon-data-definition.c" />\r
     <ClCompile Include="..\..\src\view\display-inventory.c" />\r
     <ClCompile Include="..\..\src\view\display-map.c" />\r
     <ClCompile Include="..\..\src\window\display-sub-window-items.c" />\r
     <ClInclude Include="..\..\src\store\sell-order.h" />\r
     <ClInclude Include="..\..\src\store\service-checker.h" />\r
     <ClInclude Include="..\..\src\system\alloc-entries.h" />\r
+    <ClInclude Include="..\..\src\system\dungeon-data-definition.h" />\r
     <ClInclude Include="..\..\src\system\floor-type-definition.h" />\r
     <ClInclude Include="..\..\src\term\screen-processor.h" />\r
     <ClInclude Include="..\..\src\util\bit-flags-calculator.h" />\r
index 6c1d9f2..bcaca37 100644 (file)
     <ClCompile Include="..\..\src\room\room-generator.c">
       <Filter>room</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\system\dungeon-data-definition.c">
+      <Filter>system</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\room\room-generator.h">
       <Filter>room</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\system\dungeon-data-definition.h">
+      <Filter>system</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 9c85721..a3a7565 100644 (file)
@@ -716,6 +716,7 @@ hengband_SOURCES = \
        system/alloc-entry-definition.h \
        system/angband.h system/angband-version.h \
        system/building-type-definition.c system/building-type-definition.h \
+       system/dungeon-data-definition.c system/dungeon-data-definition.h \
        system/floor-type-definition.h \
        system/game-option-types.h \
        system/h-basic.h system/h-config.h \
index 2dd07b3..f894dbf 100644 (file)
@@ -47,8 +47,9 @@
 #include "monster/monster-util.h"
 #include "player/player-status.h"
 #include "room/lake-types.h"
-#include "room/room-generator.h" // 相互依存、後で消す.
+#include "room/room-generator.h"
 #include "room/rooms.h"
+#include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "system/system-variables.h"
 #include "util/bit-flags-calculator.h"
@@ -64,11 +65,6 @@ int dun_tun_pen;
 int dun_tun_jct;
 
 /*!
- * Dungeon generation data -- see "cave_gen()"
- */
-dun_data *dun;
-
-/*!
  * @brief 上下左右の外壁数をカウントする / Count the number of walls adjacent to the given grid.
  * @param y 基準のy座標
  * @param x 基準のx座標
@@ -410,14 +406,14 @@ static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, player_type *owner_
     floor_type *floor_ptr = owner_ptr->current_floor_ptr;
     /* Possible "destroyed" level */
     if ((floor_ptr->dun_level > 30) && one_in_(DUN_DEST * 2) && (small_levels) && (dungeon_ptr->flags1 & DF1_DESTROY)) {
-        dun->destroyed = TRUE;
+        dun_data->destroyed = TRUE;
 
         /* extra rubble around the place looks cool */
         build_lake(owner_ptr, one_in_(2) ? LAKE_T_CAVE : LAKE_T_EARTH_VAULT);
     }
 
     /* Make a lake some of the time */
-    if (one_in_(LAKE_LEVEL) && !dun->empty_level && !dun->destroyed && (dungeon_ptr->flags1 & DF1_LAKE_MASK)) {
+    if (one_in_(LAKE_LEVEL) && !dun_data->empty_level && !dun_data->destroyed && (dungeon_ptr->flags1 & DF1_LAKE_MASK)) {
         int count = 0;
         if (dungeon_ptr->flags1 & DF1_LAKE_WATER)
             count += 3;
@@ -431,52 +427,52 @@ static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, player_type *owner_
         if (dungeon_ptr->flags1 & DF1_LAKE_LAVA) {
             /* Lake of Lava */
             if ((floor_ptr->dun_level > 80) && (randint0(count) < 2))
-                dun->laketype = LAKE_T_LAVA;
+                dun_data->laketype = LAKE_T_LAVA;
             count -= 2;
 
             /* Lake of Lava2 */
-            if (!dun->laketype && (floor_ptr->dun_level > 80) && one_in_(count))
-                dun->laketype = LAKE_T_FIRE_VAULT;
+            if (!dun_data->laketype && (floor_ptr->dun_level > 80) && one_in_(count))
+                dun_data->laketype = LAKE_T_FIRE_VAULT;
             count--;
         }
 
-        if ((dungeon_ptr->flags1 & DF1_LAKE_WATER) && !dun->laketype) {
+        if ((dungeon_ptr->flags1 & DF1_LAKE_WATER) && !dun_data->laketype) {
             /* Lake of Water */
             if ((floor_ptr->dun_level > 50) && randint0(count) < 2)
-                dun->laketype = LAKE_T_WATER;
+                dun_data->laketype = LAKE_T_WATER;
             count -= 2;
 
             /* Lake of Water2 */
-            if (!dun->laketype && (floor_ptr->dun_level > 50) && one_in_(count))
-                dun->laketype = LAKE_T_WATER_VAULT;
+            if (!dun_data->laketype && (floor_ptr->dun_level > 50) && one_in_(count))
+                dun_data->laketype = LAKE_T_WATER_VAULT;
             count--;
         }
 
-        if ((dungeon_ptr->flags1 & DF1_LAKE_RUBBLE) && !dun->laketype) {
+        if ((dungeon_ptr->flags1 & DF1_LAKE_RUBBLE) && !dun_data->laketype) {
             /* Lake of rubble */
             if ((floor_ptr->dun_level > 35) && (randint0(count) < 2))
-                dun->laketype = LAKE_T_CAVE;
+                dun_data->laketype = LAKE_T_CAVE;
             count -= 2;
 
             /* Lake of rubble2 */
-            if (!dun->laketype && (floor_ptr->dun_level > 35) && one_in_(count))
-                dun->laketype = LAKE_T_EARTH_VAULT;
+            if (!dun_data->laketype && (floor_ptr->dun_level > 35) && one_in_(count))
+                dun_data->laketype = LAKE_T_EARTH_VAULT;
             count--;
         }
 
         /* Lake of tree */
-        if ((floor_ptr->dun_level > 5) && (dungeon_ptr->flags1 & DF1_LAKE_TREE) && !dun->laketype)
-            dun->laketype = LAKE_T_AIR_VAULT;
+        if ((floor_ptr->dun_level > 5) && (dungeon_ptr->flags1 & DF1_LAKE_TREE) && !dun_data->laketype)
+            dun_data->laketype = LAKE_T_AIR_VAULT;
 
-        if (dun->laketype) {
+        if (dun_data->laketype) {
             msg_print_wizard(owner_ptr, CHEAT_DUNGEON, _("湖を生成します。", "Lake on the level."));
-            build_lake(owner_ptr, dun->laketype);
+            build_lake(owner_ptr, dun_data->laketype);
         }
     }
 
-    if ((floor_ptr->dun_level > DUN_CAVERN) && !dun->empty_level && (dungeon_ptr->flags1 & DF1_CAVERN) && !dun->laketype && !dun->destroyed
+    if ((floor_ptr->dun_level > DUN_CAVERN) && !dun_data->empty_level && (dungeon_ptr->flags1 & DF1_CAVERN) && !dun_data->laketype && !dun_data->destroyed
         && (randint1(1000) < floor_ptr->dun_level)) {
-        dun->cavern = TRUE;
+        dun_data->cavern = TRUE;
 
         /* make a large fractal floor_ptr->grid_array in the middle of the dungeon */
 
@@ -486,7 +482,7 @@ static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, player_type *owner_
 
     /* Hack -- No destroyed "quest" levels */
     if (quest_number(owner_ptr, floor_ptr->dun_level))
-        dun->destroyed = FALSE;
+        dun_data->destroyed = FALSE;
 }
 
 static bool has_river_flag(dungeon_type *dungeon_ptr)
@@ -505,7 +501,7 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
 {
     int i, k;
     POSITION y, x;
-    dun_data dun_body;
+    dun_data_type dun_body;
 
     floor_type *floor_ptr = player_ptr->current_floor_ptr;
     dungeon_type *dungeon_ptr = &d_info[floor_ptr->dungeon_idx];
@@ -516,12 +512,12 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
     floor_ptr->view_n = 0;
 
     /* Global data */
-    dun = &dun_body;
+    dun_data = &dun_body;
 
-    dun->destroyed = FALSE;
-    dun->empty_level = FALSE;
-    dun->cavern = FALSE;
-    dun->laketype = 0;
+    dun_data->destroyed = FALSE;
+    dun_data->empty_level = FALSE;
+    dun_data->cavern = FALSE;
+    dun_data->laketype = 0;
 
     /* Fill the arrays of floors and walls in the good proportions */
     set_floor_and_wall(floor_ptr->dungeon_idx);
@@ -535,26 +531,26 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
     dun_tun_jct = rand_range(DUN_TUN_JCT_MIN, DUN_TUN_JCT_MAX);
 
     /* Actual maximum number of rooms on this level */
-    dun->row_rooms = floor_ptr->height / BLOCK_HGT;
-    dun->col_rooms = floor_ptr->width / BLOCK_WID;
+    dun_data->row_rooms = floor_ptr->height / BLOCK_HGT;
+    dun_data->col_rooms = floor_ptr->width / BLOCK_WID;
 
     /* Initialize the room table */
-    for (y = 0; y < dun->row_rooms; y++) {
-        for (x = 0; x < dun->col_rooms; x++) {
-            dun->room_map[y][x] = FALSE;
+    for (y = 0; y < dun_data->row_rooms; y++) {
+        for (x = 0; x < dun_data->col_rooms; x++) {
+            dun_data->room_map[y][x] = FALSE;
         }
     }
 
     /* No rooms yet */
-    dun->cent_n = 0;
+    dun_data->cent_n = 0;
 
     /* Empty arena levels */
     if (ironman_empty_levels || ((dungeon_ptr->flags1 & DF1_ARENA) && (empty_levels && one_in_(EMPTY_LEVEL)))) {
-        dun->empty_level = TRUE;
+        dun_data->empty_level = TRUE;
         msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("アリーナレベルを生成。", "Arena level."));
     }
 
-    if (dun->empty_level) {
+    if (dun_data->empty_level) {
         /* Start with floors */
         for (y = 0; y < floor_ptr->height; y++) {
             for (x = 0; x < floor_ptr->width; x++) {
@@ -621,7 +617,7 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
             }
         }
 
-        if (dun->destroyed) {
+        if (dun_data->destroyed) {
             destroy_level(player_ptr);
         }
 
@@ -630,40 +626,40 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
         }
 
         /* Hack -- Scramble the room order */
-        for (i = 0; i < dun->cent_n; i++) {
+        for (i = 0; i < dun_data->cent_n; i++) {
             POSITION ty, tx;
             int pick = rand_range(0, i);
 
-            ty = dun->cent[i].y;
-            tx = dun->cent[i].x;
-            dun->cent[i].y = dun->cent[pick].y;
-            dun->cent[i].x = dun->cent[pick].x;
-            dun->cent[pick].y = ty;
-            dun->cent[pick].x = tx;
+            ty = dun_data->cent[i].y;
+            tx = dun_data->cent[i].x;
+            dun_data->cent[i].y = dun_data->cent[pick].y;
+            dun_data->cent[i].x = dun_data->cent[pick].x;
+            dun_data->cent[pick].y = ty;
+            dun_data->cent[pick].x = tx;
         }
 
         /* Start with no tunnel doors */
-        dun->door_n = 0;
+        dun_data->door_n = 0;
 
         /* Hack -- connect the first room to the last room */
-        y = dun->cent[dun->cent_n - 1].y;
-        x = dun->cent[dun->cent_n - 1].x;
+        y = dun_data->cent[dun_data->cent_n - 1].y;
+        x = dun_data->cent[dun_data->cent_n - 1].x;
 
         /* Connect all the rooms together */
-        for (i = 0; i < dun->cent_n; i++) {
+        for (i = 0; i < dun_data->cent_n; i++) {
             int j;
 
             /* Reset the arrays */
-            dun->tunn_n = 0;
-            dun->wall_n = 0;
+            dun_data->tunn_n = 0;
+            dun_data->wall_n = 0;
 
             /* Connect the room to the previous room */
             if (randint1(floor_ptr->dun_level) > dungeon_ptr->tunnel_percent) {
                 /* make cavelike tunnel */
-                (void)build_tunnel2(player_ptr, dun->cent[i].x, dun->cent[i].y, x, y, 2, 2);
+                (void)build_tunnel2(player_ptr, dun_data->cent[i].x, dun_data->cent[i].y, x, y, 2, 2);
             } else {
                 /* make normal tunnel */
-                if (!build_tunnel(player_ptr, dun->cent[i].y, dun->cent[i].x, y, x))
+                if (!build_tunnel(player_ptr, dun_data->cent[i].y, dun_data->cent[i].x, y, x))
                     tunnel_fail_count++;
             }
 
@@ -673,11 +669,11 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
             }
 
             /* Turn the tunnel into corridor */
-            for (j = 0; j < dun->tunn_n; j++) {
+            for (j = 0; j < dun_data->tunn_n; j++) {
                 grid_type *g_ptr;
                 feature_type *f_ptr;
-                y = dun->tunn[j].y;
-                x = dun->tunn[j].x;
+                y = dun_data->tunn[j].y;
+                x = dun_data->tunn[j].x;
                 g_ptr = &floor_ptr->grid_array[y][x];
                 f_ptr = &f_info[g_ptr->feat];
 
@@ -691,10 +687,10 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
             }
 
             /* Apply the piercings that we found */
-            for (j = 0; j < dun->wall_n; j++) {
+            for (j = 0; j < dun_data->wall_n; j++) {
                 grid_type *g_ptr;
-                y = dun->wall[j].y;
-                x = dun->wall[j].x;
+                y = dun_data->wall[j].y;
+                x = dun_data->wall[j].x;
                 g_ptr = &floor_ptr->grid_array[y][x];
 
                 /* Clear mimic type */
@@ -711,15 +707,15 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
             }
 
             /* Remember the "previous" room */
-            y = dun->cent[i].y;
-            x = dun->cent[i].x;
+            y = dun_data->cent[i].y;
+            x = dun_data->cent[i].x;
         }
 
         /* Place intersection doors */
-        for (i = 0; i < dun->door_n; i++) {
+        for (i = 0; i < dun_data->door_n; i++) {
             /* Extract junction location */
-            y = dun->door[i].y;
-            x = dun->door[i].x;
+            y = dun_data->door[i].y;
+            x = dun_data->door[i].x;
 
             /* Try placing doors */
             try_door(player_ptr, y, x - 1);
@@ -741,7 +737,7 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
         }
     }
 
-    if (!dun->laketype) {
+    if (!dun_data->laketype) {
         if (dungeon_ptr->stream2) {
             /* Hack -- Add some quartz streamers */
             for (i = 0; i < DUN_STR_QUA; i++) {
@@ -841,7 +837,7 @@ static bool cave_gen(player_type *player_ptr, concptr *why)
         return FALSE;
     }
 
-    bool is_empty_or_dark = dun->empty_level;
+    bool is_empty_or_dark = dun_data->empty_level;
     is_empty_or_dark &= !one_in_(DARK_EMPTY) || (randint1(100) > floor_ptr->dun_level);
     is_empty_or_dark &= (dungeon_ptr->flags1 & DF1_DARKNESS) == 0;
     if (!is_empty_or_dark)
@@ -1477,10 +1473,10 @@ bool build_tunnel(player_type *player_ptr, POSITION row1, POSITION col1, POSITIO
             col1 = tmp_col;
 
             /* Save the wall location */
-            if (dun->wall_n < WALL_MAX) {
-                dun->wall[dun->wall_n].y = row1;
-                dun->wall[dun->wall_n].x = col1;
-                dun->wall_n++;
+            if (dun_data->wall_n < WALL_MAX) {
+                dun_data->wall[dun_data->wall_n].y = row1;
+                dun_data->wall[dun_data->wall_n].x = col1;
+                dun_data->wall_n++;
             } else
                 return FALSE;
 
@@ -1510,10 +1506,10 @@ bool build_tunnel(player_type *player_ptr, POSITION row1, POSITION col1, POSITIO
             col1 = tmp_col;
 
             /* Save the tunnel location */
-            if (dun->tunn_n < TUNN_MAX) {
-                dun->tunn[dun->tunn_n].y = row1;
-                dun->tunn[dun->tunn_n].x = col1;
-                dun->tunn_n++;
+            if (dun_data->tunn_n < TUNN_MAX) {
+                dun_data->tunn[dun_data->tunn_n].y = row1;
+                dun_data->tunn[dun_data->tunn_n].x = col1;
+                dun_data->tunn_n++;
             } else
                 return FALSE;
 
@@ -1530,10 +1526,10 @@ bool build_tunnel(player_type *player_ptr, POSITION row1, POSITION col1, POSITIO
             /* Collect legal door locations */
             if (!door_flag) {
                 /* Save the door location */
-                if (dun->door_n < DOOR_MAX) {
-                    dun->door[dun->door_n].y = row1;
-                    dun->door[dun->door_n].x = col1;
-                    dun->door_n++;
+                if (dun_data->door_n < DOOR_MAX) {
+                    dun_data->door[dun_data->door_n].y = row1;
+                    dun_data->door[dun_data->door_n].x = col1;
+                    dun_data->door_n++;
                 } else
                     return FALSE;
 
@@ -1598,10 +1594,10 @@ static bool set_tunnel(player_type *player_ptr, POSITION *x, POSITION *y, bool a
 
     if (is_extra_bold(floor_ptr, *y, *x)) {
         /* Save the tunnel location */
-        if (dun->tunn_n < TUNN_MAX) {
-            dun->tunn[dun->tunn_n].y = *y;
-            dun->tunn[dun->tunn_n].x = *x;
-            dun->tunn_n++;
+        if (dun_data->tunn_n < TUNN_MAX) {
+            dun_data->tunn[dun_data->tunn_n].y = *y;
+            dun_data->tunn[dun_data->tunn_n].x = *x;
+            dun_data->tunn_n++;
 
             return TRUE;
         } else
@@ -1615,10 +1611,10 @@ static bool set_tunnel(player_type *player_ptr, POSITION *x, POSITION *y, bool a
 
     if (is_outer_grid(g_ptr) && affectwall) {
         /* Save the wall location */
-        if (dun->wall_n < WALL_MAX) {
-            dun->wall[dun->wall_n].y = *y;
-            dun->wall[dun->wall_n].x = *x;
-            dun->wall_n++;
+        if (dun_data->wall_n < WALL_MAX) {
+            dun_data->wall[dun_data->wall_n].y = *y;
+            dun_data->wall[dun_data->wall_n].x = *x;
+            dun_data->wall_n++;
         } else
             return FALSE;
 
@@ -1908,10 +1904,10 @@ bool build_tunnel2(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x
                     retval = FALSE;
 
                     /* Save the door location */
-                    if (dun->door_n < DOOR_MAX) {
-                        dun->door[dun->door_n].y = y3;
-                        dun->door[dun->door_n].x = x3;
-                        dun->door_n++;
+                    if (dun_data->door_n < DOOR_MAX) {
+                        dun_data->door[dun_data->door_n].y = y3;
+                        dun_data->door[dun_data->door_n].x = x3;
+                        dun_data->door_n++;
                     } else
                         return FALSE;
                 }
index 68d19ab..598945d 100644 (file)
@@ -1,16 +1,6 @@
 #pragma once
 
 #include "system/angband.h"
-#include "floor/floor-base-definitions.h"
-#include "floor/geometry.h"
-
-/*!
- * @file generate.h
- * @brief ダンジョン生成処理のヘッダーファイル
- * @date 2014/08/08
- * @author
- * 不明(変愚蛮怒スタッフ?)
- */
 
 #define SAFE_MAX_ATTEMPTS 5000 /*!< 生成処理基本試行回数 */
 
@@ -36,71 +26,9 @@ extern int dun_tun_jct; /*!< ダンジョンの通路交差地点付近にドア
 #define ALLOC_TYP_OBJECT       5       /* Object */
 #define ALLOC_TYP_INVIS                6       /* Invisible wall */
 
-
-
-/*
- * The "size" of a "generation block" in grids
- */
-#define BLOCK_HGT      11
-#define BLOCK_WID      11
-
-/*
- * Maximum numbers of rooms along each axis (currently 6x6)
- */
-#define MAX_ROOMS_ROW  (MAX_HGT / BLOCK_HGT)
-#define MAX_ROOMS_COL  (MAX_WID / BLOCK_WID)
-
-
-/*
- * Bounds on some arrays used in the "dun_data" structure.
- * These bounds are checked, though usually this is a formality.
- */
-#define CENT_MAX       100
-#define DOOR_MAX       200
-#define WALL_MAX       500
-#define TUNN_MAX       900
-
-
-/*
- * Structure to hold all "dungeon generation" data
- */
-typedef struct dun_data {
-       /* Array of centers of rooms */
-       int cent_n;
-       coord cent[CENT_MAX];
-
-       /* Array of possible door locations */
-       int door_n;
-       coord door[DOOR_MAX];
-
-       /* Array of wall piercing locations */
-       int wall_n;
-       coord wall[WALL_MAX];
-
-       /* Array of tunnel grids */
-       int tunn_n;
-       coord tunn[TUNN_MAX];
-
-       /* Number of blocks along each axis */
-       int row_rooms;
-       int col_rooms;
-
-       /* Array of which blocks are used */
-       bool room_map[MAX_ROOMS_ROW][MAX_ROOMS_COL];
-
-       /* Various type of dungeon floors */
-       bool destroyed;
-       bool empty_level;
-       bool cavern;
-       int laketype;
-} dun_data;
-
-extern dun_data *dun;
-
-extern bool place_quest_monsters(player_type *creature_ptr);
-extern void wipe_generate_random_floor_flags(floor_type *floor_ptr);
-extern void clear_cave(player_type *player_ptr);
-extern void generate_floor(player_type *player_ptr);
-
-extern bool build_tunnel(player_type *player_ptr, POSITION row1, POSITION col1, POSITION row2, POSITION col2);
-extern bool build_tunnel2(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type, int cutoff);
+bool place_quest_monsters(player_type *creature_ptr);
+void wipe_generate_random_floor_flags(floor_type *floor_ptr);
+void clear_cave(player_type *player_ptr);
+void generate_floor(player_type *player_ptr);
+bool build_tunnel(player_type *player_ptr, POSITION row1, POSITION col1, POSITION row2, POSITION col2);
+bool build_tunnel2(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type, int cutoff);
index 783d516..16ff767 100644 (file)
@@ -31,9 +31,9 @@
 #include "monster/monster-info.h"
 #include "object-hook/hook-enchant.h"
 #include "room/lake-types.h"
-#include "room/rooms.h"
 #include "spell-kind/spells-floor.h"
 #include "system/artifact-type-definition.h"
+#include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -209,8 +209,8 @@ void add_river(floor_type *floor_ptr)
         feature_type *f_ptr = &f_info[feat1];
 
         /* Only add river if matches lake type or if have no lake at all */
-        if (!(((dun->laketype == LAKE_T_LAVA) && have_flag(f_ptr->flags, FF_LAVA)) || ((dun->laketype == LAKE_T_WATER) && have_flag(f_ptr->flags, FF_WATER))
-                || !dun->laketype)) {
+        if (!(((dun_data->laketype == LAKE_T_LAVA) && have_flag(f_ptr->flags, FF_LAVA)) || ((dun_data->laketype == LAKE_T_WATER) && have_flag(f_ptr->flags, FF_WATER))
+                || !dun_data->laketype)) {
             return;
         }
     }
@@ -251,10 +251,10 @@ void add_river(floor_type *floor_ptr)
     recursive_river(floor_ptr, x1, y1, x2, y2, feat1, feat2, wid);
 
     /* Hack - Save the location as a "room" */
-    if (dun->cent_n < CENT_MAX) {
-        dun->cent[dun->cent_n].y = y2;
-        dun->cent[dun->cent_n].x = x2;
-        dun->cent_n++;
+    if (dun_data->cent_n < CENT_MAX) {
+        dun_data->cent[dun_data->cent_n].y = y2;
+        dun_data->cent[dun_data->cent_n].x = x2;
+        dun_data->cent_n++;
     }
 }
 
index b7877ad..bf019ec 100644 (file)
@@ -39,12 +39,4 @@ typedef struct pos_list {
        POSITION x[TEMP_MAX];
 } pos_list;
 
-/*
- * Simple structure to hold a map location
- */
-typedef struct coord {
-       POSITION y;
-       POSITION x;
-} coord;
-
 bool is_seen(player_type *creature_ptr, monster_type *m_ptr);
index ef178a2..789e5ec 100644 (file)
@@ -1,7 +1,6 @@
 #include "room/room-generator.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
-#include "floor/floor-generate.h" // 相互依存、後で消す.
 #include "game-option/birth-options.h"
 #include "game-option/cheat-types.h"
 #include "grid/grid.h"
@@ -15,6 +14,7 @@
 #include "room/rooms-trap.h"
 #include "room/rooms-vault.h"
 #include "room/rooms.h"
+#include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "wizard/wizard-messages.h"
 
@@ -155,7 +155,7 @@ bool generate_rooms(player_type *player_ptr)
     } else if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_CAVE) {
         /*! @details ダンジョンにCAVEフラグがある場合、NORMALの生成枠がFRACAVEに与えられる。/ CAVE dungeon (Orc floor_ptr->grid_array etc.) */
         move_prob_list(ROOM_T_FRACAVE, ROOM_T_NORMAL, prob_list);
-    } else if (dun->cavern || dun->empty_level) {
+    } else if (dun_data->cavern || dun_data->empty_level) {
         /*! @details ダンジョンの基本地形が最初から渓谷かアリーナ型の場合 FRACAVE は生成から除外。 /  No caves when a (random) cavern exists: they look bad */
         prob_list[ROOM_T_FRACAVE] = 0;
     }
index 69fc6f4..54f074c 100644 (file)
@@ -10,7 +10,6 @@
 #include "floor/cave.h"
 #include "floor/floor-generate.h"
 #include "floor/floor.h"
-#include "floor/geometry.h"
 #include "floor/wild.h"
 #include "game-option/cheat-types.h"
 #include "grid/feature.h"
@@ -24,6 +23,7 @@
 #include "room/rooms.h"
 #include "store/store-util.h"
 #include "store/store.h"
+#include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "wizard/wizard-messages.h"
 
index dcc7d17..d17d39d 100644 (file)
@@ -51,6 +51,7 @@
 #include "object-enchant/item-apply-magic.h"
 #include "room/cave-filler.h"
 #include "room/lake-types.h"
+#include "room/room-generator.h"
 #include "room/room-info-table.h"
 #include "room/rooms-city.h"
 #include "room/rooms-fractal.h"
@@ -59,6 +60,7 @@
 #include "room/rooms-special.h"
 #include "room/rooms-trap.h"
 #include "room/rooms-vault.h"
+#include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -188,7 +190,7 @@ static bool find_space_aux(POSITION blocks_high, POSITION blocks_wide, POSITION
         if ((block_x % 3) != 0)
             return FALSE;
     } else {
-        if (block_x + (blocks_wide / 2) <= dun->col_rooms / 2) {
+        if (block_x + (blocks_wide / 2) <= dun_data->col_rooms / 2) {
             if (((block_x % 3) == 2) && ((blocks_wide % 3) == 2))
                 return FALSE;
             if ((block_x % 3) == 1)
@@ -206,12 +208,12 @@ static bool find_space_aux(POSITION blocks_high, POSITION blocks_wide, POSITION
     POSITION by2 = block_y + blocks_high;
     POSITION bx2 = block_x + blocks_wide;
 
-    if ((by1 < 0) || (by2 > dun->row_rooms) || (bx1 < 0) || (bx2 > dun->col_rooms))
+    if ((by1 < 0) || (by2 > dun_data->row_rooms) || (bx1 < 0) || (bx2 > dun_data->col_rooms))
         return FALSE;
 
     for (POSITION by = by1; by < by2; by++)
         for (POSITION bx = bx1; bx < bx2; bx++)
-            if (dun->room_map[by][bx])
+            if (dun_data->room_map[by][bx])
                 return FALSE;
 
     return TRUE;
@@ -245,12 +247,12 @@ bool find_space(player_type *player_ptr, POSITION *y, POSITION *x, POSITION heig
     POSITION block_x = 0;
     POSITION blocks_high = 1 + ((height - 1) / BLOCK_HGT);
     POSITION blocks_wide = 1 + ((width - 1) / BLOCK_WID);
-    if ((dun->row_rooms < blocks_high) || (dun->col_rooms < blocks_wide))
+    if ((dun_data->row_rooms < blocks_high) || (dun_data->col_rooms < blocks_wide))
         return FALSE;
 
     int candidates = 0;
-    for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--) {
-        for (block_x = dun->col_rooms - blocks_wide; block_x >= 0; block_x--) {
+    for (block_y = dun_data->row_rooms - blocks_high; block_y >= 0; block_y--) {
+        for (block_x = dun_data->col_rooms - blocks_wide; block_x >= 0; block_x--) {
             if (find_space_aux(blocks_high, blocks_wide, block_y, block_x)) {
                 /* Find a valid place */
                 candidates++;
@@ -266,8 +268,8 @@ bool find_space(player_type *player_ptr, POSITION *y, POSITION *x, POSITION heig
     else
         pick = candidates / 2 + 1;
 
-    for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--) {
-        for (block_x = dun->col_rooms - blocks_wide; block_x >= 0; block_x--) {
+    for (block_y = dun_data->row_rooms - blocks_high; block_y >= 0; block_y--) {
+        for (block_x = dun_data->col_rooms - blocks_wide; block_x >= 0; block_x--) {
             if (find_space_aux(blocks_high, blocks_wide, block_y, block_x)) {
                 pick--;
                 if (!pick)
@@ -285,15 +287,15 @@ bool find_space(player_type *player_ptr, POSITION *y, POSITION *x, POSITION heig
     POSITION bx2 = block_x + blocks_wide;
     *y = ((by1 + by2) * BLOCK_HGT) / 2;
     *x = ((bx1 + bx2) * BLOCK_WID) / 2;
-    if (dun->cent_n < CENT_MAX) {
-        dun->cent[dun->cent_n].y = (byte)*y;
-        dun->cent[dun->cent_n].x = (byte)*x;
-        dun->cent_n++;
+    if (dun_data->cent_n < CENT_MAX) {
+        dun_data->cent[dun_data->cent_n].y = (byte)*y;
+        dun_data->cent[dun_data->cent_n].x = (byte)*x;
+        dun_data->cent_n++;
     }
 
     for (POSITION by = by1; by < by2; by++)
         for (POSITION bx = bx1; bx < bx2; bx++)
-            dun->room_map[by][bx] = TRUE;
+            dun_data->room_map[by][bx] = TRUE;
 
     check_room_boundary(player_ptr, *x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
     return TRUE;
diff --git a/src/system/dungeon-data-definition.c b/src/system/dungeon-data-definition.c
new file mode 100644 (file)
index 0000000..b8bdf05
--- /dev/null
@@ -0,0 +1,4 @@
+#include "system/dungeon-data-definition.h"
+
+/* Dungeon generation data -- see "cave_gen()" */
+dun_data_type *dun_data;
diff --git a/src/system/dungeon-data-definition.h b/src/system/dungeon-data-definition.h
new file mode 100644 (file)
index 0000000..9fa1e83
--- /dev/null
@@ -0,0 +1,69 @@
+#pragma once
+
+#include "floor/floor-base-definitions.h"
+#include "system/angband.h"
+
+/*
+ * Bounds on some arrays used in the "dun_data_type" structure.
+ * These bounds are checked, though usually this is a formality.
+ */
+#define CENT_MAX 100
+#define DOOR_MAX 200
+#define WALL_MAX 500
+#define TUNN_MAX 900
+
+/*
+ * The "size" of a "generation block" in grids
+ */
+#define BLOCK_HGT 11
+#define BLOCK_WID 11
+
+/*
+ * Maximum numbers of rooms along each axis (currently 6x6)
+ */
+#define MAX_ROOMS_ROW (MAX_HGT / BLOCK_HGT)
+#define MAX_ROOMS_COL (MAX_WID / BLOCK_WID)
+
+/*
+ * Simple structure to hold a map location
+ */
+typedef struct coord {
+    POSITION y;
+    POSITION x;
+} coord;
+
+/*
+ * Structure to hold all "dungeon generation" data
+ */
+typedef struct dun_data_type {
+    /* Array of centers of rooms */
+    int cent_n;
+    coord cent[CENT_MAX];
+
+    /* Array of possible door locations */
+    int door_n;
+    coord door[DOOR_MAX];
+
+    /* Array of wall piercing locations */
+    int wall_n;
+    coord wall[WALL_MAX];
+
+    /* Array of tunnel grids */
+    int tunn_n;
+    coord tunn[TUNN_MAX];
+
+    /* Number of blocks along each axis */
+    int row_rooms;
+    int col_rooms;
+
+    /* Array of which blocks are used */
+    bool room_map[MAX_ROOMS_ROW][MAX_ROOMS_COL];
+
+    /* Various type of dungeon floors */
+    bool destroyed;
+    bool empty_level;
+    bool cavern;
+    int laketype;
+} dun_data_type;
+
+extern dun_data_type *dun_data;