From f4211b46122dd49ec8015e62f1204786dd3513d1 Mon Sep 17 00:00:00 2001 From: Slimebreath6078 Date: Sun, 28 Apr 2024 22:53:12 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20MonsterPainDescriber=20=E3=81=AE=20?= =?utf8?q?MONSTER=5FIDX=20=E3=81=AB=E4=BE=9D=E5=AD=98=E3=81=97=E3=81=9F?= =?utf8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9=E3=82=AF=E3=82=BF?= =?utf8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/combat/shoot.cpp | 2 +- src/effect/effect-monster.cpp | 4 ++-- src/monster/monster-pain-describer.cpp | 5 ----- src/monster/monster-pain-describer.h | 1 - src/object-use/throw-execution.cpp | 3 +-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/combat/shoot.cpp b/src/combat/shoot.cpp index 28b00061b..c6970810a 100644 --- a/src/combat/shoot.cpp +++ b/src/combat/shoot.cpp @@ -845,7 +845,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX i_idx, ItemEntity *j_ptr, SP msg_format(_("%sは%sに突き刺さった!", "%s^ is stuck in %s!"), item_name.data(), m_name.data()); } - const auto pain_message = MonsterPainDescriber(player_ptr, c_mon_ptr->m_idx).describe(tdam); + const auto pain_message = MonsterPainDescriber(player_ptr, m_ptr).describe(tdam); if (pain_message) { msg_print(*pain_message); } diff --git a/src/effect/effect-monster.cpp b/src/effect/effect-monster.cpp index 2450abd4f..82a63808d 100644 --- a/src/effect/effect-monster.cpp +++ b/src/effect/effect-monster.cpp @@ -210,7 +210,7 @@ static void effect_damage_makes_sleep(PlayerType *player_ptr, EffectMonster *em_ if (!em_ptr->note.empty() && em_ptr->seen_msg) { msg_format("%s^%s", em_ptr->m_name, em_ptr->note.data()); } else if (em_ptr->see_s_msg) { - const auto pain_message = MonsterPainDescriber(player_ptr, em_ptr->g_ptr->m_idx).describe(em_ptr->dam); + const auto pain_message = MonsterPainDescriber(player_ptr, em_ptr->m_ptr).describe(em_ptr->dam); if (pain_message) { msg_print(*pain_message); } @@ -305,7 +305,7 @@ static bool deal_effect_damage_from_player(PlayerType *player_ptr, EffectMonster if (!em_ptr->note.empty() && em_ptr->seen) { msg_format(_("%s%s", "%s^%s"), em_ptr->m_name, em_ptr->note.data()); } else if (em_ptr->known && (em_ptr->dam || !em_ptr->do_fear)) { - const auto pain_message = MonsterPainDescriber(player_ptr, em_ptr->g_ptr->m_idx).describe(em_ptr->dam); + const auto pain_message = MonsterPainDescriber(player_ptr, em_ptr->m_ptr).describe(em_ptr->dam); if (pain_message) { msg_print(*pain_message); } diff --git a/src/monster/monster-pain-describer.cpp b/src/monster/monster-pain-describer.cpp index 0d6f4f204..b3d9cfe24 100644 --- a/src/monster/monster-pain-describer.cpp +++ b/src/monster/monster-pain-describer.cpp @@ -185,11 +185,6 @@ MonsterPainDescriber::MonsterPainDescriber(PlayerType *player_ptr, const Monster { } -MonsterPainDescriber::MonsterPainDescriber(PlayerType *player_ptr, MONSTER_IDX m_idx) - : MonsterPainDescriber(player_ptr, &player_ptr->current_floor_ptr->m_list[m_idx]) -{ -} - /*! * @brief ダメージを受けたモンスターの様子を記述する * @param dam モンスターが受けたダメージ diff --git a/src/monster/monster-pain-describer.h b/src/monster/monster-pain-describer.h index 0329d3fc2..2e98716c7 100644 --- a/src/monster/monster-pain-describer.h +++ b/src/monster/monster-pain-describer.h @@ -8,7 +8,6 @@ class MonsterEntity; class MonsterPainDescriber { public: MonsterPainDescriber(PlayerType *player_ptr, const MonsterEntity *m_ptr); - MonsterPainDescriber(PlayerType *player_ptr, MONSTER_IDX m_idx); std::optional describe(int dam); diff --git a/src/object-use/throw-execution.cpp b/src/object-use/throw-execution.cpp index 34fcff664..a0a2cc4d2 100644 --- a/src/object-use/throw-execution.cpp +++ b/src/object-use/throw-execution.cpp @@ -455,8 +455,7 @@ void ObjectThrowEntity::attack_racial_power() if (mdp.mon_take_hit(this->m_ptr->get_died_message())) { return; } - - const auto pain_message = MonsterPainDescriber(player_ptr, this->g_ptr->m_idx).describe(this->tdam); + const auto pain_message = MonsterPainDescriber(player_ptr, this->m_ptr).describe(this->tdam); if (pain_message) { msg_print(*pain_message); } -- 2.11.0