OSDN Git Service

[Refactor] #38997 artifact_scroll() にplayer_type * 引数を追加 / Added player_type * argume...
[hengband/hengband.git] / src / cmd / cmd-dump.c
index 29e612e..63f6491 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * @file cmd4.c
+ * @file cmd-dump.c
  * @brief プレイヤーのインターフェイスに関するコマンドの実装 / Interface commands
  * @date 2014/01/02
  * @author
 
 #include "english.h"
 
-/*
- *  Mark strings for auto dump
- */
+// Mark strings for auto dump
 static char auto_dump_header[] = "# vvvvvvv== %s ==vvvvvvv";
 static char auto_dump_footer[] = "# ^^^^^^^== %s ==^^^^^^^";
 
-/*
- * Variables for auto dump
- */
+// Variables for auto dump
 static FILE *auto_dump_stream;
 static concptr auto_dump_mark;
 static int auto_dump_line_num;
 
-bool write_level;
+static void do_cmd_knowledge_monsters(player_type *creature_ptr, bool *need_redraw, bool visual_only, IDX direct_r_idx);
+static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX direct_k_idx);
+static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX direct_f_idx, IDX *lighting_level);
+
+// Clipboard variables for copy&paste in visual mode
+static TERM_COLOR attr_idx = 0;
+static SYMBOL_CODE char_idx = 0;
+
+/* Hack -- for feature lighting */
+static TERM_COLOR attr_idx_feat[F_LIT_MAX];
+static SYMBOL_CODE char_idx_feat[F_LIT_MAX];
+
+// Encode the screen colors
+static char hack[17] = "dwsorgbuDWvyRGBU";
 
+// todo *抹殺* したい…
+bool write_level;
 
 /*!
  * @brief prf出力内容を消去する /
@@ -195,44 +206,42 @@ static void remove_auto_dump(concptr orig_file)
                                /* Copy orginally lines */
                                fprintf(tmp_fff, "%s\n", buf);
                        }
+
+                       continue;
                }
 
+               /* todo 処理よりもコメントが邪魔でif文を反転できない*/
                /* We are looking for the footer mark of automatic dump */
-               else
+               /* Is this line a footer? */
+               if (!strncmp(buf, footer_mark_str, mark_len))
                {
-                       /* Is this line a footer? */
-                       if (!strncmp(buf, footer_mark_str, mark_len))
-                       {
-                               int tmp;
-
-                               /*
-                                * Compare the number of lines
-                                *
-                                * If there is an inconsistency between
-                                * actual number of lines and the
-                                * number here, the automatic dump
-                                * might be edited by hand.  So it's
-                                * dangerous to kill these lines.
-                                * Seek back to the next line of the
-                                * (pseudo) header, and read again.
-                                */
-                               if (!sscanf(buf + mark_len, " (%d)", &tmp)
-                                   || tmp != line_num)
-                               {
-                                       fseek(orig_fff, header_location, SEEK_SET);
-                               }
-
-                               /* Look for another header */
-                               between_mark = FALSE;
-                       }
+                       int tmp;
 
-                       /* Not a footer */
-                       else
+                       /*
+                        * Compare the number of lines
+                        *
+                        * If there is an inconsistency between
+                        * actual number of lines and the
+                        * number here, the automatic dump
+                        * might be edited by hand.  So it's
+                        * dangerous to kill these lines.
+                        * Seek back to the next line of the
+                        * (pseudo) header, and read again.
+                        */
+                       if (!sscanf(buf + mark_len, " (%d)", &tmp)
+                               || tmp != line_num)
                        {
-                               /* Ignore old line, and count number of lines */
-                               line_num++;
+                               fseek(orig_fff, header_location, SEEK_SET);
                        }
+
+                       /* Look for another header */
+                       between_mark = FALSE;
+                       continue;
                }
+
+               /* Not a footer */
+               /* Ignore old line, and count number of lines */
+               line_num++;
        }
 
        /* Close files */
@@ -243,7 +252,6 @@ static void remove_auto_dump(concptr orig_file)
        if (changed)
        {
                /* Copy contents of temporary file */
-
                tmp_fff = my_fopen(tmp_file, "r");
                orig_fff = my_fopen(orig_file, "w");
 
@@ -254,10 +262,7 @@ static void remove_auto_dump(concptr orig_file)
                my_fclose(tmp_fff);
        }
 
-       /* Kill the temporary file */
        fd_kill(tmp_file);
-
-       return;
 }
 
 
@@ -302,7 +307,6 @@ static void auto_dump_printf(concptr fmt, ...)
  */
 static bool open_auto_dump(concptr buf, concptr mark)
 {
-
        char header_mark_str[80];
 
        /* Save the mark string */
@@ -318,7 +322,8 @@ static bool open_auto_dump(concptr buf, concptr mark)
        auto_dump_stream = my_fopen(buf, "a");
 
        /* Failure */
-       if (!auto_dump_stream) {
+       if (!auto_dump_stream)
+       {
                msg_format(_("%s を開くことができませんでした。", "Failed to open %s."), buf);
                msg_print(NULL);
 
@@ -336,7 +341,6 @@ static bool open_auto_dump(concptr buf, concptr mark)
                                           "# *Warning!*  The lines below are an automatic dump.\n"));
        auto_dump_printf(_("# *警告!!* 後で自動的に削除されるので編集しないでください。\n", 
                                           "# Don't edit them; changes will be deleted and replaced automatically.\n"));
-       /* Success */
        return TRUE;
 }
 
@@ -359,10 +363,7 @@ static void close_auto_dump(void)
        /* End of dump */
        fprintf(auto_dump_stream, "%s (%d)\n", footer_mark_str, auto_dump_line_num);
 
-       /* Close */
        my_fclose(auto_dump_stream);
-
-       return;
 }
 
 
@@ -410,11 +411,11 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note)
        char note_level_buf[40];
        QUEST_IDX q_idx;
 
-       static bool disable_nikki = FALSE;
+       static bool disable_diary = FALSE;
 
        extract_day_hour_min(&day, &hour, &min);
 
-       if (disable_nikki) return(-1);
+       if (disable_diary) return(-1);
 
        if (type == NIKKI_FIX_QUEST_C ||
            type == NIKKI_FIX_QUEST_F ||
@@ -450,7 +451,7 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note)
        {
                msg_format(_("%s を開くことができませんでした。プレイ記録を一時停止します。", "Failed to open %s. Play-Record is disabled temporally."), buf);
                msg_format(NULL);
-               disable_nikki=TRUE;
+               disable_diary=TRUE;
                return (-1);
        }
 
@@ -757,76 +758,79 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note)
  */
 static void display_diary(player_type *creature_ptr)
 {
-       char nikki_title[256];
+       char diary_title[256];
        GAME_TEXT file_name[MAX_NLEN];
        char buf[1024];
        char tmp[80];
 #ifdef JP
-       /*! */
-       static const char subtitle[][30] = {"最強の肉体を求めて",
-                                          "人生それははかない",
-                                          "明日に向かって",
-                                          "棚からぼたもち",
-                                          "あとの祭り",
-                                          "それはいい考えだ",
-                                          "何とでも言え",
-                                          "兎にも角にも",
-                                          "ウソだけど",
-                                          "もはやこれまで",
-                                          "なんでこうなるの",
-                                          "それは無理だ",
-                                          "倒すべき敵はゲ○ツ",
-                                          "ん~?聞こえんなぁ",
-                                          "オレの名を言ってみろ",
-                                          "頭が変になっちゃった",
-                                          "互換しません",
-                                          "せっかくだから",
-                                          "まだまだ甘いね",
-                                          "むごいむごすぎる",
-                                          "こんなもんじゃない",
-                                          "だめだこりゃ",
-                                          "次いってみよう",
-                                          "ちょっとだけよ",
-                                          "哀しき冒険者",
-                                          "野望の果て",
-                                          "無限地獄",
-                                          "神に喧嘩を売る者",
-                                          "未知の世界へ",
-                                          "最高の頭脳を求めて"};
+       static const char subtitle[][30] = {
+               "最強の肉体を求めて",
+               "人生それははかない",
+               "明日に向かって",
+               "棚からぼたもち",
+               "あとの祭り",
+               "それはいい考えだ",
+               "何とでも言え",
+               "兎にも角にも",
+               "ウソだけど",
+               "もはやこれまで",
+               "なんでこうなるの",
+               "それは無理だ",
+               "倒すべき敵はゲ○ツ",
+               "ん~?聞こえんなぁ",
+               "オレの名を言ってみろ",
+               "頭が変になっちゃった",
+               "互換しません",
+               "せっかくだから",
+               "まだまだ甘いね",
+               "むごいむごすぎる",
+               "こんなもんじゃない",
+               "だめだこりゃ",
+               "次いってみよう",
+               "ちょっとだけよ",
+               "哀しき冒険者",
+               "野望の果て",
+               "無限地獄",
+               "神に喧嘩を売る者",
+               "未知の世界へ",
+               "最高の頭脳を求めて"
+       };
 #else
-       static const char subtitle[][51] ={"Quest of The World's Toughest Body",
-                                          "Attack is the best form of defence.",
-                                          "Might is right.",
-                                          "An unexpected windfall",
-                                          "A drowning man will catch at a straw",
-                                          "Don't count your chickens before they are hatched.",
-                                          "It is no use crying over spilt milk.",
-                                          "Seeing is believing.",
-                                          "Strike the iron while it is hot.",
-                                          "I don't care what follows.",
-                                          "To dig a well to put out a house on fire.",
-                                          "Tomorrow is another day.",
-                                          "Easy come, easy go.",
-                                          "The more haste, the less speed.",
-                                          "Where there is life, there is hope.",
-                                          "There is no royal road to *WINNER*.",
-                                          "Danger past, God forgotten.",
-                                          "The best thing to do now is to run away.",
-                                          "Life is but an empty dream.",
-                                          "Dead men tell no tales.",
-                                          "A book that remains shut is but a block.",
-                                          "Misfortunes never come singly.",
-                                          "A little knowledge is a dangerous thing.",
-                                          "History repeats itself.",
-                                          "*WINNER* was not built in a day.",
-                                          "Ignorance is bliss.",
-                                          "To lose is to win?",
-                                          "No medicine can cure folly.",
-                                          "All good things come to an end.",
-                                          "M$ Empire strikes back.",
-                                          "To see is to believe",
-                                          "Time is money.",
-                                          "Quest of The World's Greatest Brain"};
+       static const char subtitle[][51] ={
+               "Quest of The World's Toughest Body",
+               "Attack is the best form of defence.",
+               "Might is right.",
+               "An unexpected windfall",
+               "A drowning man will catch at a straw",
+               "Don't count your chickens before they are hatched.",
+               "It is no use crying over spilt milk.",
+               "Seeing is believing.",
+               "Strike the iron while it is hot.",
+               "I don't care what follows.",
+               "To dig a well to put out a house on fire.",
+               "Tomorrow is another day.",
+               "Easy come, easy go.",
+               "The more haste, the less speed.",
+               "Where there is life, there is hope.",
+               "There is no royal road to *WINNER*.",
+               "Danger past, God forgotten.",
+               "The best thing to do now is to run away.",
+               "Life is but an empty dream.",
+               "Dead men tell no tales.",
+               "A book that remains shut is but a block.",
+               "Misfortunes never come singly.",
+               "A little knowledge is a dangerous thing.",
+               "History repeats itself.",
+               "*WINNER* was not built in a day.",
+               "Ignorance is bliss.",
+               "To lose is to win?",
+               "No medicine can cure folly.",
+               "All good things come to an end.",
+               "M$ Empire strikes back.",
+               "To see is to believe",
+               "Time is money.",
+               "Quest of The World's Greatest Brain"
+       };
 #endif
        sprintf(file_name,_("playrecord-%s.txt", "playrec-%s.txt"),savefile_base);
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
@@ -838,15 +842,16 @@ static void display_diary(player_type *creature_ptr)
        else strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-2)+1]);
 
 #ifdef JP
-       sprintf(nikki_title, "「%s%s%sの伝説 -%s-」", ap_ptr->title, ap_ptr->no ? "の" : "", creature_ptr->name, tmp);
+       sprintf(diary_title, "「%s%s%sの伝説 -%s-」", ap_ptr->title, ap_ptr->no ? "の" : "", creature_ptr->name, tmp);
 #else
-       sprintf(nikki_title, "Legend of %s %s '%s'", ap_ptr->title, creature_ptr->name, tmp);
+       sprintf(diary_title, "Legend of %s %s '%s'", ap_ptr->title, creature_ptr->name, tmp);
 #endif
 
        /* Display the file contents */
-       show_file(FALSE, buf, nikki_title, -1, 0);
+       show_file(FALSE, buf, diary_title, -1, 0);
 }
 
+
 /*!
  * @brief 日記に任意の内容を表記するコマンドのメインルーチン /
  * @return なし
@@ -869,26 +874,25 @@ static void add_diary_note(player_type *creature_ptr)
  */
 static void do_cmd_last_get(player_type *creaute_ptr)
 {
-       char buf[256];
-       GAME_TURN turn_tmp;
-
        if (record_o_name[0] == '\0') return;
 
+       char buf[256];
        sprintf(buf,_("%sの入手を記録します。", "Do you really want to record getting %s? "),record_o_name);
        if (!get_check(buf)) return;
 
-       turn_tmp = current_world_ptr->game_turn;
+       GAME_TURN turn_tmp = current_world_ptr->game_turn;
        current_world_ptr->game_turn = record_turn;
        sprintf(buf,_("%sを手に入れた。", "descover %s."), record_o_name);
        exe_write_diary(creaute_ptr, NIKKI_BUNSHOU, 0, buf);
        current_world_ptr->game_turn = turn_tmp;
 }
 
+
 /*!
  * @brief ファイル中の全日記記録を消去する /
  * @return なし
  */
-static void do_cmd_erase_nikki(void)
+static void do_cmd_erase_diary(void)
 {
        GAME_TEXT file_name[MAX_NLEN];
        char buf[256];
@@ -900,29 +904,33 @@ static void do_cmd_erase_nikki(void)
        fd_kill(buf);
 
        fff = my_fopen(buf, "w");
-       if(fff){
+       if(fff)
+       {
                my_fclose(fff);
                msg_format(_("記録を消去しました。", "deleted record."));
-       }else{
+       }else
+       {
                msg_format(_("%s の消去に失敗しました。", "failed to delete %s."), buf);
        }
+
        msg_print(NULL);
 }
 
+
 /*!
  * @brief 日記コマンド
+ * @param crerature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
-void do_cmd_nikki(void)
+void do_cmd_diary(player_type *creature_ptr)
 {
-       int i;
-
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
        screen_save();
 
        /* Interact until done */
-       while (1)
+       int i;
+       while (TRUE)
        {
                Term_clear();
 
@@ -948,16 +956,16 @@ void do_cmd_nikki(void)
                switch (i)
                {
                case '1':
-                       display_diary(p_ptr);
+                       display_diary(creature_ptr);
                        break;
                case '2':
-                       add_diary_note(p_ptr);
+                       add_diary_note(creature_ptr);
                        break;
                case '3':
-                       do_cmd_last_get(p_ptr);
+                       do_cmd_last_get(creature_ptr);
                        break;
                case '4':
-                       do_cmd_erase_nikki();
+                       do_cmd_erase_diary();
                        break;
                case 'r': case 'R':
                        screen_load();
@@ -969,12 +977,15 @@ void do_cmd_nikki(void)
 
                msg_erase();
        }
+
        screen_load();
 }
 
+
 /*!
  * @brief 画面を再描画するコマンドのメインルーチン
  * Hack -- redraw the screen
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  * @details
  * <pre>
@@ -989,11 +1000,6 @@ void do_cmd_nikki(void)
  */
 void do_cmd_redraw(player_type *creature_ptr)
 {
-       int j;
-       term *old = Term;
-
-
-       /* Hack -- react to changes */
        Term_xtra(TERM_XTRA_REACT, 0);
 
        /* Combine and Reorder the pack (later) */
@@ -1010,14 +1016,13 @@ void do_cmd_redraw(player_type *creature_ptr)
        creature_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
 
        update_playtime();
-
        handle_stuff();
 
        if (creature_ptr->prace == RACE_ANDROID) calc_android_exp(creature_ptr);
 
-
        /* Redraw every window */
-       for (j = 0; j < 8; j++)
+       term *old = Term;
+       for (int j = 0; j < 8; j++)
        {
                /* Dead window */
                if (!angband_term[j]) continue;
@@ -1043,7 +1048,7 @@ void do_cmd_player_status(player_type *creature_ptr)
        screen_save();
 
        /* Forever */
-       while (1)
+       while (TRUE)
        {
                update_playtime();
                display_player(creature_ptr, mode);
@@ -1065,7 +1070,7 @@ void do_cmd_player_status(player_type *creature_ptr)
                /* Change name */
                if (c == 'c')
                {
-                       get_name();
+                       get_name(creature_ptr);
 
                        /* Process the player name */
                        process_player_name(FALSE);
@@ -1079,7 +1084,7 @@ void do_cmd_player_status(player_type *creature_ptr)
                        {
                                if (tmp[0] && (tmp[0] != ' '))
                                {
-                                       file_character(tmp);
+                                       file_character(creature_ptr, tmp);
                                }
                        }
                }
@@ -1095,6 +1100,7 @@ void do_cmd_player_status(player_type *creature_ptr)
 
                msg_erase();
        }
+
        screen_load();
        creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
 
@@ -1137,8 +1143,6 @@ void do_cmd_message_one(void)
  */
 void do_cmd_messages(int num_now)
 {
-       int i, n;
-
        char shower_str[81];
        char finder_str[81];
        char back_str[81];
@@ -1158,15 +1162,15 @@ void do_cmd_messages(int num_now)
        strcpy(shower_str, "");
 
        /* Total messages */
-       n = message_num();
+       int n = message_num();
 
        /* Start on first message */
-       i = 0;
+       int i = 0;
        screen_save();
        Term_clear();
 
        /* Process requests until done */
-       while (1)
+       while (TRUE)
        {
                int j;
                int skey;
@@ -1179,30 +1183,26 @@ void do_cmd_messages(int num_now)
                        /* Dump the messages, bottom to top */
                        c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
 
+                       if (!shower || !shower[0]) continue;
+
                        /* Hilite "shower" */
-                       if (shower && shower[0])
-                       {
-                               concptr str = msg;
+                       concptr str = msg;
 
-                               /* Display matches */
-                               while ((str = my_strstr(str, shower)) != NULL)
-                               {
-                                       int len = strlen(shower);
+                       /* Display matches */
+                       while ((str = my_strstr(str, shower)) != NULL)
+                       {
+                               int len = strlen(shower);
 
-                                       /* Display the match */
-                                       Term_putstr(str-msg, num_lines + 1 - j, len, TERM_YELLOW, shower);
+                               /* Display the match */
+                               Term_putstr(str - msg, num_lines + 1 - j, len, TERM_YELLOW, shower);
 
-                                       /* Advance */
-                                       str += len;
-                               }
+                               /* Advance */
+                               str += len;
                        }
                }
 
                /* Erase remaining lines */
-               for (; j < num_lines; j++)
-               {
-                       Term_erase(0, num_lines + 1 - j, 255);
-               }
+               for (; j < num_lines; j++) Term_erase(0, num_lines + 1 - j, 255);
 
                /* Display header */
                /* translation */
@@ -1342,6 +1342,7 @@ void do_cmd_messages(int num_now)
                /* Hack -- Error of some kind */
                if (i == j) bell();
        }
+
        screen_load();
 }
 
@@ -1356,8 +1357,6 @@ void do_cmd_messages(int num_now)
 void do_cmd_pref(void)
 {
        char buf[80];
-
-       /* Default */
        strcpy(buf, "");
 
        /* Ask for a "user pref command" */
@@ -1367,6 +1366,7 @@ void do_cmd_pref(void)
        (void)process_pref_file_command(buf);
 }
 
+
 /*!
  * @brief 自動拾い設定ファイルをロードするコマンドのメインルーチン /
  * @return なし
@@ -1380,6 +1380,7 @@ void do_cmd_reload_autopick(void)
 
 #ifdef ALLOW_MACROS
 
+
 /*!
  * @brief マクロ情報をprefファイルに保存する /
  * @param fname ファイル名
@@ -1388,9 +1389,6 @@ void do_cmd_reload_autopick(void)
 static errr macro_dump(concptr fname)
 {
        static concptr mark = "Macro Dump";
-
-       int i;
-
        char buf[1024];
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
@@ -1404,7 +1402,7 @@ static errr macro_dump(concptr fname)
        auto_dump_printf(_("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
        
        /* Dump them */
-       for (i = 0; i < macro__num; i++)
+       for (int i = 0; i < macro__num; i++)
        {
                /* Extract the action */
                ascii_to_text(buf, macro__act[i]);
@@ -1422,10 +1420,7 @@ static errr macro_dump(concptr fname)
                auto_dump_printf("\n");
        }
 
-       /* Close */
        close_auto_dump();
-
-       /* Success */
        return (0);
 }
 
@@ -1444,19 +1439,16 @@ static errr macro_dump(concptr fname)
  */
 static void do_cmd_macro_aux(char *buf)
 {
-       char i;
-       int n = 0;
-       char tmp[1024];
-
        flush();
 
        /* Do not process macros */
        inkey_base = TRUE;
 
        /* First key */
-       i = inkey();
+       char i = inkey();
 
        /* Read the pattern */
+       int n = 0;
        while (i)
        {
                /* Save the key */
@@ -1478,6 +1470,7 @@ static void do_cmd_macro_aux(char *buf)
        flush();
 
        /* Convert the trigger */
+       char tmp[1024];
        ascii_to_text(tmp, buf);
 
        /* Hack -- display the trigger */
@@ -1527,8 +1520,6 @@ static void do_cmd_macro_aux_keymap(char *buf)
 static errr keymap_dump(concptr fname)
 {
        static concptr mark = "Keymap Dump";
-       int i;
-
        char key[1024];
        char buf[1024];
 
@@ -1558,7 +1549,7 @@ static errr keymap_dump(concptr fname)
        auto_dump_printf(_("\n# 自動キー配置セーブ\n\n", "\n# Automatic keymap dump\n\n"));
        
        /* Dump them */
-       for (i = 0; i < 256; i++)
+       for (int i = 0; i < 256; i++)
        {
                concptr act;
 
@@ -1581,10 +1572,7 @@ static errr keymap_dump(concptr fname)
                auto_dump_printf("C:%d:%s\n", mode, key);
        }
 
-       /* Close */
        close_auto_dump();
-
-       /* Success */
        return (0);
 }
 
@@ -1624,9 +1612,8 @@ void do_cmd_macros(player_type *creature_ptr)
 
        screen_save();
 
-
        /* Process requests until done */
-       while (1)
+       while (TRUE)
        {
                Term_clear();
                prt(_("[ マクロの設定 ]", "Interact with Macros"), 2, 0);
@@ -1698,7 +1685,6 @@ void do_cmd_macros(player_type *creature_ptr)
                }
 
 #ifdef ALLOW_MACROS
-
                /* Save macros */
                else if (i == '2')
                {
@@ -1967,7 +1953,6 @@ void do_cmd_macros(player_type *creature_ptr)
                        /* Extract an action */
                        text_to_ascii(macro__buf, buf);
                }
-
 #endif /* ALLOW_MACROS */
 
                else
@@ -1977,9 +1962,11 @@ void do_cmd_macros(player_type *creature_ptr)
 
                msg_erase();
        }
+
        screen_load();
 }
 
+
 /*!
  * @brief キャラクタ色の明暗表現
  */
@@ -2058,9 +2045,6 @@ static void print_visuals_menu(concptr choice_msg)
        prt(format("コマンド: %s", choice_msg ? choice_msg : _("", "")), 15, 0);
 }
 
-static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX direct_r_idx);
-static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX direct_k_idx);
-static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX direct_f_idx, IDX *lighting_level);
 
 /*
  * Interact with "visuals"
@@ -2080,7 +2064,7 @@ void do_cmd_visuals(player_type *creature_ptr)
        screen_save();
 
        /* Interact until done */
-       while (1)
+       while (TRUE)
        {
                Term_clear();
 
@@ -2363,7 +2347,7 @@ void do_cmd_visuals(player_type *creature_ptr)
                                        need_redraw = TRUE;
                                        break;
                                case 'v':
-                                       do_cmd_knowledge_monsters(&need_redraw, TRUE, r);
+                                       do_cmd_knowledge_monsters(creature_ptr, &need_redraw, TRUE, r);
                                        Term_clear();
                                        print_visuals_menu(choice_msg);
                                        break;
@@ -2574,7 +2558,7 @@ void do_cmd_visuals(player_type *creature_ptr)
 
                /* Modify monster attr/chars (visual mode) */
                case '7':
-                       do_cmd_knowledge_monsters(&need_redraw, TRUE, -1);
+                       do_cmd_knowledge_monsters(creature_ptr, &need_redraw, TRUE, -1);
                        break;
 
                /* Modify object attr/chars (visual mode) */
@@ -2610,6 +2594,7 @@ void do_cmd_visuals(player_type *creature_ptr)
 
                msg_erase();
        }
+
        screen_load();
 
        if (need_redraw) do_cmd_redraw(creature_ptr);
@@ -2631,7 +2616,7 @@ void do_cmd_colors(player_type *creature_ptr)
        screen_save();
 
        /* Interact until done */
-       while (1)
+       while (TRUE)
        {
                Term_clear();
 
@@ -2854,7 +2839,6 @@ void do_cmd_version(void)
 }
 
 
-
 /*
  * Array of feeling strings
  */
@@ -2920,22 +2904,20 @@ void do_cmd_feeling(player_type *creature_ptr)
        }
 
        /* No useful feeling in town */
-       else if (creature_ptr->town_num && !creature_ptr->current_floor_ptr->dun_level)
+       if (creature_ptr->town_num && !creature_ptr->current_floor_ptr->dun_level)
        {
                if (!strcmp(town_info[creature_ptr->town_num].name, _("荒野", "wilderness")))
                {
                        msg_print(_("何かありそうな荒野のようだ。", "Looks like a strange wilderness."));
                        return;
                }
-               else
-               {
-                       msg_print(_("典型的な町のようだ。", "Looks like a typical town."));
-                       return;
-               }
+               
+               msg_print(_("典型的な町のようだ。", "Looks like a typical town."));
+               return;
        }
 
        /* No useful feeling in the wilderness */
-       else if (!creature_ptr->current_floor_ptr->dun_level)
+       if (!creature_ptr->current_floor_ptr->dun_level)
        {
                msg_print(_("典型的な荒野のようだ。", "Looks like a typical wilderness."));
                return;
@@ -2952,7 +2934,6 @@ void do_cmd_feeling(player_type *creature_ptr)
 }
 
 
-
 /*
  * Description of each monster group.
  */
@@ -3156,36 +3137,31 @@ static concptr monster_group_char[] =
 
 
 /*
- * Build a list of monster indexes in the given group. Return the number
- * of monsters in the group.
+ * todo 引数と戻り値について追記求む
+ * Build a list of monster indexes in the given group.
  *
  * mode & 0x01 : check for non-empty group
  * mode & 0x02 : visual operation only
+
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param grp_cur ???
+ * @param mon_idx[] ???
+ * @param mode ???
+ * @return The number of monsters in the group
  */
-static IDX collect_monsters(IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
+static IDX collect_monsters(player_type *creature_ptr, IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
 {
-       IDX i;
-       IDX mon_cnt = 0;
-       int dummy_why;
-
        /* Get a list of x_char in this group */
        concptr group_char = monster_group_char[grp_cur];
 
-       /* XXX Hack -- Check if this is the "Uniques" group */
        bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
-
-       /* XXX Hack -- Check if this is the "Riding" group */
        bool grp_riding = (monster_group_char[grp_cur] == (char *) -2L);
-
-       /* XXX Hack -- Check if this is the "Wanted" group */
        bool grp_wanted = (monster_group_char[grp_cur] == (char *) -3L);
-
-       /* XXX Hack -- Check if this is the "Amberite" group */
        bool grp_amberite = (monster_group_char[grp_cur] == (char *) -4L);
 
-
        /* Check every race */
-       for (i = 0; i < max_r_idx; i++)
+       IDX mon_cnt = 0;
+       for (IDX i = 0; i < max_r_idx; i++)
        {
                /* Access the race */
                monster_race *r_ptr = &r_info[i];
@@ -3210,10 +3186,10 @@ static IDX collect_monsters(IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
                {
                        bool wanted = FALSE;
                        int j;
-                       for (j = 0; j < MAX_KUBI; j++)
+                       for (j = 0; j < MAX_BOUNTY; j++)
                        {
                                if (current_world_ptr->bounty_r_idx[j] == i || current_world_ptr->bounty_r_idx[j] - 10000 == i ||
-                                       (p_ptr->today_mon && p_ptr->today_mon == i))
+                                       (creature_ptr->today_mon && creature_ptr->today_mon == i))
                                {
                                        wanted = TRUE;
                                        break;
@@ -3243,6 +3219,7 @@ static IDX collect_monsters(IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
        /* Terminate the list */
        mon_idx[mon_cnt] = -1;
 
+       int dummy_why;
        ang_sort(mon_idx, &dummy_why, mon_cnt, ang_sort_comp_monster_level, ang_sort_swap_hook);
 
        /* Return the number of races */
@@ -3421,11 +3398,7 @@ static KIND_OBJECT_IDX collect_objects(int grp_cur, KIND_OBJECT_IDX object_idx[]
                /* Skip empty objects */
                if (!k_ptr->name) continue;
 
-               if (mode & 0x02)
-               {
-                       /* Any objects will be displayed */
-               }
-               else
+               if (!(mode & 0x02))
                {
                        if (!current_world_ptr->wizard)
                        {
@@ -3487,16 +3460,11 @@ static concptr feature_group_text[] =
  *
  * mode & 0x01 : check for non-empty group
  */
-static FEAT_IDX collect_features(int grp_cur, FEAT_IDX *feat_idx, BIT_FLAGS8 mode)
+static FEAT_IDX collect_features(FEAT_IDX *feat_idx, BIT_FLAGS8 mode)
 {
-       FEAT_IDX i;
-       FEAT_IDX feat_cnt = 0;
-
-       /* Unused;  There is a single group. */
-       (void)grp_cur;
-
        /* Check every feature */
-       for (i = 0; i < max_f_idx; i++)
+       FEAT_IDX feat_cnt = 0;
+       for (FEAT_IDX i = 0; i < max_f_idx; i++)
        {
                feature_type *f_ptr = &f_info[i];
 
@@ -3563,17 +3531,10 @@ static int collect_artifacts(int grp_cur, int object_idx[])
 
 
 /*
- * Encode the screen colors
- */
-static char hack[17] = "dwsorgbuDWvyRGBU";
-
-
-/*
  * Hack -- load a screen dump from a file
  */
 void do_cmd_load_screen(void)
 {
-       int i;
        TERM_LEN y, x;
        TERM_COLOR a = 0;
        SYMBOL_CODE c = ' ';
@@ -3588,7 +3549,8 @@ void do_cmd_load_screen(void)
        /* Append to the file */
        fff = my_fopen(buf, "r");
 
-       if (!fff) {
+       if (!fff)
+       {
                msg_format(_("%s を開くことができませんでした。", "Failed to open %s."), buf);
                msg_print(NULL);
                return;
@@ -3642,7 +3604,7 @@ void do_cmd_load_screen(void)
                        (void)(Term_what(x, y, &a, &c));
 
                        /* Look up the attr */
-                       for (i = 0; i < 16; i++)
+                       for (int i = 0; i < 16; i++)
                        {
                                /* Use attr matches */
                                if (hack[i] == buf[x]) a = (byte_hack)i;
@@ -3652,6 +3614,7 @@ void do_cmd_load_screen(void)
                        Term_draw(x, y, a, c);
                }
        }
+
        my_fclose(fff);
 
        prt(_("ファイルに書き出された画面(記念撮影)をロードしました。", "Screen dump loaded."), 0, 0);
@@ -3662,13 +3625,10 @@ void do_cmd_load_screen(void)
        screen_load();
 }
 
-
-
-
+// todo なぜこんな中途半端なところに? defineも…
 concptr inven_res_label = _("                               酸電火冷毒光闇破轟獄因沌劣 盲怖乱痺透命感消復浮",
                                                 "                               AcElFiCoPoLiDkShSoNtNxCaDi BlFeCfFaSeHlEpSdRgLv");
 
-
 #define IM_FLAG_STR  _("*", "* ")
 #define HAS_FLAG_STR _("+", "+ ")
 #define NO_FLAG_STR  _("・", ". ")
@@ -3701,81 +3661,86 @@ static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, int *j, OB
         * HACK:Ring of Lordly protection and Dragon equipment
         * have random resistances.
         */
-       if ((object_is_wearable(o_ptr) && object_is_ego(o_ptr))
-           || ((tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_RESISTANCE))
-           || ((tval == TV_RING) && (o_ptr->sval == SV_RING_LORDLY))
-           || ((tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD))
-           || ((tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
-           || ((tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
-           || ((tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE))
-           || object_is_artifact(o_ptr))
+       bool is_special_item_type = (object_is_wearable(o_ptr) && object_is_ego(o_ptr))
+               || ((tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_RESISTANCE))
+               || ((tval == TV_RING) && (o_ptr->sval == SV_RING_LORDLY))
+               || ((tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD))
+               || ((tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
+               || ((tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
+               || ((tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE))
+               || object_is_artifact(o_ptr);
+       if (!is_special_item_type)
        {
-               int i = 0;
-               object_desc(o_name, o_ptr, OD_NAME_ONLY);
+               return;
+       }
 
-               while (o_name[i] && (i < 26))
-               {
+       int i = 0;
+       object_desc(o_name, o_ptr, OD_NAME_ONLY);
+
+       while (o_name[i] && (i < 26))
+       {
 #ifdef JP
-                       if (iskanji(o_name[i])) i++;
+               if (iskanji(o_name[i])) i++;
 #endif
-                       i++;
-               }
+               i++;
+       }
 
-               if (i < 28)
+       if (i < 28)
+       {
+               while (i < 28)
                {
-                       while (i < 28)
-                       {
-                               o_name[i] = ' '; i++;
-                       }
+                       o_name[i] = ' '; i++;
                }
-               o_name[i] = '\0';
+       }
 
-               fprintf(fff, "%s %s", where, o_name);
+       o_name[i] = '\0';
 
-               if (!(o_ptr->ident & (IDENT_MENTAL)))
-               {
-                       fputs(_("-------不明--------------- -------不明---------\n", 
-                                       "-------unknown------------ -------unknown------\n"), fff);
-               }
-               else
-               {
-                       object_flags_known(o_ptr, flgs);
-
-                       print_im_or_res_flag(TR_IM_ACID, TR_RES_ACID);
-                       print_im_or_res_flag(TR_IM_ELEC, TR_RES_ELEC);
-                       print_im_or_res_flag(TR_IM_FIRE, TR_RES_FIRE);
-                       print_im_or_res_flag(TR_IM_COLD, TR_RES_COLD);
-                       print_flag(TR_RES_POIS);
-                       print_flag(TR_RES_LITE);
-                       print_flag(TR_RES_DARK);
-                       print_flag(TR_RES_SHARDS);
-                       print_flag(TR_RES_SOUND);
-                       print_flag(TR_RES_NETHER);
-                       print_flag(TR_RES_NEXUS);
-                       print_flag(TR_RES_CHAOS);
-                       print_flag(TR_RES_DISEN);
-
-                       fputs(" ", fff);
-
-                       print_flag(TR_RES_BLIND);
-                       print_flag(TR_RES_FEAR);
-                       print_flag(TR_RES_CONF);
-                       print_flag(TR_FREE_ACT);
-                       print_flag(TR_SEE_INVIS);
-                       print_flag(TR_HOLD_EXP);
-                       print_flag(TR_TELEPATHY);
-                       print_flag(TR_SLOW_DIGEST);
-                       print_flag(TR_REGEN);
-                       print_flag(TR_LEVITATION);
-
-                       fputc('\n', fff);
-               }
-               (*j)++;
-               if (*j == 9)
-               {
-                       *j = 0;
-                       fprintf(fff, "%s\n", inven_res_label);
-               }
+       fprintf(fff, "%s %s", where, o_name);
+
+       if (!(o_ptr->ident & (IDENT_MENTAL)))
+       {
+               fputs(_("-------不明--------------- -------不明---------\n",
+                       "-------unknown------------ -------unknown------\n"), fff);
+       }
+       else
+       {
+               object_flags_known(o_ptr, flgs);
+
+               print_im_or_res_flag(TR_IM_ACID, TR_RES_ACID);
+               print_im_or_res_flag(TR_IM_ELEC, TR_RES_ELEC);
+               print_im_or_res_flag(TR_IM_FIRE, TR_RES_FIRE);
+               print_im_or_res_flag(TR_IM_COLD, TR_RES_COLD);
+               print_flag(TR_RES_POIS);
+               print_flag(TR_RES_LITE);
+               print_flag(TR_RES_DARK);
+               print_flag(TR_RES_SHARDS);
+               print_flag(TR_RES_SOUND);
+               print_flag(TR_RES_NETHER);
+               print_flag(TR_RES_NEXUS);
+               print_flag(TR_RES_CHAOS);
+               print_flag(TR_RES_DISEN);
+
+               fputs(" ", fff);
+
+               print_flag(TR_RES_BLIND);
+               print_flag(TR_RES_FEAR);
+               print_flag(TR_RES_CONF);
+               print_flag(TR_FREE_ACT);
+               print_flag(TR_SEE_INVIS);
+               print_flag(TR_HOLD_EXP);
+               print_flag(TR_TELEPATHY);
+               print_flag(TR_SLOW_DIGEST);
+               print_flag(TR_REGEN);
+               print_flag(TR_LEVITATION);
+
+               fputc('\n', fff);
+       }
+
+       (*j)++;
+       if (*j == 9)
+       {
+               *j = 0;
+               fprintf(fff, "%s\n", inven_res_label);
        }
 }
 
@@ -3801,6 +3766,7 @@ static void do_cmd_knowledge_inven(player_type *creature_ptr)
            msg_print(NULL);
            return;
        }
+
        fprintf(fff, "%s\n", inven_res_label);
 
        for (tval = TV_WEARABLE_BEGIN; tval <= TV_WEARABLE_END; tval++)
@@ -3811,11 +3777,13 @@ static void do_cmd_knowledge_inven(player_type *creature_ptr)
                        j = 0;
                        fprintf(fff, "%s\n", inven_res_label);
                }
+
                strcpy(where, _("装", "E "));
                for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                {
                        do_cmd_knowledge_inven_aux(fff, &creature_ptr->inventory_list[i], &j, tval, where);
                }
+
                strcpy(where, _("持", "I "));
                for (i = 0; i < INVEN_PACK; i++)
                {
@@ -3829,6 +3797,7 @@ static void do_cmd_knowledge_inven(player_type *creature_ptr)
                        do_cmd_knowledge_inven_aux(fff, &st_ptr->stock[i], &j, tval, where);
                }
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -3839,23 +3808,12 @@ static void do_cmd_knowledge_inven(player_type *creature_ptr)
 
 void do_cmd_save_screen_html_aux(char *filename, int message)
 {
-       TERM_LEN y, x;
-       int i;
-
-       TERM_COLOR a = 0, old_a = 0;
-       char c = ' ';
-
-       FILE *fff, *tmpfff;
-       char buf[2048];
-
-       int yomikomu = 0;
        concptr tags[4] = {
                "HEADER_START:",
                "HEADER_END:",
                "FOOTER_START:",
                "FOOTER_END:",
        };
-
        concptr html_head[] = {
                "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
                "<pre>",
@@ -3868,38 +3826,48 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        };
 
        TERM_LEN wid, hgt;
-
        Term_get_size(&wid, &hgt);
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
 
        /* Append to the file */
+       FILE *fff;
        fff = my_fopen(filename, "w");
 
-       if (!fff) {
-               if (message) {
+       if (!fff)
+       {
+               if (message)
+               {
                    msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), filename);
                    msg_print(NULL);
                }
                
                return;
        }
+
        if (message) screen_save();
+       char buf[2048];
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
+       FILE *tmpfff;
        tmpfff = my_fopen(buf, "r");
-       if (!tmpfff) {
-               for (i = 0; html_head[i]; i++)
+       if (!tmpfff)
+       {
+               for (int i = 0; html_head[i]; i++)
                        fputs(html_head[i], fff);
        }
-       else {
-               yomikomu = 0;
-               while (!my_fgets(tmpfff, buf, sizeof(buf))) {
-                       if (!yomikomu) {
+       else
+       {
+               bool is_first_line = TRUE;
+               while (!my_fgets(tmpfff, buf, sizeof(buf)))
+               {
+                       if (is_first_line)
+                       {
                                if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
-                                       yomikomu = 1;
+                                       is_first_line = FALSE;
                        }
-                       else {
+                       else
+                       {
                                if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
                                        break;
                                fprintf(fff, "%s\n", buf);
@@ -3908,16 +3876,16 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        }
 
        /* Dump the screen */
-       for (y = 0; y < hgt; y++)
+       for (TERM_LEN y = 0; y < hgt; y++)
        {
                /* Start the row */
-               if (y != 0)
-                       fprintf(fff, "\n");
+               if (y != 0) fprintf(fff, "\n");
 
                /* Dump each row */
-               for (x = 0; x < wid - 1; x++)
+               TERM_COLOR a = 0, old_a = 0;
+               char c = ' ';
+               for (TERM_LEN x = 0; x < wid - 1; x++)
                {
-                       int rv, gv, bv;
                        concptr cc = NULL;
                        /* Get the attr/char */
                        (void)(Term_what(x, y, &a, &c));
@@ -3934,40 +3902,49 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
                        }
 
                        a = a & 0x0F;
-                       if ((y == 0 && x == 0) || a != old_a) {
-                               rv = angband_color_table[a][1];
-                               gv = angband_color_table[a][2];
-                               bv = angband_color_table[a][3];
+                       if ((y == 0 && x == 0) || a != old_a)
+                       {
+                               int rv = angband_color_table[a][1];
+                               int gv = angband_color_table[a][2];
+                               int bv = angband_color_table[a][3];
                                fprintf(fff, "%s<font color=\"#%02x%02x%02x\">", 
                                        ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
                                old_a = a;
                        }
+
                        if (cc)
                                fprintf(fff, "%s", cc);
                        else
                                fprintf(fff, "%c", c);
                }
        }
+
        fprintf(fff, "</font>");
 
-       if (!tmpfff) {
-               for (i = 0; html_foot[i]; i++)
+       if (!tmpfff)
+       {
+               for (int i = 0; html_foot[i]; i++)
                        fputs(html_foot[i], fff);
        }
-       else {
+       else
+       {
                rewind(tmpfff);
-               yomikomu = 0;
-               while (!my_fgets(tmpfff, buf, sizeof(buf))) {
-                       if (!yomikomu) {
+               bool is_first_line = TRUE;
+               while (!my_fgets(tmpfff, buf, sizeof(buf)))
+               {
+                       if (is_first_line)
+                       {
                                if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
-                                       yomikomu = 1;
+                                       is_first_line = FALSE;
                        }
-                       else {
+                       else
+                       {
                                if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
                                        break;
                                fprintf(fff, "%s\n", buf);
                        }
                }
+
                my_fclose(tmpfff);
        }
 
@@ -3975,10 +3952,12 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        fprintf(fff, "\n");
        my_fclose(fff);
 
-       if (message) {
+       if (message)
+       {
                msg_print(_("画面(記念撮影)をファイルに書き出しました。", "Screen dump saved."));
                msg_print(NULL);
        }
+
        if (message)
                screen_load();
 }
@@ -4007,16 +3986,14 @@ void (*screendump_aux)(void) = NULL;
 
 
 /*
- * Hack -- save a screen dump to a file
+ * Save a screen dump to a file
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-void do_cmd_save_screen(void)
+void do_cmd_save_screen(player_type *creature_ptr)
 {
-       bool old_use_graphics = use_graphics;
-       bool html_dump = FALSE;
-
-       int wid, hgt;
-
        prt(_("記念撮影しますか? [(y)es/(h)tml/(n)o] ", "Save screen dump? [(y)es/(h)tml/(n)o] "), 0, 0);
+       bool html_dump = FALSE;
        while(TRUE)
        {
                char c = inkey();
@@ -4034,20 +4011,22 @@ void do_cmd_save_screen(void)
                }
        }
 
+       int wid, hgt;
        Term_get_size(&wid, &hgt);
 
+       bool old_use_graphics = use_graphics;
        if (old_use_graphics)
        {
                use_graphics = FALSE;
                reset_visuals();
-               p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
+               creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
                handle_stuff();
        }
 
        if (html_dump)
        {
                do_cmd_save_screen_html();
-               do_cmd_redraw(p_ptr);
+               do_cmd_redraw(creature_ptr);
        }
 
        /* Do we use a special screendump function ? */
@@ -4080,7 +4059,6 @@ void do_cmd_save_screen(void)
 
                screen_save();
 
-
                /* Dump the screen */
                for (y = 0; y < hgt; y++)
                {
@@ -4138,46 +4116,41 @@ void do_cmd_save_screen(void)
        {
                use_graphics = TRUE;
                reset_visuals();
-               p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
+               creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
                handle_stuff();
        }
 }
 
 /*
+ * todo okay = 既知のアーティファクト? と思われるが確証がない
+ * 分かりやすい変数名へ変更求む&万が一未知である旨の配列なら負論理なのでゴソッと差し替えるべき
  * Check the status of "artifacts"
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
 static void do_cmd_knowledge_artifacts(player_type *player_ptr)
 {
-       ARTIFACT_IDX i;
-       ARTIFACT_IDX k;
-       POSITION x, y;
-       int n = 0;
-       ARTIFACT_IDX z;
-       u16b why = 3;
-       ARTIFACT_IDX *who;
+       /* Open a new file */
        FILE *fff;
        GAME_TEXT file_name[1024];
-       GAME_TEXT base_name[MAX_NLEN];
-
-       bool *okay;
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
 
        /* Allocate the "who" array */
+       ARTIFACT_IDX *who;
        C_MAKE(who, max_a_idx, ARTIFACT_IDX);
 
        /* Allocate the "okay" array */
+       bool *okay;
        C_MAKE(okay, max_a_idx, bool);
 
        /* Scan the artifacts */
-       for (k = 0; k < max_a_idx; k++)
+       for (ARTIFACT_IDX k = 0; k < max_a_idx; k++)
        {
                artifact_type *a_ptr = &a_info[k];
 
@@ -4195,9 +4168,9 @@ static void do_cmd_knowledge_artifacts(player_type *player_ptr)
        }
 
        /* Check the dungeon */
-       for (y = 0; y < player_ptr->current_floor_ptr->height; y++)
+       for (POSITION y = 0; y < player_ptr->current_floor_ptr->height; y++)
        {
-               for (x = 0; x < player_ptr->current_floor_ptr->width; x++)
+               for (POSITION x = 0; x < player_ptr->current_floor_ptr->width; x++)
                {
                        grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
 
@@ -4223,7 +4196,7 @@ static void do_cmd_knowledge_artifacts(player_type *player_ptr)
        }
 
        /* Check the player_ptr->inventory_list and equipment */
-       for (i = 0; i < INVEN_TOTAL; i++)
+       for (ARTIFACT_IDX i = 0; i < INVEN_TOTAL; i++)
        {
                object_type *o_ptr = &player_ptr->inventory_list[i];
 
@@ -4240,21 +4213,24 @@ static void do_cmd_knowledge_artifacts(player_type *player_ptr)
                okay[o_ptr->name1] = FALSE;
        }
 
-       for (k = 0; k < max_a_idx; k++)
+       int n = 0;
+       for (ARTIFACT_IDX k = 0; k < max_a_idx; k++)
        {
                if (okay[k]) who[n++] = k;
        }
 
+       u16b why = 3;
        ang_sort(who, &why, n, ang_sort_art_comp, ang_sort_art_swap);
 
        /* Scan the artifacts */
-       for (k = 0; k < n; k++)
+       for (ARTIFACT_IDX k = 0; k < n; k++)
        {
                artifact_type *a_ptr = &a_info[who[k]];
+               GAME_TEXT base_name[MAX_NLEN];
                strcpy(base_name, _("未知の伝説のアイテム", "Unknown Artifact"));
 
                /* Obtain the base object type */
-               z = lookup_kind(a_ptr->tval, a_ptr->sval);
+               ARTIFACT_IDX z = lookup_kind(a_ptr->tval, a_ptr->sval);
 
                /* Real object */
                if (z)
@@ -4299,8 +4275,6 @@ static void do_cmd_knowledge_artifacts(player_type *player_ptr)
  */
 static void do_cmd_knowledge_uniques(void)
 {
-       IDX i;
-       int k, n = 0;
        u16b why = 2;
        IDX *who;
 
@@ -4314,7 +4288,7 @@ static void do_cmd_knowledge_uniques(void)
        int n_alive_total = 0;
        int max_lev = -1;
 
-       for (i = 0; i < 10; i++) n_alive[i] = 0;
+       for (IDX i = 0; i < 10; i++) n_alive[i] = 0;
 
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
@@ -4330,7 +4304,8 @@ static void do_cmd_knowledge_uniques(void)
        C_MAKE(who, max_r_idx, MONRACE_IDX);
 
        /* Scan the monsters */
-       for (i = 1; i < max_r_idx; i++)
+       int n = 0;
+       for (IDX i = 1; i < max_r_idx; i++)
        {
                monster_race *r_ptr = &r_info[i];
                int          lev;
@@ -4373,11 +4348,13 @@ static void do_cmd_knowledge_uniques(void)
                fprintf(fff, _("     地上  生存: %3d体\n", "      Surface  alive: %3d\n"), n_alive_surface);
                n_alive_total += n_alive_surface;
        }
-       for (i = 0; i <= max_lev; i++)
+
+       for (IDX i = 0; i <= max_lev; i++)
        {
                fprintf(fff, _("%3d-%3d階  生存: %3d体\n", "Level %3d-%3d  alive: %3d\n"), 1 + i * 10, 10 + i * 10, n_alive[i]);
                n_alive_total += n_alive[i];
        }
+
        if (n_alive_over100)
        {
                fprintf(fff, _("101-   階  生存: %3d体\n", "Level 101-     alive: %3d\n"), n_alive_over100);
@@ -4395,10 +4372,9 @@ static void do_cmd_knowledge_uniques(void)
        }
 
        /* Scan the monster races */
-       for (k = 0; k < n; k++)
+       for (int k = 0; k < n; k++)
        {
                monster_race *r_ptr = &r_info[who[k]];
-
                fprintf(fff, _("     %s (レベル%d)\n", "     %s (level %d)\n"), r_name + r_ptr->name, (int)r_ptr->level);
        }
 
@@ -4417,48 +4393,43 @@ static void do_cmd_knowledge_uniques(void)
  */
 static void do_cmd_knowledge_weapon_exp(player_type *creature_ptr)
 {
-       int i, num;
-       SUB_EXP weapon_exp;
-       KIND_OBJECT_IDX j;
-
+       /* Open a new file */
        FILE *fff;
-
        GAME_TEXT file_name[1024];
-       char tmp[30];
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
 
-       for (i = 0; i < 5; i++)
+       for (int i = 0; i < 5; i++)
        {
-               for (num = 0; num < 64; num++)
+               for (int num = 0; num < 64; num++)
                {
-                       for (j = 0; j < max_k_idx; j++)
+                       SUB_EXP weapon_exp;
+                       char tmp[30];
+                       for (KIND_OBJECT_IDX j = 0; j < max_k_idx; j++)
                        {
                                object_kind *k_ptr = &k_info[j];
 
-                               if ((k_ptr->tval == TV_SWORD - i) && (k_ptr->sval == num))
-                               {
-                                       if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON || k_ptr->sval == SV_HARP)) continue;
-
-                                       weapon_exp = creature_ptr->weapon_exp[4 - i][num];
-                                       strip_name(tmp, j);
-                                       fprintf(fff, "%-25s ", tmp);
-                                       if (weapon_exp >= s_info[creature_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
-                                       else fprintf(fff, " ");
-                                       fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
-                                       if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
-                                       fprintf(fff, "\n");
-                                       break;
-                               }
+                               if ((k_ptr->tval != TV_SWORD - i) || (k_ptr->sval != num)) continue;
+                               if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON || k_ptr->sval == SV_HARP)) continue;
+
+                               weapon_exp = creature_ptr->weapon_exp[4 - i][num];
+                               strip_name(tmp, j);
+                               fprintf(fff, "%-25s ", tmp);
+                               if (weapon_exp >= s_info[creature_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
+                               else fprintf(fff, " ");
+                               fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
+                               if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
+                               fprintf(fff, "\n");
+                               break;
                        }
                }
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -4474,18 +4445,12 @@ static void do_cmd_knowledge_weapon_exp(player_type *creature_ptr)
  */
 static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
 {
-       SPELL_IDX i = 0;
-       SUB_EXP spell_exp;
-       int exp_level;
-
+       /* Open a new file */
        FILE *fff;
-       const magic_type *s_ptr;
-
        GAME_TEXT file_name[1024];
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
@@ -4494,8 +4459,9 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
        if (creature_ptr->realm1 != REALM_NONE)
        {
                fprintf(fff, _("%sの魔法書\n", "%s Spellbook\n"), realm_names[creature_ptr->realm1]);
-               for (i = 0; i < 32; i++)
+               for (SPELL_IDX i = 0; i < 32; i++)
                {
+                       const magic_type *s_ptr;
                        if (!is_magic(creature_ptr->realm1))
                        {
                                s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][i];
@@ -4504,10 +4470,11 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
                        {
                                s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][i];
                        }
+
                        if (s_ptr->slevel >= 99) continue;
-                       spell_exp = creature_ptr->spell_exp[i];
-                       exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", exe_spell(p_ptr, creature_ptr->realm1, i, SPELL_NAME));
+                       SUB_EXP spell_exp = creature_ptr->spell_exp[i];
+                       int exp_level = spell_exp_level(spell_exp);
+                       fprintf(fff, "%-25s ", exe_spell(creature_ptr, creature_ptr->realm1, i, SPELL_NAME));
                        if (creature_ptr->realm1 == REALM_HISSATSU)
                                fprintf(fff, "[--]");
                        else
@@ -4516,6 +4483,7 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
                                else fprintf(fff, " ");
                                fprintf(fff, "%s", exp_level_str[exp_level]);
                        }
+
                        if (cheat_xtra) fprintf(fff, " %d", spell_exp);
                        fprintf(fff, "\n");
                }
@@ -4524,8 +4492,9 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
        if (creature_ptr->realm2 != REALM_NONE)
        {
                fprintf(fff, _("%sの魔法書\n", "\n%s Spellbook\n"), realm_names[creature_ptr->realm2]);
-               for (i = 0; i < 32; i++)
+               for (SPELL_IDX i = 0; i < 32; i++)
                {
+                       const magic_type *s_ptr;
                        if (!is_magic(creature_ptr->realm1))
                        {
                                s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][i];
@@ -4534,11 +4503,12 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
                        {
                                s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][i];
                        }
+
                        if (s_ptr->slevel >= 99) continue;
 
-                       spell_exp = creature_ptr->spell_exp[i + 32];
-                       exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", exe_spell(p_ptr, creature_ptr->realm2, i, SPELL_NAME));
+                       SUB_EXP spell_exp = creature_ptr->spell_exp[i + 32];
+                       int exp_level = spell_exp_level(spell_exp);
+                       fprintf(fff, "%-25s ", exe_spell(creature_ptr, creature_ptr->realm2, i, SPELL_NAME));
                        if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
                        else fprintf(fff, " ");
                        fprintf(fff, "%s", exp_level_str[exp_level]);
@@ -4546,6 +4516,7 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
                        fprintf(fff, "\n");
                }
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -4561,11 +4532,6 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
  */
 static void do_cmd_knowledge_skill_exp(player_type *creature_ptr)
 {
-       int i = 0, skill_exp;
-
-       FILE *fff;
-
-       char file_name[1024];
        char skill_name[GINOU_TEMPMAX][20] =
        {
                _("マーシャルアーツ", "Martial Arts    "),
@@ -4575,16 +4541,19 @@ static void do_cmd_knowledge_skill_exp(player_type *creature_ptr)
        };
 
        /* Open a new file */
+       FILE *fff;
+       char file_name[1024];
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
 
-       for (i = 0; i < GINOU_TEMPMAX; i++)
+       for (int i = 0; i < GINOU_TEMPMAX; i++)
        {
-               skill_exp = creature_ptr->skill_exp[i];
+               int skill_exp = creature_ptr->skill_exp[i];
                fprintf(fff, "%-20s ", skill_name[i]);
                if (skill_exp >= s_info[creature_ptr->pclass].s_max[i]) fprintf(fff, "!");
                else fprintf(fff, " ");
@@ -4592,6 +4561,7 @@ static void do_cmd_knowledge_skill_exp(player_type *creature_ptr)
                if (cheat_xtra) fprintf(fff, " %d", skill_exp);
                fprintf(fff, "\n");
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -4603,45 +4573,42 @@ static void do_cmd_knowledge_skill_exp(player_type *creature_ptr)
 /*!
  * @brief 現在のペットを表示するコマンドのメインルーチン /
  * Display current pets
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
-static void do_cmd_knowledge_pets(void)
+static void do_cmd_knowledge_pets(player_type *creature_ptr)
 {
-       int             i;
-       FILE            *fff;
-       monster_type    *m_ptr;
-       GAME_TEXT pet_name[MAX_NLEN];
-       int             t_friends = 0;
-       int             show_upkeep = 0;
-       GAME_TEXT file_name[1024];
-
-
        /* Open a new file */
+       GAME_TEXT file_name[1024];
+       FILE *fff;
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
 
        /* Process the monsters (backwards) */
-       for (i = p_ptr->current_floor_ptr->m_max - 1; i >= 1; i--)
+       monster_type *m_ptr;
+       GAME_TEXT pet_name[MAX_NLEN];
+       int t_friends = 0;
+       for (int i = creature_ptr->current_floor_ptr->m_max - 1; i >= 1; i--)
        {
-               m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+               m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
 
                /* Ignore "dead" monsters */
                if (!monster_is_valid(m_ptr)) continue;
 
                /* Calculate "upkeep" for pets */
-               if (is_pet(m_ptr))
-               {
-                       t_friends++;
-                       monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
-                       fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
-               }
+               if (!is_pet(m_ptr)) continue;
+
+               t_friends++;
+               monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+               fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
        }
 
-       show_upkeep = calculate_upkeep(p_ptr);
+       int show_upkeep = calculate_upkeep(creature_ptr);
 
        fprintf(fff, "----------------------------------------------\n");
 #ifdef JP
@@ -4651,7 +4618,6 @@ static void do_cmd_knowledge_pets(void)
 #endif
        fprintf(fff, _(" 維持コスト: %d%% MP\n", "   Upkeep: %d%% mana.\n"), show_upkeep);
 
-
        my_fclose(fff);
 
        /* Display the file contents */
@@ -4668,33 +4634,25 @@ static void do_cmd_knowledge_pets(void)
  */
 static void do_cmd_knowledge_kill_count(void)
 {
-       MONRACE_IDX i;
-       int k, n = 0;
-       u16b why = 2;
-       MONRACE_IDX *who;
+       /* Open a new file */
        FILE *fff;
        GAME_TEXT file_name[1024];
-
-       s32b Total = 0;
-
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-
-       if (!fff) {
+if (!fff)
+       {
                msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
                msg_print(NULL);
                return;
        }
 
        /* Allocate the "who" array */
+       MONRACE_IDX *who;
        C_MAKE(who, max_r_idx, MONRACE_IDX);
 
+       s32b total = 0;
        {
                /* Monsters slain */
-               int kk;
-
-               for (kk = 1; kk < max_r_idx; kk++)
+               for (int kk = 1; kk < max_r_idx; kk++)
                {
                        monster_race *r_ptr = &r_info[kk];
 
@@ -4704,34 +4662,35 @@ static void do_cmd_knowledge_kill_count(void)
 
                                if (dead)
                                {
-                                       Total++;
+                                       total++;
                                }
                        }
                        else
                        {
-                               MONSTER_NUMBER This = r_ptr->r_pkills;
+                               MONSTER_NUMBER this_monster = r_ptr->r_pkills;
 
-                               if (This > 0)
+                               if (this_monster > 0)
                                {
-                                       Total += This;
+                                       total += this_monster;
                                }
                        }
                }
 
-               if (Total < 1)
+               if (total < 1)
                        fprintf(fff,_("あなたはまだ敵を倒していない。\n\n", "You have defeated no enemies yet.\n\n"));
                else
 #ifdef JP
-                       fprintf(fff,"あなたは%ld体の敵を倒している。\n\n", (long int)Total);
+                       fprintf(fff,"あなたは%ld体の敵を倒している。\n\n", (long int)total);
 #else
-                       fprintf(fff,"You have defeated %ld %s.\n\n", (long int)Total, (Total == 1) ? "enemy" : "enemies");
+                       fprintf(fff,"You have defeated %ld %s.\n\n", (long int)total, (total == 1) ? "enemy" : "enemies");
 #endif
        }
 
-       Total = 0;
+       total = 0;
 
        /* Scan the monsters */
-       for (i = 1; i < max_r_idx; i++)
+       int n = 0;
+       for (MONRACE_IDX i = 1; i < max_r_idx; i++)
        {
                monster_race *r_ptr = &r_info[i];
 
@@ -4740,10 +4699,11 @@ static void do_cmd_knowledge_kill_count(void)
        }
 
        /* Sort the array by dungeon depth of monsters */
+       u16b why = 2;
        ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
 
        /* Scan the monster races */
-       for (k = 0; k < n; k++)
+       for (int k = 0; k < n; k++)
        {
                monster_race *r_ptr = &r_info[who[k]];
 
@@ -4754,56 +4714,52 @@ static void do_cmd_knowledge_kill_count(void)
                        if (dead)
                        {
                                fprintf(fff, "     %s\n", (r_name + r_ptr->name));
-                               Total++;
+                               total++;
                        }
+
+                       continue;
                }
-               else
-               {
-                       MONSTER_NUMBER This = r_ptr->r_pkills;
 
-                       if (This > 0)
-                       {
-#ifdef JP
-                               /* p,tは人と数える by ita */
-                               if (my_strchr("pt", r_ptr->d_char))
-                                       fprintf(fff, "     %3d 人の %s\n", (int)This, r_name + r_ptr->name);
-                               else
-                                       fprintf(fff, "     %3d 体の %s\n", (int)This, r_name + r_ptr->name);
-#else
-                               if (This < 2)
-                               {
-                                       if (my_strstr(r_name + r_ptr->name, "coins"))
-                                       {
-                                               fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
-                                       }
-                                       else
-                                       {
-                                               fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
-                                       }
-                               }
-                               else
-                               {
-                                       char ToPlural[80];
-                                       strcpy(ToPlural, (r_name + r_ptr->name));
-                                       plural_aux(ToPlural);
-                                       fprintf(fff, "     %d %s\n", This, ToPlural);
-                               }
-#endif
+               MONSTER_NUMBER this_monster = r_ptr->r_pkills;
 
+               if (this_monster <= 0) continue;
 
-                               Total += This;
+#ifdef JP
+               /* p,tは人と数える by ita */
+               if (my_strchr("pt", r_ptr->d_char))
+                       fprintf(fff, "     %3d 人の %s\n", (int)this_monster, r_name + r_ptr->name);
+               else
+                       fprintf(fff, "     %3d 体の %s\n", (int)this_monster, r_name + r_ptr->name);
+#else
+               if (this_monster < 2)
+               {
+                       if (my_strstr(r_name + r_ptr->name, "coins"))
+                       {
+                               fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
                        }
+                       else
+                       {
+                               fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
+                       }
+               }
+               else
+               {
+                       char ToPlural[80];
+                       strcpy(ToPlural, (r_name + r_ptr->name));
+                       plural_aux(ToPlural);
+                       fprintf(fff, "     %d %s\n", this_monster, ToPlural);
                }
+#endif
+               total += this_monster;
        }
 
        fprintf(fff,"----------------------------------------------\n");
 #ifdef JP
-       fprintf(fff,"    合計: %lu 体を倒した。\n", (unsigned long int)Total);
+       fprintf(fff,"    合計: %lu 体を倒した。\n", (unsigned long int)total);
 #else
-       fprintf(fff,"   Total: %lu creature%s killed.\n", (unsigned long int)Total, (Total == 1 ? "" : "s"));
+       fprintf(fff,"   Total: %lu creature%s killed.\n", (unsigned long int)total, (total == 1 ? "" : "s"));
 #endif
 
-
        /* Free the "who" array */
        C_KILL(who, max_r_idx, s16b);
        my_fclose(fff);
@@ -4829,10 +4785,8 @@ static void do_cmd_knowledge_kill_count(void)
  */
 static void display_group_list(int col, int row, int wid, int per_page, IDX grp_idx[], concptr group_text[], int grp_cur, int grp_top)
 {
-       int i;
-
        /* Display lines until done */
-       for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
+       for (int i = 0; i < per_page && (grp_idx[i] >= 0); i++)
        {
                /* Get the group index */
                int grp = grp_idx[grp_top + i];
@@ -4965,10 +4919,8 @@ static void browser_cursor(char ch, int *column, IDX *grp_cur, int grp_cnt,
  */
 static void display_visual_list(int col, int row, int height, int width, TERM_COLOR attr_top, byte char_left)
 {
-       int i, j;
-
        /* Clear the display lines */
-       for (i = 0; i < height; i++)
+       for (int i = 0; i < height; i++)
        {
                Term_erase(col, row + i, width);
        }
@@ -4977,29 +4929,27 @@ static void display_visual_list(int col, int row, int height, int width, TERM_CO
        if (use_bigtile) width /= 2;
 
        /* Display lines until done */
-       for (i = 0; i < height; i++)
+       for (int i = 0; i < height; i++)
        {
                /* Display columns until done */
-               for (j = 0; j < width; j++)
+               for (int j = 0; j < width; j++)
                {
-                       TERM_COLOR a, ia;
-                       SYMBOL_CODE c, ic;
                        TERM_LEN x = col + j;
                        TERM_LEN y = row + i;
 
                        /* Bigtile mode uses double width */
                        if (use_bigtile) x += j;
 
-                       ia = attr_top + i;
-                       ic = char_left + j;
+                       TERM_COLOR ia = attr_top + i;
+                       SYMBOL_CODE ic = char_left + j;
 
                        /* Ignore illegal characters */
                        if (ia > 0x7f || ic > 0xff || ic < ' ' ||
                            (!use_graphics && ic > 0x7f))
                                continue;
 
-                       a = ia;
-                       c = ic;
+                       TERM_COLOR a = ia;
+                       SYMBOL_CODE c = ic;
 
                        /* Force correct code for both ASCII character and tile */
                        if (c & 0x80) a |= 0x80;
@@ -5031,16 +4981,6 @@ static void place_visual_list_cursor(TERM_LEN col, TERM_LEN row, TERM_COLOR a, b
 
 
 /*
- *  Clipboard variables for copy&paste in visual mode
- */
-static TERM_COLOR attr_idx = 0;
-static SYMBOL_CODE char_idx = 0;
-
-/* Hack -- for feature lighting */
-static TERM_COLOR attr_idx_feat[F_LIT_MAX];
-static SYMBOL_CODE char_idx_feat[F_LIT_MAX];
-
-/*
  *  Do visual mode command -- Change symbols
  */
 static bool visual_mode_command(char ch, bool *visual_list_ptr,
@@ -5180,9 +5120,8 @@ static bool visual_mode_command(char ch, bool *visual_list_ptr,
 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
        int mon_cur, int mon_top, bool visual_only)
 {
-       int i;
-
        /* Display lines until done */
+       int i;
        for (i = 0; i < per_page && (mon_idx[mon_top + i] >= 0); i++)
        {
                TERM_COLOR attr;
@@ -5204,6 +5143,7 @@ static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
                {
                        c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (current_world_ptr->wizard || visual_only) ? 56 : 61);
                }
+
                if (current_world_ptr->wizard || visual_only)
                {
                        c_prt(attr, format("%d", r_idx), row + i, 62);
@@ -5235,47 +5175,39 @@ static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
 
 
 /*
+ * todo 引数の詳細について加筆求む
  * Display known monsters.
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param need_redraw 画面の再描画が必要な時TRUE
+ * @param visual_only ???
+ * @param direct_r_idx モンスターID
+ * @return なし
  */
-static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX direct_r_idx)
+static void do_cmd_knowledge_monsters(player_type *creature_ptr, bool *need_redraw, bool visual_only, IDX direct_r_idx)
 {
-       IDX i;
-       int len, max;
-       IDX grp_cur, grp_top, old_grp_cur;
-       IDX mon_cur, mon_top;
-       IDX grp_cnt, grp_idx[100];
-       IDX mon_cnt;
-       IDX *mon_idx;
-
-       int column = 0;
-       bool flag;
-       bool redraw;
-
-       bool visual_list = FALSE;
-       TERM_COLOR attr_top = 0;
-       byte char_left = 0;
-
-       int browser_rows;
        TERM_LEN wid, hgt;
-
-       BIT_FLAGS8 mode;
-
        Term_get_size(&wid, &hgt);
 
-       browser_rows = hgt - 8;
-
        /* Allocate the "mon_idx" array */
+       IDX *mon_idx;
        C_MAKE(mon_idx, max_r_idx, MONRACE_IDX);
 
-       max = 0;
-       grp_cnt = 0;
-
+       int max = 0;
+       IDX grp_cnt = 0;
+       IDX grp_idx[100];
+       IDX mon_cnt;
+       bool visual_list = FALSE;
+       TERM_COLOR attr_top = 0;
+       byte char_left = 0;
+       BIT_FLAGS8 mode;
+       int browser_rows = hgt - 8;
        if (direct_r_idx < 0)
        {
                mode = visual_only ? 0x03 : 0x01;
 
                /* Check every group */
-               for (i = 0; monster_group_text[i] != NULL; i++)
+               int len;
+               for (IDX i = 0; monster_group_text[i] != NULL; i++)
                {
                        /* Measure the label */
                        len = strlen(monster_group_text[i]);
@@ -5284,7 +5216,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                        if (len > max) max = len;
 
                        /* See if any monsters are known */
-                       if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, mode))
+                       if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(creature_ptr, i, mon_idx, mode))
                        {
                                /* Build a list of groups with known monsters */
                                grp_idx[grp_cnt++] = i;
@@ -5308,20 +5240,17 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
        /* Terminate the list */
        grp_idx[grp_cnt] = -1;
 
-       old_grp_cur = -1;
-       grp_cur = grp_top = 0;
-       mon_cur = mon_top = 0;
-
-       flag = FALSE;
-       redraw = TRUE;
-
        mode = visual_only ? 0x02 : 0x00;
-
+       IDX old_grp_cur = -1;
+       IDX grp_cur = 0;
+       IDX grp_top = 0;
+       IDX mon_cur = 0;
+       IDX mon_top = 0;
+       int column = 0;
+       bool flag = FALSE;
+       bool redraw = TRUE;
        while (!flag)
        {
-               char ch;
-               monster_race *r_ptr;
-
                if (redraw)
                {
                        clear_from(0);
@@ -5332,14 +5261,14 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                        prt(_("文字", "Sym"), 4, 67);
                        if (!visual_only) prt(_("殺害数", "Kills"), 4, 72);
 
-                       for (i = 0; i < 78; i++)
+                       for (IDX i = 0; i < 78; i++)
                        {
                                Term_putch(i, 5, TERM_WHITE, '=');
                        }
 
                        if (direct_r_idx < 0)
                        {
-                               for (i = 0; i < browser_rows; i++)
+                               for (IDX i = 0; i < browser_rows; i++)
                                {
                                        Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
                                }
@@ -5362,7 +5291,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                                old_grp_cur = grp_cur;
 
                                /* Get a list of monsters in the current group */
-                               mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, mode);
+                               mon_cnt = collect_monsters(creature_ptr, grp_idx[grp_cur], mon_idx, mode);
                        }
 
                        /* Scroll monster list */
@@ -5396,6 +5325,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                        hgt - 1, 0);
 
                /* Get the current monster */
+               monster_race *r_ptr;
                r_ptr = &r_info[mon_idx[mon_cur]];
 
                if (!visual_only)
@@ -5418,7 +5348,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                        Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
                }
 
-               ch = inkey();
+               char ch = inkey();
 
                /* Do visual mode command if needed */
                if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &r_ptr->x_attr, &r_ptr->x_char, need_redraw))
@@ -5434,6 +5364,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
                                        break;
                                }
                        }
+
                        continue;
                }
 
@@ -5457,6 +5388,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
 
                                        redraw = TRUE;
                                }
+
                                break;
                        }
 
@@ -5481,9 +5413,8 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d
 static void display_object_list(int col, int row, int per_page, IDX object_idx[],
        int object_cur, int object_top, bool visual_only)
 {
-       int i;
-
        /* Display lines until done */
+       int i;
        for (i = 0; i < per_page && (object_idx[object_top + i] >= 0); i++)
        {
                GAME_TEXT o_name[MAX_NLEN];
@@ -5501,7 +5432,6 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[]
                TERM_COLOR attr = ((k_ptr->aware || visual_only) ? TERM_WHITE : TERM_SLATE);
                byte cursor = ((k_ptr->aware || visual_only) ? TERM_L_BLUE : TERM_BLUE);
 
-
                if (!visual_only && k_ptr->flavor)
                {
                        /* Appearance of this object is shuffled */
@@ -5513,8 +5443,6 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[]
                        flavor_k_ptr = k_ptr;
                }
 
-
-
                attr = ((i + object_top == object_cur) ? cursor : attr);
 
                if (!k_ptr->flavor || (!visual_only && k_ptr->aware))
@@ -5536,6 +5464,7 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[]
                {
                        c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (current_world_ptr->wizard || visual_only) ? 64 : 68);
                }
+
                if (current_world_ptr->wizard || visual_only)
                {
                        c_prt(attr, format("%d", k_idx), row + i, 70);
@@ -5555,6 +5484,7 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[]
        }
 }
 
+
 /*
  * Describe fake object
  */
@@ -5568,21 +5498,13 @@ static void desc_obj_fake(KIND_OBJECT_IDX k_idx)
 
        /* It's fully know */
        o_ptr->ident |= IDENT_KNOWN;
-
-       /* Track the object */
-       /* object_actual_track(o_ptr); */
-
-       /* Hack - mark as fake */
-       /* term_obj_real = FALSE; */
        handle_stuff();
 
-       if (!screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL))
-       {
-               msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
-               msg_print(NULL);
-       }
-}
+       if (screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL)) return;
 
+       msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
+       msg_print(NULL);
+}
 
 
 /*
@@ -5590,44 +5512,33 @@ static void desc_obj_fake(KIND_OBJECT_IDX k_idx)
  */
 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX direct_k_idx)
 {
-       IDX i;
-       int len, max;
-       IDX grp_cur, grp_top, old_grp_cur;
-       IDX object_old, object_cur, object_top;
-       int grp_cnt;
+       IDX object_old, object_top;
        IDX grp_idx[100];
        int object_cnt;
        OBJECT_IDX *object_idx;
 
-       int column = 0;
-       bool flag;
-       bool redraw;
-
        bool visual_list = FALSE;
        TERM_COLOR attr_top = 0;
        byte char_left = 0;
-
-       int browser_rows;
-       TERM_LEN wid, hgt;
-
        byte mode;
 
+       TERM_LEN wid, hgt;
        Term_get_size(&wid, &hgt);
 
-       browser_rows = hgt - 8;
+       int browser_rows = hgt - 8;
 
        /* Allocate the "object_idx" array */
        C_MAKE(object_idx, max_k_idx, KIND_OBJECT_IDX);
 
-       max = 0;
-       grp_cnt = 0;
-
+       int len;
+       int max = 0;
+       int grp_cnt = 0;
        if (direct_k_idx < 0)
        {
                mode = visual_only ? 0x03 : 0x01;
 
                /* Check every group */
-               for (i = 0; object_group_text[i] != NULL; i++)
+               for (IDX i = 0; object_group_text[i] != NULL; i++)
                {
                        /* Measure the label */
                        len = strlen(object_group_text[i]);
@@ -5676,18 +5587,16 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di
        /* Terminate the list */
        grp_idx[grp_cnt] = -1;
 
-       old_grp_cur = -1;
-       grp_cur = grp_top = 0;
-       object_cur = object_top = 0;
-
-       flag = FALSE;
-       redraw = TRUE;
-
        mode = visual_only ? 0x02 : 0x00;
-
+       IDX old_grp_cur = -1;
+       IDX grp_cur = 0;
+       IDX grp_top = 0;
+       IDX object_cur = object_top = 0;
+       bool flag = FALSE;
+       bool redraw = TRUE;
+       int column = 0;
        while (!flag)
        {
-               char ch;
                object_kind *k_ptr, *flavor_k_ptr;
 
                if (redraw)
@@ -5708,14 +5617,14 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di
                        prt("Sym", 4, 75);
 #endif
 
-                       for (i = 0; i < 78; i++)
+                       for (IDX i = 0; i < 78; i++)
                        {
                                Term_putch(i, 5, TERM_WHITE, '=');
                        }
 
                        if (direct_k_idx < 0)
                        {
-                               for (i = 0; i < browser_rows; i++)
+                               for (IDX i = 0; i < browser_rows; i++)
                                {
                                        Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
                                }
@@ -5821,7 +5730,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di
                        Term_gotoxy(max + 3, 6 + (object_cur - object_top));
                }
 
-               ch = inkey();
+               char ch = inkey();
 
                /* Do visual mode command if needed */
                if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw))
@@ -5880,7 +5789,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di
 static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_idx,
        FEAT_IDX feat_cur, FEAT_IDX feat_top, bool visual_only, int lighting_level)
 {
-       int lit_col[F_LIT_MAX], i, j;
+       int lit_col[F_LIT_MAX], i;
        int f_idx_col = use_bigtile ? 62 : 64;
 
        /* Correct columns 1 and 4 */
@@ -5919,14 +5828,14 @@ static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_
                Term_queue_bigchar(lit_col[F_LIT_STANDARD], row_i, f_ptr->x_attr[F_LIT_STANDARD], f_ptr->x_char[F_LIT_STANDARD], 0, 0);
 
                Term_putch(lit_col[F_LIT_NS_BEGIN], row_i, TERM_SLATE, '(');
-               for (j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
+               for (int j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
                {
                        Term_putch(lit_col[j], row_i, TERM_SLATE, '/');
                }
                Term_putch(lit_col[F_LIT_MAX - 1] + (use_bigtile ? 3 : 2), row_i, TERM_SLATE, ')');
 
                /* Mega-hack -- Use non-standard colour */
-               for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
+               for (int j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
                {
                        Term_queue_bigchar(lit_col[j] + 1, row_i, f_ptr->x_attr[j], f_ptr->x_char[j], 0, 0);
                }
@@ -5945,48 +5854,31 @@ static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_
  */
 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX direct_f_idx, IDX *lighting_level)
 {
-       FEAT_IDX i;
-       int len, max;
-       FEAT_IDX grp_cur, grp_top, old_grp_cur;
-       FEAT_IDX feat_cur, feat_top;
-       int grp_cnt;
-       FEAT_IDX grp_idx[100];
-       int feat_cnt;
-       FEAT_IDX *feat_idx;
-
-       TERM_LEN column = 0;
-       bool flag;
-       bool redraw;
-
-       bool visual_list = FALSE;
-       TERM_COLOR attr_top = 0;
-       byte char_left = 0;
-
-       TERM_LEN browser_rows;
-       TERM_LEN wid, hgt;
-
        TERM_COLOR attr_old[F_LIT_MAX];
-       SYMBOL_CODE char_old[F_LIT_MAX];
-       TERM_COLOR *cur_attr_ptr;
-       SYMBOL_CODE *cur_char_ptr;
-
        (void)C_WIPE(attr_old, F_LIT_MAX, TERM_COLOR);
+       SYMBOL_CODE char_old[F_LIT_MAX];
        (void)C_WIPE(char_old, F_LIT_MAX, SYMBOL_CODE);
 
+       TERM_LEN wid, hgt;
        Term_get_size(&wid, &hgt);
 
-       browser_rows = hgt - 8;
-
        /* Allocate the "feat_idx" array */
+       FEAT_IDX *feat_idx;
        C_MAKE(feat_idx, max_f_idx, FEAT_IDX);
 
-       max = 0;
-       grp_cnt = 0;
-
+       int len;
+       int max = 0;
+       int grp_cnt = 0;
+       int feat_cnt;
+       FEAT_IDX grp_idx[100];
+       TERM_COLOR attr_top = 0;
+       bool visual_list = FALSE;
+       byte char_left = 0;
+       TERM_LEN browser_rows = hgt - 8;
        if (direct_f_idx < 0)
        {
                /* Check every group */
-               for (i = 0; feature_group_text[i] != NULL; i++)
+               for (FEAT_IDX i = 0; feature_group_text[i] != NULL; i++)
                {
                        /* Measure the label */
                        len = strlen(feature_group_text[i]);
@@ -5995,7 +5887,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                        if (len > max) max = len;
 
                        /* See if any features are known */
-                       if (collect_features(i, feat_idx, 0x01))
+                       if (collect_features(feat_idx, 0x01))
                        {
                                /* Build a list of groups with known features */
                                grp_idx[grp_cnt++] = i;
@@ -6017,7 +5909,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
                        &attr_top, &char_left, &f_ptr->x_attr[*lighting_level], &f_ptr->x_char[*lighting_level], need_redraw);
 
-               for (i = 0; i < F_LIT_MAX; i++)
+               for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
                {
                        attr_old[i] = f_ptr->x_attr[i];
                        char_old[i] = f_ptr->x_char[i];
@@ -6027,13 +5919,16 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
        /* Terminate the list */
        grp_idx[grp_cnt] = -1;
 
-       old_grp_cur = -1;
-       grp_cur = grp_top = 0;
-       feat_cur = feat_top = 0;
-
-       flag = FALSE;
-       redraw = TRUE;
-
+       FEAT_IDX old_grp_cur = -1;
+       FEAT_IDX grp_cur = 0;
+       FEAT_IDX grp_top = 0;
+       FEAT_IDX feat_cur = 0;
+       FEAT_IDX feat_top = 0;
+       TERM_LEN column = 0;
+       bool flag = FALSE;
+       bool redraw = TRUE;
+       TERM_COLOR *cur_attr_ptr;
+       SYMBOL_CODE *cur_char_ptr;
        while (!flag)
        {
                char ch;
@@ -6057,14 +5952,14 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                                prt(_("文字 (l/d)", "Sym (l/d)"), 4, 68);
                        }
 
-                       for (i = 0; i < 78; i++)
+                       for (FEAT_IDX i = 0; i < 78; i++)
                        {
                                Term_putch(i, 5, TERM_WHITE, '=');
                        }
 
                        if (direct_f_idx < 0)
                        {
-                               for (i = 0; i < browser_rows; i++)
+                               for (FEAT_IDX i = 0; i < browser_rows; i++)
                                {
                                        Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
                                }
@@ -6087,7 +5982,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                                old_grp_cur = grp_cur;
 
                                /* Get a list of features in the current group */
-                               feat_cnt = collect_features(grp_idx[grp_cur], feat_idx, 0x00);
+                               feat_cnt = collect_features(feat_idx, 0x00);
                        }
 
                        /* Scroll feature list */
@@ -6190,7 +6085,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                        {
                        /* Restore previous visual settings */
                        case ESCAPE:
-                               for (i = 0; i < F_LIT_MAX; i++)
+                               for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
                                {
                                        f_ptr->x_attr[i] = attr_old[i];
                                        f_ptr->x_char[i] = char_old[i];
@@ -6207,7 +6102,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                        /* Preserve current visual settings */
                        case 'V':
                        case 'v':
-                               for (i = 0; i < F_LIT_MAX; i++)
+                               for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
                                {
                                        attr_old[i] = f_ptr->x_attr[i];
                                        char_old[i] = f_ptr->x_char[i];
@@ -6219,7 +6114,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                        case 'c':
                                if (!visual_list)
                                {
-                                       for (i = 0; i < F_LIT_MAX; i++)
+                                       for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
                                        {
                                                attr_idx_feat[i] = f_ptr->x_attr[i];
                                                char_idx_feat[i] = f_ptr->x_char[i];
@@ -6232,7 +6127,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
                                if (!visual_list)
                                {
                                        /* Allow TERM_DARK text */
-                                       for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
+                                       for (FEAT_IDX i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
                                        {
                                                if (attr_idx_feat[i] || (!(char_idx_feat[i] & 0x80) && char_idx_feat[i])) f_ptr->x_attr[i] = attr_idx_feat[i];
                                                if (char_idx_feat[i]) f_ptr->x_char[i] = char_idx_feat[i];
@@ -6267,49 +6162,44 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
 
 /*
  * List wanted monsters
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-static void do_cmd_knowledge_kubi(void)
+static void do_cmd_knowledge_bounty(player_type *creature_ptr)
 {
-       int i;
+       /* Open a new file */
        FILE *fff;
-       
        GAME_TEXT file_name[1024];
-       
-       
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
        
-       if (fff)
-       {
-               bool listed = FALSE;
-
-               fprintf(fff, _("今日のターゲット : %s\n", "Today target : %s\n"),
-                       (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : _("不明", "unknown")));
-               fprintf(fff, "\n");
-               fprintf(fff, _("賞金首リスト\n", "List of wanted monsters\n"));
-               fprintf(fff, "----------------------------------------------\n");
+       fprintf(fff, _("今日のターゲット : %s\n", "Today target : %s\n"),
+               (creature_ptr->today_mon ? r_name + r_info[creature_ptr->today_mon].name : _("不明", "unknown")));
+       fprintf(fff, "\n");
+       fprintf(fff, _("賞金首リスト\n", "List of wanted monsters\n"));
+       fprintf(fff, "----------------------------------------------\n");
 
-               for (i = 0; i < MAX_KUBI; i++)
+       bool listed = FALSE;
+       for (int i = 0; i < MAX_BOUNTY; i++)
+       {
+               if (current_world_ptr->bounty_r_idx[i] <= 10000)
                {
-                       if (current_world_ptr->bounty_r_idx[i] <= 10000)
-                       {
-                               fprintf(fff,"%s\n", r_name + r_info[current_world_ptr->bounty_r_idx[i]].name);
-
-                               listed = TRUE;
-                       }
+                       fprintf(fff, "%s\n", r_name + r_info[current_world_ptr->bounty_r_idx[i]].name);
+                       listed = TRUE;
                }
+       }
 
-               if (!listed)
-               {
-                       fprintf(fff,"\n%s\n", _("賞金首はもう残っていません。", "There is no more wanted monster."));
-               }
+       if (!listed)
+       {
+               fprintf(fff, "\n%s\n", _("賞金首はもう残っていません。", "There is no more wanted monster."));
        }
-               my_fclose(fff);
+       
+       my_fclose(fff);
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("賞金首の一覧", "Wanted monsters"), 0, 0);
@@ -6321,23 +6211,20 @@ static void do_cmd_knowledge_kubi(void)
  */
 static void do_cmd_knowledge_virtues(player_type *creature_ptr)
 {
-       FILE *fff;      
-       GAME_TEXT file_name[1024];
-               
        /* Open a new file */
+       FILE *fff;
+       GAME_TEXT file_name[1024];
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
        
-       if (fff)
-       {
-               fprintf(fff, _("現在の属性 : %s\n\n", "Your alighnment : %s\n\n"), your_alignment(creature_ptr));
-               dump_virtues(creature_ptr, fff);
-       }
-               my_fclose(fff);
+       fprintf(fff, _("現在の属性 : %s\n\n", "Your alighnment : %s\n\n"), your_alignment(creature_ptr));
+       dump_virtues(creature_ptr, fff);
+       my_fclose(fff);
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("八つの徳", "Virtues"), 0, 0);
@@ -6349,78 +6236,70 @@ static void do_cmd_knowledge_virtues(player_type *creature_ptr)
  */
 static void do_cmd_knowledge_dungeon(void)
 {
+       /* Open a new file */
        FILE *fff;
-       
        GAME_TEXT file_name[1024];
-       int i;
-               
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
        
-       if (fff)
+       for (int i = 1; i < current_world_ptr->max_d_idx; i++)
        {
-               for (i = 1; i < current_world_ptr->max_d_idx; i++)
-               {
-                       bool seiha = FALSE;
+               bool seiha = FALSE;
 
-                       if (!d_info[i].maxdepth) continue;
-                       if (!max_dlv[i]) continue;
-                       if (d_info[i].final_guardian)
-                       {
-                               if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
-                       }
-                       else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
-                       
-                       fprintf(fff, _("%c%-12s :  %3d 階\n", "%c%-16s :  level %3d\n"), seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
+               if (!d_info[i].maxdepth) continue;
+               if (!max_dlv[i]) continue;
+               if (d_info[i].final_guardian)
+               {
+                       if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
                }
+               else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
+
+               fprintf(fff, _("%c%-12s :  %3d 階\n", "%c%-16s :  level %3d\n"), seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
        }
-               my_fclose(fff);
+
+       my_fclose(fff);
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("今までに入ったダンジョン", "Dungeon"), 0, 0);
        fd_kill(file_name);
 }
 
+
 /*
 * List virtues & status
 *
 */
 static void do_cmd_knowledge_stat(player_type *creature_ptr)
 {
+       /* Open a new file */
        FILE *fff;
-       
        GAME_TEXT file_name[1024];
-       int percent, v_nr;
-       
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
            msg_print(NULL);
            return;
        }
        
-       if (fff)
-       {
-               percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
-                       (2 * creature_ptr->hitdie +
-                       ((PY_MAX_LEVEL - 1+3) * (creature_ptr->hitdie + 1))));
+       int percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
+               (2 * creature_ptr->hitdie +
+               ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
 
-               if (creature_ptr->knowledge & KNOW_HPRATE)
-                       fprintf(fff, _("現在の体力ランク : %d/100\n\n", "Your current Life Rating is %d/100.\n\n"), percent);
-               else fprintf(fff, _("現在の体力ランク : ???\n\n", "Your current Life Rating is ???.\n\n"));
+       if (creature_ptr->knowledge & KNOW_HPRATE)
+               fprintf(fff, _("現在の体力ランク : %d/100\n\n", "Your current Life Rating is %d/100.\n\n"), percent);
+       else fprintf(fff, _("現在の体力ランク : ???\n\n", "Your current Life Rating is ???.\n\n"));
 
-               fprintf(fff, _("能力の最大値\n\n", "Limits of maximum stats\n\n"));
-               for (v_nr = 0; v_nr < A_MAX; v_nr++)
-               {
-                       if ((creature_ptr->knowledge & KNOW_STAT) || creature_ptr->stat_max[v_nr] == creature_ptr->stat_max_max[v_nr]) fprintf(fff, "%s 18/%d\n", stat_names[v_nr], creature_ptr->stat_max_max[v_nr]-18);
-                       else fprintf(fff, "%s ???\n", stat_names[v_nr]);
-               }
+       fprintf(fff, _("能力の最大値\n\n", "Limits of maximum stats\n\n"));
+       for (int v_nr = 0; v_nr < A_MAX; v_nr++)
+       {
+               if ((creature_ptr->knowledge & KNOW_STAT) || creature_ptr->stat_max[v_nr] == creature_ptr->stat_max_max[v_nr]) fprintf(fff, "%s 18/%d\n", stat_names[v_nr], creature_ptr->stat_max_max[v_nr] - 18);
+               else fprintf(fff, "%s ???\n", stat_names[v_nr]);
        }
 
        dump_yourself(creature_ptr, fff);
@@ -6433,166 +6312,168 @@ static void do_cmd_knowledge_stat(player_type *creature_ptr)
 
 
 /*
+ * todo player_typeではなくQUEST_IDXを引数にすべきかもしれない
  * Print all active quests
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-static void do_cmd_knowledge_quests_current(FILE *fff)
+static void do_cmd_knowledge_quests_current(player_type *creature_ptr, FILE *fff)
 {
        char tmp_str[120];
        char rand_tmp_str[120] = "\0";
        GAME_TEXT name[MAX_NLEN];
        monster_race *r_ptr;
-       QUEST_IDX i;
        int rand_level = 100;
        int total = 0;
 
        fprintf(fff, _("《遂行中のクエスト》\n", "< Current Quest >\n"));
 
-       for (i = 1; i < max_q_idx; i++)
+       for (QUEST_IDX i = 1; i < max_q_idx; i++)
        {
-               if ((quest[i].status == QUEST_STATUS_TAKEN) ||
-                       ((quest[i].status == QUEST_STATUS_STAGE_COMPLETED) && (quest[i].type == QUEST_TYPE_TOWER)) ||
-                       (quest[i].status == QUEST_STATUS_COMPLETED))
-               {
-                       /* Set the quest number temporary */
-                       QUEST_IDX old_quest = p_ptr->current_floor_ptr->inside_quest;
-                       int j;
+               bool is_no_print = quest[i].status != QUEST_STATUS_TAKEN;
+               is_no_print &= (quest[i].status != QUEST_STATUS_STAGE_COMPLETED) || (quest[i].type != QUEST_TYPE_TOWER);
+               is_no_print &= quest[i].status == QUEST_STATUS_COMPLETED;
+               if (is_no_print)
+                       continue;
 
-                       /* Clear the text */
-                       for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
-                       quest_text_line = 0;
+               /* Set the quest number temporary */
+               QUEST_IDX old_quest = creature_ptr->current_floor_ptr->inside_quest;
 
-                       p_ptr->current_floor_ptr->inside_quest = i;
+               /* Clear the text */
+               for (int j = 0; j < 10; j++) quest_text[j][0] = '\0';
+               quest_text_line = 0;
 
-                       /* Get the quest text */
-                       init_flags = INIT_SHOW_TEXT;
+               creature_ptr->current_floor_ptr->inside_quest = i;
 
-                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+               /* Get the quest text */
+               init_flags = INIT_SHOW_TEXT;
 
-                       /* Reset the old quest number */
-                       p_ptr->current_floor_ptr->inside_quest = old_quest;
+               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
-                       /* No info from "silent" quests */
-                       if (quest[i].flags & QUEST_FLAG_SILENT) continue;
+               /* Reset the old quest number */
+               creature_ptr->current_floor_ptr->inside_quest = old_quest;
 
-                       total++;
+               /* No info from "silent" quests */
+               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
 
-                       if (quest[i].type != QUEST_TYPE_RANDOM)
-                       {
-                               char note[80] = "\0";
+               total++;
+
+               if (quest[i].type != QUEST_TYPE_RANDOM)
+               {
+                       char note[80] = "\0";
 
-                               if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
+                       if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
+                       {
+                               switch (quest[i].type)
                                {
-                                       switch (quest[i].type)
+                               case QUEST_TYPE_KILL_LEVEL:
+                               case QUEST_TYPE_KILL_ANY_LEVEL:
+                                       r_ptr = &r_info[quest[i].r_idx];
+                                       strcpy(name, r_name + r_ptr->name);
+                                       if (quest[i].max_num > 1)
                                        {
-                                       case QUEST_TYPE_KILL_LEVEL:
-                                       case QUEST_TYPE_KILL_ANY_LEVEL:
-                                               r_ptr = &r_info[quest[i].r_idx];
-                                               strcpy(name, r_name + r_ptr->name);
-                                               if (quest[i].max_num > 1)
-                                               {
 #ifdef JP
-                                                       sprintf(note," - %d 体の%sを倒す。(あと %d 体)",
-                                                               (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
+                                               sprintf(note, " - %d 体の%sを倒す。(あと %d 体)",
+                                                       (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
 #else
-                                                       plural_aux(name);
-                                                       sprintf(note," - kill %d %s, have killed %d.",
-                                                               (int)quest[i].max_num, name, (int)quest[i].cur_num);
+                                               plural_aux(name);
+                                               sprintf(note, " - kill %d %s, have killed %d.",
+                                                       (int)quest[i].max_num, name, (int)quest[i].cur_num);
 #endif
-                                               }
-                                               else
-                                                       sprintf(note,_(" - %sを倒す。", " - kill %s."),name);
-                                               break;
+                                       }
+                                       else
+                                               sprintf(note, _(" - %sを倒す。", " - kill %s."), name);
+                                       break;
 
-                                       case QUEST_TYPE_FIND_ARTIFACT:
-                                               if (quest[i].k_idx)
-                                               {
-                                                       artifact_type *a_ptr = &a_info[quest[i].k_idx];
-                                                       object_type forge;
-                                                       object_type *q_ptr = &forge;
-                                                       KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
-                                                       object_prep(q_ptr, k_idx);
-                                                       q_ptr->name1 = quest[i].k_idx;
-                                                       q_ptr->ident = IDENT_STORE;
-                                                       object_desc(name, q_ptr, OD_NAME_ONLY);
-                                               }
-                                               sprintf(note,_("\n   - %sを見つけ出す。", "\n   - Find out %s."), name);
-                                               break;
-                                       case QUEST_TYPE_FIND_EXIT:
-                                               sprintf(note,_(" - 出口に到達する。", " - Reach to Exit."));
-                                               break;
+                               case QUEST_TYPE_FIND_ARTIFACT:
+                                       if (quest[i].k_idx)
+                                       {
+                                               artifact_type *a_ptr = &a_info[quest[i].k_idx];
+                                               object_type forge;
+                                               object_type *q_ptr = &forge;
+                                               KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
+                                               object_prep(q_ptr, k_idx);
+                                               q_ptr->name1 = quest[i].k_idx;
+                                               q_ptr->ident = IDENT_STORE;
+                                               object_desc(name, q_ptr, OD_NAME_ONLY);
+                                       }
+                                       sprintf(note, _("\n   - %sを見つけ出す。", "\n   - Find out %s."), name);
+                                       break;
+                               case QUEST_TYPE_FIND_EXIT:
+                                       sprintf(note, _(" - 出口に到達する。", " - Reach to Exit."));
+                                       break;
 
-                                       case QUEST_TYPE_KILL_NUMBER:
+                               case QUEST_TYPE_KILL_NUMBER:
 #ifdef JP
-                                               sprintf(note," - %d 体のモンスターを倒す。(あと %d 体)",
-                                                       (int)quest[i].max_num, (int)(quest[i].max_num - quest[i].cur_num));
+                                       sprintf(note, " - %d 体のモンスターを倒す。(あと %d 体)",
+                                               (int)quest[i].max_num, (int)(quest[i].max_num - quest[i].cur_num));
 #else
-                                               sprintf(note," - Kill %d monsters, have killed %d.",
-                                                       (int)quest[i].max_num, (int)quest[i].cur_num);
+                                       sprintf(note, " - Kill %d monsters, have killed %d.",
+                                               (int)quest[i].max_num, (int)quest[i].cur_num);
 #endif
-                                               break;
+                                       break;
 
-                                       case QUEST_TYPE_KILL_ALL:
-                                       case QUEST_TYPE_TOWER:
-                                               sprintf(note,_(" - 全てのモンスターを倒す。", " - Kill all monsters."));
-                                               break;
-                                       }
+                               case QUEST_TYPE_KILL_ALL:
+                               case QUEST_TYPE_TOWER:
+                                       sprintf(note, _(" - 全てのモンスターを倒す。", " - Kill all monsters."));
+                                       break;
                                }
+                       }
 
-                               /* Print the quest info */
-                               sprintf(tmp_str, _("  %s (危険度:%d階相当)%s\n", "  %s (Danger level: %d)%s\n"),
-                                       quest[i].name, (int)quest[i].level, note);
-
-                               fputs(tmp_str, fff);
+                       /* Print the quest info */
+                       sprintf(tmp_str, _("  %s (危険度:%d階相当)%s\n", "  %s (Danger level: %d)%s\n"),
+                               quest[i].name, (int)quest[i].level, note);
 
-                               if (quest[i].status == QUEST_STATUS_COMPLETED)
-                               {
-                                       sprintf(tmp_str, _("    クエスト達成 - まだ報酬を受けとってない。\n", "    Quest Completed - Unrewarded\n"));
-                                       fputs(tmp_str, fff);
-                               }
-                               else
-                               {
-                                       j = 0;
+                       fputs(tmp_str, fff);
 
-                                       while (quest_text[j][0] && j < 10)
-                                       {
-                                               fprintf(fff, "    %s\n", quest_text[j]);
-                                               j++;
-                                       }
-                               }
+                       if (quest[i].status == QUEST_STATUS_COMPLETED)
+                       {
+                               sprintf(tmp_str, _("    クエスト達成 - まだ報酬を受けとってない。\n", "    Quest Completed - Unrewarded\n"));
+                               fputs(tmp_str, fff);
+                               continue;
                        }
-                       else if (quest[i].level < rand_level) /* QUEST_TYPE_RANDOM */
+
+                       int k = 0;
+                       while (quest_text[k][0] && k < 10)
                        {
-                               /* New random */
-                               rand_level = quest[i].level;
+                               fprintf(fff, "    %s\n", quest_text[k]);
+                               k++;
+                       }
 
-                               if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
-                               {
-                                       /* Print the quest info */
-                                       r_ptr = &r_info[quest[i].r_idx];
-                                       strcpy(name, r_name + r_ptr->name);
+                       continue;
+               }
+               
+               /* QUEST_TYPE_RANDOM */
+               if (quest[i].level >= rand_level)
+                       continue;
+
+               /* New random */
+               rand_level = quest[i].level;
+
+               if (max_dlv[DUNGEON_ANGBAND] < rand_level) continue;
+
+               /* Print the quest info */
+               r_ptr = &r_info[quest[i].r_idx];
+               strcpy(name, r_name + r_ptr->name);
+
+               if (quest[i].max_num <= 1)
+               {
+                       sprintf(rand_tmp_str, _("  %s (%d 階) - %sを倒す。\n", "  %s (Dungeon level: %d)\n  Kill %s.\n"),
+                               quest[i].name, (int)quest[i].level, name);
+                       continue;
+               }
 
-                                       if (quest[i].max_num > 1)
-                                       {
 #ifdef JP
-                                               sprintf(rand_tmp_str,"  %s (%d 階) - %d 体の%sを倒す。(あと %d 体)\n",
-                                                       quest[i].name, (int)quest[i].level,
-                                                       (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
+               sprintf(rand_tmp_str, "  %s (%d 階) - %d 体の%sを倒す。(あと %d 体)\n",
+                       quest[i].name, (int)quest[i].level,
+                       (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
 #else
-                                               plural_aux(name);
+               plural_aux(name);
 
-                                               sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
-                                                       quest[i].name, (int)quest[i].level,
-                                                       (int)quest[i].max_num, name, (int)quest[i].cur_num);
+               sprintf(rand_tmp_str, "  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
+                       quest[i].name, (int)quest[i].level,
+                       (int)quest[i].max_num, name, (int)quest[i].cur_num);
 #endif
-                                       }
-                                       else
-                                       {
-                                               sprintf(rand_tmp_str,_("  %s (%d 階) - %sを倒す。\n", "  %s (Dungeon level: %d)\n  Kill %s.\n"),
-                                                       quest[i].name, (int)quest[i].level, name);
-                                       }
-                               }
-                       }
-               }
        }
 
        /* Print the current random quest  */
@@ -6630,85 +6511,90 @@ static bool do_cmd_knowledge_quests_aux(FILE *fff, floor_type *floor_ptr, IDX q_
        strnfmt(playtime_str, sizeof(playtime_str), "%02d:%02d:%02d",
                q_ptr->comptime/(60*60), (q_ptr->comptime/60)%60, q_ptr->comptime%60);
 
-       if (!is_fixed_quest_idx(q_idx) && q_ptr->r_idx)
-       {
-               /* Print the quest info */
-               if (q_ptr->complev == 0)
-               {
-                       sprintf(tmp_str,
-                               _("  %-35s (%3d階)            -   不戦勝 - %s\n",
-                                 "  %-35s (Dungeon level: %3d) - Unearned - %s\n") ,
-                               r_name+r_info[q_ptr->r_idx].name,
-                               (int)q_ptr->level, playtime_str);
-               }
-               else
-               {
-                       sprintf(tmp_str,
-                               _("  %-35s (%3d階)            - レベル%2d - %s\n",
-                                 "  %-35s (Dungeon level: %3d) - level %2d - %s\n") ,
-                               r_name+r_info[q_ptr->r_idx].name,
-                               (int)q_ptr->level,
-                               q_ptr->complev,
-                               playtime_str);
-               }
-       }
-       else
+       if (is_fixed_quest_idx(q_idx) && q_ptr->r_idx)
        {
                /* Print the quest info */
                sprintf(tmp_str,
                        _("  %-35s (危険度:%3d階相当) - レベル%2d - %s\n",
-                         "  %-35s (Danger  level: %3d) - level %2d - %s\n") ,
+                               "  %-35s (Danger  level: %3d) - level %2d - %s\n"),
                        q_ptr->name, (int)q_ptr->level, q_ptr->complev, playtime_str);
+               fputs(tmp_str, fff);
+               return TRUE;
        }
 
+       /* Print the quest info */
+       if (q_ptr->complev == 0)
+       {
+               sprintf(tmp_str,
+                       _("  %-35s (%3d階)            -   不戦勝 - %s\n",
+                               "  %-35s (Dungeon level: %3d) - Unearned - %s\n"),
+                       r_name + r_info[q_ptr->r_idx].name,
+                       (int)q_ptr->level, playtime_str);
+               fputs(tmp_str, fff);
+               return TRUE;
+       }
+       
+       sprintf(tmp_str,
+               _("  %-35s (%3d階)            - レベル%2d - %s\n",
+                       "  %-35s (Dungeon level: %3d) - level %2d - %s\n"),
+               r_name + r_info[q_ptr->r_idx].name,
+               (int)q_ptr->level,
+               q_ptr->complev,
+               playtime_str);
        fputs(tmp_str, fff);
-
        return TRUE;
 }
 
+
 /*
  * Print all finished quests
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param fff セーブファイル (展開済?)
+ * @param quest_num[] 受注したことのあるクエスト群
+ * @return なし
  */
-void do_cmd_knowledge_quests_completed(FILE *fff, QUEST_IDX quest_num[])
+void do_cmd_knowledge_quests_completed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
 {
-       QUEST_IDX i;
-       QUEST_IDX total = 0;
-
        fprintf(fff, _("《達成したクエスト》\n", "< Completed Quest >\n"));
-       for (i = 1; i < max_q_idx; i++)
+       QUEST_IDX total = 0;
+       for (QUEST_IDX i = 1; i < max_q_idx; i++)
        {
                QUEST_IDX q_idx = quest_num[i];
                quest_type* const q_ptr = &quest[q_idx];
 
-               if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(fff, p_ptr->current_floor_ptr, q_idx))
+               if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(fff, creature_ptr->current_floor_ptr, q_idx))
                {
                        ++total;
                }
        }
+
        if (!total) fprintf(fff, _("  なし\n", "  Nothing.\n"));
 }
 
 
 /*
  * Print all failed quests
- */
-void do_cmd_knowledge_quests_failed(FILE *fff, QUEST_IDX quest_num[])
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param fff セーブファイル (展開済?)
+ * @param quest_num[] 受注したことのあるクエスト群
+ * @return なし
+*/
+void do_cmd_knowledge_quests_failed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
 {
-       QUEST_IDX i;
-       QUEST_IDX total = 0;
-
        fprintf(fff, _("《失敗したクエスト》\n", "< Failed Quest >\n"));
-       for (i = 1; i < max_q_idx; i++)
+       QUEST_IDX total = 0;
+       for (QUEST_IDX i = 1; i < max_q_idx; i++)
        {
                QUEST_IDX q_idx = quest_num[i];
                quest_type* const q_ptr = &quest[q_idx];
 
                if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) &&
-                   do_cmd_knowledge_quests_aux(fff, p_ptr->current_floor_ptr, q_idx))
+                   do_cmd_knowledge_quests_aux(fff, creature_ptr->current_floor_ptr, q_idx))
                {
                        ++total;
                }
        }
+
        if (!total) fprintf(fff, _("  なし\n", "  Nothing.\n"));
 }
 
@@ -6718,12 +6604,10 @@ void do_cmd_knowledge_quests_failed(FILE *fff, QUEST_IDX quest_num[])
  */
 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
 {
+       fprintf(fff, _("《残りのランダムクエスト》\n", "< Remaining Random Quest >\n"));
        GAME_TEXT tmp_str[120];
-       QUEST_IDX i;
        QUEST_IDX total = 0;
-
-       fprintf(fff, _("《残りのランダムクエスト》\n", "< Remaining Random Quest >\n"));
-       for (i = 1; i < max_q_idx; i++)
+       for (QUEST_IDX i = 1; i < max_q_idx; i++)
        {
                /* No info from "silent" quests */
                if (quest[i].flags & QUEST_FLAG_SILENT) continue;
@@ -6738,21 +6622,20 @@ static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
                        fputs(tmp_str, fff);
                }
        }
+
        if (!total) fprintf(fff, _("  なし\n", "  Nothing.\n"));
 }
 
 /*
  * Print quest status of all active quests
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-static void do_cmd_knowledge_quests(void)
+static void do_cmd_knowledge_quests(player_type *creature_ptr)
 {
+       /* Open a new file */
        FILE *fff;
        GAME_TEXT file_name[1024];
-       IDX *quest_num;
-       int dummy;
-       IDX i;
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
        if (!fff)
        {
@@ -6762,23 +6645,26 @@ static void do_cmd_knowledge_quests(void)
        }
 
        /* Allocate Memory */
+       IDX *quest_num;
        C_MAKE(quest_num, max_q_idx, QUEST_IDX);
 
        /* Sort by compete level */
-       for (i = 1; i < max_q_idx; i++) quest_num[i] = i;
+       for (IDX i = 1; i < max_q_idx; i++) quest_num[i] = i;
+       int dummy;
        ang_sort(quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
 
        /* Dump Quest Information */
-       do_cmd_knowledge_quests_current(fff);
+       do_cmd_knowledge_quests_current(creature_ptr, fff);
        fputc('\n', fff);
-       do_cmd_knowledge_quests_completed(fff, quest_num);
+       do_cmd_knowledge_quests_completed(creature_ptr, fff, quest_num);
        fputc('\n', fff);
-       do_cmd_knowledge_quests_failed(fff, quest_num);
+       do_cmd_knowledge_quests_failed(creature_ptr, fff, quest_num);
        if (current_world_ptr->wizard)
        {
                fputc('\n', fff);
                do_cmd_knowledge_quests_wiz_random(fff);
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -6795,70 +6681,65 @@ static void do_cmd_knowledge_quests(void)
  */
 static void do_cmd_knowledge_home(void)
 {
-       FILE *fff;
-
-       int i;
-       GAME_TEXT file_name[1024];
-       store_type  *st_ptr;
-       GAME_TEXT o_name[MAX_NLEN];
-       concptr         paren = ")";
-
        process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        /* Open a new file */
+       FILE *fff;
+       GAME_TEXT file_name[1024];
        fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
+       if (!fff)
+       {
                msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
                msg_print(NULL);
                return;
        }
 
-       if (fff)
-       {
-               /* Print all homes in the different towns */
-               st_ptr = &town_info[1].store[STORE_HOME];
+       /* Print all homes in the different towns */
+       store_type *st_ptr;
+       st_ptr = &town_info[1].store[STORE_HOME];
 
-               /* Home -- if anything there */
-               if (st_ptr->stock_num)
-               {
+       /* Home -- if anything there */
+       if (st_ptr->stock_num)
+       {
 #ifdef JP
-                       TERM_LEN x = 1;
+               TERM_LEN x = 1;
 #endif
-                       /* Header with name of the town */
-                       fprintf(fff, _("  [ 我が家のアイテム ]\n", "  [Home Inventory]\n"));
+               /* Header with name of the town */
+               fprintf(fff, _("  [ 我が家のアイテム ]\n", "  [Home Inventory]\n"));
 
-                       /* Dump all available items */
-                       for (i = 0; i < st_ptr->stock_num; i++)
-                       {
+               /* Dump all available items */
+               concptr paren = ")";
+               GAME_TEXT o_name[MAX_NLEN];
+               for (int i = 0; i < st_ptr->stock_num; i++)
+               {
 #ifdef JP
-                               if ((i % 12) == 0) fprintf(fff, "\n ( %d ページ )\n", x++);
-                               object_desc(o_name, &st_ptr->stock[i], 0);
-                               if (strlen(o_name) <= 80-3)
-                               {
-                                       fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
-                               }
-                               else
-                               {
-                                       int n;
-                                       char *t;
-                                       for (n = 0, t = o_name; n < 80-3; n++, t++)
-                                               if(iskanji(*t)) {t++; n++;}
-                                       if (n == 81-3) n = 79-3; /* 最後が漢字半分 */
-
-                                       fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
-                                       fprintf(fff, "   %.77s\n", o_name+n);
-                               }
+                       if ((i % 12) == 0) fprintf(fff, "\n ( %d ページ )\n", x++);
+                       object_desc(o_name, &st_ptr->stock[i], 0);
+                       if (strlen(o_name) <= 80 - 3)
+                       {
+                               fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
+                       }
+                       else
+                       {
+                               int n;
+                               char *t;
+                               for (n = 0, t = o_name; n < 80 - 3; n++, t++)
+                                       if (iskanji(*t)) { t++; n++; }
+                               if (n == 81 - 3) n = 79 - 3; /* 最後が漢字半分 */
+
+                               fprintf(fff, "%c%s %.*s\n", I2A(i % 12), paren, n, o_name);
+                               fprintf(fff, "   %.77s\n", o_name + n);
+                       }
 #else
-                               object_desc(o_name, &st_ptr->stock[i], 0);
-                               fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
+                       object_desc(o_name, &st_ptr->stock[i], 0);
+                       fprintf(fff, "%c%s %s\n", I2A(i % 12), paren, o_name);
 #endif
-
-                       }
-
-                       /* Add an empty line */
-                       fprintf(fff, "\n\n");
                }
+
+               /* Add an empty line */
+               fprintf(fff, "\n\n");
        }
+
        my_fclose(fff);
 
        /* Display the file contents */
@@ -6872,13 +6753,10 @@ static void do_cmd_knowledge_home(void)
  */
 static void do_cmd_knowledge_autopick(void)
 {
-       int k;
+       /* Open a new file */
        FILE *fff;
        GAME_TEXT file_name[1024];
-
-       /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
-
        if (!fff)
        {
            msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
@@ -6896,7 +6774,7 @@ static void do_cmd_knowledge_autopick(void)
                                           "   There are %d registered lines for auto picker/destroyer.\n\n"), max_autopick);
        }
 
-       for (k = 0; k < max_autopick; k++)
+       for (int k = 0; k < max_autopick; k++)
        {
                concptr tmp;
                byte act = autopick_list[k].action;
@@ -6927,7 +6805,9 @@ static void do_cmd_knowledge_autopick(void)
                string_free(tmp);
                fprintf(fff, "\n");
        }
+
        my_fclose(fff);
+
        /* Display the file contents */
        show_file(TRUE, file_name, _("自動拾い/破壊 設定リスト", "Auto-picker/Destroyer"), 0, 0);
        fd_kill(file_name);
@@ -6937,7 +6817,7 @@ static void do_cmd_knowledge_autopick(void)
 /*
  * Interact with "knowledge"
  */
-void do_cmd_knowledge(void)
+void do_cmd_knowledge(player_type *creature_ptr)
 {
        int i, p = 0;
        bool need_redraw = FALSE;
@@ -6947,7 +6827,7 @@ void do_cmd_knowledge(void)
        screen_save();
 
        /* Interact until done */
-       while (1)
+       while (TRUE)
        {
                Term_clear();
 
@@ -7025,7 +6905,7 @@ void do_cmd_knowledge(void)
                        p = 1 - p;
                        break;
                case '1': /* Artifacts */
-                       do_cmd_knowledge_artifacts(p_ptr);
+                       do_cmd_knowledge_artifacts(creature_ptr);
                        break;
                case '2': /* Objects */
                        do_cmd_knowledge_objects(&need_redraw, FALSE, -1);
@@ -7034,22 +6914,22 @@ void do_cmd_knowledge(void)
                        do_cmd_knowledge_uniques();
                        break;
                case '4': /* Monsters */
-                       do_cmd_knowledge_monsters(&need_redraw, FALSE, -1);
+                       do_cmd_knowledge_monsters(creature_ptr, &need_redraw, FALSE, -1);
                        break;
                case '5': /* Kill count  */
                        do_cmd_knowledge_kill_count();
                        break;
                case '6': /* wanted */
-                       if (!vanilla_town) do_cmd_knowledge_kubi();
+                       if (!vanilla_town) do_cmd_knowledge_bounty(creature_ptr);
                        break;
                case '7': /* Pets */
-                       do_cmd_knowledge_pets();
+                       do_cmd_knowledge_pets(creature_ptr);
                        break;
                case '8': /* Home */
                        do_cmd_knowledge_home();
                        break;
                case '9': /* Resist list */
-                       do_cmd_knowledge_inven(p_ptr);
+                       do_cmd_knowledge_inven(creature_ptr);
                        break;
                case '0': /* Feature list */
                        {
@@ -7059,28 +6939,28 @@ void do_cmd_knowledge(void)
                        break;
                /* Next page */
                case 'a': /* Max stat */
-                       do_cmd_knowledge_stat(p_ptr);
+                       do_cmd_knowledge_stat(creature_ptr);
                        break;
                case 'b': /* Mutations */
-                       do_cmd_knowledge_mutations(p_ptr);
+                       do_cmd_knowledge_mutations(creature_ptr);
                        break;
                case 'c': /* weapon-exp */
-                       do_cmd_knowledge_weapon_exp(p_ptr);
+                       do_cmd_knowledge_weapon_exp(creature_ptr);
                        break;
                case 'd': /* spell-exp */
-                       do_cmd_knowledge_spell_exp(p_ptr);
+                       do_cmd_knowledge_spell_exp(creature_ptr);
                        break;
                case 'e': /* skill-exp */
-                       do_cmd_knowledge_skill_exp(p_ptr);
+                       do_cmd_knowledge_skill_exp(creature_ptr);
                        break;
                case 'f': /* Virtues */
-                       do_cmd_knowledge_virtues(p_ptr);
+                       do_cmd_knowledge_virtues(creature_ptr);
                        break;
                case 'g': /* Dungeon */
                        do_cmd_knowledge_dungeon();
                        break;
                case 'h': /* Quests */
-                       do_cmd_knowledge_quests();
+                       do_cmd_knowledge_quests(creature_ptr);
                        break;
                case 'i': /* Autopick */
                        do_cmd_knowledge_autopick();
@@ -7091,51 +6971,43 @@ void do_cmd_knowledge(void)
 
                msg_erase();
        }
-       screen_load();
 
-       if (need_redraw) do_cmd_redraw(p_ptr);
+       screen_load();
+       if (need_redraw) do_cmd_redraw(creature_ptr);
 }
 
 
 /*
  * Check on the status of an active quest
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-void do_cmd_checkquest(void)
+void do_cmd_checkquest(player_type *creature_ptr)
 {
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
        screen_save();
 
        /* Quest info */
-       do_cmd_knowledge_quests();
+       do_cmd_knowledge_quests(creature_ptr);
        screen_load();
 }
 
 
 /*
  * Display the time and date
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
  */
-void do_cmd_time(void)
+void do_cmd_time(player_type *creature_ptr)
 {
-       int day, hour, min, full, start, end, num;
-       char desc[1024];
-
-       char buf[1024];
-       char day_buf[10];
-
-       FILE *fff;
-
+       int day, hour, min;
        extract_day_hour_min(&day, &hour, &min);
 
-       full = hour * 100 + min;
-
-       start = 9999;
-       end = -9999;
-
-       num = 0;
-
+       char desc[1024];
        strcpy(desc, _("変な時刻だ。", "It is a strange time."));
 
+       char day_buf[10];
        if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
        else strcpy(day_buf, "*****");
 
@@ -7143,7 +7015,8 @@ void do_cmd_time(void)
                   day_buf, (hour % 12 == 0) ? 12 : (hour % 12), min, (hour < 12) ? "AM" : "PM");
 
        /* Find the path */
-       if (!randint0(10) || p_ptr->image)
+       char buf[1024];
+       if (!randint0(10) || creature_ptr->image)
        {
                path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timefun_j.txt", "timefun.txt"));
        }
@@ -7153,11 +7026,16 @@ void do_cmd_time(void)
        }
 
        /* Open this file */
+       FILE *fff;
        fff = my_fopen(buf, "rt");
 
        if (!fff) return;
 
        /* Find this time */
+       int full = hour * 100 + min;
+       int start = 9999;
+       int end = -9999;
+       int num = 0;
        while (!my_fgets(fff, buf, sizeof(buf)))
        {
                /* Ignore comments */
@@ -7174,8 +7052,6 @@ void do_cmd_time(void)
 
                        /* Assume valid for an hour */
                        end = start + 59;
-
-                       /* Next... */
                        continue;
                }
 
@@ -7184,8 +7060,6 @@ void do_cmd_time(void)
                {
                        /* Extract the ending time */
                        end = atoi(buf + 2);
-
-                       /* Next... */
                        continue;
                }
 
@@ -7199,8 +7073,6 @@ void do_cmd_time(void)
 
                        /* Apply the randomizer */
                        if (!randint0(num)) strcpy(desc, buf + 2);
-
-                       /* Next... */
                        continue;
                }
        }