OSDN Git Service

[Refactor] #40577 Separated door.c/h from floor.c/h
authorHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 08:52:20 +0000 (17:52 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 08:52:20 +0000 (17:52 +0900)
15 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/floor/floor.c
src/floor/floor.h
src/grid/door.c [new file with mode: 0644]
src/grid/door.h [new file with mode: 0644]
src/grid/feature.c
src/grid/feature.h
src/grid/grid.h
src/room/rooms-builder.c
src/room/rooms-normal.c
src/room/rooms-pit-nest.c
src/room/rooms-special.c
src/room/rooms-vault.c

index a192531..7bc4ba5 100644 (file)
     <ClCompile Include="..\..\src\game-option\runtime-arguments.c" />\r
     <ClCompile Include="..\..\src\game-option\special-options.c" />\r
     <ClCompile Include="..\..\src\game-option\text-display-options.c" />\r
+    <ClCompile Include="..\..\src\grid\door.c" />\r
     <ClCompile Include="..\..\src\grid\feature-generator.c" />\r
     <ClCompile Include="..\..\src\grid\lighting-colors-table.c" />\r
     <ClCompile Include="..\..\src\info-reader\artifact-reader.c" />\r
     <ClInclude Include="..\..\src\game-option\runtime-arguments.h" />\r
     <ClInclude Include="..\..\src\game-option\special-options.h" />\r
     <ClInclude Include="..\..\src\game-option\text-display-options.h" />\r
+    <ClInclude Include="..\..\src\grid\door.h" />\r
     <ClInclude Include="..\..\src\grid\feature-flag-types.h" />\r
     <ClInclude Include="..\..\src\grid\feature-generator.h" />\r
     <ClInclude Include="..\..\src\grid\lighting-colors-table.h" />\r
index 7f5e6d7..2cf7ae7 100644 (file)
     <ClCompile Include="..\..\src\target\projection-path-calculator.c">
       <Filter>target</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\grid\door.c">
+      <Filter>grid</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\target\projection-path-calculator.h">
       <Filter>target</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\grid\door.h">
+      <Filter>grid</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 508b4df..b46ce04 100644 (file)
@@ -254,6 +254,7 @@ hengband_SOURCES = \
        game-option/special-options.c game-option/special-options.h \
        game-option/text-display-options.c game-option/text-display-options.h \
        \
+       grid/door.c grid/door.h \
        grid/feature-flag-types.h \
        grid/feature-generator.c grid/feature-generator.h \
        grid/feature.c grid/feature.h \
index bac1ef4..d886cbf 100644 (file)
@@ -13,6 +13,7 @@
 #include "game-option/birth-options.h"
 #include "game-option/cheat-options.h"
 #include "game-option/map-screen-options.h"
+#include "grid/feature.h"
 #include "grid/grid.h"
 #include "grid/trap.h"
 #include "mind/mind-ninja.h"
  */
 floor_type floor_info;
 
-/*!
- * @brief 鍵のかかったドアを配置する
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y 配置したいフロアのY座標
- * @param x 配置したいフロアのX座標
- * @return なし
- */
-void place_locked_door(player_type *player_ptr, POSITION y, POSITION x)
-{
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
-        place_bold(player_ptr, y, x, GB_FLOOR);
-        return;
-    }
-
-    set_cave_feat(floor_ptr, y, x, feat_locked_door_random((d_info[player_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
-    floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
-    delete_monster(player_ptr, y, x);
-}
-
-/*!
- * @brief 隠しドアを配置する
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y 配置したいフロアのY座標
- * @param x 配置したいフロアのX座標
- * @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
- * @return なし
- */
-void place_secret_door(player_type *player_ptr, POSITION y, POSITION x, int type)
-{
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
-        place_bold(player_ptr, y, x, GB_FLOOR);
-        return;
-    }
-
-    if (type == DOOR_DEFAULT) {
-        type = ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) && one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256))
-            ? DOOR_CURTAIN
-            : ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
-    }
-
-    place_closed_door(player_ptr, y, x, type);
-    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    if (type != DOOR_CURTAIN) {
-        g_ptr->mimic = feat_wall_inner;
-        if (feat_supports_los(g_ptr->mimic) && !feat_supports_los(g_ptr->feat)) {
-            if (have_flag(f_info[g_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[g_ptr->mimic].flags, FF_CAN_FLY)) {
-                g_ptr->feat = one_in_(2) ? g_ptr->mimic : feat_ground_type[randint0(100)];
-            }
-
-            g_ptr->mimic = 0;
-        }
-    }
-
-    g_ptr->info &= ~(CAVE_FLOOR);
-    delete_monster(player_ptr, y, x);
-}
-
 static int scent_when = 0;
 
 /*
@@ -177,49 +119,6 @@ void forget_flow(floor_type *floor_ptr)
     }
 }
 
-/*
- * Routine used by the random vault creators to add a door to a location
- * Note that range checking has to be done in the calling routine.
- *
- * The doors must be INSIDE the allocated region.
- */
-void add_door(player_type *player_ptr, POSITION x, POSITION y)
-{
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    if (!is_outer_bold(floor_ptr, y, x))
-        return;
-
-    /* look at:
-     *  x#x
-     *  .#.
-     *  x#x
-     *
-     *  where x=don't care
-     *  .=floor, #=wall
-     */
-
-    if (is_floor_bold(floor_ptr, y - 1, x) && is_floor_bold(floor_ptr, y + 1, x)
-        && (is_outer_bold(floor_ptr, y, x - 1) && is_outer_bold(floor_ptr, y, x + 1))) {
-        place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
-        place_bold(player_ptr, y, x - 1, GB_SOLID);
-        place_bold(player_ptr, y, x + 1, GB_SOLID);
-    }
-
-    /* look at:
-     *  x#x
-     *  .#.
-     *  x#x
-     *
-     *  where x = don't care
-     *  .=floor, #=wall
-     */
-    if (is_outer_bold(floor_ptr, y - 1, x) && is_outer_bold(floor_ptr, y + 1, x) && is_floor_bold(floor_ptr, y, x - 1) && is_floor_bold(floor_ptr, y, x + 1)) {
-        place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
-        place_bold(player_ptr, y - 1, x, GB_SOLID);
-        place_bold(player_ptr, y + 1, x, GB_SOLID);
-    }
-}
-
 /*!
  * @brief 所定の位置に上り階段か下り階段を配置する / Place an up/down staircase at given location
  * @param player_ptr プレーヤーへの参照ポインタ
index 144ecab..e4426fd 100644 (file)
@@ -17,9 +17,6 @@ extern floor_type floor_info;
        ((int)((G) % 256U))
 
 void update_smell(floor_type *floor_ptr, player_type *subject_ptr);
-void add_door(player_type *player_ptr, POSITION x, POSITION y);
-void place_secret_door(player_type *player_ptr, POSITION y, POSITION x, int type);
-void place_locked_door(player_type *player_ptr, POSITION y, POSITION x);
 void forget_flow(floor_type *floor_ptr);
 void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x);
 bool los(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
diff --git a/src/grid/door.c b/src/grid/door.c
new file mode 100644 (file)
index 0000000..bf42f6e
--- /dev/null
@@ -0,0 +1,111 @@
+#include "grid/door.h"
+#include "dungeon/dungeon-flag-types.h"
+#include "dungeon/dungeon.h"
+#include "floor/cave.h"
+#include "floor/floor.h"
+#include "grid/feature.h"
+#include "grid/grid.h"
+#include "system/floor-type-definition.h"
+#include "util/bit-flags-calculator.h"
+
+/*
+ * Routine used by the random vault creators to add a door to a location
+ * Note that range checking has to be done in the calling routine.
+ *
+ * The doors must be INSIDE the allocated region.
+ */
+void add_door(player_type *player_ptr, POSITION x, POSITION y)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if (!is_outer_bold(floor_ptr, y, x))
+        return;
+
+    /* look at:
+     *  x#x
+     *  .#.
+     *  x#x
+     *
+     *  where x=don't care
+     *  .=floor, #=wall
+     */
+
+    if (is_floor_bold(floor_ptr, y - 1, x) && is_floor_bold(floor_ptr, y + 1, x)
+        && (is_outer_bold(floor_ptr, y, x - 1) && is_outer_bold(floor_ptr, y, x + 1))) {
+        place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
+        place_bold(player_ptr, y, x - 1, GB_SOLID);
+        place_bold(player_ptr, y, x + 1, GB_SOLID);
+    }
+
+    /* look at:
+     *  x#x
+     *  .#.
+     *  x#x
+     *
+     *  where x = don't care
+     *  .=floor, #=wall
+     */
+    if (is_outer_bold(floor_ptr, y - 1, x) && is_outer_bold(floor_ptr, y + 1, x) && is_floor_bold(floor_ptr, y, x - 1) && is_floor_bold(floor_ptr, y, x + 1)) {
+        place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
+        place_bold(player_ptr, y - 1, x, GB_SOLID);
+        place_bold(player_ptr, y + 1, x, GB_SOLID);
+    }
+}
+
+/*!
+ * @brief \89B\82µ\83h\83A\82ð\94z\92u\82·\82é
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y \94z\92u\82µ\82½\82¢\83t\83\8d\83A\82ÌY\8dÀ\95W
+ * @param x \94z\92u\82µ\82½\82¢\83t\83\8d\83A\82ÌX\8dÀ\95W
+ * @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN \82Ì\82¢\82¸\82ê\82©
+ * @return \82È\82µ
+ */
+void place_secret_door(player_type *player_ptr, POSITION y, POSITION x, int type)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
+        place_bold(player_ptr, y, x, GB_FLOOR);
+        return;
+    }
+
+    if (type == DOOR_DEFAULT) {
+        type = ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) && one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256))
+            ? DOOR_CURTAIN
+            : ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+    }
+
+    place_closed_door(player_ptr, y, x, type);
+    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+    if (type != DOOR_CURTAIN) {
+        g_ptr->mimic = feat_wall_inner;
+        if (feat_supports_los(g_ptr->mimic) && !feat_supports_los(g_ptr->feat)) {
+            if (have_flag(f_info[g_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[g_ptr->mimic].flags, FF_CAN_FLY)) {
+                g_ptr->feat = one_in_(2) ? g_ptr->mimic : feat_ground_type[randint0(100)];
+            }
+
+            g_ptr->mimic = 0;
+        }
+    }
+
+    g_ptr->info &= ~(CAVE_FLOOR);
+    delete_monster(player_ptr, y, x);
+}
+
+/*!
+ * @brief \8c®\82Ì\82©\82©\82Á\82½\83h\83A\82ð\94z\92u\82·\82é
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y \94z\92u\82µ\82½\82¢\83t\83\8d\83A\82ÌY\8dÀ\95W
+ * @param x \94z\92u\82µ\82½\82¢\83t\83\8d\83A\82ÌX\8dÀ\95W
+ * @return \82È\82µ
+ */
+void place_locked_door(player_type *player_ptr, POSITION y, POSITION x)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
+        place_bold(player_ptr, y, x, GB_FLOOR);
+        return;
+    }
+
+    set_cave_feat(floor_ptr, y, x, feat_locked_door_random((d_info[player_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
+    floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
+    delete_monster(player_ptr, y, x);
+}
diff --git a/src/grid/door.h b/src/grid/door.h
new file mode 100644 (file)
index 0000000..f11fedb
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "system/angband.h"
+
+void add_door(player_type *player_ptr, POSITION x, POSITION y);
+void place_secret_door(player_type *player_ptr, POSITION y, POSITION x, int type);
+void place_locked_door(player_type *player_ptr, POSITION y, POSITION x);
index a8a1017..f26a8ed 100644 (file)
@@ -1,5 +1,6 @@
 #include "grid/feature.h"
 #include "grid/lighting-colors-table.h"
+#include "room/door-definition.h"
 #include "util/bit-flags-calculator.h"
 
 /*** Terrain feature variables ***/
@@ -157,3 +158,13 @@ bool is_ascii_graphics(char x) { return (x & 0x80) == 0; }
  * Determine if a "feature" is "permanent wall"
  */
 bool permanent_wall(feature_type *f_ptr) { return have_flag(f_ptr->flags, FF_WALL) && have_flag(f_ptr->flags, FF_PERMANENT); }
+
+FEAT_IDX feat_locked_door_random(int door_type)
+{
+    return feat_door[door_type].num_locked ? feat_door[door_type].locked[randint0(feat_door[door_type].num_locked)] : feat_none;
+}
+
+FEAT_IDX feat_jammed_door_random(int door_type)
+{
+    return feat_door[door_type].num_jammed ? feat_door[door_type].jammed[randint0(feat_door[door_type].num_jammed)] : feat_none;
+}
index 1673e70..60b860e 100644 (file)
@@ -120,3 +120,5 @@ bool is_trap(player_type *player_ptr, FEAT_IDX feat);
 void apply_default_feat_lighting(TERM_COLOR *f_attr, SYMBOL_CODE *f_char);
 bool is_ascii_graphics(char x);
 bool permanent_wall(feature_type *f_ptr);
+FEAT_IDX feat_locked_door_random(int door_type);
+FEAT_IDX feat_jammed_door_random(int door_type);
index 130aea6..080036f 100644 (file)
@@ -74,14 +74,6 @@ typedef struct grid_template_type {
        u16b occurrence;
 } grid_template_type;
 
-#define feat_locked_door_random(DOOR_TYPE) \
-       (feat_door[(DOOR_TYPE)].num_locked ? \
-        feat_door[(DOOR_TYPE)].locked[randint0(feat_door[(DOOR_TYPE)].num_locked)] : feat_none)
-
-#define feat_jammed_door_random(DOOR_TYPE) \
-       (feat_door[(DOOR_TYPE)].num_jammed ? \
-        feat_door[(DOOR_TYPE)].jammed[randint0(feat_door[(DOOR_TYPE)].num_jammed)] : feat_none)
-
 /*!
  * @brief 指定座標に瓦礫を配置する
  * @param Y 指定Y座標
index 568dc64..650c935 100644 (file)
@@ -39,7 +39,7 @@
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
 #include "floor/cave.h"
-#include "floor/floor.h"
+#include "grid/door.h"
 #include "grid/grid.h"
 #include "room/cave-filler.h"
 #include "room/lake-types.h"
index 5057789..6c7362c 100644 (file)
@@ -2,6 +2,7 @@
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor.h"
+#include "grid/door.h"
 #include "grid/grid.h"
 #include "grid/trap.h"
 #include "room/door-definition.h"
index f34d449..b94b677 100644 (file)
@@ -1,9 +1,9 @@
 #include "room/rooms-pit-nest.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor-generator.h"
-#include "floor/floor.h"
 #include "game-option/cheat-options.h"
 #include "game-option/cheat-types.h"
+#include "grid/door.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "monster-floor/monster-generator.h"
index 42b4110..020e740 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor-generator.h"
 #include "floor/floor.h"
 #include "game-option/cheat-types.h"
+#include "grid/door.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "monster-race/monster-race-hook.h"
index 497a0ab..407cd82 100644 (file)
@@ -13,6 +13,7 @@
 #include "floor/floor.h"
 #include "floor/wild.h"
 #include "game-option/cheat-types.h"
+#include "grid/door.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "grid/trap.h"