OSDN Git Service

[Refactor] #38997 cave_set_feat() に player_type * 引数を追加. / Add player_type * argument...
authordeskull <deskull@users.sourceforge.jp>
Sun, 8 Dec 2019 17:12:32 +0000 (02:12 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 8 Dec 2019 17:12:32 +0000 (02:12 +0900)
src/core.c
src/floor.c
src/floor.h
src/grid.c
src/grid.h
src/player-status.c
src/quest.c
src/rooms-city.c
src/spells-floor.c
src/spells1.c
src/wizard2.c

index 5de566b..b178b0a 100644 (file)
@@ -711,7 +711,7 @@ static bool pattern_effect(player_type *creature_ptr)
                (void)restore_level(creature_ptr);
                (void)cure_critical_wounds(creature_ptr, 1000);
 
-               cave_set_feat(creature_ptr->y, creature_ptr->x, feat_pattern_old);
+               cave_set_feat(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_old);
                msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
 
                /*
index 39f52d7..a2a56f8 100644 (file)
@@ -6,6 +6,8 @@
 #include "rooms.h"
 #include "quest.h"
 #include "object-hook.h"
+#include "world.h"
+#include "player-effects.h"
 
 /*
  * The array of floor [MAX_WID][MAX_HGT].
@@ -642,4 +644,111 @@ bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x)
        return (TRUE);
 }
 
+/*
+ * Change the "feat" flag for a grid, and notice/redraw the grid
+ */
+void cave_set_feat(floor_type *floor_ptr, POSITION y, POSITION x, FEAT_IDX feat)
+{
+       grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+       feature_type *f_ptr = &f_info[feat];
+       bool old_los, old_mirror;
+
+       if (!current_world_ptr->character_dungeon)
+       {
+               /* Clear mimic type */
+               g_ptr->mimic = 0;
+
+               /* Change the feature */
+               g_ptr->feat = feat;
+
+               /* Hack -- glow the GLOW terrain */
+               if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
+               {
+                       DIRECTION i;
+                       POSITION yy, xx;
+
+                       for (i = 0; i < 9; i++)
+                       {
+                               yy = y + ddy_ddd[i];
+                               xx = x + ddx_ddd[i];
+                               if (!in_bounds2(floor_ptr, yy, xx)) continue;
+                               floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
+                       }
+               }
+
+               return;
+       }
+
+       old_los = cave_have_flag_bold(y, x, FF_LOS);
+       old_mirror = is_mirror_grid(g_ptr);
+
+       /* Clear mimic type */
+       g_ptr->mimic = 0;
+
+       /* Change the feature */
+       g_ptr->feat = feat;
+
+       /* Remove flag for mirror/glyph */
+       g_ptr->info &= ~(CAVE_OBJECT);
+
+       if (old_mirror && (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
+       {
+               g_ptr->info &= ~(CAVE_GLOW);
+               if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
+
+               update_local_illumination(p_ptr, y, x);
+       }
+
+       /* Check for change to boring grid */
+       if (!have_flag(f_ptr->flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
+       if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
+
+       note_spot(y, x);
+       lite_spot(y, x);
+
+       /* Check if los has changed */
+       if (old_los ^ have_flag(f_ptr->flags, FF_LOS))
+       {
+
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
+
+               update_local_illumination(p_ptr, y, x);
+
+#endif /* COMPLEX_WALL_ILLUMINATION */
+
+               /* Update the visuals */
+               p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_MONSTERS);
+       }
+
+       /* Hack -- glow the GLOW terrain */
+       if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
+       {
+               DIRECTION i;
+               POSITION yy, xx;
+               grid_type *cc_ptr;
+
+               for (i = 0; i < 9; i++)
+               {
+                       yy = y + ddy_ddd[i];
+                       xx = x + ddx_ddd[i];
+                       if (!in_bounds2(floor_ptr, yy, xx)) continue;
+                       cc_ptr = &floor_ptr->grid_array[yy][xx];
+                       cc_ptr->info |= CAVE_GLOW;
+
+                       if (player_has_los_grid(cc_ptr))
+                       {
+                               if (cc_ptr->m_idx) update_monster(p_ptr, cc_ptr->m_idx, FALSE);
+                               note_spot(yy, xx);
+                               lite_spot(yy, xx);
+                       }
+
+                       update_local_illumination(p_ptr, yy, xx);
+               }
+
+               if (p_ptr->special_defense & NINJA_S_STEALTH)
+               {
+                       if (floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
+               }
+       }
+}
 
index a79787a..e4842cc 100644 (file)
@@ -387,3 +387,4 @@ extern int project_length;
 
 extern void vault_monsters(floor_type *floor_ptr, POSITION y1, POSITION x1, int num);
 extern bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
+extern void cave_set_feat(floor_type *floor_ptr, POSITION y, POSITION x, FEAT_IDX feat);
index e5d7cf9..c34a6eb 100644 (file)
@@ -363,7 +363,7 @@ void place_closed_door(POSITION y, POSITION x, int type)
 
        if (feat != feat_none)
        {
-               cave_set_feat(y, x, feat);
+               cave_set_feat(p_ptr->current_floor_ptr, y, x, feat);
 
                /* Now it is not floor */
                p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
@@ -1459,115 +1459,6 @@ void update_flow(void)
        }
 }
 
-/*
- * Change the "feat" flag for a grid, and notice/redraw the grid
- */
-void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat)
-{
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-       feature_type *f_ptr = &f_info[feat];
-       bool old_los, old_mirror;
-
-       if (!current_world_ptr->character_dungeon)
-       {
-               /* Clear mimic type */
-               g_ptr->mimic = 0;
-
-               /* Change the feature */
-               g_ptr->feat = feat;
-
-               /* Hack -- glow the GLOW terrain */
-               if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
-               {
-                       DIRECTION i;
-                       POSITION yy, xx;
-
-                       for (i = 0; i < 9; i++)
-                       {
-                               yy = y + ddy_ddd[i];
-                               xx = x + ddx_ddd[i];
-                               if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
-                               p_ptr->current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
-                       }
-               }
-
-               return;
-       }
-
-       old_los = cave_have_flag_bold(y, x, FF_LOS);
-       old_mirror = is_mirror_grid(g_ptr);
-
-       /* Clear mimic type */
-       g_ptr->mimic = 0;
-
-       /* Change the feature */
-       g_ptr->feat = feat;
-
-       /* Remove flag for mirror/glyph */
-       g_ptr->info &= ~(CAVE_OBJECT);
-
-       if (old_mirror && (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
-       {
-               g_ptr->info &= ~(CAVE_GLOW);
-               if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
-
-               update_local_illumination(p_ptr, y, x);
-       }
-
-       /* Check for change to boring grid */
-       if (!have_flag(f_ptr->flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
-       if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
-
-       note_spot(y, x);
-       lite_spot(y, x);
-
-       /* Check if los has changed */
-       if (old_los ^ have_flag(f_ptr->flags, FF_LOS))
-       {
-
-#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
-
-               update_local_illumination(p_ptr, y, x);
-
-#endif /* COMPLEX_WALL_ILLUMINATION */
-
-               /* Update the visuals */
-               p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_MONSTERS);
-       }
-
-       /* Hack -- glow the GLOW terrain */
-       if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
-       {
-               DIRECTION i;
-               POSITION yy, xx;
-               grid_type *cc_ptr;
-
-               for (i = 0; i < 9; i++)
-               {
-                       yy = y + ddy_ddd[i];
-                       xx = x + ddx_ddd[i];
-                       if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
-                       cc_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx];
-                       cc_ptr->info |= CAVE_GLOW;
-
-                       if (player_has_los_grid(cc_ptr))
-                       {
-                               if (cc_ptr->m_idx) update_monster(p_ptr, cc_ptr->m_idx, FALSE);
-
-                               note_spot(yy, xx);
-
-                               lite_spot(yy, xx);
-                       }
-
-                       update_local_illumination(p_ptr, yy, xx);
-               }
-
-               if (p_ptr->special_defense & NINJA_S_STEALTH)
-               {
-                       if (p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
-               }
-       }
-}
 
 FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
 {
@@ -1635,7 +1526,7 @@ void cave_alter_feat(POSITION y, POSITION x, int action)
        if (newfeat == oldfeat) return;
 
        /* Set the new feature */
-       cave_set_feat(y, x, newfeat);
+       cave_set_feat(p_ptr->current_floor_ptr, y, x, newfeat);
 
        if (!(feature_action_flags[action] & FAF_NO_DROP))
        {
index dd0812f..5f9c3d0 100644 (file)
@@ -409,7 +409,6 @@ extern void note_spot(POSITION y, POSITION x);
 extern void lite_spot(POSITION y, POSITION x);
 extern void delayed_visual_update(void);
 extern void update_flow(void);
-extern void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat);
 extern FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat);
 extern FEAT_IDX feat_state(FEAT_IDX feat, int action);
 extern void cave_alter_feat(POSITION y, POSITION x, int action);
index d80a65a..ad3620e 100644 (file)
@@ -5188,11 +5188,11 @@ void wreck_the_pattern(player_type *creature_ptr)
                if (pattern_tile(r_y, r_x) &&
                        (f_info[p_ptr->current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
-                       cave_set_feat(r_y, r_x, feat_pattern_corrupted);
+                       cave_set_feat(p_ptr->current_floor_ptr, r_y, r_x, feat_pattern_corrupted);
                }
        }
 
-       cave_set_feat(creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
+       cave_set_feat(p_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
 }
 
 
index 9f16811..920a915 100644 (file)
@@ -296,7 +296,7 @@ void check_quest_completion(monster_type *m_ptr)
                msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
 
                /* Create stairs down */
-               cave_set_feat(y, x, feat_down_stair);
+               cave_set_feat(p_ptr->current_floor_ptr, y, x, feat_down_stair);
 
                /* Remember to update everything */
                p_ptr->update |= (PU_FLOW);
index f211f65..611a7d3 100644 (file)
@@ -168,7 +168,7 @@ static void build_stores(POSITION ltcy, POSITION ltcx, int stores[], int n)
                /* Clear previous contents, add a store door */
                if (j < max_f_idx)
                {
-                       cave_set_feat(ltcy + y, ltcx + x, j);
+                       cave_set_feat(p_ptr->current_floor_ptr, ltcy + y, ltcx + x, j);
 
                        /* Init store */
                        store_init(NO_TOWN, stores[i]);
index d08084c..5b0e953 100644 (file)
@@ -344,7 +344,7 @@ void stair_creation(player_type *caster_ptr)
 
                                /* Remove old stairs */
                                g_ptr->special = 0;
-                               cave_set_feat(y, x, feat_ground_type[randint0(100)]);
+                               cave_set_feat(floor_ptr, y, x, feat_ground_type[randint0(100)]);
                        }
                }
        }
@@ -368,13 +368,13 @@ void stair_creation(player_type *caster_ptr)
        /* Create a staircase */
        if (up)
        {
-               cave_set_feat(caster_ptr->y, caster_ptr->x,
+               cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x,
                        (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= floor_ptr->dun_level - 2)) ?
                        feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
        }
        else
        {
-               cave_set_feat(caster_ptr->y, caster_ptr->x,
+               cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x,
                        (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= floor_ptr->dun_level + 2)) ?
                        feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
        }
@@ -598,22 +598,22 @@ bool destroy_area(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION r, b
                                        if (t < 20)
                                        {
                                                /* Create granite wall */
-                                               cave_set_feat(y, x, feat_granite);
+                                               cave_set_feat(floor_ptr, y, x, feat_granite);
                                        }
                                        else if (t < 70)
                                        {
                                                /* Create quartz vein */
-                                               cave_set_feat(y, x, feat_quartz_vein);
+                                               cave_set_feat(floor_ptr, y, x, feat_quartz_vein);
                                        }
                                        else if (t < 100)
                                        {
                                                /* Create magma vein */
-                                               cave_set_feat(y, x, feat_magma_vein);
+                                               cave_set_feat(floor_ptr, y, x, feat_magma_vein);
                                        }
                                        else
                                        {
                                                /* Create floor */
-                                               cave_set_feat(y, x, feat_ground_type[randint0(100)]);
+                                               cave_set_feat(floor_ptr, y, x, feat_ground_type[randint0(100)]);
                                        }
                                }
                                else /* In generation */
@@ -1078,28 +1078,28 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                                if (t < 20)
                                {
                                        /* Create granite wall */
-                                       cave_set_feat(yy, xx, feat_granite);
+                                       cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_granite);
                                }
 
                                /* Quartz */
                                else if (t < 70)
                                {
                                        /* Create quartz vein */
-                                       cave_set_feat(yy, xx, feat_quartz_vein);
+                                       cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_quartz_vein);
                                }
 
                                /* Magma */
                                else if (t < 100)
                                {
                                        /* Create magma vein */
-                                       cave_set_feat(yy, xx, feat_magma_vein);
+                                       cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_magma_vein);
                                }
 
                                /* Floor */
                                else
                                {
                                        /* Create floor */
-                                       cave_set_feat(yy, xx, feat_ground_type[randint0(100)]);
+                                       cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_ground_type[randint0(100)]);
                                }
                        }
                }
index 011d45b..e798793 100644 (file)
@@ -320,7 +320,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                if (message)
                {
                        msg_format(_("木は%s。", "A tree %s"), message);
-                       cave_set_feat(y, x, one_in_(3) ? feat_brake : feat_grass);
+                       cave_set_feat(floor_ptr, y, x, one_in_(3) ? feat_brake : feat_grass);
 
                        /* Observe */
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
@@ -496,7 +496,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        if (!cave_naked_bold(p_ptr, p_ptr->current_floor_ptr, y, x)) break;
                        if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(y, x, feat_door[DOOR_DOOR].closed);
+                       cave_set_feat(floor_ptr, y, x, feat_door[DOOR_DOOR].closed);
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
                        break;
                }
@@ -511,7 +511,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        if (!cave_naked_bold(p_ptr, p_ptr->current_floor_ptr, y, x)) break;
                        if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(y, x, feat_tree);
+                       cave_set_feat(floor_ptr, y, x, feat_tree);
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
                        break;
                }
@@ -530,7 +530,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        if (!cave_naked_bold(p_ptr, p_ptr->current_floor_ptr, y, x)) break;
                        if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(y, x, feat_granite);
+                       cave_set_feat(floor_ptr, y, x, feat_granite);
                        break;
                }
 
@@ -540,11 +540,11 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (dam == 1)
                        {
                                if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
-                               cave_set_feat(y, x, feat_shallow_lava);
+                               cave_set_feat(floor_ptr, y, x, feat_shallow_lava);
                        }
                        else if (dam)
                        {
-                               cave_set_feat(y, x, feat_deep_lava);
+                               cave_set_feat(floor_ptr, y, x, feat_deep_lava);
                        }
                        break;
                }
@@ -555,11 +555,11 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (dam == 1)
                        {
                                if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
-                               cave_set_feat(y, x, feat_shallow_water);
+                               cave_set_feat(floor_ptr, y, x, feat_shallow_water);
                        }
                        else if (dam)
                        {
-                               cave_set_feat(y, x, feat_deep_water);
+                               cave_set_feat(floor_ptr, y, x, feat_deep_water);
                        }
                        break;
                }
index ff1a7df..de3a490 100644 (file)
@@ -1644,7 +1644,7 @@ static void do_cmd_wiz_create_feature(player_type *creature_ptr)
        if (tmp_mimic < 0) tmp_mimic = 0;
        else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1;
 
-       cave_set_feat(y, x, tmp_feat);
+       cave_set_feat(creature_ptr->current_floor_ptr, y, x, tmp_feat);
        g_ptr->mimic = (s16b)tmp_mimic;
 
        f_ptr = &f_info[get_feat_mimic(g_ptr)];