OSDN Git Service

[Refactor] #38997 place_extra_grid() を削除し、place_grid() に統合 / Removed place_extra_grid...
[hengband/hengband.git] / src / grid.c
index 49df35c..2b69681 100644 (file)
@@ -1,21 +1,19 @@
-
- /*!
-  * @file grid.c
-  * @brief グリッドの実装 / low level dungeon routines -BEN-
-  * @date 2013/12/30
-  * @author
-  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
-  *\n
-  * This software may be copied and distributed for educational, research,\n
-  * and not for profit purposes provided that this copyright and statement\n
-  * are included in all such copies.  Other copyrights may also apply.\n
-  * \n
-  * Support for Adam Bolt's tileset, lighting and transparency effects\n
-  * by Robert Ruehlmann (rr9@angband.org)\n
-  * \n
-  * 2013 Deskull Doxygen向けのコメント整理\n
-  */
-
+/*!
+ * @file grid.c
+ * @brief グリッドの実装 / low level dungeon routines -BEN-
+ * @date 2013/12/30
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ *\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies.  Other copyrights may also apply.\n
+ * \n
+ * Support for Adam Bolt's tileset, lighting and transparency effects\n
+ * by Robert Ruehlmann (rr9@angband.org)\n
+ * \n
+ * 2013 Deskull Doxygen向けのコメント整理\n
+ */
 
 #include "angband.h"
 #include "util.h"
@@ -214,7 +212,7 @@ bool new_player_spot(player_type *creature_ptr)
                        /* Refuse to start on anti-teleport grids in dungeon */
                        if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) continue;
                }
-               if (!player_can_enter(g_ptr->feat, 0)) continue;
+               if (!player_can_enter(creature_ptr, g_ptr->feat, 0)) continue;
                if (!in_bounds(creature_ptr->current_floor_ptr, y, x)) continue;
 
                /* Refuse to start on anti-teleport grids */
@@ -234,110 +232,6 @@ bool new_player_spot(player_type *creature_ptr)
 }
 
 /*!
- * @brief 特殊な部屋向けに各種アイテムを配置する / Create up to "num" objects near the given coordinates
- * @param y 配置したい中心マスのY座標
- * @param x 配置したい中心マスのX座標
- * @param num 配置したい数
- * @return なし
- * @details
- * Only really called by some of the "vault" routines.
- */
-void vault_objects(POSITION y, POSITION x, int num)
-{
-       int dummy = 0;
-       int i = 0, j = y, k = x;
-
-       grid_type *g_ptr;
-
-
-       /* Attempt to place 'num' objects */
-       for (; num > 0; --num)
-       {
-               /* Try up to 11 spots looking for empty space */
-               for (i = 0; i < 11; ++i)
-               {
-                       /* Pick a random location */
-                       while (dummy < SAFE_MAX_ATTEMPTS)
-                       {
-                               j = rand_spread(y, 2);
-                               k = rand_spread(x, 3);
-                               dummy++;
-                               if (!in_bounds(p_ptr->current_floor_ptr, j, k)) continue;
-                               break;
-                       }
-
-                       if (dummy >= SAFE_MAX_ATTEMPTS && cheat_room)
-                       {
-                               msg_print(_("警告!地下室のアイテムを配置できません!", "Warning! Could not place vault object!"));
-                       }
-
-                       /* Require "clean" floor space */
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[j][k];
-                       if (!is_floor_grid(g_ptr) || g_ptr->o_idx) continue;
-
-                       if (randint0(100) < 75)
-                       {
-                               place_object(j, k, 0L);
-                       }
-                       else
-                       {
-                               place_gold(j, k);
-                       }
-
-                       /* Placement accomplished */
-                       break;
-               }
-       }
-}
-
-
-/*!
- * @brief 特殊な部屋向けに各種アイテムを配置する(メインルーチン) / Place some traps with a given displacement of given location
- * @param y トラップを配置したいマスの中心Y座標
- * @param x トラップを配置したいマスの中心X座標
- * @param yd Y方向の配置分散マス数
- * @param xd X方向の配置分散マス数
- * @param num 配置したいトラップの数
- * @return なし
- * @details
- * Only really called by some of the "vault" routines.
- */
-void vault_traps(POSITION y, POSITION x, POSITION yd, POSITION xd, int num)
-{
-       int i;
-
-       for (i = 0; i < num; i++)
-       {
-               vault_trap_aux(p_ptr->current_floor_ptr, y, x, yd, xd);
-       }
-}
-
-/*!
- * @brief 指定のマスを床地形に変える / Set a square to be floor.  (Includes range checking.)
- * @param x 地形を変えたいマスのX座標
- * @param y 地形を変えたいマスのY座標
- * @return なし
- */
-void set_floor(POSITION x, POSITION y)
-{
-       if (!in_bounds(p_ptr->current_floor_ptr, y, x))
-       {
-               /* Out of bounds */
-               return;
-       }
-
-       if (p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ROOM)
-       {
-               /* A room border don't touch. */
-               return;
-       }
-
-       /* Set to be floor if is a wall (don't touch lakes). */
-       if (is_extra_bold(p_ptr->current_floor_ptr, y, x))
-               place_floor_bold(p_ptr->current_floor_ptr, y, x);
-}
-
-/*!
  * @brief マスにフロア端用の永久壁を配置する / Set boundary mimic and add "solid" perma-wall
  * @param g_ptr 永久壁を配置したいマス構造体の参照ポインタ
  * @return なし
@@ -461,7 +355,7 @@ void update_local_illumination(player_type * creature_ptr, POSITION y, POSITION
        int i;
        POSITION yy, xx;
 
-       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return;
+       if (!in_bounds(creature_ptr->current_floor_ptr, y, x)) return;
 
 #ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
 
@@ -554,15 +448,15 @@ void update_local_illumination(player_type * creature_ptr, POSITION y, POSITION
  * @return 視覚に収められていないならTRUEを返す
  * @details player_can_see_bold()関数の返り値の否定を返している。
  */
-bool no_lite(void)
+bool no_lite(player_type *creature_ptr)
 {
-       return (!player_can_see_bold(p_ptr->y, p_ptr->x));
+       return (!player_can_see_bold(creature_ptr, creature_ptr->y, creature_ptr->x));
 }
 
 /*
  * Place an attr/char pair at the given map coordinate, if legal.
  */
-void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
+void print_rel(player_type *subject_ptr, SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
 {
        /* Only do "legal" locations */
        if (panel_contains(y, x))
@@ -571,8 +465,8 @@ void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
                if (!use_graphics)
                {
                        if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
-                       else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
-                       else if (p_ptr->wraith_form) a = TERM_L_DARK;
+                       else if (IS_INVULN(subject_ptr) || subject_ptr->timewalk) a = TERM_WHITE;
+                       else if (subject_ptr->wraith_form) a = TERM_L_DARK;
                }
 
                /* Draw the char using the attr */
@@ -582,6 +476,7 @@ void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
 
 
 /*
+ * todo ここにplayer_type を追加した時のコンパイルエラーに対処できなかったので保留
  * Memorize interesting viewable object/features in the given grid
  *
  * This function should only be called on "legal" grids.
@@ -721,13 +616,13 @@ void lite_spot(POSITION y, POSITION x)
                TERM_COLOR ta;
                SYMBOL_CODE tc;
 
-               map_info(y, x, &a, &c, &ta, &tc);
+               map_info(p_ptr, y, x, &a, &c, &ta, &tc);
 
                /* Hack -- fake monochrome */
                if (!use_graphics)
                {
                        if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
-                       else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
+                       else if (IS_INVULN(p_ptr) || p_ptr->timewalk) a = TERM_WHITE;
                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                }
 
@@ -809,7 +704,7 @@ void lite_spot(POSITION y, POSITION x)
  * grid and maintains an array of all "CAVE_VIEW" grids.
  *
  * This set of grids is the complete set of all grids within line of sight
- * of the player, allowing the "player_has_los_bold(p_ptr, )" macro to work very
+ * of the player, allowing the "player_has_los_bold()" macro to work very
  * quickly.
  *
  *
@@ -840,7 +735,7 @@ void lite_spot(POSITION y, POSITION x)
  * To simplify various things, a grid may be marked as "CAVE_MARK", meaning
  * that even if the player cannot "see" the grid, he "knows" the terrain in
  * that grid.  This is used to "remember" walls/doors/stairs/floors when they
- * are "seen" or "detected", and also to "memorize" floors, after "wiz_lite(p_ptr, )",
+ * are "seen" or "detected", and also to "memorize" floors, after "wiz_lite()",
  * or when one of the "memorize floor grids" options induces memorization.
  *
  * Objects are "memorized" in a different way, using a special "marked" flag
@@ -915,7 +810,7 @@ void lite_spot(POSITION y, POSITION x)
  * I am thinking in terms of an algorithm that "walks" from the central point
  * out to the maximal "distance", at each point, determining the "view" code
  * (above).  For each grid not on a major axis or diagonal, the "view" code
- * depends on the "cave_los_bold(p_ptr->current_floor_ptr, )" and "view" of exactly two other grids
+ * depends on the "cave_los_bold()" and "view" of exactly two other grids
  * (the one along the nearest diagonal, and the one next to that one, see
  * "update_view_aux()"...).
  *
@@ -946,43 +841,6 @@ void lite_spot(POSITION y, POSITION x)
  */
 
 /*
- * Mega-Hack -- Delayed visual update
- * Only used if update_view(), update_lite() or update_mon_lite() was called
- */
-void delayed_visual_update(void)
-{
-       int i;
-       POSITION y, x;
-       grid_type *g_ptr;
-
-       /* Update needed grids */
-       for (i = 0; i < p_ptr->current_floor_ptr->redraw_n; i++)
-       {
-               y = p_ptr->current_floor_ptr->redraw_y[i];
-               x = p_ptr->current_floor_ptr->redraw_x[i];
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-
-               /* Update only needed grids (prevent multiple updating) */
-               if (!(g_ptr->info & CAVE_REDRAW)) continue;
-
-               /* If required, note */
-               if (g_ptr->info & CAVE_NOTE) note_spot(y, x);
-
-               lite_spot(y, x);
-
-               /* Hack -- Visual update of monster on this grid */
-               if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
-
-               /* No longer in the array */
-               g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
-       }
-
-       /* None left */
-       p_ptr->current_floor_ptr->redraw_n = 0;
-}
-
-
-/*
  * Hack - speed up the update_flow algorithm by only doing
  * it everytime the player moves out of LOS of the last
  * "way-point".
@@ -990,8 +848,6 @@ void delayed_visual_update(void)
 static POSITION flow_x = 0;
 static POSITION flow_y = 0;
 
-
-
 /*
  * Hack -- fill in the "cost" field of every grid that the player
  * can "reach" with the number of steps needed to reach that grid.
@@ -1005,7 +861,7 @@ static POSITION flow_y = 0;
  * We do not need a priority queue because the cost from grid
  * to grid is always "one" and we process them in order.
  */
-void update_flow(void)
+void update_flow(player_type *subject_ptr)
 {
        POSITION x, y;
        DIRECTION d;
@@ -1016,29 +872,29 @@ void update_flow(void)
        if (tmp_pos.n) return;
 
        /* The last way-point is on the map */
-       if (p_ptr->running && in_bounds(p_ptr->current_floor_ptr, flow_y, flow_x))
+       if (subject_ptr->running && in_bounds(subject_ptr->current_floor_ptr, flow_y, flow_x))
        {
                /* The way point is in sight - do not update.  (Speedup) */
-               if (p_ptr->current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return;
+               if (subject_ptr->current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return;
        }
 
        /* Erase all of the current flow information */
-       for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
+       for (y = 0; y < subject_ptr->current_floor_ptr->height; y++)
        {
-               for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
+               for (x = 0; x < subject_ptr->current_floor_ptr->width; x++)
                {
-                       p_ptr->current_floor_ptr->grid_array[y][x].cost = 0;
-                       p_ptr->current_floor_ptr->grid_array[y][x].dist = 0;
+                       subject_ptr->current_floor_ptr->grid_array[y][x].cost = 0;
+                       subject_ptr->current_floor_ptr->grid_array[y][x].dist = 0;
                }
        }
 
        /* Save player position */
-       flow_y = p_ptr->y;
-       flow_x = p_ptr->x;
+       flow_y = subject_ptr->y;
+       flow_x = subject_ptr->x;
 
        /* Add the player's grid to the queue */
-       tmp_pos.y[0] = p_ptr->y;
-       tmp_pos.x[0] = p_ptr->x;
+       tmp_pos.y[0] = subject_ptr->y;
+       tmp_pos.x[0] = subject_ptr->x;
 
        /* Now process the queue */
        while (flow_head != flow_tail)
@@ -1056,8 +912,8 @@ void update_flow(void)
                for (d = 0; d < 8; d++)
                {
                        int old_head = flow_head;
-                       byte_hack m = p_ptr->current_floor_ptr->grid_array[ty][tx].cost + 1;
-                       byte_hack n = p_ptr->current_floor_ptr->grid_array[ty][tx].dist + 1;
+                       byte_hack m = subject_ptr->current_floor_ptr->grid_array[ty][tx].cost + 1;
+                       byte_hack n = subject_ptr->current_floor_ptr->grid_array[ty][tx].dist + 1;
                        grid_type *g_ptr;
 
                        /* Child location */
@@ -1065,9 +921,9 @@ void update_flow(void)
                        x = tx + ddx_ddd[d];
 
                        /* Ignore player's grid */
-                       if (player_bold(p_ptr, y, x)) continue;
+                       if (player_bold(subject_ptr, y, x)) continue;
 
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
 
                        if (is_closed_door(g_ptr->feat)) m += 3;
 
@@ -1097,37 +953,6 @@ void update_flow(void)
        }
 }
 
-
-FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
-{
-       feature_type *f_ptr = &f_info[newfeat];
-
-       if (have_flag(f_ptr->flags, FF_CONVERT))
-       {
-               switch (f_ptr->subtype)
-               {
-               case CONVERT_TYPE_FLOOR:
-                       return feat_ground_type[randint0(100)];
-               case CONVERT_TYPE_WALL:
-                       return feat_wall_type[randint0(100)];
-               case CONVERT_TYPE_INNER:
-                       return feat_wall_inner;
-               case CONVERT_TYPE_OUTER:
-                       return feat_wall_outer;
-               case CONVERT_TYPE_SOLID:
-                       return feat_wall_solid;
-               case CONVERT_TYPE_STREAM1:
-                       return d_info[p_ptr->dungeon_idx].stream1;
-               case CONVERT_TYPE_STREAM2:
-                       return d_info[p_ptr->dungeon_idx].stream2;
-               default:
-                       return newfeat;
-               }
-       }
-       else return newfeat;
-}
-
-
 /*
  * Take a feature, determine what that feature becomes
  * through applying the given action.
@@ -1140,22 +965,23 @@ FEAT_IDX feat_state(FEAT_IDX feat, int action)
        /* Get the new feature */
        for (i = 0; i < MAX_FEAT_STATES; i++)
        {
-               if (f_ptr->state[i].action == action) return conv_dungeon_feat(f_ptr->state[i].result);
+               if (f_ptr->state[i].action == action) return conv_dungeon_feat(p_ptr->current_floor_ptr, f_ptr->state[i].result);
        }
 
        if (have_flag(f_ptr->flags, FF_PERMANENT)) return feat;
 
-       return (feature_action_flags[action] & FAF_DESTROY) ? conv_dungeon_feat(f_ptr->destroyed) : feat;
+       return (feature_action_flags[action] & FAF_DESTROY) ? conv_dungeon_feat(p_ptr->current_floor_ptr, f_ptr->destroyed) : feat;
 }
 
 /*
  * Takes a location and action and changes the feature at that
  * location through applying the given action.
  */
-void cave_alter_feat(POSITION y, POSITION x, int action)
+void cave_alter_feat(player_type *player_ptr, POSITION y, POSITION x, int action)
 {
        /* Set old feature */
-       FEAT_IDX oldfeat = p_ptr->current_floor_ptr->grid_array[y][x].feat;
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       FEAT_IDX oldfeat = floor_ptr->grid_array[y][x].feat;
 
        /* Get the new feat */
        FEAT_IDX newfeat = feat_state(oldfeat, action);
@@ -1164,7 +990,7 @@ void cave_alter_feat(POSITION y, POSITION x, int action)
        if (newfeat == oldfeat) return;
 
        /* Set the new feature */
-       cave_set_feat(p_ptr->current_floor_ptr, y, x, newfeat);
+       cave_set_feat(player_ptr, y, x, newfeat);
 
        if (!(feature_action_flags[action] & FAF_NO_DROP))
        {
@@ -1176,19 +1002,19 @@ void cave_alter_feat(POSITION y, POSITION x, int action)
                if (have_flag(old_f_ptr->flags, FF_HAS_GOLD) && !have_flag(f_ptr->flags, FF_HAS_GOLD))
                {
                        /* Place some gold */
-                       place_gold(y, x);
+                       place_gold(floor_ptr, y, x);
                        found = TRUE;
                }
 
                /* Handle item */
-               if (have_flag(old_f_ptr->flags, FF_HAS_ITEM) && !have_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - p_ptr->current_floor_ptr->dun_level / 2)))
+               if (have_flag(old_f_ptr->flags, FF_HAS_ITEM) && !have_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - floor_ptr->dun_level / 2)))
                {
                        /* Place object */
-                       place_object(y, x, 0L);
+                       place_object(player_ptr, y, x, 0L);
                        found = TRUE;
                }
 
-               if (found && current_world_ptr->character_dungeon && player_can_see_bold(y, x))
+               if (found && current_world_ptr->character_dungeon && player_can_see_bold(player_ptr, y, x))
                {
                        msg_print(_("何かを発見した!", "You have found something!"));
                }
@@ -1200,7 +1026,7 @@ void cave_alter_feat(POSITION y, POSITION x, int action)
 
                if (have_flag(old_f_ptr->flags, FF_GLASS) && current_world_ptr->character_dungeon)
                {
-                       project(p_ptr, PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(p_ptr->current_floor_ptr->dun_level, 100) / 4, GF_SHARDS,
+                       project(player_ptr, PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(floor_ptr->dun_level, 100) / 4, GF_SHARDS,
                                (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                }
        }
@@ -1208,21 +1034,21 @@ void cave_alter_feat(POSITION y, POSITION x, int action)
 
 
 /* Remove a mirror */
-void remove_mirror(POSITION y, POSITION x)
+void remove_mirror(player_type *caster_ptr, POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
 
        /* Remove the mirror */
        g_ptr->info &= ~(CAVE_OBJECT);
        g_ptr->mimic = 0;
 
-       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)
+       if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS)
        {
                g_ptr->info &= ~(CAVE_GLOW);
                if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
-               if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
+               if (g_ptr->m_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
 
-               update_local_illumination(p_ptr, y, x);
+               update_local_illumination(caster_ptr, y, x);
        }
 
        note_spot(y, x);
@@ -1323,14 +1149,14 @@ bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode)
 
        if (!(mode & TELEPORT_PASSIVE))
        {
-               if (!player_can_enter(g_ptr->feat, 0)) return FALSE;
+               if (!player_can_enter(p_ptr, g_ptr->feat, 0)) return FALSE;
 
                if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
                {
                        if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
                }
 
-               if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
+               if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN(p_ptr))
                {
                        /* Always forbid deep lava */
                        if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
@@ -1361,23 +1187,140 @@ bool is_open(FEAT_IDX feat)
  * @param mode 移動に関するオプションフラグ
  * @return 移動可能ならばTRUEを返す
  */
-bool player_can_enter(FEAT_IDX feature, BIT_FLAGS16 mode)
+bool player_can_enter(player_type *creature_ptr, FEAT_IDX feature, BIT_FLAGS16 mode)
 {
        feature_type *f_ptr = &f_info[feature];
 
-       if (p_ptr->riding) return monster_can_cross_terrain(feature, &r_info[p_ptr->current_floor_ptr->m_list[p_ptr->riding].r_idx], mode | CEM_RIDING);
+       if (creature_ptr->riding) return monster_can_cross_terrain(feature, &r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx], mode | CEM_RIDING);
 
        if (have_flag(f_ptr->flags, FF_PATTERN))
        {
                if (!(mode & CEM_P_CAN_ENTER_PATTERN)) return FALSE;
        }
 
-       if (have_flag(f_ptr->flags, FF_CAN_FLY) && p_ptr->levitation) return TRUE;
-       if (have_flag(f_ptr->flags, FF_CAN_SWIM) && p_ptr->can_swim) return TRUE;
-       if (have_flag(f_ptr->flags, FF_CAN_PASS) && p_ptr->pass_wall) return TRUE;
+       if (have_flag(f_ptr->flags, FF_CAN_FLY) && creature_ptr->levitation) return TRUE;
+       if (have_flag(f_ptr->flags, FF_CAN_SWIM) && creature_ptr->can_swim) return TRUE;
+       if (have_flag(f_ptr->flags, FF_CAN_PASS) && creature_ptr->pass_wall) return TRUE;
 
        if (!have_flag(f_ptr->flags, FF_MOVE)) return FALSE;
 
        return TRUE;
 }
 
+
+void place_inner_grid(grid_type *g_ptr)
+{
+       g_ptr->feat = feat_wall_inner;
+       g_ptr->info &= ~(CAVE_MASK);
+       g_ptr->info |= CAVE_INNER;
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+void place_inner_perm_grid(grid_type *g_ptr)
+{
+       g_ptr->feat = feat_permanent;
+       g_ptr->info &= ~(CAVE_MASK);
+       g_ptr->info |= CAVE_INNER;
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+void place_outer_grid(grid_type *g_ptr)
+{
+       g_ptr->feat = feat_wall_outer;
+       g_ptr->info &= ~(CAVE_MASK);
+       g_ptr->info |= CAVE_OUTER;
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+void place_outer_noperm_grid(grid_type *g_ptr)
+{
+       feature_type *_f_ptr = &f_info[feat_wall_outer];
+       if (permanent_wall(_f_ptr)) g_ptr->feat = (s16b)feat_state(feat_wall_outer, FF_UNPERM);
+       else g_ptr->feat = feat_wall_outer;
+       g_ptr->info &= ~(CAVE_MASK);
+       g_ptr->info |= (CAVE_OUTER | CAVE_VAULT);
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+void place_solid_perm_grid(grid_type *g_ptr)
+{
+       g_ptr->feat = feat_permanent;
+       g_ptr->info &= ~(CAVE_MASK);
+       g_ptr->info |= CAVE_SOLID;
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+void place_grid(grid_type *g_ptr, place_grid_type pg_type)
+{
+       switch (pg_type)
+       {
+       case floor:
+       {
+               g_ptr->feat = feat_ground_type[randint0(100)];
+               g_ptr->info |= CAVE_FLOOR;
+               break;
+       }
+       case extra:
+       {
+               g_ptr->feat = feat_wall_type[randint0(100)];
+               g_ptr->info |= CAVE_EXTRA;
+               break;
+       }
+       case innner:
+       {
+               g_ptr->feat = feat_wall_inner;
+               g_ptr->info |= CAVE_INNER;
+               break;
+       }
+       case outer:
+       {
+               g_ptr->feat = feat_permanent;
+               g_ptr->info |= CAVE_INNER;
+               break;
+       }
+       case outer_noperm:
+       {
+               feature_type *f_ptr = &f_info[feat_wall_outer];
+               if (permanent_wall(f_ptr))
+               {
+                       g_ptr->feat = (s16b)feat_state(feat_wall_outer, FF_UNPERM);
+               }
+               else
+               {
+                       g_ptr->feat = feat_wall_outer;
+               }
+
+               g_ptr->info |= (CAVE_OUTER | CAVE_VAULT);
+               break;
+       }
+       case solid_perm:
+       {
+               g_ptr->feat = feat_permanent;
+               g_ptr->info |= CAVE_SOLID;
+               break;
+       }
+       default:
+               return;
+       }
+
+       g_ptr->info &= ~(CAVE_MASK);
+       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+}
+
+
+/*!
+ * モンスターにより照明が消されている地形か否かを判定する。 / Is this grid "darkened" by monster?
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param g_ptr グリッドへの参照ポインタ
+ * @return 照明が消されている地形ならばTRUE
+ */
+bool darkened_grid(player_type *player_ptr, grid_type *g_ptr)
+{
+       return ((g_ptr->info & (CAVE_VIEW | CAVE_LITE | CAVE_MNLT | CAVE_MNDK)) == (CAVE_VIEW | CAVE_MNDK)) &&
+               !player_ptr->see_nocto;
+}