OSDN Git Service

[Refactor] #38997 関数マクロcave_empty_bold*() を普通の関数に展開し、player-type * 引数を追加 / Changed...
authorHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 13:12:11 +0000 (22:12 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 14:01:54 +0000 (23:01 +0900)
17 files changed:
src/chest.c
src/combat/shoot.c
src/floor-save.c
src/floor.c
src/floor.h
src/mind.c
src/monster1.c
src/monster2.c
src/mspells1.c
src/mspells4.c
src/realm-crusade.c
src/realm-hex.c
src/realm-hissatsu.c
src/spells-floor.c
src/spells2.c
src/spells3.c
src/wizard2.c

index 2351612..1cfc5f3 100644 (file)
@@ -99,7 +99,7 @@ void chest_death(player_type *owner_ptr, bool scatter, POSITION y, POSITION x, O
                                x = randint0(MAX_WID);
 
                                /* Must be an empty floor. */
-                               if (!cave_empty_bold(floor_ptr, y, x)) continue;
+                               if (!is_cave_empty_bold(owner_ptr, y, x)) continue;
 
                                /* Place the object there. */
                                (void)drop_near(owner_ptr, q_ptr, -1, y, x);
index c39d590..4815ee0 100644 (file)
@@ -786,7 +786,7 @@ void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr,
                                                                if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
 
                                                                /* Stopped by monsters */
-                                                               if (!cave_empty_bold(shooter_ptr->current_floor_ptr, ny, nx)) break;
+                                                               if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
 
                                                                shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
                                                                shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
index a2ff81f..cea5893 100644 (file)
@@ -738,7 +738,7 @@ static void get_out_monster(player_type *protected_ptr)
                if (!in_bounds(floor_ptr, ny, nx)) continue;
 
                /* Require "empty" floor space */
-               if (!cave_empty_bold(floor_ptr, ny, nx)) continue;
+               if (!is_cave_empty_bold(protected_ptr, ny, nx)) continue;
 
                /* Hack -- no teleport onto glyph of warding */
                if (is_glyph_grid(&floor_ptr->grid_array[ny][nx])) continue;
index c9ff4ff..1415eab 100644 (file)
@@ -45,6 +45,39 @@ bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x)
 }
 
 
+/*
+ * Determine if a "legal" grid is an "empty" floor grid
+ * Determine if monsters are allowed to move into a grid
+ *
+ * Line 1 -- forbid non-placement grids
+ * Line 2 -- forbid normal monsters
+ * Line 3 -- forbid the player
+ */
+bool is_cave_empty_bold(player_type *player_ptr, POSITION x, POSITION y)
+{
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       bool is_empty_grid = cave_have_flag_bold(floor_ptr, y, x, FF_PLACE);
+       is_empty_grid &= !(floor_ptr->grid_array[y][x].m_idx);
+       is_empty_grid &= !player_bold(player_ptr, y, x);
+       return is_empty_grid;
+}
+
+
+/*
+  * Determine if a "legal" grid is an "empty" floor grid
+  * Determine if monster generation is allowed in a grid
+  *
+  * Line 1 -- forbid non-empty grids
+  * Line 2 -- forbid trees while dungeon generation
+  */
+bool is_cave_empty_bold2(player_type *player_ptr, POSITION y, POSITION x)
+{
+       bool is_empty_grid = is_cave_empty_bold(player_ptr, y, x);
+       is_empty_grid &= current_world_ptr->character_dungeon || !cave_have_flag_bold(player_ptr->current_floor_ptr, y, x, FF_TREE);
+       return is_empty_grid;
+}
+
+
 /*!
 * @brief 鍵のかかったドアを配置する
 * @param player_ptr プレーヤーへの参照ポインタ
index f9b263d..f033af0 100644 (file)
@@ -255,32 +255,6 @@ extern floor_type floor_info;
 
 
 /*
- * Determine if a "legal" grid is an "empty" floor grid
- * Determine if monsters are allowed to move into a grid
- *
- * Line 1 -- forbid non-placement grids
- * Line 2 -- forbid normal monsters
- * Line 3 -- forbid the player
- */
-#define cave_empty_bold(F,Y,X) \
-       (cave_have_flag_bold((F), (Y), (X), FF_PLACE) && \
-        !((F)->grid_array[Y][X].m_idx) && \
-        !player_bold(p_ptr, Y,X))
-
-
-/*
- * Determine if a "legal" grid is an "empty" floor grid
- * Determine if monster generation is allowed in a grid
- *
- * Line 1 -- forbid non-empty grids
- * Line 2 -- forbid trees while dungeon generation
- */
-#define cave_empty_bold2(F,Y,X) \
-       (cave_empty_bold(F,Y,X) && \
-        (current_world_ptr->character_dungeon || !cave_have_flag_bold((F), (Y), (X), FF_TREE)))
-
-
-/*
  * Determine if a "legal" grid is an "naked" floor grid
  *
  * Line 1 -- forbid non-clean gird
@@ -363,6 +337,8 @@ extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
        ((int)((G) % 256U))
 
 extern bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x);
+extern bool is_cave_empty_bold(player_type *player_ptr, POSITION x, POSITION y);
+extern bool is_cave_empty_bold2(player_type *player_ptr, POSITION x, POSITION y);
 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 de5887e..b73af3d 100644 (file)
@@ -1663,7 +1663,7 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
                        POSITION nx = GRID_X(path_g[i]);
                        grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
 
-                       if (in_bounds(floor_ptr, ny, nx) && cave_empty_bold(floor_ptr, ny, nx) &&
+                       if (in_bounds(floor_ptr, ny, nx) && is_cave_empty_bold(caster_ptr, ny, nx) &&
                            !(g_ptr->info & CAVE_OBJECT) &&
                                !pattern_tile(floor_ptr, ny, nx))
                        {
index 62f3bbf..2a0ee4d 100644 (file)
@@ -2583,7 +2583,7 @@ void monster_death(player_type *player_ptr, MONSTER_IDX m_idx, bool drop_item)
                do
                {
                        scatter(player_ptr, &wy, &wx, y, x, 20, 0);
-               } while (!(in_bounds(floor_ptr, wy, wx) && cave_empty_bold2(floor_ptr, wy, wx)) && --attempts);
+               } while (!(in_bounds(floor_ptr, wy, wx) && is_cave_empty_bold2(player_ptr, wy, wx)) && --attempts);
 
                if (attempts <= 0) break;
 
index bab36fe..8b4281f 100644 (file)
@@ -2873,7 +2873,7 @@ static bool mon_scatter(player_type *player_ptr, MONRACE_IDX r_idx, POSITION *yp
                        else
                        {
                                /* Walls and Monsters block flow */
-                               if (!cave_empty_bold2(floor_ptr, ny, nx)) continue;
+                               if (!is_cave_empty_bold2(player_ptr, ny, nx)) continue;
 
                                /* ... nor on the Pattern */
                                if (pattern_tile(floor_ptr, ny, nx)) continue;
@@ -2972,7 +2972,7 @@ static bool place_monster_group(player_type *player_ptr, MONSTER_IDX who, POSITI
                        scatter(player_ptr, &my, &mx, hy, hx, 4, 0);
 
                        /* Walls and Monsters block flow */
-                       if (!cave_empty_bold2(floor_ptr, my, mx)) continue;
+                       if (!is_cave_empty_bold2(player_ptr, my, mx)) continue;
 
                        /* Attempt to place another monster */
                        if (place_monster_one(player_ptr, who, my, mx, r_idx, mode))
@@ -3122,7 +3122,7 @@ bool place_monster_aux(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
                scatter(player_ptr, &ny, &nx, y, x, d, 0);
 
                /* Require empty grids */
-               if (!cave_empty_bold2(player_ptr->current_floor_ptr, ny, nx)) continue;
+               if (!is_cave_empty_bold2(player_ptr, ny, nx)) continue;
                get_mon_num_prep(player_ptr, place_monster_can_escort, get_monster_hook2(player_ptr, ny, nx));
 
                /* Pick a random race */
@@ -3260,7 +3260,7 @@ bool alloc_guardian(player_type *player_ptr, bool def_val)
                POSITION ox = randint1(floor_ptr->width - 4) + 2;
 
                /* Is it a good spot ? */
-               if (!cave_empty_bold2(floor_ptr, oy, ox))
+               if (!is_cave_empty_bold2(player_ptr, oy, ox))
                {
                        try_count++;
                        continue;
@@ -3310,11 +3310,11 @@ bool alloc_monster(player_type *player_ptr, POSITION dis, BIT_FLAGS mode)
                /* Require empty floor grid (was "naked") */
                if (floor_ptr->dun_level)
                {
-                       if (!cave_empty_bold2(floor_ptr, y, x)) continue;
+                       if (!is_cave_empty_bold2(player_ptr, y, x)) continue;
                }
                else
                {
-                       if (!cave_empty_bold(floor_ptr, y, x)) continue;
+                       if (!is_cave_empty_bold(player_ptr, y, x)) continue;
                }
 
                /* Accept far away grids */
index 0022628..1caa7e4 100644 (file)
@@ -394,7 +394,7 @@ bool summon_possible(player_type *target_ptr, POSITION y1, POSITION x1)
                        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;
+                       if (is_cave_empty_bold(target_ptr, y, x) && projectable(target_ptr, y1, x1, y, x) && projectable(target_ptr, y, x, y1, x1)) return TRUE;
                }
        }
 
index 43fed0f..bf261db 100644 (file)
@@ -3395,23 +3395,22 @@ MONSTER_NUMBER summon_NAZGUL(player_type *target_ptr, POSITION y, POSITION x, MO
 
        msg_print(NULL);
 
-       floor_type *floor_ptr = target_ptr->current_floor_ptr;
        int count = 0;
        for (int k = 0; k < 30; k++)
        {
-               if (!summon_possible(target_ptr, cy, cx) || !cave_empty_bold(floor_ptr, cy, cx))
+               if (!summon_possible(target_ptr, cy, cx) || !is_cave_empty_bold(target_ptr, cy, cx))
                {
                        int j;
                        for (j = 100; j > 0; j--)
                        {
                                scatter(target_ptr, &cy, &cx, y, x, 2, 0);
-                               if (cave_empty_bold(floor_ptr, cy, cx)) break;
+                               if (is_cave_empty_bold(target_ptr, cy, cx)) break;
                        }
 
                        if (!j) break;
                }
 
-               if (!cave_empty_bold(floor_ptr, cy, cx)) continue;
+               if (!is_cave_empty_bold(target_ptr, cy, cx)) continue;
 
                if (!summon_named_creature(target_ptr, m_idx, cy, cx, MON_NAZGUL, mode)) continue;
 
index b89ebb1..3286304 100644 (file)
@@ -562,7 +562,7 @@ concptr do_crusade_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mod
                                                scatter(caster_ptr, &my, &mx, caster_ptr->y, caster_ptr->x, 4, 0);
 
                                                /* Require empty grids */
-                                               if (cave_empty_bold2(caster_ptr->current_floor_ptr, my, mx)) break;
+                                               if (is_cave_empty_bold2(caster_ptr, my, mx)) break;
                                        }
                                        if (attempt < 0) continue;
                                        summon_specific(caster_ptr, -1, my, mx, plev, SUMMON_KNIGHTS, (PM_ALLOW_GROUP | PM_FORCE_PET | PM_HASTE));
index 79fa510..6e2a937 100644 (file)
@@ -1026,7 +1026,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
                                        if (caster_ptr->current_floor_ptr->grid_array[dy][dx].m_idx) flag = TRUE;
                                }
 
-                               if (!cave_empty_bold(caster_ptr->current_floor_ptr, y, x) || (caster_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
+                               if (!is_cave_empty_bold(caster_ptr, y, x) || (caster_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
                                        (distance(y, x, caster_ptr->y, caster_ptr->x) > plev + 2))
                                {
                                        msg_print(_("そこには移動できない。", "Can not teleport to there."));
index c18c7c0..34287a7 100644 (file)
@@ -313,7 +313,7 @@ concptr do_hissatsu_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mo
                                {
                                        y += ddy[dir];
                                        x += ddx[dir];
-                                       if (cave_empty_bold(caster_ptr->current_floor_ptr, y, x))
+                                       if (is_cave_empty_bold(caster_ptr, y, x))
                                        {
                                                ty = y;
                                                tx = x;
index 961f615..5df07da 100644 (file)
@@ -800,7 +800,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                        x = caster_ptr->x + ddx_ddd[i];
 
                        /* Skip non-empty grids */
-                       if (!cave_empty_bold(floor_ptr, y, x)) continue;
+                       if (!is_cave_empty_bold(caster_ptr, y, x)) continue;
 
                        /* Important -- Skip "quake" grids */
                        if (map[16 + y - cy][16 + x - cx]) continue;
@@ -949,7 +949,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                                        x = xx + ddx_ddd[i];
 
                                        /* Skip non-empty grids */
-                                       if (!cave_empty_bold(floor_ptr, y, x)) continue;
+                                       if (!is_cave_empty_bold(caster_ptr, y, x)) continue;
 
                                        /* Hack -- no safety on glyph of warding */
                                        if (is_glyph_grid(&floor_ptr->grid_array[y][x])) continue;
index 6c0c393..b49c921 100644 (file)
@@ -3104,7 +3104,7 @@ bool rush_attack(player_type *attacker_ptr, bool *mdeath)
                int ny = GRID_Y(path_g[i]);
                int nx = GRID_X(path_g[i]);
 
-               if (cave_empty_bold(floor_ptr, ny, nx) && player_can_enter(attacker_ptr, floor_ptr->grid_array[ny][nx].feat, 0))
+               if (is_cave_empty_bold(attacker_ptr, ny, nx) && player_can_enter(attacker_ptr, floor_ptr->grid_array[ny][nx].feat, 0))
                {
                        ty = ny;
                        tx = nx;
index a79dee6..80c14d3 100644 (file)
@@ -3215,7 +3215,7 @@ bool shock_power(player_type *caster_ptr)
        {
                y += ddy[dir];
                x += ddx[dir];
-               if (cave_empty_bold(caster_ptr->current_floor_ptr, y, x))
+               if (is_cave_empty_bold(caster_ptr, y, x))
                {
                        ty = y;
                        tx = x;
index 7a339c9..ab8d599 100644 (file)
@@ -197,7 +197,7 @@ static void do_cmd_summon_horde(player_type *caster_ptr)
        while (--attempts)
        {
                scatter(caster_ptr, &wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
-               if (cave_empty_bold(caster_ptr->current_floor_ptr, wy, wx)) break;
+               if (is_cave_empty_bold(caster_ptr, wy, wx)) break;
        }
 
        (void)alloc_horde(caster_ptr, wy, wx);