OSDN Git Service

[Refactor] #38997 hex_spelling() を関数マクロから普通の関数に展開し、player_type * 引数を追加 / Changed...
authorHourier <hourier@users.sourceforge.jp>
Wed, 15 Jan 2020 11:56:18 +0000 (20:56 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 15 Jan 2020 11:56:37 +0000 (20:56 +0900)
src/bldg.c
src/cmd/cmd-quaff.c
src/cmd/cmd-spell.c
src/combat/melee1.c
src/files.c
src/player-status.c
src/realm-hex.c
src/realm-hex.h
src/spells1.c
src/view-mainwindow.c

index 17a9ef2..597fca1 100644 (file)
@@ -2460,7 +2460,7 @@ static void compare_weapon_aux(player_type *owner_ptr, object_type *o_ptr, int c
 
 
        /* Vorpal Hit*/
-       if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)))
+       if ((have_flag(flgs, TR_VORPAL) || hex_spelling(owner_ptr, HEX_RUNESWORD)))
        {
                if ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
                {
index a14849e..8aa4616 100644 (file)
@@ -60,7 +60,7 @@ void exe_quaff_potion(player_type *creature_ptr, INVENTORY_IDX item)
        if (music_singing_any(creature_ptr)) stop_singing(creature_ptr);
        if (hex_spelling_any(creature_ptr))
        {
-               if (!hex_spelling(HEX_INHAIL)) stop_hex_spell_all(creature_ptr);
+               if (!hex_spelling(creature_ptr, HEX_INHAIL)) stop_hex_spell_all(creature_ptr);
        }
 
        o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
index ac39fef..1ce6e3f 100644 (file)
@@ -1142,7 +1142,7 @@ void do_cmd_cast(player_type *caster_ptr)
        use_realm = tval2realm(o_ptr->tval);
        if (use_realm == REALM_HEX)
        {
-               if (hex_spelling(spell))
+               if (hex_spelling(caster_ptr, spell))
                {
                        msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
                        return;
index b1eaae7..06cf344 100644 (file)
@@ -865,7 +865,7 @@ HIT_POINT tot_dam_aux(player_type *attacker_ptr, object_type *o_ptr, HIT_POINT t
                if (attacker_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
        }
 
-       if (hex_spelling(HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
+       if (hex_spelling(attacker_ptr, HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
 
        MULTIPLY mult = 10;
        switch (o_ptr->tval)
@@ -1599,7 +1599,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                }
 
                /* Vampiric drain */
-               if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN) || hex_spelling(HEX_VAMP_BLADE))
+               if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN) || hex_spelling(attacker_ptr, HEX_VAMP_BLADE))
                {
                        /* Only drain "living" monsters */
                        if (monster_living(m_ptr->r_idx))
@@ -1608,7 +1608,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                                can_drain = FALSE;
                }
 
-               if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)) && (randint1(vorpal_chance * 3 / 2) == 1) && !zantetsu_mukou)
+               if ((have_flag(flgs, TR_VORPAL) || hex_spelling(attacker_ptr, HEX_RUNESWORD)) && (randint1(vorpal_chance * 3 / 2) == 1) && !zantetsu_mukou)
                        vorpal_cut = TRUE;
                else vorpal_cut = FALSE;
 
@@ -1991,7 +1991,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                                {
                                        drain_heal = damroll(2, drain_result / 6);
 
-                                       if (hex_spelling(HEX_VAMP_BLADE)) drain_heal *= 2;
+                                       if (hex_spelling(attacker_ptr, HEX_VAMP_BLADE)) drain_heal *= 2;
 
                                        if (cheat_xtra)
                                        {
@@ -2034,7 +2034,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                drain_result = 0;
 
                /* Confusion attack */
-               if ((attacker_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF) || hex_spelling(HEX_CONFUSION))
+               if ((attacker_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF) || hex_spelling(attacker_ptr, HEX_CONFUSION))
                {
                        /* Cancel glowing hands */
                        if (attacker_ptr->special_attack & ATTACK_CONFUSE)
@@ -3888,7 +3888,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        }
                                }
 
-                               if (hex_spelling(HEX_SHADOW_CLOAK) && alive && !target_ptr->is_dead)
+                               if (hex_spelling(target_ptr, HEX_SHADOW_CLOAK) && alive && !target_ptr->is_dead)
                                {
                                        HIT_POINT dam = 1;
                                        object_type *o_armed_ptr = &target_ptr->inventory_list[INVEN_RARM];
@@ -4044,7 +4044,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
        /* Hex - revenge damage stored */
        revenge_store(target_ptr, get_damage);
 
-       if ((target_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
+       if ((target_ptr->tim_eyeeye || hex_spelling(target_ptr, HEX_EYE_FOR_EYE))
                && get_damage > 0 && !target_ptr->is_dead)
        {
 #ifdef JP
index 0a4616d..c64d4ce 100644 (file)
@@ -2763,14 +2763,14 @@ static void tim_player_flags(player_type *creature_ptr, BIT_FLAGS flgs[TR_FLAG_S
 
        if (creature_ptr->realm1 != REALM_HEX) return;
 
-       if (hex_spelling(HEX_DEMON_AURA))
+       if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
        {
                add_flag(flgs, TR_SH_FIRE);
                add_flag(flgs, TR_REGEN);
        }
 
-       if (hex_spelling(HEX_ICE_ARMOR)) add_flag(flgs, TR_SH_COLD);
-       if (hex_spelling(HEX_SHOCK_CLOAK)) add_flag(flgs, TR_SH_ELEC);
+       if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) add_flag(flgs, TR_SH_COLD);
+       if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) add_flag(flgs, TR_SH_ELEC);
 }
 
 
index 9045769..eb4f107 100644 (file)
@@ -2669,26 +2669,26 @@ void calc_bonuses(player_type *creature_ptr)
        if (creature_ptr->realm1 == REALM_HEX)
        {
                if (hex_spelling_any(creature_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
-               if (hex_spelling(HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
-               if (hex_spelling(HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
-               if (hex_spelling(HEX_BUILDING))
+               if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
+               if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
+               if (hex_spelling(creature_ptr, HEX_BUILDING))
                {
                        creature_ptr->stat_add[A_STR] += 4;
                        creature_ptr->stat_add[A_DEX] += 4;
                        creature_ptr->stat_add[A_CON] += 4;
                }
-               if (hex_spelling(HEX_DEMON_AURA))
+               if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
                {
                        creature_ptr->sh_fire = TRUE;
                        creature_ptr->regenerate = TRUE;
                }
-               if (hex_spelling(HEX_ICE_ARMOR))
+               if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
                {
                        creature_ptr->sh_cold = TRUE;
                        creature_ptr->to_a += 30;
                        creature_ptr->dis_to_a += 30;
                }
-               if (hex_spelling(HEX_SHOCK_CLOAK))
+               if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
                {
                        creature_ptr->sh_elec = TRUE;
                        new_speed += 3;
@@ -3295,7 +3295,7 @@ void calc_bonuses(player_type *creature_ptr)
                        }
 
                        /* Hex - extra mights gives +1 bonus to max blows */
-                       if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
+                       if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
 
                        /* Enforce a minimum "weight" (tenth pounds) */
                        div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
@@ -3409,7 +3409,7 @@ void calc_bonuses(player_type *creature_ptr)
                                if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
                                if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
                                if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
-                               if (hex_spelling(HEX_RUNESWORD))
+                               if (hex_spelling(creature_ptr, HEX_RUNESWORD))
                                {
                                        if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
                                        if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
@@ -4036,8 +4036,8 @@ static void calc_hitpoints(player_type *creature_ptr)
        if (creature_ptr->tsuyoshi) mhp += 50;
 
        /* Factor in the hex spell settings */
-       if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
-       if (hex_spelling(HEX_BUILDING)) mhp += 60;
+       if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
+       if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
 
        /* New maximum hitpoints */
        if (creature_ptr->mhp != mhp)
@@ -5907,7 +5907,7 @@ void cheat_death(player_type *creature_ptr)
  */
 bool is_blessed(player_type *creature_ptr)
 {
-       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(HEX_BLESS);
+       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
 }
 
 
index 364eb03..79fa510 100644 (file)
@@ -50,7 +50,7 @@ bool stop_hex_spell_all(player_type *caster_ptr)
 
        for (i = 0; i < 32; i++)
        {
-               if (hex_spelling(i)) exe_spell(caster_ptr, REALM_HEX, i, SPELL_STOP);
+               if (hex_spelling(caster_ptr, i)) exe_spell(caster_ptr, REALM_HEX, i, SPELL_STOP);
        }
 
        CASTING_HEX_FLAGS(caster_ptr) = 0;
@@ -103,7 +103,7 @@ bool stop_hex_spell(player_type *caster_ptr)
                        prt(_("     名前", "     Name"), y, x + 5);
                        for (spell = 0; spell < 32; spell++)
                        {
-                               if (hex_spelling(spell))
+                               if (hex_spelling(caster_ptr, spell))
                                {
                                        Term_erase(x, y + n + 1, 255);
                                        put_str(format("%c)  %s", I2A(n), exe_spell(caster_ptr, REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
@@ -175,7 +175,7 @@ void check_hex(player_type *caster_ptr)
        need_mana = 0;
        for (spell = 0; spell < 32; spell++)
        {
-               if (hex_spelling(spell))
+               if (hex_spelling(caster_ptr, spell))
                {
                        const magic_type *s_ptr;
                        s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
@@ -219,7 +219,7 @@ void check_hex(player_type *caster_ptr)
        {
                const magic_type *s_ptr;
 
-               if (!hex_spelling(spell)) continue;
+               if (!hex_spelling(caster_ptr, spell)) continue;
 
                s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
 
@@ -236,7 +236,7 @@ void check_hex(player_type *caster_ptr)
        /* Do any effects of continual spells */
        for (spell = 0; spell < 32; spell++)
        {
-               if (hex_spelling(spell))
+               if (hex_spelling(caster_ptr, spell))
                {
                        exe_spell(caster_ptr, REALM_HEX, spell, SPELL_CONT);
                }
@@ -295,7 +295,7 @@ bool teleport_barrier(player_type *caster_ptr, MONSTER_IDX m_idx)
        monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       if (!hex_spelling(HEX_ANTI_TELE)) return FALSE;
+       if (!hex_spelling(caster_ptr, HEX_ANTI_TELE)) return FALSE;
        if ((caster_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
 
        return TRUE;
@@ -311,7 +311,7 @@ bool magic_barrier(player_type *target_ptr, MONSTER_IDX m_idx)
        monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       if (!hex_spelling(HEX_ANTI_MAGIC)) return FALSE;
+       if (!hex_spelling(target_ptr, HEX_ANTI_MAGIC)) return FALSE;
        if ((target_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
 
        return TRUE;
@@ -327,7 +327,7 @@ bool multiply_barrier(player_type *caster_ptr, MONSTER_IDX m_idx)
        monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       if (!hex_spelling(HEX_ANTI_MULTI)) return FALSE;
+       if (!hex_spelling(caster_ptr, HEX_ANTI_MULTI)) return FALSE;
        if ((caster_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
 
        return TRUE;
@@ -1135,3 +1135,8 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
 
        return "";
 }
+
+bool hex_spelling(player_type *caster_ptr, int hex)
+{
+       return (caster_ptr->realm1 == REALM_HEX) && (caster_ptr->magic_num1[0] & (1L << (hex)));
+}
index 15be191..5285762 100644 (file)
@@ -4,8 +4,6 @@
 
 #define hex_spelling_any(CREATURE_PTR) \
        (((CREATURE_PTR)->realm1 == REALM_HEX) && ((CREATURE_PTR)->magic_num1[0]))
-#define hex_spelling(X) \
-       ((p_ptr->realm1 == REALM_HEX) && (p_ptr->magic_num1[0] & (1L << (X))))
 #define CASTING_HEX_FLAGS(P_PTR) ((P_PTR)->magic_num1[0])
 #define CASTING_HEX_NUM(P_PTR) ((P_PTR)->magic_num2[0])
 #define HEX_REVENGE_POWER(P_PTR) ((P_PTR)->magic_num1[2])
@@ -59,4 +57,4 @@ extern bool teleport_barrier(player_type *caster_ptr, MONSTER_IDX m_idx);
 extern bool magic_barrier(player_type *target_ptr, MONSTER_IDX m_idx);
 extern bool multiply_barrier(player_type *caster_ptr, MONSTER_IDX m_idx);
 extern concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode);
-
+extern bool hex_spelling(player_type *caster_type, int hex);
index 876642b..ede21bc 100644 (file)
@@ -5057,7 +5057,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        /* Hex - revenge damage stored */
        revenge_store(target_ptr, get_damage);
 
-       if ((target_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
+       if ((target_ptr->tim_eyeeye || hex_spelling(target_ptr, HEX_EYE_FOR_EYE))
                && (get_damage > 0) && !target_ptr->is_dead && (who > 0))
        {
                GAME_TEXT m_name_self[80];
index 3a941b8..dafa514 100644 (file)
@@ -656,24 +656,24 @@ static void print_status(player_type *creature_ptr)
        /* Hex spells */
        if (creature_ptr->realm1 == REALM_HEX)
        {
-               if (hex_spelling(HEX_BLESS)) ADD_FLG(BAR_BLESSED);
-               if (hex_spelling(HEX_DEMON_AURA)) { ADD_FLG(BAR_SHFIRE); ADD_FLG(BAR_REGENERATION); }
-               if (hex_spelling(HEX_XTRA_MIGHT)) ADD_FLG(BAR_MIGHT);
-               if (hex_spelling(HEX_DETECT_EVIL)) ADD_FLG(BAR_ESP_EVIL);
-               if (hex_spelling(HEX_ICE_ARMOR)) ADD_FLG(BAR_SHCOLD);
-               if (hex_spelling(HEX_RUNESWORD)) ADD_FLG(BAR_RUNESWORD);
-               if (hex_spelling(HEX_BUILDING)) ADD_FLG(BAR_BUILD);
-               if (hex_spelling(HEX_ANTI_TELE)) ADD_FLG(BAR_ANTITELE);
-               if (hex_spelling(HEX_SHOCK_CLOAK)) ADD_FLG(BAR_SHELEC);
-               if (hex_spelling(HEX_SHADOW_CLOAK)) ADD_FLG(BAR_SHSHADOW);
-               if (hex_spelling(HEX_CONFUSION)) ADD_FLG(BAR_ATTKCONF);
-               if (hex_spelling(HEX_EYE_FOR_EYE)) ADD_FLG(BAR_EYEEYE);
-               if (hex_spelling(HEX_ANTI_MULTI)) ADD_FLG(BAR_ANTIMULTI);
-               if (hex_spelling(HEX_VAMP_BLADE)) ADD_FLG(BAR_VAMPILIC);
-               if (hex_spelling(HEX_ANTI_MAGIC)) ADD_FLG(BAR_ANTIMAGIC);
-               if (hex_spelling(HEX_CURE_LIGHT) ||
-                       hex_spelling(HEX_CURE_SERIOUS) ||
-                       hex_spelling(HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
+               if (hex_spelling(creature_ptr, HEX_BLESS)) ADD_FLG(BAR_BLESSED);
+               if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) { ADD_FLG(BAR_SHFIRE); ADD_FLG(BAR_REGENERATION); }
+               if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) ADD_FLG(BAR_MIGHT);
+               if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) ADD_FLG(BAR_ESP_EVIL);
+               if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) ADD_FLG(BAR_SHCOLD);
+               if (hex_spelling(creature_ptr, HEX_RUNESWORD)) ADD_FLG(BAR_RUNESWORD);
+               if (hex_spelling(creature_ptr, HEX_BUILDING)) ADD_FLG(BAR_BUILD);
+               if (hex_spelling(creature_ptr, HEX_ANTI_TELE)) ADD_FLG(BAR_ANTITELE);
+               if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) ADD_FLG(BAR_SHELEC);
+               if (hex_spelling(creature_ptr, HEX_SHADOW_CLOAK)) ADD_FLG(BAR_SHSHADOW);
+               if (hex_spelling(creature_ptr, HEX_CONFUSION)) ADD_FLG(BAR_ATTKCONF);
+               if (hex_spelling(creature_ptr, HEX_EYE_FOR_EYE)) ADD_FLG(BAR_EYEEYE);
+               if (hex_spelling(creature_ptr, HEX_ANTI_MULTI)) ADD_FLG(BAR_ANTIMULTI);
+               if (hex_spelling(creature_ptr, HEX_VAMP_BLADE)) ADD_FLG(BAR_VAMPILIC);
+               if (hex_spelling(creature_ptr, HEX_ANTI_MAGIC)) ADD_FLG(BAR_ANTIMAGIC);
+               if (hex_spelling(creature_ptr, HEX_CURE_LIGHT) ||
+                       hex_spelling(creature_ptr, HEX_CURE_SERIOUS) ||
+                       hex_spelling(creature_ptr, HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
 
                if (HEX_REVENGE_TURN(creature_ptr))
                {