OSDN Git Service

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

index d0a974b..0d63202 100644 (file)
@@ -457,7 +457,7 @@ extern bool monster_can_cross_terrain(player_type *player_ptr, FEAT_IDX feat, mo
 extern bool monster_can_enter(player_type *player_ptr, POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode);
 
 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 bool monster_has_hostile_align(player_type *player_ptr, 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);
 extern int get_monster_crowd_number(player_type *player_ptr, MONSTER_IDX m_idx);
index b8bfac0..482a102 100644 (file)
@@ -2285,6 +2285,7 @@ bool are_enemies(player_type *player_ptr, monster_type *m_ptr, monster_type *n_p
 /*!
  * @brief モンスターがプレイヤーに対して敵意を抱くかどうかを返す
  * Check if this monster race has "hostile" alignment
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param m_ptr モンスター情報構造体の参照ポインタ
  * @param pa_good プレイヤーの善傾向値
  * @param pa_evil プレイヤーの悪傾向値
@@ -2293,7 +2294,7 @@ bool are_enemies(player_type *player_ptr, monster_type *m_ptr, monster_type *n_p
  * @details
  * If user is player, m_ptr == NULL.
  */
-bool monster_has_hostile_align(monster_type *m_ptr, int pa_good, int pa_evil, monster_race *r_ptr)
+bool monster_has_hostile_align(player_type *player_ptr, monster_type *m_ptr, int pa_good, int pa_evil, monster_race *r_ptr)
 {
        byte sub_align1 = SUB_ALIGN_NEUTRAL;
        byte sub_align2 = SUB_ALIGN_NEUTRAL;
@@ -2304,8 +2305,8 @@ bool monster_has_hostile_align(monster_type *m_ptr, int pa_good, int pa_evil, mo
        }
        else /* For player */
        {
-               if (p_ptr->align >= pa_good) sub_align1 |= SUB_ALIGN_GOOD;
-               if (p_ptr->align <= pa_evil) sub_align1 |= SUB_ALIGN_EVIL;
+               if (player_ptr->align >= pa_good) sub_align1 |= SUB_ALIGN_GOOD;
+               if (player_ptr->align <= pa_evil) sub_align1 |= SUB_ALIGN_EVIL;
        }
 
        /* Racial alignment flags */
index 8b4281f..18fcf32 100644 (file)
@@ -2193,13 +2193,13 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
        /* Not born */
        if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
        {
-               if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(p_ptr, m_ptr, 0, 0, r_ptr)) return FALSE;
        }
 
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(p_ptr, &floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return TRUE;
@@ -2241,7 +2241,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(p_ptr, &floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return (*(get_monster_hook(p_ptr)))(r_idx);
@@ -2663,7 +2663,7 @@ static bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION
        else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
                (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(player_ptr, who))
        {
-               if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
+               if (!monster_has_hostile_align(player_ptr, NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
        }
 
        /* Assume no sleeping */
@@ -3032,11 +3032,11 @@ static bool place_monster_can_escort(MONRACE_IDX r_idx)
        if (place_monster_idx == r_idx) return FALSE;
 
        /* Skip different alignment */
-       if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
+       if (monster_has_hostile_align(p_ptr, m_ptr, 0, 0, z_ptr)) return FALSE;
 
        if (r_ptr->flags7 & RF7_FRIENDLY)
        {
-               if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
+               if (monster_has_hostile_align(p_ptr, NULL, 1, -1, z_ptr)) return FALSE;
        }
 
        if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
@@ -3370,13 +3370,13 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
                /* Do not summon enemies */
 
                /* Friendly vs. opposite aligned normal or pet */
-               if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(p_ptr, m_ptr, 0, 0, r_ptr)) return FALSE;
        }
        /* Use the player's alignment */
        else if (summon_specific_who < 0)
        {
                /* Do not summon enemies of the pets */
-               if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
+               if (monster_has_hostile_align(p_ptr, NULL, 10, -10, r_ptr))
                {
                        if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
                }
@@ -3389,7 +3389,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
 
        if ((summon_specific_who < 0) &&
                ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
-               monster_has_hostile_align(NULL, 10, -10, r_ptr))
+               monster_has_hostile_align(p_ptr, NULL, 10, -10, r_ptr))
                return FALSE;
 
        if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
index c12fa08..252809d 100644 (file)
@@ -323,7 +323,7 @@ bool build_type5(player_type *player_ptr)
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
+                       if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;
@@ -533,7 +533,7 @@ bool build_type6(player_type *player_ptr)
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
+                       if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;
@@ -842,7 +842,7 @@ bool build_type13(player_type *player_ptr)
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
+                       if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;