OSDN Git Service

[Refactor] #38997 place_outer_noperm_grid() を削除し、place_grid() に統合 / Removed place_out...
[hengband/hengband.git] / src / grid.c
index 2c06677..237db15 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"
@@ -478,6 +476,7 @@ void print_rel(player_type *subject_ptr, SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y
 
 
 /*
+ * todo ここにplayer_type を追加した時のコンパイルエラーに対処できなかったので保留
  * Memorize interesting viewable object/features in the given grid
  *
  * This function should only be called on "legal" grids.
@@ -617,7 +616,7 @@ 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)
@@ -991,7 +990,7 @@ void cave_alter_feat(player_type *player_ptr, POSITION y, POSITION x, int action
        if (newfeat == oldfeat) return;
 
        /* Set the new feature */
-       cave_set_feat(floor_ptr, y, x, newfeat);
+       cave_set_feat(player_ptr, y, x, newfeat);
 
        if (!(feature_action_flags[action] & FAF_NO_DROP))
        {
@@ -1208,3 +1207,88 @@ bool player_can_enter(player_type *creature_ptr, FEAT_IDX feature, BIT_FLAGS16 m
        return TRUE;
 }
 
+
+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 inner:
+       {
+               g_ptr->feat = feat_wall_inner;
+               g_ptr->info |= CAVE_INNER;
+               break;
+       }
+       case inner_perm:
+       {
+               g_ptr->feat = feat_permanent;
+               g_ptr->info |= CAVE_INNER;
+               break;
+       }
+       case outer:
+       {
+               g_ptr->feat = feat_wall_outer;
+               g_ptr->info |= CAVE_OUTER;
+               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;
+}