OSDN Git Service

[Refactor] #38997 monster_can_*()にplayer_type * 引数を追加 / Added player_type * argument...
authorHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 12:15:25 +0000 (21:15 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 14:01:53 +0000 (23:01 +0900)
src/cmd/cmd-activate.c
src/floor-generate.c
src/floor-save.c
src/floor-streams.c
src/grid.c
src/monster-process.c
src/monster.h
src/monster1.c
src/monster2.c
src/player-move.c
src/realm-hissatsu.c

index ddd3ce7..4bf735f 100644 (file)
@@ -537,7 +537,7 @@ void exe_activate(player_type *user_ptr, INVENTORY_IDX item)
                {
                        success = FALSE;
                        if (!get_direction(user_ptr, &dir, FALSE, FALSE)) return;
-                       if (monster_can_enter(user_ptr->y + ddy[dir], user_ptr->x + ddx[dir], &r_info[o_ptr->pval], 0))
+                       if (monster_can_enter(user_ptr, user_ptr->y + ddy[dir], user_ptr->x + ddx[dir], &r_info[o_ptr->pval], 0))
                        {
                                if (place_monster_aux(user_ptr, 0, user_ptr->y + ddy[dir], user_ptr->x + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
                                {
index b01e092..f0bb28b 100644 (file)
@@ -454,7 +454,7 @@ bool place_quest_monsters(player_type *creature_ptr)
                                        f_ptr = &f_info[g_ptr->feat];
 
                                        if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) continue;
-                                       if (!monster_can_enter(y, x, r_ptr, 0)) continue;
+                                       if (!monster_can_enter(creature_ptr, y, x, r_ptr, 0)) continue;
                                        if (distance(y, x, creature_ptr->y, creature_ptr->x) < 10) continue;
                                        if (g_ptr->info & CAVE_ICKY) continue;
                                        else break;
index 90fa7ef..85283a6 100644 (file)
@@ -580,7 +580,7 @@ static void place_pet(player_type *master_ptr)
                                for (j = 1000; j > 0; j--)
                                {
                                        scatter(master_ptr, &cy, &cx, master_ptr->y, master_ptr->x, d, 0);
-                                       if (monster_can_enter(cy, cx, &r_info[party_mon[i].r_idx], 0)) break;
+                                       if (monster_can_enter(master_ptr, cy, cx, &r_info[party_mon[i].r_idx], 0)) break;
                                }
                                if (j) break;
                        }
index 68db430..aabfb4c 100644 (file)
@@ -294,7 +294,7 @@ void build_streamer(player_type *player_ptr, FEAT_IDX feat, int chance)
                                if (is_closed_door(player_ptr, g_ptr->feat)) continue;
                        }
 
-                       if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[floor_ptr->m_list[g_ptr->m_idx].r_idx], 0)))
+                       if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(player_ptr, feat, &r_info[floor_ptr->m_list[g_ptr->m_idx].r_idx], 0)))
                        {
                                /* Delete the monster (if any) */
                                delete_monster(player_ptr, ty, tx);
index f4a508e..cb5c7bc 100644 (file)
@@ -1122,7 +1122,7 @@ bool cave_monster_teleportable_bold(player_type *player_ptr, MONSTER_IDX m_idx,
 
        if (!(mode & TELEPORT_PASSIVE))
        {
-               if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
+               if (!monster_can_cross_terrain(player_ptr, g_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
        }
 
        return TRUE;
@@ -1196,7 +1196,7 @@ bool player_can_enter(player_type *creature_ptr, FEAT_IDX feature, BIT_FLAGS16 m
 {
        feature_type *f_ptr = &f_info[feature];
 
-       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 (creature_ptr->riding) return monster_can_cross_terrain(creature_ptr, 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))
        {
index efd9632..7b85644 100644 (file)
@@ -728,7 +728,7 @@ static bool find_safety(player_type *target_ptr, MONSTER_IDX m_idx, POSITION *yp
                        g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Skip locations in a wall */
-                       if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == target_ptr->riding) ? CEM_RIDING : 0)) continue;
+                       if (!monster_can_cross_terrain(target_ptr, g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == target_ptr->riding) ? CEM_RIDING : 0)) continue;
 
                        /* Check for "availability" (if monsters can flow) */
                        if (!(m_ptr->mflag2 & MFLAG2_NOFLOW))
@@ -815,7 +815,7 @@ static bool find_hiding(player_type *target_ptr, MONSTER_IDX m_idx, POSITION *yp
                        if (!in_bounds(floor_ptr, y, x)) continue;
 
                        /* Skip occupied locations */
-                       if (!monster_can_enter(y, x, r_ptr, 0)) continue;
+                       if (!monster_can_enter(target_ptr, y, x, r_ptr, 0)) continue;
 
                        /* Check for hidden, available grid */
                        if (projectable(target_ptr, target_ptr->y, target_ptr->x, y, x) && clean_shot(target_ptr, fy, fx, y, x, FALSE))
@@ -911,7 +911,7 @@ static bool get_moves(player_type *target_ptr, MONSTER_IDX m_idx, DIRECTION *mm)
                                g_ptr = &floor_ptr->grid_array[yy][xx];
 
                                /* Check grid */
-                               if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
+                               if (monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, 0))
                                {
                                        /* One more room grid */
                                        room++;
@@ -954,7 +954,7 @@ static bool get_moves(player_type *target_ptr, MONSTER_IDX m_idx, DIRECTION *mm)
                                if (!in_bounds2(floor_ptr, y2, x2)) continue;
 
                                /* Ignore filled grids */
-                               if (!monster_can_enter(y2, x2, r_ptr, 0)) continue;
+                               if (!monster_can_enter(target_ptr, y2, x2, r_ptr, 0)) continue;
 
                                /* Try to fill this hole */
                                break;
@@ -1756,7 +1756,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
                /* Access that grid */
                g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
                f_ptr = &f_info[g_ptr->feat];
-               can_cross = monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
+               can_cross = monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
 
                /* Access that grid's contents */
                y_ptr = &target_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
@@ -2055,7 +2055,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
                        else if ((r_ptr->flags2 & RF2_MOVE_BODY) && !(r_ptr->flags1 & RF1_NEVER_MOVE) &&
                                (r_ptr->mexp > z_ptr->mexp) &&
                                can_cross && (g_ptr->m_idx != target_ptr->riding) &&
-                               monster_can_cross_terrain(target_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
+                               monster_can_cross_terrain(target_ptr, target_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
                        {
                                /* Allow movement */
                                do_move = TRUE;
@@ -2105,7 +2105,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
 
                if (must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
                {
-                       if (!monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
+                       if (!monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
                        {
                                /* Assume no move allowed */
                                do_move = FALSE;
index d17bcf3..85979ae 100644 (file)
@@ -453,8 +453,8 @@ extern void anger_monster(player_type *player_ptr, monster_type *m_ptr);
  */
 #define CEM_RIDING              0x0001
 #define CEM_P_CAN_ENTER_PATTERN 0x0002
-extern bool monster_can_cross_terrain(FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 mode);
-extern bool monster_can_enter(POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode);
+extern bool monster_can_cross_terrain(player_type *player_ptr, FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 mode);
+extern bool monster_can_enter(player_type *player_ptr, POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode);
 
 extern bool are_enemies(monster_type *m_ptr1, monster_type *m_ptr2);
 extern bool monster_has_hostile_align(monster_type *m_ptr, int pa_good, int pa_evil, monster_race *r_ptr);
index 26e7f67..62f3bbf 100644 (file)
@@ -2117,12 +2117,13 @@ void anger_monster(player_type *player_ptr, monster_type *m_ptr)
 /*!
  * @brief モンスターが地形を踏破できるかどうかを返す
  * Check if monster can cross terrain
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param feat 地形ID
  * @param r_ptr モンスター種族構造体の参照ポインタ
  * @param mode オプション
  * @return 踏破可能ならばTRUEを返す
  */
-bool monster_can_cross_terrain(FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 mode)
+bool monster_can_cross_terrain(player_type *player_ptr, FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 mode)
 {
        feature_type *f_ptr = &f_info[feat];
 
@@ -2143,7 +2144,7 @@ bool monster_can_cross_terrain(FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 m
        if (have_flag(f_ptr->flags, FF_CAN_SWIM) && (r_ptr->flags7 & RF7_CAN_SWIM)) return TRUE;
        if (have_flag(f_ptr->flags, FF_CAN_PASS))
        {
-               if ((r_ptr->flags2 & RF2_PASS_WALL) && (!(mode & CEM_RIDING) || p_ptr->pass_wall)) return TRUE;
+               if ((r_ptr->flags2 & RF2_PASS_WALL) && (!(mode & CEM_RIDING) || player_ptr->pass_wall)) return TRUE;
        }
 
        if (!have_flag(f_ptr->flags, FF_MOVE)) return FALSE;
@@ -2204,19 +2205,20 @@ bool monster_can_cross_terrain(FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 m
 /*!
  * @brief 指定された座標の地形をモンスターが踏破できるかどうかを返す
  * Strictly check if monster can enter the grid
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param y 地形のY座標
  * @param x 地形のX座標
  * @param r_ptr モンスター種族構造体の参照ポインタ
  * @param mode オプション
  * @return 踏破可能ならばTRUEを返す
  */
-bool monster_can_enter(POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode)
+bool monster_can_enter(player_type *player_ptr, POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode)
 {
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-       if (player_bold(p_ptr, y, x)) return FALSE;
+       grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+       if (player_bold(player_ptr, y, x)) return FALSE;
        if (g_ptr->m_idx) return FALSE;
 
-       return monster_can_cross_terrain(g_ptr->feat, r_ptr, mode);
+       return monster_can_cross_terrain(player_ptr, g_ptr->feat, r_ptr, mode);
 }
 
 
index 71b9045..2f0903e 100644 (file)
@@ -2188,7 +2188,7 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
        if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
                return FALSE;
 
-       if (!monster_can_cross_terrain(floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
+       if (!monster_can_cross_terrain(p_ptr, floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
 
        /* Not born */
        if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
@@ -2228,7 +2228,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
        if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
                return FALSE;
 
-       if (!monster_can_cross_terrain(floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
+       if (!monster_can_cross_terrain(p_ptr, floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
 
        /* Not born */
        if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
@@ -2483,7 +2483,7 @@ static bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION
                if (pattern_tile(y, x)) return FALSE;
 
                /* Require empty space (if not ghostly) */
-               if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
+               if (!monster_can_enter(player_ptr, y, x, r_ptr, 0)) return FALSE;
        }
 
        if (!player_ptr->phase_out)
@@ -2867,7 +2867,7 @@ static bool mon_scatter(player_type *player_ptr, MONRACE_IDX r_idx, POSITION *yp
                                monster_race *r_ptr = &r_info[r_idx];
 
                                /* Require empty space (if not ghostly) */
-                               if (!monster_can_enter(ny, nx, r_ptr, 0))
+                               if (!monster_can_enter(player_ptr, ny, nx, r_ptr, 0))
                                        continue;
                        }
                        else
@@ -3266,7 +3266,7 @@ bool alloc_guardian(player_type *player_ptr, bool def_val)
                        continue;
                }
 
-               if (!monster_can_cross_terrain(floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
+               if (!monster_can_cross_terrain(player_ptr, floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
                {
                        try_count++;
                        continue;
index 7ae0208..b259e13 100644 (file)
@@ -1010,7 +1010,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                                py_attack(creature_ptr, y, x, 0);
                                can_move = FALSE;
                        }
-                       else if (monster_can_cross_terrain(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat, r_ptr, 0))
+                       else if (monster_can_cross_terrain(creature_ptr, floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat, r_ptr, 0))
                        {
                                do_past = TRUE;
                        }
index 4e5b53d..c18c7c0 100644 (file)
@@ -678,7 +678,7 @@ concptr do_hissatsu_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mo
                                m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
 
                                /* Monster cannot move back? */
-                               if (!monster_can_enter(ny, nx, &r_info[m_ptr->r_idx], 0))
+                               if (!monster_can_enter(caster_ptr, ny, nx, &r_info[m_ptr->r_idx], 0))
                                {
                                        /* -more- */
                                        if (i < 2) msg_print(NULL);