OSDN Git Service

[Refactor] #38997 関数マクロpattern_tile() を普通の関数に展開し、player-type * 引数を追加 / Changed macro...
authorHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 12:47:03 +0000 (21:47 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 14:01:53 +0000 (23:01 +0900)
src/core.c
src/floor-generate.c
src/floor-save.c
src/floor.c
src/floor.h
src/mind.c
src/monster2.c
src/mspells1.c
src/player-status.c
src/spells-floor.c

index a8f6371..533a253 100644 (file)
@@ -692,7 +692,8 @@ static bool pattern_effect(player_type *creature_ptr)
 {
        int pattern_type;
 
-       if (!pattern_tile(creature_ptr->y, creature_ptr->x)) return FALSE;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (!pattern_tile(floor_ptr, creature_ptr->y, creature_ptr->x)) return FALSE;
 
        if ((PRACE_IS_(creature_ptr, RACE_AMBERITE)) &&
                (creature_ptr->cut > 0) && one_in_(10))
@@ -700,7 +701,6 @@ static bool pattern_effect(player_type *creature_ptr)
                wreck_the_pattern(creature_ptr);
        }
 
-       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
 
        switch (pattern_type)
index f0bb28b..564f703 100644 (file)
@@ -161,18 +161,20 @@ static int next_to_walls(floor_type* floor_ptr, POSITION y, POSITION x)
 
 /*!
  * @brief alloc_stairs()の補助として指定の位置に階段を生成できるかの判定を行う / Helper function for alloc_stairs(). Is this a good location for stairs?
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param y 基準のy座標
  * @param x 基準のx座標
  * @param walls 最低減隣接させたい外壁の数
  * @return 階段を生成して問題がないならばTRUEを返す。
  */
-static bool alloc_stairs_aux(floor_type *floor_ptr, POSITION y, POSITION x, int walls)
+static bool alloc_stairs_aux(player_type *player_ptr, POSITION y, POSITION x, int walls)
 {
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        grid_type *g_ptr = &floor_ptr->grid_array[y][x];
 
        /* Require "naked" floor grid */
        if (!is_floor_grid(g_ptr)) return FALSE;
-       if (pattern_tile(y, x)) return FALSE;
+       if (pattern_tile(floor_ptr, y, x)) return FALSE;
        if (g_ptr->o_idx || g_ptr->m_idx) return FALSE;
 
        /* Require a certain number of adjacent walls */
@@ -244,7 +246,7 @@ static bool alloc_stairs(player_type *owner_ptr, FEAT_IDX feat, int num, int wal
                        {
                                for (x = 1; x < floor_ptr->width - 1; x++)
                                {
-                                       if (alloc_stairs_aux(floor_ptr, y, x, walls))
+                                       if (alloc_stairs_aux(owner_ptr, y, x, walls))
                                        {
                                                /* A valid space found */
                                                candidates++;
@@ -270,7 +272,7 @@ static bool alloc_stairs(player_type *owner_ptr, FEAT_IDX feat, int num, int wal
                        {
                                for (x = 1; x < floor_ptr->width - 1; x++)
                                {
-                                       if (alloc_stairs_aux(floor_ptr, y, x, walls))
+                                       if (alloc_stairs_aux(owner_ptr, y, x, walls))
                                        {
                                                pick--;
 
index 85283a6..a2ff81f 100644 (file)
@@ -702,12 +702,13 @@ static void update_unique_artifact(floor_type *floor_ptr, s16b cur_floor_id)
  * @brief フロア移動時、プレイヤーの移動先モンスターが既にいた場合ランダムな近隣に移動させる / When a monster is at a place where player will return,
  * @return なし
  */
-static void get_out_monster(floor_type *floor_ptr, player_type *protected_ptr)
+static void get_out_monster(player_type *protected_ptr)
 {
        int tries = 0;
        POSITION dis = 1;
        POSITION oy = protected_ptr->y;
        POSITION ox = protected_ptr->x;
+       floor_type *floor_ptr = protected_ptr->current_floor_ptr;
        MONSTER_IDX m_idx = floor_ptr->grid_array[oy][ox].m_idx;
 
        /* Nothing to do if no monster */
@@ -737,14 +738,14 @@ static void get_out_monster(floor_type *floor_ptr, player_type *protected_ptr)
                if (!in_bounds(floor_ptr, ny, nx)) continue;
 
                /* Require "empty" floor space */
-               if (!cave_empty_bold(protected_ptr->current_floor_ptr, ny, nx)) continue;
+               if (!cave_empty_bold(floor_ptr, ny, nx)) continue;
 
                /* Hack -- no teleport onto glyph of warding */
                if (is_glyph_grid(&floor_ptr->grid_array[ny][nx])) continue;
                if (is_explosive_rune_grid(&floor_ptr->grid_array[ny][nx])) continue;
 
                /* ...nor onto the Pattern */
-               if (pattern_tile(ny, nx)) continue;
+               if (pattern_tile(floor_ptr, ny, nx)) continue;
 
                /*** It's a good place ***/
 
@@ -1074,7 +1075,7 @@ void leave_floor(player_type *creature_ptr)
            !(creature_ptr->change_floor_mode & CFM_NO_RETURN))
        {
                /* Get out of the my way! */
-               get_out_monster(creature_ptr->current_floor_ptr, creature_ptr);
+               get_out_monster(creature_ptr);
 
                /* Record the last visit turn of current floor */
                sf_ptr->last_visit = current_world_ptr->game_turn;
index 263351d..c9ff4ff 100644 (file)
@@ -39,6 +39,12 @@ bool is_cave_empty_grid(player_type *player_ptr, grid_type *g_ptr)
 }
 
 
+bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+       return cave_have_flag_bold(floor_ptr, y, x, FF_PATTERN);
+}
+
+
 /*!
 * @brief 鍵のかかったドアを配置する
 * @param player_ptr プレーヤーへの参照ポインタ
index 332d73b..f9b263d 100644 (file)
@@ -309,9 +309,6 @@ extern floor_type floor_info;
        (cave_have_flag_grid((C), FF_PERMANENT))
 
 
-#define pattern_tile(Y,X) \
-       (cave_have_flag_bold(p_ptr->current_floor_ptr, (Y), (X), FF_PATTERN))
-
 /*
  * Does the grid stop disintegration?
  */
@@ -365,6 +362,7 @@ extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 #define GRID_X(G) \
        ((int)((G) % 256U))
 
+extern bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x);
 extern void update_smell(floor_type *floor_ptr, player_type *subject_ptr);
 
 extern void add_door(player_type *player_ptr, POSITION x, POSITION y);
index cc9ee89..de5887e 100644 (file)
@@ -1545,6 +1545,7 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
        PLAYER_LEVEL plev = caster_ptr->lev;
 
        /* spell code */
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
        switch (spell)
        {
        case 0:
@@ -1646,12 +1647,12 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
                POSITION ty, tx;
 
                if (!target_set(caster_ptr, TARGET_KILL)) return FALSE;
-               m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
+               m_idx = floor_ptr->grid_array[target_row][target_col].m_idx;
                if (!m_idx) break;
                if (m_idx == caster_ptr->riding) break;
                if (!player_has_los_bold(caster_ptr, target_row, target_col)) break;
                if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col)) break;
-               m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
+               m_ptr = &floor_ptr->m_list[m_idx];
                monster_desc(caster_ptr, m_name, m_ptr, 0);
                msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
                path_n = project_path(caster_ptr, path_g, MAX_RANGE, target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
@@ -1660,21 +1661,21 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
                {
                        POSITION ny = GRID_Y(path_g[i]);
                        POSITION nx = GRID_X(path_g[i]);
-                       grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[ny][nx];
+                       grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
 
-                       if (in_bounds(caster_ptr->current_floor_ptr, ny, nx) && cave_empty_bold(caster_ptr->current_floor_ptr, ny, nx) &&
+                       if (in_bounds(floor_ptr, ny, nx) && cave_empty_bold(floor_ptr, ny, nx) &&
                            !(g_ptr->info & CAVE_OBJECT) &&
-                               !pattern_tile(ny, nx))
+                               !pattern_tile(floor_ptr, ny, nx))
                        {
                                ty = ny;
                                tx = nx;
                        }
                }
                /* Update the old location */
-               caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx = 0;
+               floor_ptr->grid_array[target_row][target_col].m_idx = 0;
 
                /* Update the new location */
-               caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
+               floor_ptr->grid_array[ty][tx].m_idx = m_idx;
 
                /* Move the monster */
                m_ptr->fy = ty;
index 2f0903e..bab36fe 100644 (file)
@@ -2480,7 +2480,7 @@ static bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION
        if (!(mode & PM_IGNORE_TERRAIN))
        {
                /* Not on the Pattern */
-               if (pattern_tile(y, x)) return FALSE;
+               if (pattern_tile(floor_ptr, y, x)) return FALSE;
 
                /* Require empty space (if not ghostly) */
                if (!monster_can_enter(player_ptr, y, x, r_ptr, 0)) return FALSE;
@@ -2876,7 +2876,7 @@ static bool mon_scatter(player_type *player_ptr, MONRACE_IDX r_idx, POSITION *yp
                                if (!cave_empty_bold2(floor_ptr, ny, nx)) continue;
 
                                /* ... nor on the Pattern */
-                               if (pattern_tile(ny, nx)) continue;
+                               if (pattern_tile(floor_ptr, ny, nx)) continue;
                        }
 
                        i = distance(y, x, ny, nx);
index a6cd51e..0022628 100644 (file)
@@ -391,7 +391,7 @@ bool summon_possible(player_type *target_ptr, POSITION y1, POSITION x1)
                        if (distance(y1, x1, y, x) > 2) continue;
 
                        /* ...nor on the Pattern */
-                       if (pattern_tile(y, x)) continue;
+                       if (pattern_tile(floor_ptr, y, x)) continue;
 
                        /* Require empty floor grid in line of projection */
                        if (cave_empty_bold(floor_ptr, y, x) && projectable(target_ptr, y1, x1, y, x) && projectable(target_ptr, y, x, y1, x1)) return TRUE;
index da1e896..c6efa5f 100644 (file)
@@ -5094,7 +5094,7 @@ void wreck_the_pattern(player_type *creature_ptr)
                POSITION r_y, r_x;
                scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
 
-               if (pattern_tile(r_y, r_x) &&
+               if (pattern_tile(floor_ptr, r_y, r_x) &&
                        (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
                        cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
index 0ad3721..961f615 100644 (file)
@@ -956,7 +956,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                                        if (is_explosive_rune_grid(&floor_ptr->grid_array[y][x])) continue;
 
                                        /* ... nor on the Pattern */
-                                       if (pattern_tile(y, x)) continue;
+                                       if (pattern_tile(floor_ptr, y, x)) continue;
 
                                        /* Important -- Skip "quake" grids */
                                        if (map[16 + y - cy][16 + x - cx]) continue;