OSDN Git Service

[Refactor] #40577 Separated place_random_door() and place_closed_door() from projecti...
authorHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 09:24:37 +0000 (18:24 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 09:24:37 +0000 (18:24 +0900)
src/floor/cave-generator.c
src/floor/floor.c
src/floor/floor.h
src/grid/door.c
src/grid/door.h
src/grid/feature-generator.c

index fb48a92..06140ff 100644 (file)
@@ -5,7 +5,6 @@
 #include "floor/dungeon-tunnel-util.h"
 #include "floor/floor-allocation-types.h"
 #include "floor/floor-streams.h"
-#include "floor/floor.h"
 #include "floor/geometry.h"
 #include "floor/object-allocator.h"
 #include "floor/tunnel-generator.h"
@@ -13,6 +12,7 @@
 #include "game-option/birth-options.h"
 #include "game-option/cheat-types.h"
 #include "game-option/game-play-options.h"
+#include "grid/door.h"
 #include "grid/feature-generator.h"
 #include "grid/grid.h"
 #include "monster-floor/monster-generator.h"
index a650dd5..4d086f3 100644 (file)
@@ -306,65 +306,6 @@ void cave_set_feat(player_type *player_ptr, POSITION y, POSITION x, FEAT_IDX fea
 }
 
 /*!
- * @brief 所定の位置にさまざまな状態や種類のドアを配置する / Place a random type of door at the given location
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y ドアの配置を試みたいマスのY座標
- * @param x ドアの配置を試みたいマスのX座標
- * @param room 部屋に接している場合向けのドア生成か否か
- * @return なし
- */
-void place_random_door(player_type *player_ptr, POSITION y, POSITION x, bool room)
-{
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    g_ptr->mimic = 0;
-
-    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
-        place_bold(player_ptr, y, x, GB_FLOOR);
-        return;
-    }
-
-    int 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);
-
-    int tmp = randint0(1000);
-    FEAT_IDX feat = feat_none;
-    if (tmp < 300) {
-        feat = feat_door[type].open;
-    } else if (tmp < 400) {
-        feat = feat_door[type].broken;
-    } else if (tmp < 600) {
-        place_closed_door(player_ptr, y, x, type);
-
-        if (type != DOOR_CURTAIN) {
-            g_ptr->mimic = room ? feat_wall_outer : feat_wall_type[randint0(100)];
-            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;
-            }
-        }
-    } else {
-        place_closed_door(player_ptr, y, x, type);
-    }
-
-    if (tmp >= 400) {
-        delete_monster(player_ptr, y, x);
-        return;
-    }
-
-    if (feat != feat_none) {
-        set_cave_feat(floor_ptr, y, x, feat);
-    } else {
-        place_bold(player_ptr, y, x, GB_FLOOR);
-    }
-
-    delete_monster(player_ptr, y, x);
-}
-
-/*!
  * @brief グローバルオブジェクト配列を初期化する /
  * Delete all the items when player leaves the level
  * @note we do NOT visually reflect these (irrelevant) changes
@@ -411,42 +352,6 @@ void wipe_o_list(floor_type *floor_ptr)
 }
 
 /*!
- * @brief 所定の位置に各種の閉じたドアを配置する / Place a random type of normal door at the given location.
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y ドアの配置を試みたいマスのY座標
- * @param x ドアの配置を試みたいマスのX座標
- * @param type ドアの地形ID
- * @return なし
- */
-void place_closed_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;
-    }
-
-    int tmp = randint0(400);
-    FEAT_IDX feat = feat_none;
-    if (tmp < 300) {
-        /* Create closed door */
-        feat = feat_door[type].closed;
-    } else if (tmp < 399) {
-        feat = feat_locked_door_random(type);
-    } else {
-        feat = feat_jammed_door_random(type);
-    }
-
-    if (feat == feat_none) {
-        place_bold(player_ptr, y, x, GB_FLOOR);
-        return;
-    }
-
-    cave_set_feat(player_ptr, y, x, feat);
-    floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
-}
-
-/*!
  * @brief 指定のマスが床系地形であるかを返す / Function that sees if a square is a floor.  (Includes range checking.)
  * @param x チェックするマスのX座標
  * @param y チェックするマスのY座標
index b9a4b14..cb0a22d 100644 (file)
@@ -23,8 +23,6 @@ int get_max_range(player_type *creature_ptr);
 bool projectable(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
 bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
 void cave_set_feat(player_type *player_ptr, POSITION y, POSITION x, FEAT_IDX feat);
-void place_random_door(player_type *player_ptr, POSITION y, POSITION x, bool room);
-void place_closed_door(player_type *player_ptr, POSITION y, POSITION x, int type);
 void wipe_o_list(floor_type *floor_ptr);
 bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y);
 FEAT_IDX conv_dungeon_feat(floor_type *floor_ptr, FEAT_IDX newfeat);
index bf42f6e..4dc7753 100644 (file)
@@ -5,6 +5,7 @@
 #include "floor/floor.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "room/door-definition.h"
 #include "system/floor-type-definition.h"
 #include "util/bit-flags-calculator.h"
 
@@ -109,3 +110,97 @@ void place_locked_door(player_type *player_ptr, POSITION y, POSITION x)
     floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
     delete_monster(player_ptr, y, x);
 }
+
+/*!
+ * @brief \8f\8a\92è\82Ì\88Ê\92u\82É\82³\82Ü\82´\82Ü\82È\8fó\91Ô\82â\8eí\97Þ\82Ì\83h\83A\82ð\94z\92u\82·\82é / Place a random type of door at the given location
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y \83h\83A\82Ì\94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌY\8dÀ\95W
+ * @param x \83h\83A\82Ì\94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌX\8dÀ\95W
+ * @param room \95\94\89®\82É\90Ú\82µ\82Ä\82¢\82é\8fê\8d\87\8cü\82¯\82Ì\83h\83A\90\90¬\82©\94Û\82©
+ * @return \82È\82µ
+ */
+void place_random_door(player_type *player_ptr, POSITION y, POSITION x, bool room)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+    g_ptr->mimic = 0;
+
+    if (d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) {
+        place_bold(player_ptr, y, x, GB_FLOOR);
+        return;
+    }
+
+    int 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);
+
+    int tmp = randint0(1000);
+    FEAT_IDX feat = feat_none;
+    if (tmp < 300) {
+        feat = feat_door[type].open;
+    } else if (tmp < 400) {
+        feat = feat_door[type].broken;
+    } else if (tmp < 600) {
+        place_closed_door(player_ptr, y, x, type);
+
+        if (type != DOOR_CURTAIN) {
+            g_ptr->mimic = room ? feat_wall_outer : feat_wall_type[randint0(100)];
+            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;
+            }
+        }
+    } else {
+        place_closed_door(player_ptr, y, x, type);
+    }
+
+    if (tmp >= 400) {
+        delete_monster(player_ptr, y, x);
+        return;
+    }
+
+    if (feat == feat_none) {
+        place_bold(player_ptr, y, x, GB_FLOOR);
+    } else {
+        set_cave_feat(floor_ptr, y, x, feat);
+    }
+
+    delete_monster(player_ptr, y, x);
+}
+
+/*!
+ * @brief \8f\8a\92è\82Ì\88Ê\92u\82É\8ae\8eí\82Ì\95Â\82\82½\83h\83A\82ð\94z\92u\82·\82é / Place a random type of normal door at the given location.
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y \83h\83A\82Ì\94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌY\8dÀ\95W
+ * @param x \83h\83A\82Ì\94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌX\8dÀ\95W
+ * @param type \83h\83A\82Ì\92n\8c`ID
+ * @return \82È\82µ
+ */
+void place_closed_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;
+    }
+
+    int tmp = randint0(400);
+    FEAT_IDX feat = feat_none;
+    if (tmp < 300) {
+        feat = feat_door[type].closed;
+    } else if (tmp < 399) {
+        feat = feat_locked_door_random(type);
+    } else {
+        feat = feat_jammed_door_random(type);
+    }
+
+    if (feat == feat_none) {
+        place_bold(player_ptr, y, x, GB_FLOOR);
+        return;
+    }
+
+    cave_set_feat(player_ptr, y, x, feat);
+    floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
+}
index f11fedb..4d243fb 100644 (file)
@@ -5,3 +5,5 @@
 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 place_random_door(player_type *player_ptr, POSITION y, POSITION x, bool room);
+void place_closed_door(player_type *player_ptr, POSITION y, POSITION x, int type);
index bf83f1d..525ef96 100644 (file)
@@ -3,10 +3,10 @@
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "floor/cave.h"
-#include "floor/floor.h" // todo place_random_door() が依存している。ここへ引っ越し.
 #include "floor/dungeon-tunnel-util.h"
 #include "game-option/cheat-types.h"
 #include "game-option/game-play-options.h"
+#include "grid/door.h"
 #include "grid/grid.h"
 #include "room/lake-types.h"
 #include "room/rooms-builder.h"