OSDN Git Service

[Refactor] #38997 IS_BLESSED() の関数マクロを普通の関数に変更し、store.is_blessed() をis_blessed_item...
authorHourier <hourier@users.sourceforge.jp>
Sun, 12 Jan 2020 08:39:38 +0000 (17:39 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 12 Jan 2020 16:06:58 +0000 (01:06 +0900)
src/player-effects.c
src/player-status.c
src/player-status.h
src/selfinfo.c
src/store.c
src/view-mainwindow.c

index c848b23..501c2a3 100644 (file)
@@ -1070,13 +1070,12 @@ bool set_blessed(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
                {
                        if (creature_ptr->blessed > v) return FALSE;
                }
-               else if (!IS_BLESSED())
+               else if (!is_blessed(creature_ptr))
                {
                        msg_print(_("高潔な気分になった!", "You feel righteous!"));
                        notice = TRUE;
                }
        }
-
        else
        {
                if (creature_ptr->blessed && !music_singing(creature_ptr, MUSIC_BLESS))
index b8d63a7..be22fc1 100644 (file)
@@ -1405,7 +1405,7 @@ void calc_bonuses(player_type *creature_ptr)
        bool old_mighty_throw = creature_ptr->mighty_throw;
 
        /* Current feature under player. */
-       floor_type *floor_ptr = floor_ptr;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
 
        /* Save the old armor class */
@@ -2848,7 +2848,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Temporary blessing */
-       if (IS_BLESSED())
+       if (is_blessed(creature_ptr))
        {
                creature_ptr->to_a += 5;
                creature_ptr->dis_to_a += 5;
@@ -4987,7 +4987,7 @@ void update_creature(player_type *creature_ptr)
 {
        if (!creature_ptr->update) return;
 
-       floor_type *floor_ptr = floor_ptr;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        if (creature_ptr->update & (PU_AUTODESTROY))
        {
                creature_ptr->update &= ~(PU_AUTODESTROY);
@@ -5174,7 +5174,7 @@ void wreck_the_pattern(player_type *creature_ptr)
 {
        int to_ruin = 0;
        POSITION r_y, r_x;
-       floor_type *floor_ptr = floor_ptr;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
 
        if (pattern_type == PATTERN_TILE_WRECKED)
@@ -5920,3 +5920,13 @@ void cheat_death(player_type *creature_ptr)
        leave_floor(creature_ptr);
        wipe_m_list();
 }
+
+
+/*!
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 祝福状態ならばTRUE
+ */
+bool is_blessed(player_type *creature_ptr)
+{
+       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(HEX_BLESS);
+}
index 8ada293..7d1aba9 100644 (file)
@@ -32,6 +32,8 @@
 #define MAGIC_GAIN_EXP          0x0004
 
 /*
+ * todo ここからp_ptrを消すと、object-hookにある大量の関数ポインタを全部修正する必要がある
+ * 影響範囲が広すぎるので保留
  * Magic-books for the realms
  */
 #define REALM1_BOOK     (p_ptr->realm1 + TV_LIFE_BOOK - 1)
@@ -800,7 +802,6 @@ extern const s32b player_exp_a[PY_MAX_LEVEL];
 #define IS_FAST(C) (C->fast || music_singing(C, MUSIC_SPEED) || music_singing(C, MUSIC_SHERO))
 #define IS_INVULN(C) (C->invuln || music_singing(C, MUSIC_INVULN))
 #define IS_HERO(C) (C->hero || music_singing(C, MUSIC_HERO) || music_singing(C, MUSIC_SHERO))
-#define IS_BLESSED() (p_ptr->blessed || music_singing(p_ptr, MUSIC_BLESS) || hex_spelling(HEX_BLESS))
 #define IS_OPPOSE_ACID() (p_ptr->oppose_acid || music_singing(p_ptr, MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
 #define IS_OPPOSE_ELEC() (p_ptr->oppose_elec || music_singing(p_ptr, MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
 #define IS_OPPOSE_FIRE() (p_ptr->oppose_fire || music_singing(p_ptr, MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
@@ -811,6 +812,8 @@ extern const s32b player_exp_a[PY_MAX_LEVEL];
 
 #define P_PTR_KI (p_ptr->magic_num1[0])
 
+extern bool is_blessed(player_type *player_ptr);
+
 /*
  * Player "food" crucial values
  */
index 275db48..fe3c0e2 100644 (file)
@@ -1020,7 +1020,7 @@ void self_knowledge(player_type *creature_ptr)
        {
                info[i++] = _("あなたは魔力を吸われている。", "You brain is drained.");
        }
-       if (IS_BLESSED())
+       if (is_blessed(creature_ptr))
        {
                info[i++] = _("あなたは高潔さを感じている。", "You feel rightous.");
        }
index 43672a9..6bc64ba 100644 (file)
@@ -2626,7 +2626,7 @@ static int store_check_num(object_type *o_ptr)
  * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
  * @return アイテムが祝福されたアイテムならばTRUEを返す
  */
-static bool is_blessed(object_type *o_ptr)
+static bool is_blessed_item(object_type *o_ptr)
 {
        BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
@@ -2766,7 +2766,7 @@ static bool store_will_buy(object_type *o_ptr)
                                case TV_POLEARM:
                                case TV_SWORD:
                                {
-                                       if (is_blessed(o_ptr)) break;
+                                       if (is_blessed_item(o_ptr)) break;
                                }
                                default:
                                return FALSE;
index 5e9504d..8a77b1a 100644 (file)
@@ -573,7 +573,7 @@ static void prt_status(player_type *creature_ptr)
        if (creature_ptr->shero) ADD_FLG(BAR_BERSERK);
 
        /* Blessed */
-       if (IS_BLESSED()) ADD_FLG(BAR_BLESSED);
+       if (is_blessed(creature_ptr)) ADD_FLG(BAR_BLESSED);
 
        /* Shield */
        if (creature_ptr->magicdef) ADD_FLG(BAR_MAGICDEFENSE);