OSDN Git Service

[Refactor] #37353 avatar.h 追加。 / Add avatar.h.
[hengband/hengband.git] / src / xtra1.c
index 96fb642..8258695 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
  */
 
 #include "angband.h"
+#include "world.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
 
 /*!
  * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
@@ -96,7 +100,7 @@ s16b modify_stat_value(int value, int amount)
        }
 
        /* Return new value */
-       return (value);
+       return (s16b)(value);
 }
 
 
@@ -109,7 +113,7 @@ s16b modify_stat_value(int value, int amount)
  * @param col 描画行
  * @return なし
  */
-static void prt_field(cptr info, int row, int col)
+static void prt_field(concptr info, TERM_LEN row, TERM_LEN col)
 {
        /* Dump 13 spaces to clear */
        c_put_str(TERM_WHITE, "             ", row, col);
@@ -118,49 +122,6 @@ static void prt_field(cptr info, int row, int col)
        c_put_str(TERM_L_BLUE, info, row, col);
 }
 
-
-/*!
- * @brief ゲーム時間が日中かどうかを返す /
- * Whether daytime or not
- * @param 日中ならばTRUE、夜ならばFALSE
- */
-bool is_daytime(void)
-{
-       s32b len = TURNS_PER_TICK * TOWN_DAWN;
-       if ((turn % len) < (len / 2))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-/*!
- * @brief 現在の日数、時刻を返す /
- * Extract day, hour, min
- * @param day 日数を返すための参照ポインタ
- * @param hour 時数を返すための参照ポインタ
- * @param min 分数を返すための参照ポインタ
- */
-void extract_day_hour_min(int *day, int *hour, int *min)
-{
-       const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
-       s32b turn_in_today = (turn + A_DAY / 4) % A_DAY;
-
-       switch (p_ptr->start_race)
-       {
-       case RACE_VAMPIRE:
-       case RACE_SKELETON:
-       case RACE_ZOMBIE:
-       case RACE_SPECTRE:
-               *day = (turn - A_DAY * 3 / 4) / A_DAY + 1;
-               break;
-       default:
-               *day = (turn + A_DAY / 4) / A_DAY + 1;
-               break;
-       }
-       *hour = (24 * turn_in_today / A_DAY) % 24;
-       *min = (1440 * turn_in_today / A_DAY) % 60;
-}
-
 /*!
  * @brief ゲーム時刻を表示する /
  * Print time
@@ -186,7 +147,7 @@ void prt_time(void)
  * @brief 現在のマップ名を返す /
  * @return マップ名の文字列参照ポインタ
  */
-cptr map_name(void)
+concptr map_name(void)
 {
        if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)
            && (quest[p_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
@@ -209,8 +170,8 @@ cptr map_name(void)
  */
 static void prt_dungeon(void)
 {
-       cptr dungeon_name;
-       int col;
+       concptr dungeon_name;
+       TERM_LEN col;
 
        /* Dump 13 spaces to clear */
        c_put_str(TERM_WHITE, "             ", ROW_DUNGEON, COL_DUNGEON);
@@ -337,9 +298,9 @@ static void prt_stat(int stat)
 #define BAR_ESP_EVIL 66     /*!< 下部ステータス表示: 邪悪感知 */
 
 static struct {
-       byte attr;
-       cptr sstr;
-       cptr lstr;
+       TERM_COLOR attr;
+       concptr sstr;
+       concptr lstr;
 } bar[]
 #ifdef JP
 = {
@@ -503,14 +464,15 @@ static struct {
 
 
 /*!
- * @param 下部に状態表示を行う / Show status bar
+ * @brief 下部に状態表示を行う / Show status bar
  * @return なし
  */
 static void prt_status(void)
 {
-       u32b bar_flags[3];
-       int wid, hgt, row_statbar, max_col_statbar;
-       int i, col = 0, num = 0;
+       BIT_FLAGS bar_flags[3];
+       TERM_LEN wid, hgt, row_statbar, max_col_statbar;
+       int i;
+       TERM_LEN col = 0, num = 0;
        int space = 2;
 
        Term_get_size(&wid, &hgt);
@@ -674,10 +636,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);
                }
        }
 
@@ -722,7 +684,7 @@ static void prt_status(void)
        {
                if (IS_FLG(i))
                {
-                       cptr str;
+                       concptr str;
                        if (space == 2) str = bar[i].lstr;
                        else str = bar[i].sstr;
 
@@ -736,46 +698,27 @@ static void prt_status(void)
 
 
 /*!
- * @param プレイヤーの称号を表示する / Prints "title", including "wizard" or "winner" as needed.
+ * @brief プレイヤーの称号を表示する / Prints "title", including "wizard" or "winner" as needed.
  * @return なし
  */
 static void prt_title(void)
 {
-       cptr p = "";
-       char str[14];
+       concptr p = "";
+       GAME_TEXT str[14];
 
-       /* Wizard */
        if (p_ptr->wizard)
        {
-#ifdef JP
-               /* 英日切り替え機能 称号 */
-               p = "[ウィザード]";
-#else
-               p = "[=-WIZARD-=]";
-#endif
-
+               p = _("[ウィザード]", "[=-WIZARD-=]");
        }
-
-       /* Winner */
        else if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
        {
                if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
                {
-#ifdef JP
-                       /* 英日切り替え機能 称号 */
-                       p = "*真・勝利者*";
-#else
-                       p = "*TRUEWINNER*";
-#endif
+                       p = _("*真・勝利者*", "*TRUEWINNER*");
                }
                else
                {
-#ifdef JP
-                       /* 英日切り替え機能 称号 */
-                       p = "***勝利者***";
-#else
-                       p = "***WINNER***";
-#endif
+                       p = _("***勝利者***", "***WINNER***");
                }
        }
 
@@ -791,7 +734,7 @@ static void prt_title(void)
 
 
 /*!
- * @param プレイヤーのレベルを表示する / Prints level
+ * @brief プレイヤーのレベルを表示する / Prints level
  * @return なし
  */
 static void prt_level(void)
@@ -802,31 +745,19 @@ static void prt_level(void)
 
        if (p_ptr->lev >= p_ptr->max_plv)
        {
-#ifdef JP
-               put_str("レベル ", ROW_LEVEL, 0);
+               put_str(_("レベル ", "LEVEL "), ROW_LEVEL, 0);
                c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
-#else
-               put_str("LEVEL ", ROW_LEVEL, 0);
-               c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 6);
-#endif
-
        }
        else
        {
-#ifdef JP
-               put_str("xレベル", ROW_LEVEL, 0);
+               put_str(_("xレベル", "Level "), ROW_LEVEL, 0);
                c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
-#else
-               put_str("Level ", ROW_LEVEL, 0);
-               c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 6);
-#endif
-
        }
 }
 
 
 /*!
- * @param プレイヤーの経験値を表示する / Display the experience
+ * @brief プレイヤーの経験値を表示する / Display the experience
  * @return なし
  */
 static void prt_exp(void)
@@ -835,7 +766,7 @@ static void prt_exp(void)
 
        if ((!exp_need)||(p_ptr->prace == RACE_ANDROID))
        {
-               (void)sprintf(out_val, _("%7ld", "%8ld"), (long)p_ptr->exp);
+               (void)sprintf(out_val, "%8ld", (long)p_ptr->exp);
        }
        else
        {
@@ -845,42 +776,25 @@ static void prt_exp(void)
                }
                else
                {
-#ifdef JP
-                       (void)sprintf(out_val, "%7ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
-#else      
                        (void)sprintf(out_val, "%8ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
-#endif
                }
        }
 
        if (p_ptr->exp >= p_ptr->max_exp)
        {
-#ifdef JP
-               if (p_ptr->prace == RACE_ANDROID) put_str("強化 ", ROW_EXP, 0);
-               else put_str("経験 ", ROW_EXP, 0);
-               c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 5);
-#else
-               if (p_ptr->prace == RACE_ANDROID) put_str("Cst ", ROW_EXP, 0);
-               else put_str("EXP ", ROW_EXP, 0);
+               if (p_ptr->prace == RACE_ANDROID) put_str(_("強化 ", "Cst "), ROW_EXP, 0);
+               else put_str(_("経験 ", "EXP "), ROW_EXP, 0);
                c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
-#endif
-
        }
        else
        {
-#ifdef JP
-               put_str("x経験", ROW_EXP, 0);
-               c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 5);
-#else
-               put_str("Exp ", ROW_EXP, 0);
+               put_str(_("x経験", "Exp "), ROW_EXP, 0);
                c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
-#endif
-
        }
 }
 
 /*!
- * @param プレイヤーの所持金を表示する / Prints current gold
+ * @brief プレイヤーの所持金を表示する / Prints current gold
  * @return なし
  */
 static void prt_gold(void)
@@ -893,7 +807,7 @@ static void prt_gold(void)
 
 
 /*!
- * @param プレイヤーのACを表示する / Prints current AC
+ * @brief プレイヤーのACを表示する / Prints current AC
  * @return なし
  */
 static void prt_ac(void)
@@ -915,19 +829,17 @@ static void prt_ac(void)
 
 
 /*!
- * @param プレイヤーのHPを表示する / Prints Cur/Max hit points
+ * @brief プレイヤーのHPを表示する / Prints Cur/Max hit points
  * @return なし
  */
 static void prt_hp(void)
 {
-/* ヒットポイントの表示方法を変更 */
+       /* ヒットポイントの表示方法を変更 */
        char tmp[32];
   
-       byte color;
+       TERM_COLOR color;
   
        /* タイトル */
-/*     put_str(" HP・MP", ROW_HPMP, COL_HPMP); */
-
        put_str("HP", ROW_CURHP, COL_CURHP);
 
        /* 現在のヒットポイント */
@@ -960,7 +872,7 @@ static void prt_hp(void)
 
 
 /*!
- * @param プレイヤーのMPを表示する / Prints players max/cur spell points
+ * @brief プレイヤーのMPを表示する / Prints players max/cur spell points
  * @return なし
  */
 static void prt_sp(void)
@@ -974,7 +886,6 @@ static void prt_sp(void)
        if (!mp_ptr->spell_book) return;
 
        /* タイトル */
-/*     put_str(" MP / 最大", ROW_MAXSP, COL_MAXSP); */
        put_str(_("MP", "SP"), ROW_CURSP, COL_CURSP);
 
        /* 現在のマジックポイント */
@@ -1007,14 +918,14 @@ static void prt_sp(void)
 
 
 /*!
- * @param 現在のフロアの深さを表示する / Prints depth in stat area
+ * @brief 現在のフロアの深さを表示する / Prints depth in stat area
  * @return なし
  */
 static void prt_depth(void)
 {
        char depths[32];
-       int wid, hgt, row_depth, col_depth;
-       byte attr = TERM_WHITE;
+       TERM_LEN wid, hgt, row_depth, col_depth;
+       TERM_COLOR attr = TERM_WHITE;
 
        Term_get_size(&wid, &hgt);
        col_depth = wid + COL_DEPTH;
@@ -1030,8 +941,8 @@ static void prt_depth(void)
        }
        else
        {
-               if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), dun_level * 50);
-               else (void)sprintf(depths, _("%d 階", "Lev %d"), dun_level);
+               if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), (int)dun_level * 50);
+               else (void)sprintf(depths, _("%d 階", "Lev %d"), (int)dun_level);
 
                /* Get color of level based on feeling  -JSV- */
                switch (p_ptr->feeling)
@@ -1056,7 +967,7 @@ static void prt_depth(void)
 
 
 /*!
- * @param プレイヤーの空腹状態を表示する / Prints status of hunger
+ * @brief プレイヤーの空腹状態を表示する / Prints status of hunger
  * @return なし
  */
 static void prt_hunger(void)
@@ -1102,7 +1013,7 @@ static void prt_hunger(void)
 
 
 /*!
- * @param プレイヤーの行動状態を表示する / Prints Searching, Resting, Paralysis, or 'count' status
+ * @brief プレイヤーの行動状態を表示する / Prints Searching, Resting, Paralysis, or 'count' status
  * @return なし
  * @details
  * Display is always exactly 10 characters wide (see below)
@@ -1111,9 +1022,8 @@ static void prt_hunger(void)
  */
 static void prt_state(void)
 {
-       byte attr = TERM_WHITE;
-
-       char text[5];
+       TERM_COLOR attr = TERM_WHITE;
+       GAME_TEXT text[16];
 
        /* Repeating */
        if (command_rep)
@@ -1181,13 +1091,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] = '&';
                                }
@@ -1256,7 +1166,7 @@ static void prt_state(void)
 
 
 /*!
- * @param プレイヤーの行動速度を表示する / Prints the speed of a character.                     -CJS-
+ * @brief プレイヤーの行動速度を表示する / Prints the speed of a character.                     -CJS-
  * @return なし
  */
 static void prt_speed(void)
@@ -1264,9 +1174,9 @@ static void prt_speed(void)
        int i = p_ptr->pspeed;
        bool is_fast = IS_FAST();
 
-       byte attr = TERM_WHITE;
+       TERM_COLOR attr = TERM_WHITE;
        char buf[32] = "";
-       int wid, hgt, row_speed, col_speed;
+       TERM_LEN wid, hgt, row_speed, col_speed;
 
        Term_get_size(&wid, &hgt);
        col_speed = wid + COL_SPEED;
@@ -1327,12 +1237,12 @@ static void prt_speed(void)
 
 
 /*!
- * @param プレイヤーの呪文学習可能状態を表示する
+ * @brief プレイヤーの呪文学習可能状態を表示する
  * @return なし
  */
 static void prt_study(void)
 {
-       int wid, hgt, row_study, col_study;
+       TERM_LEN wid, hgt, row_study, col_study;
 
        Term_get_size(&wid, &hgt);
        col_study = wid + COL_STUDY;
@@ -1350,12 +1260,12 @@ static void prt_study(void)
 
 
 /*!
- * @param プレイヤーのものまね可能状態を表示する
+ * @brief プレイヤーのものまね可能状態を表示する
  * @return なし
  */
 static void prt_imitation(void)
 {
-       int wid, hgt, row_study, col_study;
+       TERM_LEN wid, hgt, row_study, col_study;
 
        Term_get_size(&wid, &hgt);
        col_study = wid + COL_STUDY;
@@ -1365,7 +1275,7 @@ static void prt_imitation(void)
        {
                if (p_ptr->mane_num)
                {
-                       byte attr;
+                       TERM_COLOR attr;
                        if (new_mane) attr = TERM_L_RED;
                        else attr = TERM_WHITE;
                        c_put_str(attr, _("まね", "Imit"), row_study, col_study);
@@ -1378,7 +1288,7 @@ static void prt_imitation(void)
 }
 
 /*!
- * @param プレイヤーの負傷状態を表示する
+ * @brief プレイヤーの負傷状態を表示する
  * @return なし
  */
 static void prt_cut(void)
@@ -1421,7 +1331,7 @@ static void prt_cut(void)
 
 
 /*!
- * @param プレイヤーの朦朧状態を表示する
+ * @brief プレイヤーの朦朧状態を表示する
  * @return なし
  */
 static void prt_stun(void)
@@ -1449,7 +1359,7 @@ static void prt_stun(void)
 
 
 /*!
- * @param モンスターの体力ゲージを表示する
+ * @brief モンスターの体力ゲージを表示する
  * @param riding TRUEならば騎乗中のモンスターの体力、FALSEならターゲットモンスターの体力を表示する。表示位置は固定。
  * @return なし
  * @details
@@ -1562,14 +1472,14 @@ static void health_redraw(bool riding)
                else
                {
                        /* Extract the "percent" of health */
-                       int pct = 100L * m_ptr->hp / m_ptr->maxhp;
-                       int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
+                       int pct = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
+                       int pct2 = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->max_maxhp: 0;
 
                        /* Convert percent into "health" */
                        int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
 
                        /* Default to almost dead */
-                       byte attr = TERM_RED;
+                       TERM_COLOR attr = TERM_RED;
 
                        /* Invulnerable */
                        if (MON_INVULNER(m_ptr)) attr = TERM_WHITE;
@@ -1603,8 +1513,9 @@ static void health_redraw(bool riding)
 
 
 
-/*
- * Display basic info (mostly left of map)
+/*!
+ * @brief プレイヤーのステータスを一括表示する(左側部分) / Display basic info (mostly left of map)
+ * @return なし
  */
 static void prt_frame_basic(void)
 {
@@ -1631,7 +1542,7 @@ static void prt_frame_basic(void)
        prt_exp();
 
        /* All Stats */
-       for (i = 0; i < 6; i++) prt_stat(i);
+       for (i = 0; i < A_MAX; i++) prt_stat(i);
 
        /* Armor */
        prt_ac();
@@ -1654,8 +1565,9 @@ static void prt_frame_basic(void)
 }
 
 
-/*
- * Display extra info (mostly below map)
+/*!
+ * @brief プレイヤーのステータスを一括表示する(下部分) / Display extra info (mostly below map)
+ * @return なし
  */
 static void prt_frame_extra(void)
 {
@@ -1681,8 +1593,9 @@ static void prt_frame_extra(void)
 }
 
 
-/*
- * Hack -- display inventory in sub-windows
+/*!
+ * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
+ * @return なし
  */
 static void fix_inven(void)
 {
@@ -1704,8 +1617,6 @@ static void fix_inven(void)
 
                /* Display inventory */
                display_inven();
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -1714,18 +1625,26 @@ static void fix_inven(void)
 }
 
 
-/*
- * Print monster info in line
+/*!
+ * @brief モンスターの現在数を一行で表現する / Print monster info in line
+ * @param x 表示列
+ * @param y 表示行
+ * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
+ * @param n_same モンスターの数の現在数
+ * @details
+ * <pre>
  * nnn X LV name
  *  nnn : number or unique(U) or wanted unique(W)
  *  X   : symbol of monster
  *  LV  : monster lv if known
  *  name: name of monster
+ * @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;
-       int r_idx = m_ptr->ap_r_idx;
+       MONRACE_IDX r_idx = m_ptr->ap_r_idx;
        monster_race* r_ptr = &r_info[r_idx];
  
        Term_gotoxy(x, y);
@@ -1751,7 +1670,7 @@ static void print_monster_line(int x, int y, monster_type* m_ptr, int n_same){
        Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
        //LV
        if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE)){
-               sprintf(buf, " %2d", r_ptr->level);
+               sprintf(buf, " %2d", (int)r_ptr->level);
        }else{
                strcpy(buf, " ??");
        }
@@ -1763,11 +1682,14 @@ static void print_monster_line(int x, int y, monster_type* m_ptr, int n_same){
        //Term_addstr(-1, TERM_WHITE, look_mon_desc(m_ptr, 0));
 }
 
- /*
-       max_lines : 最大何行描画するか.
-*/
-void print_monster_list(int x, int y, int max_lines){
-       int line = y;
+/*!
+ * @brief モンスターの出現リストを表示する / Print monster info in line
+ * @param x 表示列
+ * @param y 表示行
+ * @param max_lines 最大何行描画するか
+ */
+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;
@@ -1781,10 +1703,10 @@ void print_monster_list(int x, int y, int max_lines){
                if(!m_ptr->r_idx)continue;//dead?
                {
                        /*
-                       int r_idx = m_ptr->ap_r_idx;
+                       MONRACE_IDX r_idx = m_ptr->ap_r_idx;
                        monster_race* r_ptr = &r_info[r_idx];
-                       cptr name = (r_name + r_ptr->name);
-                       cptr ename = (r_name + r_ptr->name);
+                       concptr name = (r_name + r_ptr->name);
+                       concptr ename = (r_name + r_ptr->name);
                        //ミミック類や「それ」等は、一覧に出てはいけない
                        if(r_ptr->flags1&RF1_CHAR_CLEAR)continue;
                        if((r_ptr->flags1&RF1_NEVER_MOVE)&&(r_ptr->flags2&RF2_CHAR_MULTI))continue;
@@ -1823,8 +1745,10 @@ void print_monster_list(int x, int y, int max_lines){
                if(last_mons)print_monster_line(x, line++, last_mons, n_same);
        }
 }
-/*
- * Hack -- display monster list in sub-windows
+
+/*!
+ * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
+ * @return なし
  */
 static void fix_monster_list(void)
 {
@@ -1850,8 +1774,6 @@ static void fix_monster_list(void)
 
                target_set_prepare_look();//モンスター一覧を生成,ソート
                print_monster_list(0, 0, h);
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -1861,9 +1783,10 @@ static void fix_monster_list(void)
 
 
 
-
-/*
+/*!
+ * @brief 現在の装備品をサブウィンドウに表示する / 
  * Hack -- display equipment in sub-windows
+ * @return なし
  */
 static void fix_equip(void)
 {
@@ -1885,8 +1808,6 @@ static void fix_equip(void)
 
                /* Display equipment */
                display_equip();
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -1895,8 +1816,10 @@ static void fix_equip(void)
 }
 
 
-/*
- * Hack -- display equipment in sub-windows
+/*!
+ * @brief 現在の習得済魔法をサブウィンドウに表示する / 
+ * Hack -- display spells in sub-windows
+ * @return なし
  */
 static void fix_spell(void)
 {
@@ -1918,8 +1841,6 @@ static void fix_spell(void)
 
                /* Display spell list */
                display_spell_list();
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -1928,8 +1849,10 @@ static void fix_spell(void)
 }
 
 
-/*
+/*!
+ * @brief 現在のプレイヤーステータスをサブウィンドウに表示する / 
  * Hack -- display character in sub-windows
+ * @return なし
  */
 static void fix_player(void)
 {
@@ -1950,11 +1873,7 @@ static void fix_player(void)
                Term_activate(angband_term[j]);
 
                update_playtime();
-
-               /* Display player */
                display_player(0);
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -1962,18 +1881,17 @@ 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++)
@@ -1989,7 +1907,6 @@ static void fix_message(void)
                /* Activate */
                Term_activate(angband_term[j]);
 
-               /* Get size */
                Term_get_size(&w, &h);
 
                /* Dump messages */
@@ -2004,8 +1921,6 @@ static void fix_message(void)
                        /* Clear to end of line */
                        Term_erase(x, y, 255);
                }
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -2014,22 +1929,24 @@ static void fix_message(void)
 }
 
 
-/*
+/*!
+ * @brief 簡易マップをサブウィンドウに表示する / 
  * Hack -- display overhead view in sub-windows
- *
+ * Adjust for width and split messages
+ * @return なし
+ * @details
  * Note that the "player" symbol does NOT appear on the map.
  */
 static void fix_overhead(void)
 {
        int j;
-
        int cy, cx;
 
        /* Scan windows */
        for (j = 0; j < 8; j++)
        {
                term *old = Term;
-               int wid, hgt;
+               TERM_LEN wid, hgt;
 
                /* No window */
                if (!angband_term[j]) continue;
@@ -2044,10 +1961,8 @@ static void fix_overhead(void)
                Term_get_size(&wid, &hgt);
                if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2)
                {
-                       /* Redraw map */
-                       display_map(&cy, &cx);
 
-                       /* Fresh */
+                       display_map(&cy, &cx);
                        Term_fresh();
                }
 
@@ -2057,8 +1972,10 @@ static void fix_overhead(void)
 }
 
 
-/*
+/*!
+ * @brief ダンジョンの地形をサブウィンドウに表示する / 
  * Hack -- display dungeon view in sub-windows
+ * @return なし
  */
 static void fix_dungeon(void)
 {
@@ -2080,8 +1997,6 @@ static void fix_dungeon(void)
 
                /* Redraw dungeon view */
                display_dungeon();
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -2090,8 +2005,10 @@ static void fix_dungeon(void)
 }
 
 
-/*
- * Hack -- display monster recall in sub-windows
+/*!
+ * @brief モンスターの思い出をサブウィンドウに表示する / 
+ * Hack -- display dungeon view in sub-windows
+ * @return なし
  */
 static void fix_monster(void)
 {
@@ -2113,8 +2030,6 @@ static void fix_monster(void)
 
                /* Display monster race info */
                if (p_ptr->monster_race_idx) display_roff(p_ptr->monster_race_idx);
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -2123,8 +2038,10 @@ static void fix_monster(void)
 }
 
 
-/*
+/*!
+ * @brief ベースアイテム情報をサブウィンドウに表示する / 
  * Hack -- display object recall in sub-windows
+ * @return なし
  */
 static void fix_object(void)
 {
@@ -2146,8 +2063,6 @@ static void fix_object(void)
 
                /* Display monster race info */
                if (p_ptr->object_kind_idx) display_koff(p_ptr->object_kind_idx);
-
-               /* Fresh */
                Term_fresh();
 
                /* Restore */
@@ -2156,25 +2071,28 @@ static void fix_object(void)
 }
 
 
-/*
+
+/*!
+ * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
  * Calculate number of spells player should have, and forget,
  * or remember, spells until that number is properly reflected.
- *
+ * @return なし
+ * @details
  * Note that this function induces various "status" messages,
  * which must be bypasses until the character is created.
  */
 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;
-       int which;
+       REALM_IDX which;
        int bonus = 0;
 
 
-       cptr p;
+       concptr p;
 
        /* Hack -- must be literate */
        if (!mp_ptr->spell_book) return;
@@ -2297,13 +2215,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
 
 
@@ -2357,7 +2272,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 );
@@ -2433,13 +2347,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
 
 
@@ -2471,7 +2382,11 @@ static void calc_spells(void)
                        k++;
                }
                if (k > 32) k = 32;
-               if ((p_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) p_ptr->new_spells = k;
+               if ((p_ptr->new_spells > k) &&
+                       ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
+               {
+                       p_ptr->new_spells = (s16b)k;
+               }
        }
 
        if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
@@ -2482,7 +2397,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);
@@ -2508,16 +2422,17 @@ static void calc_spells(void)
        }
 }
 
-
-/*
+/*!
+ * @brief プレイヤーの最大MPを計算する /
  * Calculate maximum mana.  You do not need to know any spells.
  * Note that mana is lowered by heavy (or inappropriate) armor.
- *
+ * @return なし
+ * @details
  * This function induces status messages.
  */
 static void calc_mana(void)
 {
-       int             msp, levels, cur_wgt, max_wgt;
+       int msp, levels, cur_wgt, max_wgt;
 
        object_type     *o_ptr;
 
@@ -2573,7 +2488,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;
@@ -2770,8 +2685,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 */
@@ -2780,7 +2694,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);
        }
@@ -2792,7 +2705,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."));
@@ -2810,7 +2722,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."));
@@ -2827,9 +2738,12 @@ static void calc_mana(void)
 
 
 
-/*
+/*!
+ * @brief プレイヤーの最大HPを計算する /
  * Calculate the players (maximal) hit points
  * Adjust current hitpoints if necessary
+ * @return なし
+ * @details
  */
 static void calc_hitpoints(void)
 {
@@ -2893,8 +2807,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 */
@@ -2903,24 +2816,21 @@ static void calc_hitpoints(void)
                /* Display hitpoints (later) */
                p_ptr->redraw |= (PR_HP);
 
-               /* Window stuff */
                p_ptr->window |= (PW_PLAYER);
        }
 }
 
-
-
-/*
- * Extract and set the current "lite radius"
- *
+/*!
+ * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
+ * @return なし
+ * @details
  * SWD: Experimental modification: multiple light sources have additive effect.
- *
  */
 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;
@@ -2943,8 +2853,6 @@ static void calc_torch(void)
                                if((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
                        }
                }
-
-               /* Extract the flags */
                object_flags(o_ptr, flgs);
 
                /* calc the lite_radius */
@@ -2956,7 +2864,7 @@ static void calc_torch(void)
                if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
                if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
                if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
-               p_ptr->cur_lite += rad;
+               p_ptr->cur_lite += (s16b)rad;
        }
 
        /* max radius is 14 (was 5) without rewriting other code -- */
@@ -2978,7 +2886,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);
 
@@ -2991,28 +2898,38 @@ static void calc_torch(void)
 }
 
 
-
-/*
+/*!
+ * @brief プレイヤーの所持重量制限を計算する /
  * 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 */
        return i;
 }
 
-
+/*!
+ * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
+ * @param i 判定する手のID(右手:0 左手:1)
+ * @return 持っているならばTRUE
+ */
 bool buki_motteruka(int i)
 {
        return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
 }
 
+/*!
+ * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
+ * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
+ * @return 重すぎるならばTRUE
+ */
 bool is_heavy_shoot(object_type *o_ptr)
 {
        int hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
@@ -3020,6 +2937,11 @@ bool is_heavy_shoot(object_type *o_ptr)
        return (hold < o_ptr->weight / 10);
 }
 
+/*!
+ * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す /
+ * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
+ * @return 対応する矢/弾薬のベースアイテムID
+ */
 int bow_tval_ammo(object_type *o_ptr)
 {
        /* Analyze the launcher */
@@ -3043,6 +2965,7 @@ int bow_tval_ammo(object_type *o_ptr)
                        return TV_BOLT;
                }
                case SV_CRIMSON:
+               case SV_HARP:
                {
                        return TV_NO_AMMO;
                }
@@ -3051,15 +2974,20 @@ int bow_tval_ammo(object_type *o_ptr)
        return 0;
 }
 
-/* calcurate the fire rate of target object */
+/*!
+ * @brief 装備中の射撃武器の威力倍率を返す /
+ * calcurate the fire rate of target object
+ * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
+ * @return 射撃倍率の値(100で1.00倍)
+ */
 s16b calc_num_fire(object_type *o_ptr)
 {
        int extra_shots = 0;
        int i;
        int num = 0;
-       int tval_ammo = bow_tval_ammo(o_ptr);
+       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++)
@@ -3125,14 +3053,17 @@ s16b calc_num_fire(object_type *o_ptr)
                        num += (p_ptr->lev * 4);
                }
        }
-       return num;
+       return (s16b)num;
 }
 
-/*
+/*!
+ * @brief プレイヤーの全ステータスを更新する / 
  * Calculate the players current "state", taking into account
  * not only race/class intrinsics, but also objects being worn
  * and temporary spell effects.
- *
+ * @return なし
+ * @details
+ * <pre>
  * See also calc_mana() and calc_hitpoints().
  *
  * Take note of the new "speed code", in particular, a very strong
@@ -3147,26 +3078,27 @@ s16b calc_num_fire(object_type *o_ptr)
  * are actually added in later, at the appropriate place.
  *
  * This function induces various "status" messages.
+ * </pre>
  */
 void calc_bonuses(void)
 {
-       int             i, j, hold, neutral[2];
-       int             new_speed;
-       int             default_hand = 0;
-       int             empty_hands_status = empty_hands(TRUE);
-       int             extra_blows[2];
-       object_type     *o_ptr;
-       u32b flgs[TR_FLAG_SIZE];
-       bool            omoi = FALSE;
-       bool            yoiyami = FALSE;
-       bool            down_saving = FALSE;
+       int i, j, hold, neutral[2];
+       int new_speed;
+       int default_hand = 0;
+       int empty_hands_status = empty_hands(TRUE);
+       int extra_blows[2];
+       object_type *o_ptr;
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
+       bool omoi = FALSE;
+       bool yoiyami = FALSE;
+       bool down_saving = FALSE;
 #if 0
-       bool            have_dd_s = FALSE, have_dd_t = FALSE;
+       bool have_dd_s = FALSE, have_dd_t = FALSE;
 #endif
-       bool            have_sw = FALSE, have_kabe = FALSE;
-       bool            easy_2weapon = FALSE;
-       bool            riding_levitation = FALSE;
-       s16b this_o_idx, next_o_idx = 0;
+       bool have_sw = FALSE, have_kabe = FALSE;
+       bool easy_2weapon = FALSE;
+       bool riding_levitation = FALSE;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        const player_race *tmp_rp_ptr;
 
        /* Save the old vision stuff */
@@ -3186,16 +3118,19 @@ void calc_bonuses(void)
        bool old_see_inv = p_ptr->see_inv;
        bool old_mighty_throw = p_ptr->mighty_throw;
 
+       /* Current feature under player. */
+       feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
+
        /* Save the old armor class */
-       bool old_dis_ac = p_ptr->dis_ac;
-       bool old_dis_to_a = p_ptr->dis_to_a;
+       ARMOUR_CLASS old_dis_ac = p_ptr->dis_ac;
+       ARMOUR_CLASS old_dis_to_a = p_ptr->dis_to_a;
 
 
        /* Clear extra blows/shots */
        extra_blows[0] = extra_blows[1] = 0;
 
        /* Clear the stat modifiers */
-       for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0;
+       for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
 
 
        /* Clear the Displayed/Real armor class */
@@ -3287,6 +3222,7 @@ void calc_bonuses(void)
        p_ptr->resist_blind = FALSE;
        p_ptr->resist_neth = FALSE;
        p_ptr->resist_time = FALSE;
+       p_ptr->resist_water = FALSE;
        p_ptr->resist_fear = FALSE;
        p_ptr->reflect = FALSE;
        p_ptr->sh_fire = FALSE;
@@ -3767,6 +3703,9 @@ void calc_bonuses(void)
                        p_ptr->resist_pois = TRUE;
                        p_ptr->hold_exp = TRUE;
                        break;
+               case RACE_MERFOLK:
+                       p_ptr->resist_water = TRUE;
+                       break;
                default:
                        /* Do nothing */
                        ;
@@ -3834,10 +3773,17 @@ void calc_bonuses(void)
 
        /* Sexy Gal */
        if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
+
        if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
        if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
        if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
 
+       if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
+       {
+               p_ptr->to_m_chance += 5;
+               p_ptr->resist_conf = TRUE;
+       }
+
        /* Lucky man */
        if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
 
@@ -3860,7 +3806,7 @@ void calc_bonuses(void)
 
        /* Hack -- apply racial/class stat maxes */
        /* Apply the racial modifiers */
-       for (i = 0; i < 6; i++)
+       for (i = 0; i < A_MAX; i++)
        {
                /* Modify the stats for "race" */
                p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
@@ -4146,7 +4092,7 @@ void calc_bonuses(void)
                        if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
                        else
                        {
-                               cptr insc = quark_str(o_ptr->inscription);
+                               concptr insc = quark_str(o_ptr->inscription);
 
                                if (o_ptr->inscription && my_strchr(insc, '.'))
                                {
@@ -4299,25 +4245,25 @@ void calc_bonuses(void)
                /* To Bow and Natural attack */
 
                /* Apply the bonuses to hit/damage */
-               p_ptr->to_h_b += bonus_to_h;
-               p_ptr->to_h_m += bonus_to_h;
-               p_ptr->to_d_m += bonus_to_d;
+               p_ptr->to_h_b += (s16b)bonus_to_h;
+               p_ptr->to_h_m += (s16b)bonus_to_h;
+               p_ptr->to_d_m += (s16b)bonus_to_d;
 
                /* Apply the mental bonuses tp hit/damage, if known */
-               if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
+               if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += (s16b)bonus_to_h;
 
                /* To Melee */
                if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
                {
                        /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[i-INVEN_RIGHT] += bonus_to_h;
-                       p_ptr->to_d[i-INVEN_RIGHT] += bonus_to_d;
+                       p_ptr->to_h[i-INVEN_RIGHT] += (s16b)bonus_to_h;
+                       p_ptr->to_d[i-INVEN_RIGHT] += (s16b)bonus_to_d;
 
                        /* Apply the mental bonuses tp hit/damage, if known */
                        if (object_is_known(o_ptr))
                        {
-                               p_ptr->dis_to_h[i-INVEN_RIGHT] += bonus_to_h;
-                               p_ptr->dis_to_d[i-INVEN_RIGHT] += bonus_to_d;
+                               p_ptr->dis_to_h[i-INVEN_RIGHT] += (s16b)bonus_to_h;
+                               p_ptr->dis_to_d[i-INVEN_RIGHT] += (s16b)bonus_to_d;
                        }
                }
                else if (p_ptr->migite && p_ptr->hidarite)
@@ -4340,18 +4286,25 @@ void calc_bonuses(void)
                else
                {
                        /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[default_hand] += bonus_to_h;
-                       p_ptr->to_d[default_hand] += bonus_to_d;
+                       p_ptr->to_h[default_hand] += (s16b)bonus_to_h;
+                       p_ptr->to_d[default_hand] += (s16b)bonus_to_d;
 
                        /* Apply the mental bonuses to hit/damage, if known */
                        if (object_is_known(o_ptr))
                        {
-                               p_ptr->dis_to_h[default_hand] += bonus_to_h;
-                               p_ptr->dis_to_d[default_hand] += bonus_to_d;
+                               p_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
+                               p_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
                        }
                }
        }
 
+       /* Shield skill bonus */
+       if (object_is_armour(&inventory[INVEN_RARM]) || object_is_armour(&inventory[INVEN_LARM]))
+       {
+               p_ptr->ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
+               p_ptr->dis_ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
+       }
+
        if (old_mighty_throw != p_ptr->mighty_throw)
        {
                /* Redraw average damege display of Shuriken */
@@ -4421,7 +4374,7 @@ void calc_bonuses(void)
 
        if (p_ptr->special_defense & KATA_KOUKIJIN)
        {
-               for (i = 0; i < 6; i++)
+               for (i = 0; i < A_MAX; i++)
                        p_ptr->stat_add[i] += 5;
                p_ptr->to_a -= 50;
                p_ptr->dis_to_a -= 50;
@@ -4440,7 +4393,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))
@@ -4467,7 +4420,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;
@@ -4475,13 +4428,13 @@ void calc_bonuses(void)
                        ac += 5;
                        if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
                        if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
-                       p_ptr->to_a += ac;
-                       p_ptr->dis_to_a += ac;
+                       p_ptr->to_a += (s16b)ac;
+                       p_ptr->dis_to_a += (s16b)ac;
                }
        }
 
        /* Calculate stats */
-       for (i = 0; i < 6; i++)
+       for (i = 0; i < A_MAX; i++)
        {
                int top, use, ind;
 
@@ -4492,12 +4445,11 @@ void calc_bonuses(void)
                if (p_ptr->stat_top[i] != top)
                {
                        /* Save the new value */
-                       p_ptr->stat_top[i] = top;
+                       p_ptr->stat_top[i] = (s16b)top;
 
                        /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -4518,12 +4470,11 @@ void calc_bonuses(void)
                if (p_ptr->stat_use[i] != use)
                {
                        /* Save the new value */
-                       p_ptr->stat_use[i] = use;
+                       p_ptr->stat_use[i] = (s16b)use;
 
                        /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -4541,7 +4492,7 @@ void calc_bonuses(void)
                if (p_ptr->stat_ind[i] != ind)
                {
                        /* Save the new index */
-                       p_ptr->stat_ind[i] = ind;
+                       p_ptr->stat_ind[i] = (s16b)ind;
 
                        /* Change in CON affects Hitpoints */
                        if (i == A_CON)
@@ -4576,7 +4527,6 @@ void calc_bonuses(void)
                                }
                        }
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER);
                }
        }
@@ -4833,10 +4783,10 @@ void calc_bonuses(void)
                }
                if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
                if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
-               p_ptr->to_h[0] -= penalty1;
-               p_ptr->to_h[1] -= penalty2;
-               p_ptr->dis_to_h[0] -= penalty1;
-               p_ptr->dis_to_h[1] -= penalty2;
+               p_ptr->to_h[0] -= (s16b)penalty1;
+               p_ptr->to_h[1] -= (s16b)penalty2;
+               p_ptr->dis_to_h[0] -= (s16b)penalty1;
+               p_ptr->dis_to_h[1] -= (s16b)penalty2;
        }
 
        /* Extract the current weight (in tenth pounds) */
@@ -4851,7 +4801,7 @@ void calc_bonuses(void)
        {
                monster_type *riding_m_ptr = &m_list[p_ptr->riding];
                monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
-               int speed = riding_m_ptr->mspeed;
+               SPEED speed = riding_m_ptr->mspeed;
 
                if (riding_m_ptr->mspeed > 110)
                {
@@ -4877,12 +4827,26 @@ 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 */
        if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
 
+       /* Feature bonus */
+       if(p_ptr->prace == RACE_MERFOLK)
+       {
+               if (have_flag(f_ptr->flags, FF_WATER))
+               {
+                       new_speed += (2 + p_ptr->lev / 10);
+               }
+               else if (!p_ptr->levitation)
+               {
+                       new_speed -= 2;
+               }
+       }
+
+
        /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
        p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
        p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
@@ -4928,7 +4892,7 @@ void calc_bonuses(void)
        /* Compute "extra shots" if needed */
        if (o_ptr->k_idx)
        {
-               p_ptr->tval_ammo = bow_tval_ammo(o_ptr);
+               p_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
 
                /* Apply special flags */
                if (o_ptr->k_idx && !p_ptr->heavy_shoot)
@@ -4946,8 +4910,7 @@ void calc_bonuses(void)
                }
        }
 
-       if (p_ptr->ryoute)
-               hold *= 2;
+       if (p_ptr->ryoute) hold *= 2;
 
        for(i = 0 ; i < 2 ; i++)
        {
@@ -4961,7 +4924,11 @@ void calc_bonuses(void)
                p_ptr->icky_wield[i] = FALSE;
                p_ptr->riding_wield[i] = FALSE;
 
-               if (!buki_motteruka(INVEN_RARM+i)) {p_ptr->num_blow[i]=1;continue;}
+               if (!buki_motteruka(INVEN_RARM+i))
+               {
+                       p_ptr->num_blow[i] = 1;
+                       continue;
+               }
                /* It is hard to hold a heavy weapon */
                if (hold < o_ptr->weight / 10)
                {
@@ -5106,10 +5073,10 @@ void calc_bonuses(void)
                        p_ptr->num_blow[i] = blows_table[str_index][dex_index];
 
                        /* Maximal value */
-                       if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = num;
+                       if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = (s16b)num;
 
                        /* Add in the "bonus blows" */
-                       p_ptr->num_blow[i] += extra_blows[i];
+                       p_ptr->num_blow[i] += (s16b)extra_blows[i];
 
 
                        if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
@@ -5225,8 +5192,8 @@ void calc_bonuses(void)
                                        penalty += 30;
                                        if (penalty < 30) penalty = 30;
                                }
-                               p_ptr->to_h[i] -= penalty;
-                               p_ptr->dis_to_h[i] -= penalty;
+                               p_ptr->to_h[i] -= (s16b)penalty;
+                               p_ptr->dis_to_h[i] -= (s16b)penalty;
 
                                /* Riding weapon */
                                p_ptr->riding_wield[i] = TRUE;
@@ -5265,8 +5232,8 @@ void calc_bonuses(void)
                        if (penalty < 30) penalty = 30;
                }
                if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
-               p_ptr->to_h_b -= penalty;
-               p_ptr->dis_to_h_b -= penalty;
+               p_ptr->to_h_b -= (s16b)penalty;
+               p_ptr->dis_to_h_b -= (s16b)penalty;
        }
 
        /* Different calculation for monks with empty hands */
@@ -5282,10 +5249,10 @@ void calc_bonuses(void)
                        if (blow_base > 31) p_ptr->num_blow[0]++;
                        if (blow_base > 44) p_ptr->num_blow[0]++;
                        if (blow_base > 58) p_ptr->num_blow[0]++;
-                       if (p_ptr->magic_num1[0])
+                       if (P_PTR_KI)
                        {
-                               p_ptr->to_d[0] += (p_ptr->magic_num1[0]/5);
-                               p_ptr->dis_to_d[0] += (p_ptr->magic_num1[0]/5);
+                               p_ptr->to_d[0] += P_PTR_KI / 5;
+                               p_ptr->dis_to_d[0] += P_PTR_KI / 5;
                        }
                }
                else
@@ -5366,8 +5333,8 @@ void calc_bonuses(void)
        {
                if (buki_motteruka(INVEN_RARM+i))
                {
-                       int tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
-                       int sval = inventory[INVEN_RARM+i].sval;
+                       OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
+                       OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM+i].sval;
 
                        p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
                        p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
@@ -5424,14 +5391,10 @@ void calc_bonuses(void)
        /* Redraw armor (if needed) */
        if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
        {
-               /* Redraw */
                p_ptr->redraw |= (PR_ARMOR);
-
-               /* Window stuff */
                p_ptr->window |= (PW_PLAYER);
        }
 
-
        if (p_ptr->ryoute && !omoi)
        {
                int bonus_to_h=0, bonus_to_d=0;
@@ -5563,7 +5526,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."));
@@ -5586,7 +5548,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."));
@@ -5611,7 +5572,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."));
@@ -5631,11 +5591,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);
                                }
@@ -5656,7 +5615,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
@@ -5682,7 +5640,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);
                        }
@@ -5704,11 +5662,9 @@ void calc_bonuses(void)
                if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
                if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
        }
-       for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
-       {
-               object_type *o_ptr;
 
-               /* Acquire object */
+       for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
+       {
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -5750,170 +5706,21 @@ void calc_bonuses(void)
 }
 
 
-
-/*
- * Handle "p_ptr->notice"
- */
-void notice_stuff(void)
-{
-       /* Notice stuff */
-       if (!p_ptr->notice) return;
-
-
-       /* Actually do auto-destroy */
-       if (p_ptr->notice & (PN_AUTODESTROY))
-       {
-               p_ptr->notice &= ~(PN_AUTODESTROY);
-               autopick_delayed_alter();
-       }
-
-       /* Combine the pack */
-       if (p_ptr->notice & (PN_COMBINE))
-       {
-               p_ptr->notice &= ~(PN_COMBINE);
-               combine_pack();
-       }
-
-       /* Reorder the pack */
-       if (p_ptr->notice & (PN_REORDER))
-       {
-               p_ptr->notice &= ~(PN_REORDER);
-               reorder_pack();
-       }
-}
-
-
-/*
- * Handle "p_ptr->update"
- */
-void update_stuff(void)
-{
-       /* Update stuff */
-       if (!p_ptr->update) return;
-
-
-       if (p_ptr->update & (PU_BONUS))
-       {
-               p_ptr->update &= ~(PU_BONUS);
-               calc_bonuses();
-       }
-
-       if (p_ptr->update & (PU_TORCH))
-       {
-               p_ptr->update &= ~(PU_TORCH);
-               calc_torch();
-       }
-
-       if (p_ptr->update & (PU_HP))
-       {
-               p_ptr->update &= ~(PU_HP);
-               calc_hitpoints();
-       }
-
-       if (p_ptr->update & (PU_MANA))
-       {
-               p_ptr->update &= ~(PU_MANA);
-               calc_mana();
-       }
-
-       if (p_ptr->update & (PU_SPELLS))
-       {
-               p_ptr->update &= ~(PU_SPELLS);
-               calc_spells();
-       }
-
-
-       /* Character is not ready yet, no screen updates */
-       if (!character_generated) return;
-
-
-       /* Character is in "icky" mode, no screen updates */
-       if (character_icky) return;
-
-
-       if (p_ptr->update & (PU_UN_LITE))
-       {
-               p_ptr->update &= ~(PU_UN_LITE);
-               forget_lite();
-       }
-
-       if (p_ptr->update & (PU_UN_VIEW))
-       {
-               p_ptr->update &= ~(PU_UN_VIEW);
-               forget_view();
-       }
-
-       if (p_ptr->update & (PU_VIEW))
-       {
-               p_ptr->update &= ~(PU_VIEW);
-               update_view();
-       }
-
-       if (p_ptr->update & (PU_LITE))
-       {
-               p_ptr->update &= ~(PU_LITE);
-               update_lite();
-       }
-
-
-       if (p_ptr->update & (PU_FLOW))
-       {
-               p_ptr->update &= ~(PU_FLOW);
-               update_flow();
-       }
-
-       if (p_ptr->update & (PU_DISTANCE))
-       {
-               p_ptr->update &= ~(PU_DISTANCE);
-
-               /* Still need to call update_monsters(FALSE) after update_mon_lite() */ 
-               /* p_ptr->update &= ~(PU_MONSTERS); */
-
-               update_monsters(TRUE);
-       }
-
-       if (p_ptr->update & (PU_MON_LITE))
-       {
-               p_ptr->update &= ~(PU_MON_LITE);
-               update_mon_lite();
-       }
-
-       /*
-        * Mega-Hack -- Delayed visual update
-        * Only used if update_view(), update_lite() or update_mon_lite() was called
-        */
-       if (p_ptr->update & (PU_DELAY_VIS))
-       {
-               p_ptr->update &= ~(PU_DELAY_VIS);
-               delayed_visual_update();
-       }
-
-       if (p_ptr->update & (PU_MONSTERS))
-       {
-               p_ptr->update &= ~(PU_MONSTERS);
-               update_monsters(FALSE);
-       }
-}
-
-
-/*
- * Handle "p_ptr->redraw"
+/*! 
+ * @brief p_ptr->redraw のフラグに応じた更新をまとめて行う / Handle "p_ptr->redraw"
+ * @return なし
+ * @details 更新処理の対象はゲーム中の全描画処理
  */
-void redraw_stuff(void)
+static void redraw_stuff(void)
 {
-       /* Redraw stuff */
        if (!p_ptr->redraw) return;
 
-
        /* Character is not ready yet, no screen updates */
        if (!character_generated) return;
 
-
        /* Character is in "icky" mode, no screen updates */
        if (character_icky) return;
 
-
-
        /* Hack -- clear the screen */
        if (p_ptr->redraw & (PR_WIPE))
        {
@@ -5922,14 +5729,12 @@ void redraw_stuff(void)
                Term_clear();
        }
 
-
        if (p_ptr->redraw & (PR_MAP))
        {
                p_ptr->redraw &= ~(PR_MAP);
                prt_map();
        }
 
-
        if (p_ptr->redraw & (PR_BASIC))
        {
                p_ptr->redraw &= ~(PR_BASIC);
@@ -5953,7 +5758,6 @@ void redraw_stuff(void)
                p_ptr->redraw &= ~(PR_MISC);
                prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
 /*             prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
-
        }
 
        if (p_ptr->redraw & (PR_TITLE))
@@ -6033,7 +5837,6 @@ void redraw_stuff(void)
                health_redraw(TRUE);
        }
 
-
        if (p_ptr->redraw & (PR_EXTRA))
        {
                p_ptr->redraw &= ~(PR_EXTRA);
@@ -6088,16 +5891,15 @@ void redraw_stuff(void)
        }
 }
 
-
-/*
- * Handle "p_ptr->window"
+/*! 
+ * @brief p_ptr->window のフラグに応じた更新をまとめて行う / Handle "p_ptr->window"
+ * @return なし
+ * @details 更新処理の対象はサブウィンドウ全般
  */
-void window_stuff(void)
+static void window_stuff(void)
 {
        int j;
-
-       u32b mask = 0L;
-
+       BIT_FLAGS mask = 0L;
 
        /* Nothing to do */
        if (!p_ptr->window) return;
@@ -6115,7 +5917,6 @@ void window_stuff(void)
        /* Nothing to do */
        if (!p_ptr->window) return;
 
-
        /* Display inventory */
        if (p_ptr->window & (PW_INVEN))
        {
@@ -6188,25 +5989,162 @@ void window_stuff(void)
 }
 
 
-/*
+/*!
+ * @brief 全更新処理をチェックして処理していく
  * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
+ * @return なし
  */
 void handle_stuff(void)
 {
-       /* Update stuff */
-       if (p_ptr->update) update_stuff();
-
-       /* Redraw stuff */
+       if (p_ptr->update) update_creature(p_ptr);
        if (p_ptr->redraw) redraw_stuff();
+       if (p_ptr->window) window_stuff();
+}
 
-       /* Window stuff */
+void update_output(void)
+{
+       if (p_ptr->redraw) redraw_stuff();
        if (p_ptr->window) window_stuff();
 }
 
+/*!
+ * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update"
+ * @return なし
+ * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
+ */
+void update_creature(player_type *creature_ptr)
+{
+       if (!creature_ptr->update) return;
+
+       /* Actually do auto-destroy */
+       if (creature_ptr->update & (PU_AUTODESTROY))
+       {
+               creature_ptr->update &= ~(PU_AUTODESTROY);
+               autopick_delayed_alter();
+       }
+
+       /* Combine the pack */
+       if (creature_ptr->update & (PU_COMBINE))
+       {
+               creature_ptr->update &= ~(PU_COMBINE);
+               combine_pack();
+       }
+
+       /* Reorder the pack */
+       if (creature_ptr->update & (PU_REORDER))
+       {
+               creature_ptr->update &= ~(PU_REORDER);
+               reorder_pack();
+       }
+
+       if (creature_ptr->update & (PU_BONUS))
+       {
+               creature_ptr->update &= ~(PU_BONUS);
+               calc_bonuses();
+       }
+
+       if (creature_ptr->update & (PU_TORCH))
+       {
+               creature_ptr->update &= ~(PU_TORCH);
+               calc_torch();
+       }
+
+       if (creature_ptr->update & (PU_HP))
+       {
+               creature_ptr->update &= ~(PU_HP);
+               calc_hitpoints();
+       }
+
+       if (creature_ptr->update & (PU_MANA))
+       {
+               creature_ptr->update &= ~(PU_MANA);
+               calc_mana();
+       }
+
+       if (creature_ptr->update & (PU_SPELLS))
+       {
+               creature_ptr->update &= ~(PU_SPELLS);
+               calc_spells();
+       }
+
+       /* Character is not ready yet, no screen updates */
+       if (!character_generated) return;
+
+       /* Character is in "icky" mode, no screen updates */
+       if (character_icky) return;
+
+       if (creature_ptr->update & (PU_UN_LITE))
+       {
+               creature_ptr->update &= ~(PU_UN_LITE);
+               forget_lite();
+       }
+
+       if (creature_ptr->update & (PU_UN_VIEW))
+       {
+               creature_ptr->update &= ~(PU_UN_VIEW);
+               forget_view();
+       }
+
+       if (creature_ptr->update & (PU_VIEW))
+       {
+               creature_ptr->update &= ~(PU_VIEW);
+               update_view();
+       }
+
+       if (creature_ptr->update & (PU_LITE))
+       {
+               creature_ptr->update &= ~(PU_LITE);
+               update_lite();
+       }
 
-s16b empty_hands(bool riding_control)
+
+       if (creature_ptr->update & (PU_FLOW))
+       {
+               creature_ptr->update &= ~(PU_FLOW);
+               update_flow();
+       }
+
+       if (creature_ptr->update & (PU_DISTANCE))
+       {
+               creature_ptr->update &= ~(PU_DISTANCE);
+
+               /* Still need to call update_monsters(FALSE) after update_mon_lite() */
+               /* creature_ptr->update &= ~(PU_MONSTERS); */
+
+               update_monsters(TRUE);
+       }
+
+       if (creature_ptr->update & (PU_MON_LITE))
+       {
+               creature_ptr->update &= ~(PU_MON_LITE);
+               update_mon_lite();
+       }
+
+       /*
+        * Mega-Hack -- Delayed visual update
+        * Only used if update_view(), update_lite() or update_mon_lite() was called
+        */
+       if (creature_ptr->update & (PU_DELAY_VIS))
+       {
+               creature_ptr->update &= ~(PU_DELAY_VIS);
+               delayed_visual_update();
+       }
+
+       if (creature_ptr->update & (PU_MONSTERS))
+       {
+               creature_ptr->update &= ~(PU_MONSTERS);
+               update_monsters(FALSE);
+       }
+}
+
+/*!
+ * @brief プレイヤーの現在開いている手の状態を返す
+ * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
+ * @return 開いている手のビットフラグ
+ */
+BIT_FLAGS16 empty_hands(bool riding_control)
 {
-       s16b status = EMPTY_HAND_NONE;
+       BIT_FLAGS16 status = EMPTY_HAND_NONE;
 
        if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
        if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
@@ -6221,9 +6159,13 @@ s16b empty_hands(bool riding_control)
 }
 
 
+/*!
+ * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
+ * @return ペナルティが適用されるならばTRUE。
+ */
 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;
 
@@ -6239,12 +6181,15 @@ bool heavy_armor(void)
        return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
 }
 
+/*!
+ * @brief 実ゲームプレイ時間を更新する
+ */
 void update_playtime(void)
 {
        /* Check if the game has started */
        if (start_time != 0)
        {
-               u32b tmp = time(NULL);
+               u32b tmp = (u32b)time(NULL);
                playtime += (tmp - start_time);
                start_time = tmp;
        }