From a9bc8c2342ceed74c465ac91ba2cf6502ebfba57 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 18 Jan 2020 14:05:43 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20get=5Fdungeon=5Ffeeling()?= =?utf8?q?=20=E3=81=ABplayer=5Ftype=20*=20=E5=BC=95=E6=95=B0=E8=BF=BD?= =?utf8?q?=E5=8A=A0=20/=20Added=20player=5Ftype=20*=20argument=20to=20get?= =?utf8?q?=5Fdungeon=5Ffeeling()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/floor-events.c | 10 ++++++---- src/floor-events.h | 1 - src/monster.h | 2 +- src/monster2.c | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/floor-events.c b/src/floor-events.c index 33571d4d5..d0d46f549 100644 --- a/src/floor-events.c +++ b/src/floor-events.c @@ -19,6 +19,7 @@ static bool mon_invis; static POSITION mon_fy, mon_fx; +byte get_dungeon_feeling(player_type *subject_ptr); void day_break(player_type *subject_ptr) { @@ -140,9 +141,10 @@ MONSTER_NUMBER count_all_hostile_monsters(floor_type *floor_ptr) * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor * @return 算出されたダンジョンの雰囲気ランク */ -byte get_dungeon_feeling(floor_type *floor_ptr) +byte get_dungeon_feeling(player_type *subject_ptr) { /* Hack -- no feeling in the town */ + floor_type *floor_ptr = subject_ptr->current_floor_ptr; if (!floor_ptr->dun_level) return 0; /* Examine each monster */ @@ -181,11 +183,11 @@ byte get_dungeon_feeling(floor_type *floor_ptr) /* Unusually crowded monsters get a little bit of rating boost */ if (r_ptr->flags1 & RF1_FRIENDS) { - if (5 <= get_monster_crowd_number(i)) delta += 1; + if (5 <= get_monster_crowd_number(subject_ptr, i)) delta += 1; } else { - if (2 <= get_monster_crowd_number(i)) delta += 1; + if (2 <= get_monster_crowd_number(subject_ptr, i)) delta += 1; } @@ -295,7 +297,7 @@ void update_dungeon_feeling(player_type *subject_ptr) /* Get new dungeon feeling */ - byte new_feeling = get_dungeon_feeling(floor_ptr); + byte new_feeling = get_dungeon_feeling(subject_ptr); /* Remember last time updated */ subject_ptr->feeling_turn = current_world_ptr->game_turn; diff --git a/src/floor-events.h b/src/floor-events.h index 56bd80e94..52bb153e6 100644 --- a/src/floor-events.h +++ b/src/floor-events.h @@ -3,7 +3,6 @@ extern void day_break(player_type *subject_ptr); extern void night_falls(player_type *subject_ptr); extern MONSTER_NUMBER count_all_hostile_monsters(floor_type *floor_ptr); -extern byte get_dungeon_feeling(floor_type *floor_ptr); extern void update_dungeon_feeling(player_type *subject_ptr); extern void glow_deep_lava_and_bldg(player_type *subject_ptr); extern void forget_lite(floor_type *floor_ptr); diff --git a/src/monster.h b/src/monster.h index 3bc1dd4f1..6ec3056f3 100644 --- a/src/monster.h +++ b/src/monster.h @@ -460,7 +460,7 @@ 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); 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(MONSTER_IDX m_idx); +extern int get_monster_crowd_number(player_type *player_ptr, MONSTER_IDX m_idx); extern void message_pain(player_type *player_ptr, MONSTER_IDX m_idx, HIT_POINT dam); /* monster2.c */ diff --git a/src/monster2.c b/src/monster2.c index 7878548bd..1bcbdcb07 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -4096,14 +4096,16 @@ void monster_drop_carried_objects(player_type *player_ptr, monster_type *m_ptr) } /*! + * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留 * @brief 指定したモンスターに隣接しているモンスターの数を返す。 * / Count number of adjacent monsters + * @param player_ptr プレーヤーへの参照ポインタ * @param m_idx 隣接数を調べたいモンスターのID * @return 隣接しているモンスターの数 */ -int get_monster_crowd_number(MONSTER_IDX m_idx) +int get_monster_crowd_number(player_type *player_ptr, MONSTER_IDX m_idx) { - floor_type *floor_ptr = p_ptr->current_floor_ptr; + floor_type *floor_ptr = player_ptr->current_floor_ptr; monster_type *m_ptr = &floor_ptr->m_list[m_idx]; POSITION my = m_ptr->fy; POSITION mx = m_ptr->fx; -- 2.11.0