From 1a210014e57caed33d1997f5034c92b1f0c4fc8f Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 11 Sep 2021 22:39:10 +0900 Subject: [PATCH] [Refactor] #1473 Replaced casting_hex_flags() to set_casting_flag() --- src/realm/realm-hex.cpp | 22 ++++++++++++++-------- src/spell-realm/spells-hex.cpp | 7 +++++++ src/spell-realm/spells-hex.h | 1 + src/system/player-type-definition.h | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/realm/realm-hex.cpp b/src/realm/realm-hex.cpp index 664505494..638f58894 100644 --- a/src/realm/realm-hex.cpp +++ b/src/realm/realm-hex.cpp @@ -343,19 +343,25 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m (void)cure_serious_wounds(player_ptr, 2, 10); break; - case HEX_INHALE: - if (name) + case HEX_INHALE: { + if (name) { return _("薬品吸入", "Inhale potion"); - if (desc) + } + + if (desc) { return _("呪文詠唱を中止することなく、薬の効果を得ることができる。", "Quaffs a potion without canceling spell casting."); + } + + SpellHex spell_hex(player_ptr); if (cast) { - casting_hex_flags(player_ptr) |= (1UL << HEX_INHALE); + spell_hex.set_casting_flag(HEX_INHALE); do_cmd_quaff_potion(player_ptr); casting_hex_flags(player_ptr) &= ~(1UL << HEX_INHALE); add = false; } - break; + break; + } case HEX_VAMP_MIST: if (name) return _("衰弱の霧", "Hypodynamic mist"); @@ -874,9 +880,9 @@ concptr do_hex_spell(player_type *player_ptr, spell_hex_type spell, spell_type m } /* start casting */ - if ((cast) && (add)) { - /* add spell */ - casting_hex_flags(player_ptr) |= 1UL << (spell); + if (cast && add) { + SpellHex spell_hex(player_ptr); + spell_hex.set_casting_flag(spell); casting_hex_num(player_ptr)++; if (player_ptr->action != ACTION_SPELL) diff --git a/src/spell-realm/spells-hex.cpp b/src/spell-realm/spells-hex.cpp index cf371d5ae..41e7dee36 100644 --- a/src/spell-realm/spells-hex.cpp +++ b/src/spell-realm/spells-hex.cpp @@ -435,3 +435,10 @@ void SpellHex::thief_teleport() teleport_away(this->player_ptr, this->monap_ptr->m_idx, MAX_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS); } } + +void SpellHex::set_casting_flag(spell_hex_type type) +{ + auto value = static_cast(this->player_ptr->magic_num1[0]); + set_bits(value, 1U << type); + this->player_ptr->magic_num1[0] = value; +} diff --git a/src/spell-realm/spells-hex.h b/src/spell-realm/spells-hex.h index a58e70e13..14d6e2494 100644 --- a/src/spell-realm/spells-hex.h +++ b/src/spell-realm/spells-hex.h @@ -23,6 +23,7 @@ public: bool is_spelling_any() const; void eyes_on_eyes(); void thief_teleport(); + void set_casting_flag(spell_hex_type type); private: player_type *player_ptr; diff --git a/src/system/player-type-definition.h b/src/system/player-type-definition.h index 8bd54f46a..4398fd6e5 100644 --- a/src/system/player-type-definition.h +++ b/src/system/player-type-definition.h @@ -188,6 +188,7 @@ typedef struct player_type { SUB_EXP weapon_exp[5][64]{}; /* Proficiency of weapons */ SUB_EXP skill_exp[MAX_SKILLS]{}; /* Proficiency of misc. skill */ + // @todo uint32_tで定義したいが可能か? int32_t magic_num1[MAX_SPELLS]{}; /*!< Array for non-spellbook type magic */ byte magic_num2[MAX_SPELLS]{}; /*!< 魔道具術師の取り込み済魔道具使用回数 / Flags for non-spellbook type magics */ -- 2.11.0