OSDN Git Service

[Refactor] #37353 place_locked_door(), place_secret_door() を floor.c へ移動. / Move...
authordeskull <deskull@users.sourceforge.jp>
Sat, 2 Nov 2019 22:52:26 +0000 (07:52 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sat, 2 Nov 2019 23:12:09 +0000 (08:12 +0900)
src/floor.c
src/floor.h
src/grid.c
src/grid.h

index d52b48d..8e9db99 100644 (file)
@@ -1,6 +1,9 @@
 #include "angband.h"
 #include "floor.h"
 #include "floor-save.h"
+#include "grid.h"
+#include "dungeon.h"
+#include "rooms.h"
 
 /*
  * The array of floor [MAX_WID][MAX_HGT].
@@ -14,3 +17,71 @@ floor_type floor_info;
  */
 saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 
+/*!
+* @brief 鍵のかかったドアを配置する
+* @param y 配置したいフロアのY座標
+* @param x 配置したいフロアのX座標
+* @return なし
+*/
+void place_locked_door(POSITION y, POSITION x)
+{
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
+       {
+               place_floor_bold(y, x);
+       }
+       else
+       {
+               set_cave_feat(p_ptr->current_floor_ptr, y, x, feat_locked_door_random((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
+               p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
+               delete_monster(y, x);
+       }
+}
+
+
+/*!
+* @brief 隠しドアを配置する
+* @param y 配置したいフロアのY座標
+* @param x 配置したいフロアのX座標
+* @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
+* @return なし
+*/
+void place_secret_door(POSITION y, POSITION x, int type)
+{
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
+       {
+               place_floor_bold(y, x);
+       }
+       else
+       {
+               grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+
+               if (type == DOOR_DEFAULT)
+               {
+                       type = ((d_info[p_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
+                               one_in_((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+                               ((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+               }
+
+               /* Create secret door */
+               place_closed_door(y, x, type);
+
+               if (type != DOOR_CURTAIN)
+               {
+                       /* Hide by inner wall because this is used in rooms only */
+                       g_ptr->mimic = feat_wall_inner;
+
+                       /* Floor type terrain cannot hide a door */
+                       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(y, x);
+       }
+}
index 6c59510..d5cfb25 100644 (file)
@@ -372,3 +372,5 @@ extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 #define GRID_X(G) \
        ((int)((G) % 256U))
 
+extern void place_secret_door(POSITION y, POSITION x, int type);
+extern void place_locked_door(POSITION y, POSITION x);
index 42ad23c..82a3c7a 100644 (file)
 #define FAF_NO_DROP     0x02
 #define FAF_CRASH_GLASS 0x04
 
-#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 地形状態フラグテーブル /
  * The table of features' actions
@@ -413,75 +405,6 @@ void place_closed_door(POSITION y, POSITION x, int type)
        }
 }
 
-/*!
-* @brief 鍵のかかったドアを配置する
-* @param y 配置したいフロアのY座標
-* @param x 配置したいフロアのX座標
-* @return なし
-*/
-void place_locked_door(POSITION y, POSITION x)
-{
-       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
-       {
-               place_floor_bold(y, x);
-       }
-       else
-       {
-               set_cave_feat(p_ptr->current_floor_ptr, y, x, feat_locked_door_random((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
-               p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
-               delete_monster(y, x);
-       }
-}
-
-
-/*!
-* @brief 隠しドアを配置する
-* @param y 配置したいフロアのY座標
-* @param x 配置したいフロアのX座標
-* @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
-* @return なし
-*/
-void place_secret_door(POSITION y, POSITION x, int type)
-{
-       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
-       {
-               place_floor_bold(y, x);
-       }
-       else
-       {
-               grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-
-               if (type == DOOR_DEFAULT)
-               {
-                       type = ((d_info[p_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
-                               one_in_((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
-                               ((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
-               }
-
-               /* Create secret door */
-               place_closed_door(y, x, type);
-
-               if (type != DOOR_CURTAIN)
-               {
-                       /* Hide by inner wall because this is used in rooms only */
-                       g_ptr->mimic = feat_wall_inner;
-
-                       /* Floor type terrain cannot hide a door */
-                       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(y, x);
-       }
-}
-
 /*
  * 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.
index 122bded..74e7f19 100644 (file)
@@ -79,13 +79,21 @@ typedef struct
        u16b occurrence;
 } grid_template_type;
 
+/* This should not be used */
+/*#define set_cave_info(Y,X,I)    (p_ptr->current_floor_ptr->grid_array[(Y)][(X)].info = (I)) */
+
+#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)
+
 /* Macros */
 #define set_cave_feat(FL,Y,X,F)    ((FL)->grid_array[(Y)][(X)].feat = (F))
 #define add_cave_info(FL,Y,X,I)    ((FL)->grid_array[(Y)][(X)].info |= (I))
 
-/* This should not be used */
-/*#define set_cave_info(Y,X,I)    (p_ptr->current_floor_ptr->grid_array[(Y)][(X)].info = (I)) */
-
 /*!
  * @brief 指定座標に瓦礫を配置する
  * @param Y 指定Y座標
@@ -366,9 +374,8 @@ extern void add_door(POSITION x, POSITION y);
 
 #define MAX_DOOR_TYPES   3
 extern void place_closed_door(POSITION y, POSITION x, int type);
-extern void place_secret_door(POSITION y, POSITION x, int type);
 
-extern void place_locked_door(POSITION y, POSITION x);
+
 extern void try_door(POSITION y, POSITION x);
 extern void place_floor(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light);
 extern void place_room(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light);