OSDN Git Service

[Refactor] #37353 player-item.c/hにref_item()を追加。
[hengband/hengband.git] / src / xtra1.c
index 9c0807e..dc24bca 100644 (file)
@@ -1,7 +1,7 @@
 /*!
  * @file xtra1.c
- * @brief 雑多なその他の処理1 / misc code
- * @date 2014/08/17
+ * @brief プレイヤーのステータス処理 / status
+ * @date 2018/09/25
  * @author
  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
  * This software may be copied and distributed for educational, research, and\n
@@ -674,10 +674,10 @@ static void prt_status(void)
                        hex_spelling(HEX_CURE_SERIOUS) ||
                        hex_spelling(HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
 
-               if (p_ptr->magic_num2[2])
+               if (HEX_REVENGE_TURN(p_ptr))
                {
-                       if (p_ptr->magic_num2[1] == 1) ADD_FLG(BAR_PATIENCE);
-                       if (p_ptr->magic_num2[1] == 2) ADD_FLG(BAR_REVENGE);
+                       if (HEX_REVENGE_TYPE(p_ptr) == 1) ADD_FLG(BAR_PATIENCE);
+                       if (HEX_REVENGE_TYPE(p_ptr) == 2) ADD_FLG(BAR_REVENGE);
                }
        }
 
@@ -1113,7 +1113,7 @@ static void prt_state(void)
 {
        byte attr = TERM_WHITE;
 
-       char text[5];
+       char text[16];
 
        /* Repeating */
        if (command_rep)
@@ -1181,13 +1181,13 @@ static void prt_state(void)
                                }
 
                                /* Rest until healed */
-                               else if (resting == -1)
+                               else if (resting == COMMAND_ARG_REST_FULL_HEALING)
                                {
                                        text[0] = text[1] = text[2] = text[3] = '*';
                                }
 
                                /* Rest until done */
-                               else if (resting == -2)
+                               else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
                                {
                                        text[0] = text[1] = text[2] = text[3] = '&';
                                }
@@ -1733,7 +1733,7 @@ static void fix_inven(void)
  * @return なし
  * </pre>
  */
-static void print_monster_line(int x, int y, monster_type* m_ptr, int n_same){
+static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type* m_ptr, int n_same){
        char buf[256];
        int i;
        MONRACE_IDX r_idx = m_ptr->ap_r_idx;
@@ -1780,8 +1780,8 @@ static void print_monster_line(int x, int y, monster_type* m_ptr, int n_same){
  * @param y 表示行
  * @param max_lines 最大何行描画するか
  */
-void print_monster_list(int x, int y, int max_lines){
-       int line = y;
+void print_monster_list(TERM_LEN x, TERM_LEN y, TERM_LEN max_lines){
+       TERM_LEN line = y;
        monster_type* last_mons = NULL;
        monster_type* m_ptr = NULL;
        int n_same = 0;
@@ -1986,14 +1986,14 @@ static void fix_player(void)
 /*!
  * @brief ゲームメッセージ履歴をサブウィンドウに表示する / 
  * Hack -- display recent messages in sub-windows
- * XXX XXX XXX Adjust for width and split messages
+ * Adjust for width and split messages
  * @return なし
  */
 static void fix_message(void)
 {
        int j, i;
-       int w, h;
-       int x, y;
+       TERM_LEN w, h;
+       TERM_LEN x, y;
 
        /* Scan windows */
        for (j = 0; j < 8; j++)
@@ -2037,7 +2037,7 @@ static void fix_message(void)
 /*!
  * @brief 簡易マップをサブウィンドウに表示する / 
  * Hack -- display overhead view in sub-windows
- * XXX XXX XXX Adjust for width and split messages
+ * Adjust for width and split messages
  * @return なし
  * @details
  * Note that the "player" symbol does NOT appear on the map.
@@ -2197,9 +2197,9 @@ static void fix_object(void)
  */
 static void calc_spells(void)
 {
-       int                     i, j, k, levels;
-       int                     num_allowed;
-       int         num_boukyaku = 0;
+       int i, j, k, levels;
+       int num_allowed;
+       int num_boukyaku = 0;
 
        const magic_type        *s_ptr;
        REALM_IDX which;
@@ -2329,13 +2329,10 @@ static void calc_spells(void)
                                which = p_ptr->realm2;
                        }
 
-                       /* Message */
 #ifdef JP
-                       msg_format("%sの%sを忘れてしまった。",
-                                  do_spell(which, j%32, SPELL_NAME), p );
+                       msg_format("%sの%sを忘れてしまった。", do_spell(which, j%32, SPELL_NAME), p );
 #else
-                       msg_format("You have forgotten the %s of %s.", p,
-                       do_spell(which, j%32, SPELL_NAME));
+                       msg_format("You have forgotten the %s of %s.", p, do_spell(which, j%32, SPELL_NAME));
 #endif
 
 
@@ -2389,7 +2386,6 @@ static void calc_spells(void)
                                which = p_ptr->realm2;
                        }
 
-                       /* Message */
 #ifdef JP
                        msg_format("%sの%sを忘れてしまった。",
                                   do_spell(which, j%32, SPELL_NAME), p );
@@ -2465,13 +2461,10 @@ static void calc_spells(void)
                                which = p_ptr->realm2;
                        }
 
-                       /* Message */
 #ifdef JP
-                       msg_format("%sの%sを思い出した。",
-                                  do_spell(which, j%32, SPELL_NAME), p );
+                       msg_format("%sの%sを思い出した。", do_spell(which, j%32, SPELL_NAME), p );
 #else
-                       msg_format("You have remembered the %s of %s.",
-                                  p, do_spell(which, j%32, SPELL_NAME));
+                       msg_format("You have remembered the %s of %s.", p, do_spell(which, j%32, SPELL_NAME));
 #endif
 
 
@@ -2518,7 +2511,6 @@ static void calc_spells(void)
                /* Message if needed */
                if (p_ptr->new_spells)
                {
-                       /* Message */
 #ifdef JP
                        if( p_ptr->new_spells < 10 ){
                                msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
@@ -2554,7 +2546,7 @@ static void calc_spells(void)
  */
 static void calc_mana(void)
 {
-       int             msp, levels, cur_wgt, max_wgt;
+       int msp, levels, cur_wgt, max_wgt;
 
        object_type     *o_ptr;
 
@@ -2610,7 +2602,7 @@ static void calc_mana(void)
        /* Only mages are affected */
        if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
        {
-               u32b flgs[TR_FLAG_SIZE];
+               BIT_FLAGS flgs[TR_FLAG_SIZE];
 
                /* Assume player is not encumbered by gloves */
                p_ptr->cumber_glove = FALSE;
@@ -2807,8 +2799,7 @@ static void calc_mana(void)
                /* レベルアップの時は上昇量を表示する */
                if ((level_up == 1) && (msp > p_ptr->msp))
                {
-                       msg_format("最大マジック・ポイントが %d 増加した!",
-                                  (msp - p_ptr->msp));
+                       msg_format("最大マジック・ポイントが %d 増加した!", (msp - p_ptr->msp));
                }
 #endif
                /* Save new mana */
@@ -2817,7 +2808,6 @@ static void calc_mana(void)
                /* Display mana later */
                p_ptr->redraw |= (PR_MANA);
 
-               /* Window stuff */
                p_ptr->window |= (PW_PLAYER);
                p_ptr->window |= (PW_SPELL);
        }
@@ -2829,7 +2819,6 @@ static void calc_mana(void)
        /* Take note when "glove state" changes */
        if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
        {
-               /* Message */
                if (p_ptr->cumber_glove)
                {
                        msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
@@ -2847,7 +2836,6 @@ static void calc_mana(void)
        /* Take note when "armor state" changes */
        if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
        {
-               /* Message */
                if (p_ptr->cumber_armor)
                {
                        msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
@@ -2933,8 +2921,7 @@ static void calc_hitpoints(void)
                /* レベルアップの時は上昇量を表示する */
                if ((level_up == 1) && (mhp > p_ptr->mhp))
                {
-                       msg_format("最大ヒット・ポイントが %d 増加した!",
-                                  (mhp - p_ptr->mhp) );
+                       msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - p_ptr->mhp) );
                }
 #endif
                /* Save the new max-hitpoints */
@@ -2943,7 +2930,6 @@ static void calc_hitpoints(void)
                /* Display hitpoints (later) */
                p_ptr->redraw |= (PR_HP);
 
-               /* Window stuff */
                p_ptr->window |= (PW_PLAYER);
        }
 }
@@ -2958,7 +2944,7 @@ static void calc_torch(void)
 {
        int i, rad;
        object_type *o_ptr;
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
 
        /* Assume no light */
        p_ptr->cur_lite = 0;
@@ -3016,7 +3002,6 @@ static void calc_torch(void)
        /* Notice changes in the "lite radius" */
        if (p_ptr->old_lite != p_ptr->cur_lite)
        {
-               /* Update stuff */
                /* Hack -- PU_MON_LITE for monsters' darkness */
                p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
 
@@ -3034,12 +3019,12 @@ static void calc_torch(void)
  * Computes current weight limit.
  * @return 制限重量(ポンド)
  */
-u32b weight_limit(void)
+WEIGHT weight_limit(void)
 {
-       u32b i;
+       WEIGHT i;
 
        /* Weight limit based only on strength */
-       i = (u32b)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
+       i = (WEIGHT)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
        if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
 
        /* Return the result */
@@ -3118,7 +3103,7 @@ s16b calc_num_fire(object_type *o_ptr)
        int num = 0;
        OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
        object_type *q_ptr;
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        
        /* Scan the usable inventory */
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
@@ -3219,7 +3204,7 @@ void calc_bonuses(void)
        int             empty_hands_status = empty_hands(TRUE);
        int             extra_blows[2];
        object_type     *o_ptr;
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        bool            omoi = FALSE;
        bool            yoiyami = FALSE;
        bool            down_saving = FALSE;
@@ -3229,7 +3214,7 @@ void calc_bonuses(void)
        bool            have_sw = FALSE, have_kabe = FALSE;
        bool            easy_2weapon = FALSE;
        bool            riding_levitation = FALSE;
-       s16b this_o_idx, next_o_idx = 0;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        const player_race *tmp_rp_ptr;
 
        /* Save the old vision stuff */
@@ -4503,7 +4488,7 @@ void calc_bonuses(void)
        /* Hex bonuses */
        if (p_ptr->realm1 == REALM_HEX)
        {
-               if (hex_spelling_any()) p_ptr->skill_stl -= (1 + p_ptr->magic_num2[0]);
+               if (hex_spelling_any()) p_ptr->skill_stl -= (1 + CASTING_HEX_NUM(p_ptr));
                if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
                if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
                if (hex_spelling(HEX_BUILDING))
@@ -4530,7 +4515,7 @@ void calc_bonuses(void)
                }
                for (i = INVEN_RARM; i <= INVEN_FEET; i++)
                {
-                       int ac = 0;
+                       ARMOUR_CLASS ac = 0;
                        o_ptr = &inventory[i];
                        if (!o_ptr->k_idx) continue;
                        if (!object_is_armour(o_ptr)) continue;
@@ -4560,7 +4545,6 @@ void calc_bonuses(void)
                        /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -4586,7 +4570,6 @@ void calc_bonuses(void)
                        /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -4639,7 +4622,6 @@ void calc_bonuses(void)
                                }
                        }
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
        }
@@ -4940,7 +4922,7 @@ void calc_bonuses(void)
                i = 1500 + riding_r_ptr->level * 25;
        }
 
-       /* XXX XXX XXX Apply "encumbrance" from weight */
+       /* Apply "encumbrance" from weight */
        if (j > i) new_speed -= ((j - i) / (i / 5));
 
        /* Searching slows the player down */
@@ -5489,7 +5471,6 @@ void calc_bonuses(void)
                /* Redraw */
                p_ptr->redraw |= (PR_ARMOR);
 
-               /* Window stuff */
                p_ptr->window |= (PW_PLAYER);
        }
 
@@ -5625,7 +5606,6 @@ void calc_bonuses(void)
        /* Take note when "heavy bow" changes */
        if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
        {
-               /* Message */
                if (p_ptr->heavy_shoot)
                {
                        msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
@@ -5648,7 +5628,6 @@ void calc_bonuses(void)
                /* Take note when "heavy weapon" changes */
                if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
                {
-                       /* Message */
                        if (p_ptr->heavy_wield[i])
                        {
                                msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
@@ -5673,7 +5652,6 @@ void calc_bonuses(void)
                /* Take note when "heavy weapon" changes */
                if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
                {
-                       /* Message */
                        if (p_ptr->riding_wield[i])
                        {
                                msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
@@ -5693,11 +5671,10 @@ void calc_bonuses(void)
                /* Take note when "illegal weapon" changes */
                if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
                {
-                       /* Message */
                        if (p_ptr->icky_wield[i])
                        {
                                msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
-                               if (hack_mind)
+                               if (is_loading_now)
                                {
                                        chg_virtue(V_FAITH, -1);
                                }
@@ -5718,7 +5695,6 @@ void calc_bonuses(void)
 
        if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
        {
-               /* Message */
                if (p_ptr->riding_ryoute)
                {
 #ifdef JP
@@ -5744,7 +5720,7 @@ void calc_bonuses(void)
                if (heavy_armor())
                {
                        msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
-                       if (hack_mind)
+                       if (is_loading_now)
                        {
                                chg_virtue(V_HARMONY, -1);
                        }
@@ -5853,7 +5829,6 @@ void notice_stuff(void)
  */
 void update_stuff(void)
 {
-       /* Update stuff */
        if (!p_ptr->update) return;
 
 
@@ -6264,13 +6239,11 @@ void window_stuff(void)
  */
 void handle_stuff(void)
 {
-       /* Update stuff */
        if (p_ptr->update) update_stuff();
 
        /* Redraw stuff */
        if (p_ptr->redraw) redraw_stuff();
 
-       /* Window stuff */
        if (p_ptr->window) window_stuff();
 }
 
@@ -6302,7 +6275,7 @@ s16b empty_hands(bool riding_control)
  */
 bool heavy_armor(void)
 {
-       u16b monk_arm_wgt = 0;
+       WEIGHT monk_arm_wgt = 0;
 
        if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;