OSDN Git Service

[Refactor] #38997 are_enemies()にplayer_type * 引数を追加 / Added player_type * argument...
authorHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 13:15:59 +0000 (22:15 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 14:01:54 +0000 (23:01 +0900)
src/monster-process.c
src/monster.h
src/monster1.c
src/mspells2.c

index 7b85644..20a928f 100644 (file)
@@ -114,7 +114,7 @@ static bool get_enemy_dir(player_type *target_ptr, MONSTER_IDX m_idx, int *mm)
                        }
 
                        /* Monster must be 'an enemy' */
-                       if (!are_enemies(m_ptr, t_ptr)) continue;
+                       if (!are_enemies(target_ptr, m_ptr, t_ptr)) continue;
 
                        /* Monster must be projectable if we can't pass through walls */
                        if (((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != target_ptr->riding) || target_ptr->pass_wall)) ||
@@ -875,7 +875,7 @@ static bool get_moves(player_type *target_ptr, MONSTER_IDX m_idx, DIRECTION *mm)
 
                /* The monster must be an enemy, and in LOS */
                if (t_m_idx &&
-                       are_enemies(m_ptr, &floor_ptr->m_list[t_m_idx]) &&
+                       are_enemies(target_ptr, m_ptr, &floor_ptr->m_list[t_m_idx]) &&
                        los(target_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
                        projectable(target_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                {
@@ -1588,7 +1588,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
                        MONSTER_IDX t_m_idx = target_ptr->current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                        /* The monster must be an enemy, and projectable */
-                       if (t_m_idx && are_enemies(m_ptr, &target_ptr->current_floor_ptr->m_list[t_m_idx]) &&
+                       if (t_m_idx && are_enemies(target_ptr, m_ptr, &target_ptr->current_floor_ptr->m_list[t_m_idx]) &&
                                projectable(target_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                        {
                                counterattack = TRUE;
@@ -2023,7 +2023,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
                        if (((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW) &&
                                (r_ptr->mexp * r_ptr->level > z_ptr->mexp * z_ptr->level) &&
                                can_cross && (g_ptr->m_idx != target_ptr->riding)) ||
-                               are_enemies(m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
+                               are_enemies(target_ptr, m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
                        {
                                if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
                                {
index 85979ae..d0a974b 100644 (file)
@@ -456,7 +456,7 @@ extern void anger_monster(player_type *player_ptr, monster_type *m_ptr);
 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 are_enemies(player_type *player_ptr, 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);
 extern void dice_to_string(int base_damage, int dice_num, int dice_side, int dice_mult, int dice_div, char* msg);
 extern concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode);
index 2a0ee4d..b8bfac0 100644 (file)
@@ -2249,12 +2249,12 @@ static bool check_hostile_align(byte sub_align1, byte sub_align2)
  * @param n_ptr モンスター2の構造体参照ポインタ
  * @return 敵対関係にあるならばTRUEを返す
  */
-bool are_enemies(monster_type *m_ptr, monster_type *n_ptr)
+bool are_enemies(player_type *player_ptr, monster_type *m_ptr, monster_type *n_ptr)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        monster_race *s_ptr = &r_info[n_ptr->r_idx];
 
-       if (p_ptr->phase_out)
+       if (player_ptr->phase_out)
        {
                if (is_pet(m_ptr) || is_pet(n_ptr)) return FALSE;
                return TRUE;
index 3eb7891..3f02451 100644 (file)
@@ -61,7 +61,7 @@ static bool direct_beam(player_type *target_ptr, POSITION y1, POSITION x1, POSIT
                if (y == y2 && x == x2)
                        hit2 = TRUE;
                else if (is_friend && floor_ptr->grid_array[y][x].m_idx > 0 &&
-                       !are_enemies(m_ptr, &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx]))
+                       !are_enemies(target_ptr, m_ptr, &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx]))
                {
                        /* Friends don't shoot friends */
                        return FALSE;
@@ -321,7 +321,7 @@ bool monst_spell_monst(player_type *target_ptr, MONSTER_IDX m_idx)
 
                        /* Cancel if neither enemy nor a given target */
                        if ((m_idx == target_idx) ||
-                               ((target_idx != target_ptr->pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
+                               ((target_idx != target_ptr->pet_t_m_idx) && !are_enemies(target_ptr, m_ptr, t_ptr)))
                        {
                                target_idx = 0;
                        }
@@ -360,7 +360,7 @@ bool monst_spell_monst(player_type *target_ptr, MONSTER_IDX m_idx)
                        if (!monster_is_valid(t_ptr)) continue;
 
                        /* Monster must be 'an enemy' */
-                       if ((m_idx == target_idx) || !are_enemies(m_ptr, t_ptr)) continue;
+                       if ((m_idx == target_idx) || !are_enemies(target_ptr, m_ptr, t_ptr)) continue;
 
                        /* Monster must be projectable */
                        if (!projectable(target_ptr, m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;