From ae6e7902f07eb2c1da9e7eb8d93fc43b22767ef7 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 18 Jan 2020 00:46:51 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20is=5Ffriendly=5Fidx()=20?= =?utf8?q?=E3=82=92=E6=99=AE=E9=80=9A=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AB?= =?utf8?q?=E5=B1=95=E9=96=8B=E3=81=97=E3=80=81player=5Ftype=20*=20?= =?utf8?q?=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0=20/=20Changed=20ma?= =?utf8?q?cro=20function=20is=5Ffriendly=5Fidx()=20to=20normal=20function?= =?utf8?q?=20and=20added=20player=5Ftype=20*=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/monster.h | 3 --- src/monster2.c | 10 +++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/monster.h b/src/monster.h index 60d09a6fe..04566d29e 100644 --- a/src/monster.h +++ b/src/monster.h @@ -513,9 +513,6 @@ extern void monster_drop_carried_objects(monster_type *m_ptr); #define is_friendly(A) \ (bool)(((A)->smart & SM_FRIENDLY) ? TRUE : FALSE) -#define is_friendly_idx(MONSTER_IDX) \ - (bool)((MONSTER_IDX) > 0 && is_friendly(&p_ptr->current_floor_ptr->m_list[(MONSTER_IDX)])) - #define is_pet(A) \ (bool)(((A)->smart & SM_PET) ? TRUE : FALSE) diff --git a/src/monster2.c b/src/monster2.c index 382c60ae6..9761fdafc 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -49,6 +49,8 @@ MONSTER_IDX hack_m_idx = 0; /* Hack -- see "process_monsters()" */ MONSTER_IDX hack_m_idx_ii = 0; +bool is_friendly_idx(MONSTER_IDX m_idx); + /*! * @brief モンスターの目標地点をセットする / Set the target of counter attack * @param m_ptr モンスターの参照ポインタ @@ -2701,7 +2703,7 @@ static bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION } /* Friendly? */ else if ((r_ptr->flags7 & RF7_FRIENDLY) || - (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who)) + (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(player_ptr, who)) { if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr); } @@ -4093,3 +4095,9 @@ int get_monster_crowd_number(MONSTER_IDX m_idx) return count; } + + +bool is_friendly_idx(player_type *player_ptr, MONSTER_IDX m_idx) +{ + return m_idx > 0 && is_friendly(&player_ptr->current_floor_ptr->m_list[(m_idx)]); +} -- 2.11.0