OSDN Git Service

refactor: drain-life->HP damage, drain-exp->Exp damage
[hengband/hengband.git] / src / cmd4.c
index 0ab40cd..fd29579 100644 (file)
@@ -1,23 +1,18 @@
-/* File: cmd4.c */
-
-/*
+/*!
+ * @file cmd4.c
+ * @brief ¥×¥ì¥¤¥ä¡¼¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤Ë´Ø¤¹¤ë¥³¥Þ¥ó¥É¤Î¼ÂÁõ / Interface commands
+ * @date 2014/01/02
+ * @author
+ * <pre>
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
  * This software may be copied and distributed for educational, research,
  * and not for profit purposes provided that this copyright and statement
  * are included in all such copies.  Other copyrights may also apply.
- */
-
-/* Purpose: Interface commands */
-
-#include "angband.h"
-
-
-
-/*
+ * </pre>
+ * @details
+ * <pre>
  * A set of functions to maintain automatic dumps of various kinds.
  * -Mogami-
- *
  * remove_auto_dump(orig_file, mark)
  *     Remove the old automatic dump of type "mark".
  * auto_dump_printf(fmt, ...)
  *     Open a file, remove old dump, and add new header.
  * close_auto_dump(void)
  *     Add a footer, and close the file.
- *
  *    The dump commands of original Angband simply add new lines to
  * existing files; these files will become bigger and bigger unless
  * an user deletes some or all of these files by hand at some
  * point.
- *
  *     These three functions automatically delete old dumped lines 
  * before adding new ones.  Since there are various kinds of automatic 
  * dumps in a single file, we add a header and a footer with a type 
  * name for every automatic dump, and kill old lines only when the 
  * lines have the correct type of header and footer.
- *
  *     We need to be quite paranoid about correctness; the user might 
  * (mistakenly) edit the file by hand, and see all their work come
  * to nothing on the next auto dump otherwise.  The current code only 
  * detects changes by noting inconsistencies between the actual number 
  * of lines and the number written in the footer.  Note that this will 
  * not catch single-line edits.
+ * </pre>
+ */
+
+#include "angband.h"
+
+
+
+/*
  */
 
 /*
@@ -59,8 +59,11 @@ static FILE *auto_dump_stream;
 static cptr auto_dump_mark;
 static int auto_dump_line_num;
 
-/*
+
+/*!
+ * @brief prf½ÐÎÏÆâÍƤò¾Ãµî¤¹¤ë /
  * Remove old lines automatically generated before.
+ * @param orig_file ¾Ãµî¤ò¹Ô¤¦¥Õ¥¡¥¤¥ë̾
  */
 static void remove_auto_dump(cptr orig_file)
 {
@@ -223,8 +226,10 @@ static void remove_auto_dump(cptr orig_file)
 }
 
 
-/*
+/*!
+ * @brief prf¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ë½¾¤Ã¤¿ÆâÍƤò½ÐÎϤ¹¤ë /
  * Dump a formatted line, using "vstrnfmt()".
+ * @param fmt ½ÐÎÏÆâÍÆ
  */
 static void auto_dump_printf(cptr fmt, ...)
 {
@@ -253,8 +258,12 @@ static void auto_dump_printf(cptr fmt, ...)
 }
 
 
-/*
- *  Open file to append auto dump.
+/*!
+ * @brief prf¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¥ª¡¼¥×¥ó¤¹¤ë /
+ * Open file to append auto dump.
+ * @param buf ¥Õ¥¡¥¤¥ë̾
+ * @param mark ½ÐÎϤ¹¤ë¥Ø¥Ã¥À¥Þ¡¼¥¯
+ * @return ¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤ò¼èÆÀ¤Ç¤­¤¿¤éTRUE¤òÊÖ¤¹
  */
 static bool open_auto_dump(cptr buf, cptr mark)
 {
@@ -304,8 +313,10 @@ static bool open_auto_dump(cptr buf, cptr mark)
        return TRUE;
 }
 
-/*
- *  Append foot part and close auto dump.
+/*!
+ * @brief prf¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¥¯¥í¡¼¥º¤¹¤ë /
+ * Append foot part and close auto dump.
+ * @return ¤Ê¤·
  */
 static void close_auto_dump(void)
 {
@@ -333,8 +344,11 @@ static void close_auto_dump(void)
 
 
 #ifndef JP
-/*
- * Return suffix of ordinal number
+
+/*!
+ * @brief Return suffix of ordinal number
+ * @param num number
+ * @return pointer of suffix string.
  */
 cptr get_ordinal_number_suffix(int num)
 {
@@ -354,8 +368,13 @@ cptr get_ordinal_number_suffix(int num)
 #endif
 
 
-/*
- *   Take note to the diary.
+/*!
+ * @brief Æüµ­¤Ë¥á¥Ã¥»¡¼¥¸¤òÄɲ乤ë /
+ * Take note to the diary.
+ * @param type Æüµ­ÆâÍƤÎID
+ * @param num Æüµ­ÆâÍƤÎID¤Ë±þ¤¸¤¿¿ôÃÍ
+ * @param note Æüµ­ÆâÍƤÎID¤Ë±þ¤¸¤¿Ê¸»úÎ󻲾ȥݥ¤¥ó¥¿
+ * @return ¥¨¥é¡¼ID
  */
 errr do_cmd_write_nikki(int type, int num, cptr note)
 {
@@ -386,7 +405,7 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
                p_ptr->inside_quest = (quest[num].type == QUEST_TYPE_RANDOM) ? 0 : num;
 
                /* Get the quest text */
-               init_flags = INIT_ASSIGN;
+               init_flags = INIT_NAME_ONLY;
 
                process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
@@ -461,9 +480,11 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
                case NIKKI_HIGAWARI:
                {
 #ifdef JP
-                       fprintf(fff, "%dÆüÌÜ\n",day);
+                       if (day < MAX_DAYS) fprintf(fff, "%dÆüÌÜ\n", day);
+                       else fputs("*****ÆüÌÜ\n", fff);
 #else
-                       fprintf(fff, "Day %d\n",day);
+                       if (day < MAX_DAYS) fprintf(fff, "Day %d\n", day);
+                       else fputs("Day *****\n", fff);
 #endif
                        do_level = FALSE;
                        break;
@@ -524,7 +545,7 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
 #ifdef JP
                        fprintf(fff, " %2d:%02d %20s ¥é¥ó¥À¥à¥¯¥¨¥¹¥È(%s)¤òãÀ®¤·¤¿¡£\n", hour, min, note_level, name);
 #else
-                       fprintf(fff, " %2d:%02d %20s completed randome quest '%s'\n", hour, min, note_level, name);
+                       fprintf(fff, " %2d:%02d %20s completed random quest '%s'\n", hour, min, note_level, name);
 #endif
                        break;
                }
@@ -749,62 +770,111 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
                        fprintf(fff, " %2d:%02d %20s ", hour, min, note_level);
                        switch (num)
                        {
-                               case 0:
+                               case RECORD_NAMED_PET_NAME:
 #ifdef JP
                                        fprintf(fff, "%s¤òι¤Îͧ¤Ë¤¹¤ë¤³¤È¤Ë·è¤á¤¿¡£\n", note);
 #else
                                        fprintf(fff, "decided to travel together with %s.\n", note);
 #endif
                                        break;
-                               case 1:
+                               case RECORD_NAMED_PET_UNNAME:
 #ifdef JP
                                        fprintf(fff, "%s¤Î̾Á°¤ò¾Ã¤·¤¿¡£\n", note);
 #else
                                        fprintf(fff, "unnamed %s.\n", note);
 #endif
                                        break;
-                               case 2:
+                               case RECORD_NAMED_PET_DISMISS:
 #ifdef JP
                                        fprintf(fff, "%s¤ò²òÊü¤·¤¿¡£\n", note);
 #else
                                        fprintf(fff, "dismissed %s.\n", note);
 #endif
                                        break;
-                               case 3:
+                               case RECORD_NAMED_PET_DEATH:
 #ifdef JP
                                        fprintf(fff, "%s¤¬»à¤ó¤Ç¤·¤Þ¤Ã¤¿¡£\n", note);
 #else
                                        fprintf(fff, "%s died.\n", note);
 #endif
                                        break;
-                               case 4:
+                               case RECORD_NAMED_PET_MOVED:
 #ifdef JP
                                        fprintf(fff, "%s¤ò¤ª¤¤¤ÆÊ̤ΥޥåפذÜÆ°¤·¤¿¡£\n", note);
 #else
                                        fprintf(fff, "moved to another map leaving %s behind.\n", note);
 #endif
                                        break;
-                               case 5:
+                               case RECORD_NAMED_PET_LOST_SIGHT:
 #ifdef JP
                                        fprintf(fff, "%s¤È¤Ï¤°¤ì¤Æ¤·¤Þ¤Ã¤¿¡£\n", note);
 #else
                                        fprintf(fff, "lost sight of %s.\n", note);
 #endif
                                        break;
-                               case 6:
+                               case RECORD_NAMED_PET_DESTROY:
 #ifdef JP
                                        fprintf(fff, "%s¤¬*Ç˲õ*¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
 #else
                                        fprintf(fff, "%s was made disappeared by *destruction*.\n", note);
 #endif
                                        break;
-                               case 7:
+                               case RECORD_NAMED_PET_EARTHQUAKE:
 #ifdef JP
                                        fprintf(fff, "%s¤¬´äÀФ˲¡¤·ÄÙ¤µ¤ì¤¿¡£\n", note);
 #else
                                        fprintf(fff, "%s was crushed by falling rocks.\n", note);
 #endif
                                        break;
+                               case RECORD_NAMED_PET_GENOCIDE:
+#ifdef JP
+                                       fprintf(fff, "%s¤¬Ëõ»¦¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s was made disappeared by genocide.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_WIZ_ZAP:
+#ifdef JP
+                                       fprintf(fff, "%s¤¬¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s was removed by debug command.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_TELE_LEVEL:
+#ifdef JP
+                                       fprintf(fff, "%s¤¬¥Æ¥ì¥Ý¡¼¥È¡¦¥ì¥Ù¥ë¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s was made disappeared by teleport level.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_BLAST:
+#ifdef JP
+                                       fprintf(fff, "%s¤òÇúÇˤ·¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "blasted %s.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_HEAL_LEPER:
+#ifdef JP
+                                       fprintf(fff, "%s¤Îɵ¤¤¬¼£¤ê餫¤é³°¤ì¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s was healed and left.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_COMPACT:
+#ifdef JP
+                                       fprintf(fff, "%s¤¬¥â¥ó¥¹¥¿¡¼¾ðÊ󰵽̤ˤè¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s was made disappeared by compacting monsters.\n", note);
+#endif
+                                       break;
+                               case RECORD_NAMED_PET_LOSE_PARENT:
+#ifdef JP
+                                       fprintf(fff, "%s¤Î¾¤´­¼Ô¤¬´û¤Ë¤¤¤Ê¤¤¤¿¤á¾Ã¤¨µî¤Ã¤¿¡£\n", note);
+#else
+                                       fprintf(fff, "%s disappeared because there does not exist summoner.\n", note);
+#endif
+                                       break;
                                default:
                                        fprintf(fff, "\n");
                                        break;
@@ -825,6 +895,10 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
 
 #define MAX_SUBTITLE (sizeof(subtitle)/sizeof(subtitle[0]))
 
+/*!
+ * @brief Æüµ­¤Î¥¿¥¤¥È¥ëɽµ­¤ÈÆâÍƽÐÎÏ /
+ * @return ¤Ê¤·
+ */
 static void do_cmd_disp_nikki(void)
 {
        char nikki_title[256];
@@ -924,6 +998,10 @@ static void do_cmd_disp_nikki(void)
        show_file(FALSE, buf, nikki_title, -1, 0);
 }
 
+/*!
+ * @brief Æüµ­¤ËǤ°Õ¤ÎÆâÍƤòɽµ­¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * @return ¤Ê¤·
+ */
 static void do_cmd_bunshou(void)
 {
        char tmp[80] = "\0";
@@ -941,6 +1019,10 @@ static void do_cmd_bunshou(void)
        }
 }
 
+/*!
+ * @brief ºÇ¸å¤Ë¼èÆÀ¤·¤¿¥¢¥¤¥Æ¥à¤Î¾ðÊó¤òÆüµ­¤ËÄɲ乤ë¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * @return ¤Ê¤·
+ */
 static void do_cmd_last_get(void)
 {
        char buf[256];
@@ -1008,7 +1090,10 @@ static void do_cmd_erase_nikki(void)
        msg_print(NULL);
 }
 
-
+/*!
+ * @brief Æüµ­¥³¥Þ¥ó¥É
+ * @return ¤Ê¤·
+ */
 void do_cmd_nikki(void)
 {
        int i;
@@ -1039,11 +1124,15 @@ void do_cmd_nikki(void)
                prt("(2) Ê¸¾Ï¤òµ­Ï¿¤¹¤ë", 5, 5);
                prt("(3) Ä¾Á°¤ËÆþ¼êËô¤Ï´ÕÄꤷ¤¿¤â¤Î¤òµ­Ï¿¤¹¤ë", 6, 5);
                prt("(4) µ­Ï¿¤ò¾Ãµî¤¹¤ë", 7, 5);
+
+               prt("(R) ¥×¥ì¥¤Æ°²è¤òµ­Ï¿¤¹¤ë/Ãæ»ß¤¹¤ë", 9, 5);
 #else
                prt("(1) Display your record", 4, 5);
                prt("(2) Add record", 5, 5);
                prt("(3) Record item you last get/identify", 6, 5);
                prt("(4) Delete your record", 7, 5);
+
+               prt("(R) Record playing movie / or stop it", 9, 5);
 #endif
 
 
@@ -1075,6 +1164,10 @@ void do_cmd_nikki(void)
                case '4':
                        do_cmd_erase_nikki();
                        break;
+               case 'r': case 'R':
+                       screen_load();
+                       prepare_movie_hooks();
+                       return;
                default: /* Unknown option */
                        bell();
                }
@@ -1087,9 +1180,12 @@ void do_cmd_nikki(void)
        screen_load();
 }
 
-/*
+/*!
+ * @brief ²èÌ̤òºÆÉÁ²è¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
  * Hack -- redraw the screen
- *
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * This command performs various low level updates, clears all the "extra"
  * windows, does a total redraw of the main window, and requests all of the
  * interesting updates and redraws that I can think of.
@@ -1097,6 +1193,7 @@ void do_cmd_nikki(void)
  * This command is also used to "instantiate" the results of the user
  * selecting various things, such as graphics mode, so it must call
  * the "TERM_XTRA_REACT" hook before redrawing the windows.
+ * </pre>
  */
 void do_cmd_redraw(void)
 {
@@ -1166,8 +1263,10 @@ void do_cmd_redraw(void)
 }
 
 
-/*
+/*!
+ * @brief Ì¾Á°¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
  * Hack -- change name
+ * @return ¤Ê¤·
  */
 void do_cmd_change_name(void)
 {
@@ -1264,8 +1363,10 @@ void do_cmd_change_name(void)
 }
 
 
-/*
+/*!
+ * @brief ºÇ¶áɽ¼¨¤µ¤ì¤¿¥á¥Ã¥»¡¼¥¸¤òºÆɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
  * Recall the most recent message
+ * @return ¤Ê¤·
  */
 void do_cmd_message_one(void)
 {
@@ -1274,7 +1375,12 @@ void do_cmd_message_one(void)
 }
 
 
-/*
+/*!
+ * @brief ¥á¥Ã¥»¡¼¥¸¤Î¥í¥°¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
+ * Recall the most recent message
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Show previous messages to the user  -BEN-
  *
  * The screen format uses line 0 and 23 for headers and prompts,
@@ -1288,13 +1394,16 @@ void do_cmd_message_one(void)
  * "slide" the virtual display to the left or right.
  *
  * Attempt to only hilite the matching portions of the string.
+ * </pre>
  */
 void do_cmd_messages(int num_now)
 {
        int i, n;
 
-       char shower[80];
-       char finder[80];
+       char shower_str[81];
+       char finder_str[81];
+       char back_str[81];
+       cptr shower = NULL;
        int wid, hgt;
        int num_lines;
 
@@ -1305,11 +1414,10 @@ void do_cmd_messages(int num_now)
        num_lines = hgt - 4;
 
        /* Wipe finder */
-       strcpy(finder, "");
+       strcpy(finder_str, "");
 
        /* Wipe shower */
-       strcpy(shower, "");
-
+       strcpy(shower_str, "");
 
        /* Total messages */
        n = message_num();
@@ -1335,10 +1443,10 @@ void do_cmd_messages(int num_now)
                        cptr msg = message_str(i+j);
 
                        /* Dump the messages, bottom to top */
-                       c_prt((i+j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
+                       c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
 
                        /* Hilite "shower" */
-                       if (shower[0])
+                       if (shower && shower[0])
                        {
                                cptr str = msg;
 
@@ -1366,13 +1474,12 @@ void do_cmd_messages(int num_now)
 #ifdef JP
                /* translation */
                prt(format("°ÊÁ°¤Î¥á¥Ã¥»¡¼¥¸ %d-%d Á´Éô¤Ç(%d)",
-                          i, i+j-1, n), 0, 0);
+                          i, i + j - 1, n), 0, 0);
 #else
                prt(format("Message Recall (%d-%d of %d)",
-                          i, i+j-1, n), 0, 0);
+                          i, i + j - 1, n), 0, 0);
 #endif
 
-
                /* Display prompt (not very informative) */
 #ifdef JP
                prt("[ 'p' ¤Ç¹¹¤Ë¸Å¤¤¤â¤Î, 'n' ¤Ç¹¹¤Ë¿·¤·¤¤¤â¤Î, '/' ¤Ç¸¡º÷, ESC ¤ÇÃæÃÇ ]", hgt - 1, 0);
@@ -1380,7 +1487,6 @@ void do_cmd_messages(int num_now)
                prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", hgt - 1, 0);
 #endif
 
-
                /* Get a command */
                skey = inkey_special(TRUE);
 
@@ -1390,9 +1496,10 @@ void do_cmd_messages(int num_now)
                /* Hack -- Save the old index */
                j = i;
 
-               /* Hack -- handle show */
-               if (skey == '=')
+               switch (skey)
                {
+               /* Hack -- handle show */
+               case '=':
                        /* Prompt */
 #ifdef JP
                        prt("¶¯Ä´: ", hgt - 1, 0);
@@ -1400,104 +1507,121 @@ void do_cmd_messages(int num_now)
                        prt("Show: ", hgt - 1, 0);
 #endif
 
-
                        /* Get a "shower" string, or continue */
-                       if (!askfor(shower, 80)) continue;
+                       strcpy(back_str, shower_str);
+                       if (askfor(shower_str, 80))
+                       {
+                               /* Show it */
+                               shower = shower_str[0] ? shower_str : NULL;
+                       }
+                       else strcpy(shower_str, back_str);
 
                        /* Okay */
                        continue;
-               }
 
                /* Hack -- handle find */
-               if (skey == '/' || skey == KTRL('s'))
-               {
-                       int z;
+               case '/':
+               case KTRL('s'):
+                       {
+                               int z;
 
-                       /* Prompt */
+                               /* Prompt */
 #ifdef JP
-                       prt("¸¡º÷: ", hgt - 1, 0);
+                               prt("¸¡º÷: ", hgt - 1, 0);
 #else
-                       prt("Find: ", hgt - 1, 0);
+                               prt("Find: ", hgt - 1, 0);
 #endif
 
+                               /* Get a "finder" string, or continue */
+                               strcpy(back_str, finder_str);
+                               if (!askfor(finder_str, 80))
+                               {
+                                       strcpy(finder_str, back_str);
+                                       continue;
+                               }
+                               else if (!finder_str[0])
+                               {
+                                       shower = NULL; /* Stop showing */
+                                       continue;
+                               }
 
-                       /* Get a "finder" string, or continue */
-                       if (!askfor(finder, 80)) continue;
-
-                       /* Show it */
-                       strcpy(shower, finder);
-
-                       /* Scan messages */
-                       for (z = i + 1; z < n; z++)
-                       {
-                               cptr msg = message_str(z);
+                               /* Show it */
+                               shower = finder_str;
 
-                               /* Search for it */
-                               if (my_strstr(msg, finder))
+                               /* Scan messages */
+                               for (z = i + 1; z < n; z++)
                                {
-                                       /* New location */
-                                       i = z;
+                                       cptr msg = message_str(z);
 
-                                       /* Done */
-                                       break;
+                                       /* Search for it */
+                                       if (my_strstr(msg, finder_str))
+                                       {
+                                               /* New location */
+                                               i = z;
+
+                                               /* Done */
+                                               break;
+                                       }
                                }
                        }
-               }
+                       break;
 
                /* Recall 1 older message */
-               if (skey == SKEY_TOP)
-               {
+               case SKEY_TOP:
                        /* Go to the oldest line */
                        i = n - num_lines;
-               }
+                       break;
 
                /* Recall 1 newer message */
-               if (skey == SKEY_BOTTOM)
-               {
+               case SKEY_BOTTOM:
                        /* Go to the newest line */
                        i = 0;
-               }
+                       break;
 
                /* Recall 1 older message */
-               if (skey == '8' || skey == SKEY_UP || skey == '\n' || skey == '\r')
-               {
+               case '8':
+               case SKEY_UP:
+               case '\n':
+               case '\r':
                        /* Go older if legal */
                        i = MIN(i + 1, n - num_lines);
-               }
+                       break;
 
                /* Recall 10 older messages */
-               if (skey == '+')
-               {
+               case '+':
                        /* Go older if legal */
                        i = MIN(i + 10, n - num_lines);
-               }
+                       break;
 
                /* Recall 20 older messages */
-               if (skey == 'p' || skey == KTRL('P') || skey == ' ' || skey == SKEY_PGUP)
-               {
+               case 'p':
+               case KTRL('P'):
+               case ' ':
+               case SKEY_PGUP:
                        /* Go older if legal */
                        i = MIN(i + num_lines, n - num_lines);
-               }
+                       break;
 
                /* Recall 20 newer messages */
-               if (skey == 'n' || skey == KTRL('N') || skey == SKEY_PGDOWN)
-               {
+               case 'n':
+               case KTRL('N'):
+               case SKEY_PGDOWN:
                        /* Go newer (if able) */
                        i = MAX(0, i - num_lines);
-               }
+                       break;
 
                /* Recall 10 newer messages */
-               if (skey == '-')
-               {
+               case '-':
                        /* Go newer (if able) */
                        i = MAX(0, i - 10);
-               }
+                       break;
 
                /* Recall 1 newer messages */
-               if (skey == '2' || skey == SKEY_DOWN)
-               {
+               case '2':
+               case SKEY_DOWN:
                        /* Go newer (if able) */
                        i = MAX(0, i - 1);
+                       break;
                }
 
                /* Hack -- Error of some kind */
@@ -1510,13 +1634,13 @@ void do_cmd_messages(int num_now)
 
 
 
-/*
- * Number of cheating options
+/*!
+ * ¥Á¡¼¥È¥ª¥×¥·¥ç¥ó¤ÎºÇÂç¿ô / Number of cheating options
  */
 #define CHEAT_MAX 7
 
-/*
- * Cheating options
+/*!
+ * ¥Á¡¼¤È¥ª¥×¥·¥ç¥ó¤ÎÄêµÁ¥Æ¡¼¥Ö¥ë / Cheating options
  */
 static option_type cheat_info[CHEAT_MAX] =
 {
@@ -1577,8 +1701,11 @@ static option_type cheat_info[CHEAT_MAX] =
        }
 };
 
-/*
+/*!
+ * @brief ¥Á¡¼¥È¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
  * Interact with some options for cheating
+ * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
+ * @return ¤Ê¤·
  */
 static void do_cmd_options_cheat(cptr info)
 {
@@ -1721,6 +1848,9 @@ static void do_cmd_options_cheat(cptr info)
 }
 
 
+/*!
+ * ¼«Æ°¥»¡¼¥Ö¥ª¥×¥·¥ç¥ó¥Æ¡¼¥Ö¥ë
+ */
 static option_type autosave_info[2] =
 {
        { &autosave_l,      FALSE, 255, 0x01, 0x00,
@@ -1740,7 +1870,11 @@ static option_type autosave_info[2] =
 
 };
 
-
+/*!
+ * @brief ¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥ó¤Î¼¡¤ÎÃͤòÊÖ¤¹
+ * @param current ¸½ºß¤Î¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥óÃÍ
+ * @return ¼¡¤Î¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥óÃÍ
+ */
 static s16b toggle_frequency(s16b current)
 {
        switch (current)
@@ -1759,8 +1893,10 @@ static s16b toggle_frequency(s16b current)
 }
 
 
-/*
- * Interact with some options for cheating
+/*!
+ * @brief ¼«Æ°¥»¡¼¥Ö¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
+ * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
+ * @return ¤Ê¤·
  */
 static void do_cmd_options_autosave(cptr info)
 {
@@ -1901,8 +2037,12 @@ static void do_cmd_options_autosave(cptr info)
 }
 
 
-/*
+/*!
+ * @brief É¸½à¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
  * Interact with some options
+ * @param page ¥ª¥×¥·¥ç¥ó¥Ú¡¼¥¸ÈÖ¹æ
+ * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
+ * @return ¤Ê¤·
  */
 void do_cmd_options_aux(int page, cptr info)
 {
@@ -2064,8 +2204,10 @@ void do_cmd_options_aux(int page, cptr info)
 }
 
 
-/*
+/*!
+ * @brief ¥¦¥£¥ó¥É¥¦¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Modify the "window" options
+ * @return ¤Ê¤·
  */
 static void do_cmd_options_win(void)
 {
@@ -2260,17 +2402,71 @@ static void do_cmd_options_win(void)
 
 
 
+#define OPT_NUM 15
 
-/*
+static struct opts
+{
+       char key;
+       cptr name;
+       int row;
+}
+option_fields[OPT_NUM] =
+{
+#ifdef JP
+       { '1', "    ¥­¡¼ÆþÎÏ     ¥ª¥×¥·¥ç¥ó", 3 },
+       { '2', "   ¥Þ¥Ã¥×²èÌÌ    ¥ª¥×¥·¥ç¥ó", 4 },
+       { '3', "  ¥Æ¥­¥¹¥Èɽ¼¨   ¥ª¥×¥·¥ç¥ó", 5 },
+       { '4', "  ¥²¡¼¥à¥×¥ì¥¤   ¥ª¥×¥·¥ç¥ó", 6 },
+       { '5', "  ¹ÔÆ°Ãæ»ß´Ø·¸   ¥ª¥×¥·¥ç¥ó", 7 },
+       { '6', "  ´Ê°×¼«Æ°Ç˲õ   ¥ª¥×¥·¥ç¥ó", 8 },
+       { 'r', "   ¥×¥ì¥¤µ­Ï¿    ¥ª¥×¥·¥ç¥ó", 9 },
+
+       { 'p', "¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿", 11 },
+       { 'd', " ´ðËÜ¥¦¥§¥¤¥ÈÎÌ ", 12 },
+       { 'h', "Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È", 13 },
+       { 'm', "  ÄãËâÎÏ¿§ïçÃÍ  ", 14 },
+       { 'a', "   ¼«Æ°¥»¡¼¥Ö    ¥ª¥×¥·¥ç¥ó", 15 },
+       { 'w', "¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 16 },
+
+       { 'b', "      ½é´ü       ¥ª¥×¥·¥ç¥ó (»²¾È¤Î¤ß)", 18 },
+       { 'c', "      º¾µ½       ¥ª¥×¥·¥ç¥ó", 19 },
+#else
+       { '1', "Input Options", 3 },
+       { '2', "Map Screen Options", 4 },
+       { '3', "Text Display Options", 5 },
+       { '4', "Game-Play Options", 6 },
+       { '5', "Disturbance Options", 7 },
+       { '6', "Easy Auto-Destroyer Options", 8 },
+       { 'r', "Play record Options", 9 },
+
+       { 'p', "Auto-picker/destroyer editor", 11 },
+       { 'd', "Base Delay Factor", 12 },
+       { 'h', "Hitpoint Warning", 13 },
+       { 'm', "Mana Color Threshold", 14 },
+       { 'a', "Autosave Options", 15 },
+       { 'w', "Window Flags", 16 },
+
+       { 'b', "Birth Options (Browse Only)", 18 },
+       { 'c', "Cheat Options", 19 },
+#endif
+};
+
+
+/*!
+ * @brief É¸½à¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Set or unset various options.
- *
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * The user must use the "Ctrl-R" command to "adapt" to changes
  * in any options which control "visual" aspects of the game.
+ * </pre>
  */
 void do_cmd_options(void)
 {
-       int k;
-
+       char k;
+       int i, d, skey;
+       int y = 0;
 
        /* Save the screen */
        screen_save();
@@ -2278,6 +2474,11 @@ void do_cmd_options(void)
        /* Interact */
        while (1)
        {
+               int n = OPT_NUM;
+
+               /* Does not list cheat option when cheat option is off */
+               if (!p_ptr->noscore && !allow_debug_opts) n--;
+
                /* Clear screen */
                Term_clear();
 
@@ -2285,87 +2486,58 @@ void do_cmd_options(void)
 #ifdef JP
                prt("[ ¥ª¥×¥·¥ç¥ó¤ÎÀßÄê ]", 1, 0);
 #else
-               prt("Options", 1, 0);
+               prt("TinyAngband options", 1, 0);
 #endif
 
-
-               /* Give some choices */
-#ifdef JP
-               prt("(1)      ¥­¡¼ÆþÎÏ        ¥ª¥×¥·¥ç¥ó", 2, 5);
-               prt("(2)     ¥Þ¥Ã¥×²èÌÌ       ¥ª¥×¥·¥ç¥ó", 3, 5);
-               prt("(3)    ¥Æ¥­¥¹¥Èɽ¼¨      ¥ª¥×¥·¥ç¥ó", 4, 5);
-               prt("(4)    ¥²¡¼¥à¥×¥ì¥¤      ¥ª¥×¥·¥ç¥ó", 5, 5);
-               prt("(5)    ¹ÔÆ°Ãæ»ß´Ø·¸      ¥ª¥×¥·¥ç¥ó", 6, 5);
-               prt("(6)    ´Ê°×¼«Æ°Ç˲õ      ¥ª¥×¥·¥ç¥ó", 7, 5);
-               prt("(R)     ¥×¥ì¥¤µ­Ï¿       ¥ª¥×¥·¥ç¥ó", 8, 5);
-
-               /* Special choices */
-               prt("(P)  ¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿", 10, 5);
-               prt("(D)   ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 11, 5);
-               prt("(H) Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 12, 5);
-               prt("(M)    ÄãËâÎÏ¿§ïçÃÍ", 13, 5);
-               prt("(A)     ¼«Æ°¥»¡¼¥Ö       ¥ª¥×¥·¥ç¥ó", 14, 5);
-               /* Window flags */
-               prt("(W)  ¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 15, 5);
-#else
-               prt("(1) Input Options", 2, 5);
-               prt("(2) Map Screen Options", 3, 5);
-               prt("(3) Text Display Options", 4, 5);
-               prt("(4) Game-Play Options", 5, 5);
-               prt("(5) Disturbance Options", 6, 5);
-               prt("(6) Easy Auto-Destroyer Options", 7, 5);
-               prt("(R) Play-record Options", 8, 5);
-               /* Special choices */
-               prt("(P) Auto-picker/destroyer editor", 10, 5);
-               prt("(D) Base Delay Factor", 11, 5);
-               prt("(H) Hitpoint Warning", 12, 5);
-               prt("(M) Mana Color Threshold", 13, 5);
-               prt("(A) Autosave Options", 14, 5);
-               /* Window flags */
-               prt("(W) Window Flags", 15, 5);
-#endif
-
-               if (!p_ptr->wizard || !allow_debug_opts)
-               {
-                       /* Birth */
-#ifdef JP
-                       prt("(B)        ½é´ü          ¥ª¥×¥·¥ç¥ó (»²¾È¤Î¤ß)", 16, 5);
-#else
-                       prt("(B) Birth Options (Browse Only)", 16, 5);
-#endif
-               }
-               else
+               while(1)
                {
-                       /* Birth */
+                       /* Give some choices */
+                       for (i = 0; i < n; i++)
+                       {
+                               byte a = TERM_WHITE;
+                               if (i == y) a = TERM_L_BLUE;
+                               Term_putstr(5, option_fields[i].row, -1, a, 
+                                       format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
+                       }
+
 #ifdef JP
-                       prt("(B)        ½é´ü          ¥ª¥×¥·¥ç¥ó", 16, 5);
+                       prt("<Êý¸þ>¤Ç°ÜÆ°, Enter¤Ç·èÄê, ESC¤Ç¥­¥ã¥ó¥»¥ë, ?¤Ç¥Ø¥ë¥×: ", 21, 0);
 #else
-                       prt("(B) Birth Options", 16, 5);
+                       prt("Move to <dir>, Select to Enter, Cancel to ESC, ? to help: ", 21, 0);
 #endif
-               }
 
+                       /* Get command */
+                       skey = inkey_special(TRUE);
+                       if (!(skey & SKEY_MASK)) k = (char)skey;
+                       else k = 0;
 
-               if (p_ptr->noscore || allow_debug_opts)
-               {
-                       /* Cheating */
-#ifdef JP
-                       prt("(C)        º¾µ½          ¥ª¥×¥·¥ç¥ó", 17, 5);
-#else
-                       prt("(C) Cheating Options", 17, 5);
-#endif
-               }
+                       /* Exit */
+                       if (k == ESCAPE) break;
 
+                       if (my_strchr("\n\r ", k))
+                       {
+                               k = option_fields[y].key;
+                               break;
+                       }
 
-               /* Prompt */
-#ifdef JP
-               prt("¥³¥Þ¥ó¥É:", 19, 0);
-#else
-               prt("Command: ", 19, 0);
-#endif
+                       for (i = 0; i < n; i++)
+                       {
+                               if (tolower(k) == option_fields[i].key) break;
+                       }
 
+                       /* Command is found */
+                       if (i < n) break;
 
-               /* Get command */
-               k = inkey();
+                       /* Hack -- browse help */
+                       if (k == '?') break;
+
+                       /* Move cursor */
+                       d = 0;
+                       if (skey == SKEY_UP) d = 8;
+                       if (skey == SKEY_DOWN) d = 2;
+                       y = (y + ddy[d] + n) % n;
+                       if (!d) bell();
+               }
 
                /* Exit */
                if (k == ESCAPE) break;
@@ -2381,7 +2553,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_INPUT, "Input Options");
 #endif
-
                                break;
                        }
 
@@ -2393,7 +2564,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "Map Screen Options");
 #endif
-
                                break;
                        }
 
@@ -2405,7 +2575,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_TEXT, "Text Display Options");
 #endif
-
                                break;
                        }
 
@@ -2417,7 +2586,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "Game-Play Options");
 #endif
-
                                break;
                        }
 
@@ -2429,7 +2597,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "Disturbance Options");
 #endif
-
                                break;
                        }
 
@@ -2467,7 +2634,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "Birth Options(browse only)" : "Birth Options((*)s effect score)");
 #endif
-
                                break;
                        }
 
@@ -2487,7 +2653,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_cheat("Cheaters never win");
 #endif
-
                                break;
                        }
 
@@ -2499,7 +2664,6 @@ void do_cmd_options(void)
 #else
                                do_cmd_options_autosave("Autosave");
 #endif
-
                                break;
                        }
 
@@ -2511,8 +2675,9 @@ void do_cmd_options(void)
                                do_cmd_options_win();
                                p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL |
                                                  PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
-                                                 PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
-                                                 PW_BORG_1 | PW_BORG_2 | PW_DUNGEON);
+                                                       PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
+                                                       PW_BORG_1 | PW_BORG_2 | PW_DUNGEON   |
+                                                       PW_MONSTER_LIST);
                                break;
                        }
 
@@ -2529,13 +2694,13 @@ void do_cmd_options(void)
                        case 'd':
                        {
                                /* Prompt */
+                               clear_from(18);
 #ifdef JP
                                prt("¥³¥Þ¥ó¥É: ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 19, 0);
 #else
                                prt("Command: Base Delay Factor", 19, 0);
 #endif
 
-
                                /* Get a new value */
                                while (1)
                                {
@@ -2577,13 +2742,13 @@ void do_cmd_options(void)
                        case 'h':
                        {
                                /* Prompt */
+                               clear_from(18);
 #ifdef JP
                                prt("¥³¥Þ¥ó¥É: Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 19, 0);
 #else
                                prt("Command: Hitpoint Warning", 19, 0);
 #endif
 
-
                                /* Get a new value */
                                while (1)
                                {
@@ -2624,13 +2789,13 @@ void do_cmd_options(void)
                        case 'm':
                        {
                                /* Prompt */
+                               clear_from(18);
 #ifdef JP
                                prt("¥³¥Þ¥ó¥É: ÄãËâÎÏ¿§ïçÃÍ", 19, 0);
 #else
                                prt("Command: Mana Color Threshold", 19, 0);
 #endif
 
-
                                /* Get a new value */
                                while (1)
                                {
@@ -2698,9 +2863,11 @@ void do_cmd_options(void)
 
 
 
-/*
+/*!
+ * @brief pref¥Õ¥¡¥¤¥ë¤òÁªÂò¤·¤Æ½èÍý¤¹¤ë /
  * Ask for a "user pref line" and process it
- *
+ * @return ¤Ê¤·
+ * @details
  * XXX XXX XXX Allow absolute file names?
  */
 void do_cmd_pref(void)
@@ -2722,6 +2889,10 @@ void do_cmd_pref(void)
        (void)process_pref_file_command(buf);
 }
 
+/*!
+ * @brief ¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * @return ¤Ê¤·
+ */
 void do_cmd_reload_autopick(void)
 {
 #ifdef JP
@@ -2736,8 +2907,10 @@ void do_cmd_reload_autopick(void)
 
 #ifdef ALLOW_MACROS
 
-/*
- * Hack -- append all current macros to the given file
+/*!
+ * @brief ¥Þ¥¯¥í¾ðÊó¤òpref¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë /
+ * @param fname ¥Õ¥¡¥¤¥ë̾
+ * @return ¤Ê¤·
  */
 static errr macro_dump(cptr fname)
 {
@@ -2790,12 +2963,17 @@ static errr macro_dump(cptr fname)
 }
 
 
-/*
+/*!
+ * @brief ¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¥­¡¼¤ò¼èÆÀ¤¹¤ë /
  * Hack -- ask for a "trigger" (see below)
- *
+ * @param buf ¥­¡¼É½µ­¤òÊݴɤ¹¤ë¥Ð¥Ã¥Õ¥¡
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Note the complex use of the "inkey()" function from "util.c".
  *
  * Note that both "flush()" calls are extremely important.
+ * </pre>
  */
 static void do_cmd_macro_aux(char *buf)
 {
@@ -2845,12 +3023,16 @@ static void do_cmd_macro_aux(char *buf)
 
 #endif
 
-
-/*
+/*!
+ * @brief ¥Þ¥¯¥í¤Î¥­¡¼É½µ­¤«¤é¥¢¥¹¥­¡¼¥³¡¼¥É¤òÆÀ¤Æ¥¿¡¼¥ß¥Ê¥ë¤Ëɽ¼¨¤¹¤ë /
  * Hack -- ask for a keymap "trigger" (see below)
- *
+ * @param buf ¥­¡¼É½µ­¤ò¼èÆÀ¤¹¤ë¥Ð¥Ã¥Õ¥¡
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Note that both "flush()" calls are extremely important.  This may
  * no longer be true, since "util.c" is much simpler now.  XXX XXX XXX
+ * </pre>
  */
 static void do_cmd_macro_aux_keymap(char *buf)
 {
@@ -2878,8 +3060,12 @@ static void do_cmd_macro_aux_keymap(char *buf)
 }
 
 
-/*
+/*!
+ * @brief ¥­¡¼¥Þ¥Ã¥×¤òpref¥Õ¥¡¥¤¥ë¤Ë¥À¥ó¥×¤¹¤ë /
  * Hack -- append all keymaps to the given file
+ * @param fname ¥Õ¥¡¥¤¥ë¥Í¡¼¥à
+ * @return ¥¨¥é¡¼¥³¡¼¥É
+ * @details
  */
 static errr keymap_dump(cptr fname)
 {
@@ -2952,13 +3138,16 @@ static errr keymap_dump(cptr fname)
 }
 
 
-
-/*
+/*!
+ * @brief ¥Þ¥¯¥í¤òÀßÄꤹ¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Interact with "macros"
- *
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Note that the macro "action" must be defined before the trigger.
  *
  * Could use some helpful instructions on this page.  XXX XXX XXX
+ * </pre>
  */
 void do_cmd_macros(void)
 {
@@ -3008,7 +3197,7 @@ void do_cmd_macros(void)
 
                /* Describe that action */
 #ifdef JP
-               prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
+               prt("¥Þ¥¯¥í¹ÔÆ°¤¬(¤â¤·¤¢¤ì¤Ð)²¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹:", 20, 0);
 #else
                prt("Current action (if any) shown below:", 20, 0);
 #endif
@@ -3089,7 +3278,7 @@ void do_cmd_macros(void)
 
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Ask for a file */
                        if (!askfor(tmp, 80)) continue;
@@ -3145,7 +3334,7 @@ void do_cmd_macros(void)
 
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Ask for a file */
                        if (!askfor(tmp, 80)) continue;
@@ -3339,7 +3528,7 @@ void do_cmd_macros(void)
 
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Ask for a file */
                        if (!askfor(tmp, 80)) continue;
@@ -3615,7 +3804,7 @@ static bool cmd_visuals_aux(int i, int *num, int max)
 static void print_visuals_menu(cptr choice_msg)
 {
 #ifdef JP
-       prt("²èÌÌɽ¼¨¤ÎÀßÄê", 1, 0);
+       prt("[ ²èÌÌɽ¼¨¤ÎÀßÄê ]", 1, 0);
 #else
        prt("Interact with Visuals", 1, 0);
 #endif
@@ -3723,7 +3912,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Query */
                        if (!askfor(tmp, 70)) continue;
@@ -3756,7 +3945,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Get a filename */
                        if (!askfor(tmp, 70)) continue;
@@ -3775,7 +3964,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Dump monsters */
-                       for (i = 1; i < max_r_idx; i++)
+                       for (i = 0; i < max_r_idx; i++)
                        {
                                monster_race *r_ptr = &r_info[i];
 
@@ -3823,7 +4012,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Get a filename */
                        if (!askfor(tmp, 70)) continue;
@@ -3842,7 +4031,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Dump objects */
-                       for (i = 1; i < max_k_idx; i++)
+                       for (i = 0; i < max_k_idx; i++)
                        {
                                char o_name[80];
                                object_kind *k_ptr = &k_info[i];
@@ -3850,11 +4039,21 @@ void do_cmd_visuals(void)
                                /* Skip non-entries */
                                if (!k_ptr->name) continue;
 
-                               /* Skip entries with flavor */
-                               if (k_ptr->flavor) continue;
+                               if (!k_ptr->flavor)
+                               {
+                                       /* Tidy name */
+                                       strip_name(o_name, i);
+                               }
+                               else
+                               {
+                                       object_type forge;
+
+                                       /* Prepare dummy object */
+                                       object_prep(&forge, i);
 
-                               /* Tidy name */
-                               strip_name(o_name, i);
+                                       /* Get un-shuffled flavor name */
+                                       object_desc(o_name, &forge, OD_FORCE_FLAVOR);
+                               }
 
                                /* Dump a comment */
                                auto_dump_printf("# %s\n", o_name);
@@ -3897,7 +4096,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Get a filename */
                        if (!askfor(tmp, 70)) continue;
@@ -3916,7 +4115,7 @@ void do_cmd_visuals(void)
 #endif
 
                        /* Dump features */
-                       for (i = 1; i < max_f_idx; i++)
+                       for (i = 0; i < max_f_idx; i++)
                        {
                                feature_type *f_ptr = &f_info[i];
 
@@ -4104,11 +4303,11 @@ void do_cmd_visuals(void)
 #ifdef JP
                                Term_putstr(5, 17, -1, TERM_WHITE,
                                            format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
-                                                  k, (k_name + k_ptr->name)));
+                                                  k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
 #else
                                Term_putstr(5, 17, -1, TERM_WHITE,
                                            format("Object = %d, Name = %-40.40s",
-                                                  k, (k_name + k_ptr->name)));
+                                                  k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
 #endif
 
                                /* Label the Default values */
@@ -4167,7 +4366,7 @@ void do_cmd_visuals(void)
                                                                break;
                                                        }
                                                }
-                                               while (!k_info[k].name || k_info[k].flavor);
+                                               while (!k_info[k].name);
                                        }
                                        break;
                                case 'a':
@@ -4467,7 +4666,7 @@ void do_cmd_colors(void)
 
 
                        /* Default file */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Query */
                        if (!askfor(tmp, 70)) continue;
@@ -4506,7 +4705,7 @@ void do_cmd_colors(void)
 
 
                        /* Default filename */
-                       sprintf(tmp, "%s.prf", player_name);
+                       sprintf(tmp, "%s.prf", player_base);
 
                        /* Get a filename */
                        if (!askfor(tmp, 70)) continue;
@@ -4909,9 +5108,6 @@ static cptr do_cmd_feeling_text_lucky[11] =
  */
 void do_cmd_feeling(void)
 {
-       /* Verify the feeling */
-       if (feeling > 10) feeling = 10;
-
        /* No useful feeling in quests */
        if (p_ptr->inside_quest && !random_quest_number(dun_level))
        {
@@ -4966,20 +5162,13 @@ void do_cmd_feeling(void)
        }
 
        /* Display the feeling */
-       if (turn - old_turn >= (150 - dun_level)*TURNS_PER_TICK || cheat_xtra)
-       {
-               if (p_ptr->muta3 & MUT3_GOOD_LUCK) msg_print(do_cmd_feeling_text_lucky[feeling]);
-               else {
-                                       if((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)){
-                                               msg_print(do_cmd_feeling_text_combat[feeling]);
-                                       }else
-                                               msg_print(do_cmd_feeling_text[feeling]);
-                               }
-       }
+       if (p_ptr->muta3 & MUT3_GOOD_LUCK)
+               msg_print(do_cmd_feeling_text_lucky[p_ptr->feeling]);
+       else if (p_ptr->pseikaku == SEIKAKU_COMBAT ||
+                inventory[INVEN_BOW].name1 == ART_CRIMSON)
+               msg_print(do_cmd_feeling_text_combat[p_ptr->feeling]);
        else
-       {
-               msg_print(do_cmd_feeling_text[0]);
-       }
+               msg_print(do_cmd_feeling_text[p_ptr->feeling]);
 }
 
 
@@ -4992,6 +5181,8 @@ static cptr monster_group_text[] =
 #ifdef JP
        "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
        "¾èÇϲÄǽ¤Ê¥â¥ó¥¹¥¿¡¼", /* "Riding" */
+       "¾Þ¶â¼ó", /* "Wanted */
+       "¥¢¥ó¥Ð¡¼¤Î²¦Â²", /* "Ambertite" */
        "¥¢¥ê",
        "¥³¥¦¥â¥ê",
        "¥à¥«¥Ç",
@@ -5051,6 +5242,8 @@ static cptr monster_group_text[] =
 #else
        "Uniques",
        "Ridable monsters",
+       "Wanted monsters",
+       "Ambertite",
        "Ant",
        "Bat",
        "Centipede",
@@ -5120,6 +5313,8 @@ static cptr monster_group_char[] =
 {
        (char *) -1L,
        (char *) -2L,
+       (char *) -3L,
+       (char *) -4L,
        "a",
        "b",
        "c",
@@ -5225,6 +5420,13 @@ static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
        /* 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++)
        {
@@ -5247,6 +5449,27 @@ static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
                        if (!(r_ptr->flags7 & RF7_RIDING)) continue;
                }
 
+               else if (grp_wanted)
+               {
+                       bool wanted = FALSE;
+                       int j;
+                       for (j = 0; j < MAX_KUBI; j++)
+                       {
+                               if (kubi_r_idx[j] == i || kubi_r_idx[j] - 10000 == i ||
+                                       (p_ptr->today_mon && p_ptr->today_mon == i))
+                               {
+                                       wanted = TRUE;
+                                       break;
+                               }
+                       }
+                       if (!wanted) continue;
+               }
+
+               else if (grp_amberite)
+               {
+                       if (!(r_ptr->flags3 & RF3_AMBERITE)) continue;
+               }
+
                else
                {
                        /* Check for race in the group */
@@ -5302,6 +5525,7 @@ static cptr object_group_text[] =
        "¥´¥ß",
        "¶õ¤Î¥Ó¥ó",
        "¹ü",
+       "»àÂÎ",
        "Åá·õÎà",       /* "Swords" */
        "Æß´ï",         /* "Blunt Weapons" */
        "ĹÊÁÉð´ï",     /* "Polearms" */
@@ -5320,6 +5544,7 @@ static cptr object_group_text[] =
        "´§",   /* "Crowns" */
        "¥Ö¡¼¥Ä",       /* "Boots" */
        "ËâË¡½ñ",
+       "ºâÊõ",
        "²¿¤«",
 #else
        "Mushrooms",
@@ -5343,6 +5568,7 @@ static cptr object_group_text[] =
        "Junks",
        "Bottles",
        "Skeletons",
+       "Corpses",
        "Swords",
        "Blunt Weapons",
        "Polearms",
@@ -5361,6 +5587,7 @@ static cptr object_group_text[] =
        "Crowns",
        "Boots",
        "Spellbooks",
+       "Treasure",
        "Something",
 #endif
        NULL
@@ -5393,6 +5620,7 @@ static byte object_group_tval[] =
        TV_JUNK,
        TV_BOTTLE,
        TV_SKELETON,
+       TV_CORPSE,
        TV_SWORD,
        TV_HAFTED,
        TV_POLEARM,
@@ -5411,6 +5639,7 @@ static byte object_group_tval[] =
        TV_CROWN,
        TV_BOOTS,
        TV_LIFE_BOOK, /* Hack -- all spellbooks */
+       TV_GOLD,
        0,
        0,
 };
@@ -5441,7 +5670,7 @@ static int collect_objects(int grp_cur, int object_idx[], byte mode)
 
                if (mode & 0x02)
                {
-                       if (k_ptr->flavor) continue;
+                       /* Any objects will be displayed */
                }
                else
                {
@@ -5463,7 +5692,7 @@ static int collect_objects(int grp_cur, int object_idx[], byte mode)
                if (TV_LIFE_BOOK == group_tval)
                {
                        /* Hack -- All spell books */
-                       if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HISSATSU_BOOK)
+                       if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HEX_BOOK)
                        {
                                /* Add the object */
                                object_idx[object_cnt++] = i;
@@ -5820,11 +6049,11 @@ static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, int *j, by
                        print_flag(TR_RES_CONF);
                        print_flag(TR_FREE_ACT);
                        print_flag(TR_SEE_INVIS);
-                       print_flag(TR_HOLD_LIFE);
+                       print_flag(TR_HOLD_EXP);
                        print_flag(TR_TELEPATHY);
                        print_flag(TR_SLOW_DIGEST);
                        print_flag(TR_REGEN);
-                       print_flag(TR_FEATHER);
+                       print_flag(TR_LEVITATION);
 
                        fputc('\n', fff);
                }
@@ -5987,7 +6216,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        tmpfff = my_fopen(buf, "r");
        if (!tmpfff) {
                for (i = 0; html_head[i]; i++)
-                       fprintf(fff, html_head[i]);
+                       fputs(html_head[i], fff);
        }
        else {
                yomikomu = 0;
@@ -6049,7 +6278,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 
        if (!tmpfff) {
                for (i = 0; html_foot[i]; i++)
-                       fprintf(fff, html_foot[i]);
+                       fputs(html_foot[i], fff);
        }
        else {
                rewind(tmpfff);
@@ -6562,6 +6791,7 @@ static void do_cmd_knowledge_artifacts(void)
 
 /*
  * Display known uniques
+ * With "XTRA HACK UNIQHIST" (Originally from XAngband)
  */
 static void do_cmd_knowledge_uniques(void)
 {
@@ -6573,10 +6803,19 @@ static void do_cmd_knowledge_uniques(void)
 
        char file_name[1024];
 
+       int n_alive[10];
+       int n_alive_surface = 0;
+       int n_alive_over100 = 0;
+       int n_alive_total = 0;
+       int max_lev = -1;
+
+       for (i = 0; i < 10; i++) n_alive[i] = 0;
+
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
 
-       if (!fff) {
+       if (!fff)
+       {
 #ifdef JP
            msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
 #else
@@ -6593,9 +6832,36 @@ static void do_cmd_knowledge_uniques(void)
        for (i = 1; i < max_r_idx; i++)
        {
                monster_race *r_ptr = &r_info[i];
+               int          lev;
 
-               /* Use that monster */
-               if (r_ptr->name) who[n++] = i;
+               if (!r_ptr->name) continue;
+
+               /* Require unique monsters */
+               if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
+
+               /* Only display "known" uniques */
+               if (!cheat_know && !r_ptr->r_sights) continue;
+
+               /* Only print rarity <= 100 uniques */
+               if (!r_ptr->rarity || ((r_ptr->rarity > 100) && !(r_ptr->flags1 & RF1_QUESTOR))) continue;
+
+               /* Only "alive" uniques */
+               if (r_ptr->max_num == 0) continue;
+
+               if (r_ptr->level)
+               {
+                       lev = (r_ptr->level - 1) / 10;
+                       if (lev < 10)
+                       {
+                               n_alive[lev]++;
+                               if (max_lev < lev) max_lev = lev;
+                       }
+                       else n_alive_over100++;
+               }
+               else n_alive_surface++;
+
+               /* Collect "appropriate" monsters */
+               who[n++] = i;
        }
 
        /* Select the sort method */
@@ -6605,32 +6871,64 @@ static void do_cmd_knowledge_uniques(void)
        /* Sort the array by dungeon depth of monsters */
        ang_sort(who, &why, n);
 
+       if (n_alive_surface)
+       {
+#ifdef JP
+               fprintf(fff, "     ÃϾ堠À¸Â¸: %3dÂÎ\n", n_alive_surface);
+#else
+               fprintf(fff, "      Surface  alive: %3d\n", n_alive_surface);
+#endif
+               n_alive_total += n_alive_surface;
+       }
+       for (i = 0; i <= max_lev; i++)
+       {
+#ifdef JP
+               fprintf(fff, "%3d-%3d³¬  À¸Â¸: %3dÂÎ\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
+#else
+               fprintf(fff, "Level %3d-%3d  alive: %3d\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
+#endif
+               n_alive_total += n_alive[i];
+       }
+       if (n_alive_over100)
+       {
+#ifdef JP
+               fprintf(fff, "101-   ³¬  À¸Â¸: %3dÂÎ\n", n_alive_over100);
+#else
+               fprintf(fff, "Level 101-     alive: %3d\n", n_alive_over100);
+#endif
+               n_alive_total += n_alive_over100;
+       }
+
+       if (n_alive_total)
+       {
+#ifdef JP
+               fputs("---------  -----------\n", fff);
+               fprintf(fff, "     ¹ç·×  À¸Â¸: %3dÂÎ\n\n", n_alive_total);
+#else
+               fputs("-------------  ----------\n", fff);
+               fprintf(fff, "        Total  alive: %3d\n\n", n_alive_total);
+#endif
+       }
+       else
+       {
+#ifdef JP
+               fputs("¸½ºß¤Ï´ûÃΤÎÀ¸Â¸¥æ¥Ë¡¼¥¯¤Ï¤¤¤Þ¤»¤ó¡£\n", fff);
+#else
+               fputs("No known uniques alive.\n", fff);
+#endif
+       }
+
        /* Scan the monster races */
        for (k = 0; k < n; k++)
        {
                monster_race *r_ptr = &r_info[who[k]];
 
-               /* Only print Uniques */
-               if (r_ptr->flags1 & (RF1_UNIQUE))
-               {
-                       bool dead = (r_ptr->max_num == 0);
-
-                       if (dead) continue;
-
-                       /* Only display "known" uniques */
-                       if (dead || cheat_know || r_ptr->r_sights)
-                       {
-                               /* Print a message */
+               /* Print a message */
 #ifdef JP
-                               fprintf(fff, "     %s¤Ï¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¡£\n",
-                                       (r_name + r_ptr->name));
+               fprintf(fff, "     %s (¥ì¥Ù¥ë%d)\n", r_name + r_ptr->name, r_ptr->level);
 #else
-                               fprintf(fff, "     %s is alive\n",
-                                       (r_name + r_ptr->name));
+               fprintf(fff, "     %s (level %d)\n", r_name + r_ptr->name, r_ptr->level);
 #endif
-
-                       }
-               }
        }
 
        /* Free the "who" array */
@@ -6718,15 +7016,17 @@ static void do_cmd_knowledge_weapon_exp(void)
 }
 
 
-/*
+/*!
+ * @brief ËâË¡¤Î·Ð¸³Ãͤòɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
  * Display spell-exp
+ * @return ¤Ê¤·
  */
 static void do_cmd_knowledge_spell_exp(void)
 {
        int i = 0, spell_exp, exp_level;
 
        FILE *fff;
-       magic_type *s_ptr;
+       const magic_type *s_ptr;
 
        char file_name[1024];
 
@@ -6762,7 +7062,7 @@ static void do_cmd_knowledge_spell_exp(void)
                        if (s_ptr->slevel >= 99) continue;
                        spell_exp = p_ptr->spell_exp[i];
                        exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", spell_names[technic2magic(p_ptr->realm1) - 1][i]);
+                       fprintf(fff, "%-25s ", do_spell(p_ptr->realm1, i, SPELL_NAME));
                        if (p_ptr->realm1 == REALM_HISSATSU)
                                fprintf(fff, "[--]");
                        else
@@ -6797,7 +7097,7 @@ static void do_cmd_knowledge_spell_exp(void)
 
                        spell_exp = p_ptr->spell_exp[i + 32];
                        exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", spell_names[technic2magic(p_ptr->realm2) - 1][i]);
+                       fprintf(fff, "%-25s ", do_spell(p_ptr->realm2, i, SPELL_NAME));
                        if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
                        else fprintf(fff, " ");
                        fprintf(fff, "%s", exp_level_str[exp_level]);
@@ -6822,8 +7122,10 @@ static void do_cmd_knowledge_spell_exp(void)
 }
 
 
-/*
+/*!
+ * @brief ¥¹¥­¥ë¾ðÊó¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Display skill-exp
+ * @return ¤Ê¤·
  */
 static void do_cmd_knowledge_skill_exp(void)
 {
@@ -6877,8 +7179,10 @@ static void do_cmd_knowledge_skill_exp(void)
 }
 
 
-/*
- * Pluralize a monster name
+/*!
+ * @brief ±Ññ¸ì¡¢¶ç¡¢Àâ¤òÊ£¿ô·Á¤òÊÑ´¹¤¹¤ë / Pluralize a monster name
+ * @param Name ÊÑ´¹¤·¤¿¤¤Ê¸»úÎó¤Î»²¾È¥Ý¥¤¥ó¥¿
+ * @return ¤Ê¤·
  */
 void plural_aux(char *Name)
 {
@@ -7000,8 +7304,10 @@ void plural_aux(char *Name)
        }
 }
 
-/*
+/*!
+ * @brief ¸½ºß¤Î¥Ú¥Ã¥È¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Display current pets
+ * @return ¤Ê¤·
  */
 static void do_cmd_knowledge_pets(void)
 {
@@ -7048,7 +7354,7 @@ static void do_cmd_knowledge_pets(void)
 
        fprintf(fff, "----------------------------------------------\n");
 #ifdef JP
-       fprintf(fff, "    ¹ç·×: %d ɤ¤Î¥Ú¥Ã¥È\n", t_friends);
+       fprintf(fff, "    ¹ç·×: %d ÂΤΥڥåÈ\n", t_friends);
        fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
 #else
        fprintf(fff, "   Total: %d pet%s.\n",
@@ -7074,10 +7380,11 @@ static void do_cmd_knowledge_pets(void)
 }
 
 
-/*
+/*!
+ * @brief ¸½ºß¤Î¥Ú¥Ã¥È¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Total kill count
- *
- * Note that the player ghosts are ignored.  XXX XXX XXX
+ * @return ¤Ê¤·
+ * @note the player ghosts are ignored.  XXX XXX XXX
  */
 static void do_cmd_knowledge_kill_count(void)
 {
@@ -7142,21 +7449,12 @@ static void do_cmd_knowledge_kill_count(void)
 #else
                        fprintf(fff,"You have defeated no enemies yet.\n\n");
 #endif
-
-               else if (Total == 1)
-#ifdef JP
-                       fprintf(fff,"¤¢¤Ê¤¿¤Ï°ìɤ¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n");
-#else
-                       fprintf(fff,"You have defeated one enemy.\n\n");
-#endif
-
                else
 #ifdef JP
-                       fprintf(fff,"¤¢¤Ê¤¿¤Ï %lu É¤¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total);
+                       fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", (long int)Total);
 #else
-                       fprintf(fff,"You have defeated %lu enemies.\n\n", Total);
+                       fprintf(fff,"You have defeated %ld %s.\n\n", (long int)Total, (Total == 1) ? "enemy" : "enemies");
 #endif
-
        }
 
        Total = 0;
@@ -7201,11 +7499,11 @@ static void do_cmd_knowledge_kill_count(void)
                        if (This > 0)
                        {
 #ifdef JP
-                               /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
-                               if(my_strchr("pt",r_ptr->d_char))
+                               /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita */
+                               if (my_strchr("pt", r_ptr->d_char))
                                        fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
                                else
-                                       fprintf(fff, "     %3d ɤ¤Î %s\n", This, r_name + r_ptr->name);
+                                       fprintf(fff, "     %3d ÂΤΠ%s\n", This, r_name + r_ptr->name);
 #else
                                if (This < 2)
                                {
@@ -7235,10 +7533,10 @@ static void do_cmd_knowledge_kill_count(void)
 
        fprintf(fff,"----------------------------------------------\n");
 #ifdef JP
-       fprintf(fff,"    ¹ç·×: %lu É¤¤òÅݤ·¤¿¡£\n", Total);
+       fprintf(fff,"    ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", (unsigned long int)Total);
 #else
        fprintf(fff,"   Total: %lu creature%s killed.\n",
-               Total, (Total == 1 ? "" : "s"));
+               (unsigned long int)Total, (Total == 1 ? "" : "s"));
 #endif
 
 
@@ -7261,8 +7559,18 @@ static void do_cmd_knowledge_kill_count(void)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¾ðÊó¥ê¥¹¥ÈÃæ¤Î¥°¥ë¡¼¥×¤òɽ¼¨¤¹¤ë /
  * Display the object groups.
+ * @param col ³«»Ï¹Ô
+ * @param row ³«»ÏÎó
+ * @param wid É½¼¨Ê¸»ú¿ôÉý
+ * @param per_page ¥ê¥¹¥È¤Îɽ¼¨¹Ô
+ * @param grp_idx ¥°¥ë¡¼¥×¤ÎIDÇÛÎó
+ * @param group_text ¥°¥ë¡¼¥×̾¤Îʸ»úÎóÇÛÎó
+ * @param grp_cur ¸½ºß¤ÎÁªÂòID
+ * @param grp_top ¸½ºß¤ÎÁªÂò¥ê¥¹¥ÈºÇ¾åÉôID
+ * @return ¤Ê¤·
  */
 static void display_group_list(int col, int row, int wid, int per_page,
        int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
@@ -7552,7 +7860,7 @@ static bool visual_mode_command(char ch, bool *visual_list_ptr,
 
        case 'P':
        case 'p':
-               if (attr_idx || (!(char_idx & 0x80) && char_idx)) /* Allow ATTR_DARK text */
+               if (attr_idx || (!(char_idx & 0x80) && char_idx)) /* Allow TERM_DARK text */
                {
                        /* Set the char */
                        *cur_attr_ptr = attr_idx;
@@ -7777,8 +8085,8 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int d
                        if (direct_r_idx < 0) prt("Group", 4, 0);
                        prt("Name", 4, max + 3);
                        if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
-                       prt("Sym  ", 4, 67);
-                       if (!visual_only) prt(" Kills", 4, 72);
+                       prt("Sym", 4, 68);
+                       if (!visual_only) prt("Kills", 4, 73);
 #endif
 
                        for (i = 0; i < 78; i++)
@@ -7947,6 +8255,7 @@ static void display_object_list(int col, int row, int per_page, int object_idx[]
        {
                char o_name[80];
                byte a, c;
+               object_kind *flavor_k_ptr;
 
                /* Get the object index */
                int k_idx = object_idx[object_top + i];
@@ -7958,10 +8267,32 @@ static void display_object_list(int col, int row, int per_page, int object_idx[]
                byte 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 */
+                       flavor_k_ptr = &k_info[k_ptr->flavor];
+               }
+               else
+               {
+                       /* Appearance of this object is very normal */
+                       flavor_k_ptr = k_ptr;
+               }
+
+
+
                attr = ((i + object_top == object_cur) ? cursor : attr);
 
-               /* Tidy name */
-               strip_name(o_name, k_idx);
+               if (!k_ptr->flavor || (!visual_only && k_ptr->aware))
+               {
+                       /* Tidy name */
+                       strip_name(o_name, k_idx);
+               }
+               else
+               {
+                       /* Flavor name */
+                       strcpy(o_name, k_name + flavor_k_ptr->flavor_name);
+               }
 
                /* Display the name */
                c_prt(attr, o_name, row + i, col);
@@ -7969,22 +8300,15 @@ static void display_object_list(int col, int row, int per_page, int object_idx[]
                /* Hack -- visual_list mode */
                if (per_page == 1)
                {
-                       c_prt(attr, format("%02x/%02x", k_ptr->x_attr, k_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 64 : 68);
+                       c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 64 : 68);
                }
                if (p_ptr->wizard || visual_only)
                {
                        c_prt(attr, format("%d", k_idx), row + i, 70);
                }
 
-               a = k_ptr->flavor ? misc_to_attr[k_ptr->flavor] : k_ptr->x_attr;
-               c = k_ptr->flavor ? misc_to_char[k_ptr->flavor] : k_ptr->x_char;
-
-               /* Symbol is unknown */
-               if (!k_ptr->aware && !p_ptr->wizard)
-               {
-                       c = ' ';
-                       a = TERM_DARK;
-               }
+               a = flavor_k_ptr->x_attr;
+               c = flavor_k_ptr->x_char;
 
                /* Display symbol */
                Term_queue_bigchar(use_bigtile ? 76 : 77, row + i, a, c, 0, 0);
@@ -8026,7 +8350,7 @@ static void desc_obj_fake(int k_idx)
        /* Hack -- Handle stuff */
        handle_stuff();
 
-       if (!screen_object(o_ptr, FALSE))
+       if (!screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL))
        {
 #ifdef JP
                msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
@@ -8100,6 +8424,20 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
        }
        else
        {
+               object_kind *k_ptr = &k_info[direct_k_idx];
+               object_kind *flavor_k_ptr;
+
+               if (!visual_only && k_ptr->flavor)
+               {
+                       /* Appearance of this object is shuffled */
+                       flavor_k_ptr = &k_info[k_ptr->flavor];
+               }
+               else
+               {
+                       /* Appearance of this object is very normal */
+                       flavor_k_ptr = k_ptr;
+               }
+
                object_idx[0] = direct_k_idx;
                object_old = direct_k_idx;
                object_cnt = 1;
@@ -8108,7 +8446,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
                object_idx[1] = -1;
 
                (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
-                       &attr_top, &char_left, &k_info[direct_k_idx].x_attr, &k_info[direct_k_idx].x_char, need_redraw);
+                       &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw);
        }
 
        /* Terminate the list */
@@ -8126,7 +8464,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
        while (!flag)
        {
                char ch;
-               object_kind *k_ptr;
+               object_kind *k_ptr, *flavor_k_ptr;
 
                if (redraw)
                {
@@ -8205,17 +8543,28 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
                /* Get the current object */
                k_ptr = &k_info[object_idx[object_cur]];
 
+               if (!visual_only && k_ptr->flavor)
+               {
+                       /* Appearance of this object is shuffled */
+                       flavor_k_ptr = &k_info[k_ptr->flavor];
+               }
+               else
+               {
+                       /* Appearance of this object is very normal */
+                       flavor_k_ptr = k_ptr;
+               }
+
                /* Prompt */
 #ifdef JP
                prt(format("<Êý¸þ>%s%s%s, ESC",
                        (!visual_list && !visual_only) ? ", 'r'¤Ç¾ÜºÙ¤ò¸«¤ë" : "",
-                       k_ptr->flavor ? "" : visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
+                       visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
                        (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
                        hgt - 1, 0);
 #else
                prt(format("<dir>%s%s%s, ESC",
                        (!visual_list && !visual_only) ? ", 'r' to recall" : "",
-                       k_ptr->flavor ? "" : visual_list ? ", ENTER to accept" : ", 'v' for visuals",
+                       visual_list ? ", ENTER to accept" : ", 'v' for visuals",
                        (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
                        hgt - 1, 0);
 #endif
@@ -8238,7 +8587,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
 
                if (visual_list)
                {
-                       place_visual_list_cursor(max + 3, 7, k_ptr->x_attr, k_ptr->x_char, attr_top, char_left);
+                       place_visual_list_cursor(max + 3, 7, flavor_k_ptr->x_attr, flavor_k_ptr->x_char, attr_top, char_left);
                }
                else if (!column)
                {
@@ -8252,8 +8601,7 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int di
                ch = inkey();
 
                /* Do visual mode command if needed */
-               /* Symbol of objects with flavor cannot be changed */
-               if (!k_ptr->flavor && visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &k_ptr->x_attr, &k_ptr->x_char, need_redraw))
+               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))
                {
                        if (direct_k_idx >= 0)
                        {
@@ -8400,8 +8748,8 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int d
        byte char_old[F_LIT_MAX];
        byte *cur_attr_ptr, *cur_char_ptr;
 
-       C_WIPE(attr_old, F_LIT_MAX, byte);
-       C_WIPE(char_old, F_LIT_MAX, byte);
+       (void)C_WIPE(attr_old, F_LIT_MAX, byte);
+       (void)C_WIPE(char_old, F_LIT_MAX, byte);
 
        /* Get size */
        Term_get_size(&wid, &hgt);
@@ -8685,7 +9033,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int d
                        case 'p':
                                if (!visual_list)
                                {
-                                       /* Allow ATTR_DARK text */
+                                       /* Allow TERM_DARK text */
                                        for (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];
@@ -8983,7 +9331,9 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
 
        for (i = 1; i < max_quests; i++)
        {
-               if ((quest[i].status == QUEST_STATUS_TAKEN) || (quest[i].status == QUEST_STATUS_COMPLETED))
+               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 */
                        int old_quest = p_ptr->inside_quest;
@@ -9012,7 +9362,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                        {
                                char note[80] = "\0";
 
-                               if (quest[i].status == QUEST_STATUS_TAKEN)
+                               if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
                                {
                                        switch (quest[i].type)
                                        {
@@ -9040,19 +9390,28 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                                                break;
 
                                        case QUEST_TYPE_FIND_ARTIFACT:
-                                               strcpy(name, a_name + a_info[quest[i].k_idx].name);
+                                               if (quest[i].k_idx)
+                                               {
+                                                       artifact_type *a_ptr = &a_info[quest[i].k_idx];
+                                                       object_type forge;
+                                                       object_type *q_ptr = &forge;
+                                                       int 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);
+                                               }
 #ifdef JP
-                                               sprintf(note," - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
+                                               sprintf(note,"\n   - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
 #else
-                                               sprintf(note," - Find out %s.", name);
+                                               sprintf(note,"\n   - Find out %s.", name);
 #endif
                                                break;
-
                                        case QUEST_TYPE_FIND_EXIT:
 #ifdef JP
-                                               sprintf(note," - Ãµº÷¤¹¤ë¡£");
+                                               sprintf(note," - ½Ð¸ý¤ËÅþ㤹¤ë¡£");
 #else
-                                               sprintf(note," - Search.");
+                                               sprintf(note," - Reach to Exit.");
 #endif
                                                break;
 
@@ -9067,6 +9426,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                                                break;
 
                                        case QUEST_TYPE_KILL_ALL:
+                                       case QUEST_TYPE_TOWER:
 #ifdef JP
                                                sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
 #else
@@ -9085,7 +9445,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                                        quest[i].name, quest[i].level, note);
 #endif
 
-                               fprintf(fff, tmp_str);
+                               fputs(tmp_str, fff);
 
                                if (quest[i].status == QUEST_STATUS_COMPLETED)
                                {
@@ -9094,7 +9454,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
 #else
                                        sprintf(tmp_str, "    Quest Completed - Unrewarded\n");
 #endif
-                                       fprintf(fff, tmp_str);
+                                       fputs(tmp_str, fff);
                                }
                                else
                                {
@@ -9148,7 +9508,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
        }
 
        /* Print the current random quest  */
-       if (rand_tmp_str[0]) fprintf(fff, rand_tmp_str);
+       if (rand_tmp_str[0]) fputs(rand_tmp_str, fff);
 
 #ifdef JP
        if (!total) fprintf(fff, "  ¤Ê¤·\n");
@@ -9158,12 +9518,75 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
 }
 
 
+static bool do_cmd_knowledge_quests_aux(FILE *fff, int q_idx)
+{
+       char tmp_str[120];
+       char playtime_str[16];
+       quest_type* const q_ptr = &quest[q_idx];
+
+       if (is_fixed_quest_idx(q_idx))
+       {
+               /* Set the quest number temporary */
+               int old_quest = p_ptr->inside_quest;
+
+               p_ptr->inside_quest = q_idx;
+
+               /* Get the quest */
+               init_flags = INIT_NAME_ONLY;
+
+               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+
+               /* Reset the old quest number */
+               p_ptr->inside_quest = old_quest;
+
+               /* No info from "silent" quests */
+               if (q_ptr->flags & QUEST_FLAG_SILENT) return FALSE;
+       }
+
+       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,
+                               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,
+                               q_ptr->level,
+                               q_ptr->complev,
+                               playtime_str);
+               }
+       }
+       else
+       {
+               /* Print the quest info */
+               sprintf(tmp_str,
+                       _("  %-35s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d - %s\n",
+                         "  %-35s (Danger  level: %3d) - level %2d - %s\n") ,
+                       q_ptr->name, q_ptr->level, q_ptr->complev, playtime_str);
+       }
+
+       fputs(tmp_str, fff);
+
+       return TRUE;
+}
+
 /*
  * Print all finished quests
  */
 void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
 {
-       char tmp_str[120];
        int i;
        int total = 0;
 
@@ -9175,71 +9598,12 @@ void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
        for (i = 1; i < max_quests; i++)
        {
                int q_idx = quest_num[i];
+               quest_type* const q_ptr = &quest[q_idx];
 
-               if (quest[q_idx].status == QUEST_STATUS_FINISHED)
+               if (q_ptr->status == QUEST_STATUS_FINISHED &&
+                   do_cmd_knowledge_quests_aux(fff, q_idx))
                {
-                       if (is_fixed_quest_idx(q_idx))
-                       {
-                               /* Set the quest number temporary */
-                               int old_quest = p_ptr->inside_quest;
-
-                               p_ptr->inside_quest = q_idx;
-
-                               /* Get the quest */
-                               init_flags = INIT_ASSIGN;
-
-                               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
-
-                               /* Reset the old quest number */
-                               p_ptr->inside_quest = old_quest;
-
-                               /* No info from "silent" quests */
-                               if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
-                       }
-
-                       total++;
-
-                       if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
-                       {
-                               /* Print the quest info */
-
-                               if (quest[q_idx].complev == 0)
-                               {
-                                       sprintf(tmp_str,
-#ifdef JP
-                                               "  %-40s (%3d³¬)            -   ÉÔÀᄀ\n",
-#else
-                                               "  %-40s (Dungeon level: %3d) - (Cancelled)\n",
-#endif
-                                               r_name+r_info[quest[q_idx].r_idx].name,
-                                               quest[q_idx].level);
-                               }
-                               else
-                               {
-                                       sprintf(tmp_str,
-#ifdef JP
-                                               "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
-#else
-                                               "  %-40s (Dungeon level: %3d) - level %2d\n",
-#endif
-                                               r_name+r_info[quest[q_idx].r_idx].name,
-                                               quest[q_idx].level,
-                                               quest[q_idx].complev);
-                               }
-                       }
-                       else
-                       {
-                               /* Print the quest info */
-#ifdef JP
-                               sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
-                                       quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#else
-                               sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
-                                       quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#endif
-                       }
-
-                       fprintf(fff, tmp_str);
+                       ++ total;
                }
        }
 #ifdef JP
@@ -9255,7 +9619,6 @@ void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
  */
 void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
 {
-       char tmp_str[120];
        int i;
        int total = 0;
 
@@ -9267,53 +9630,12 @@ void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
        for (i = 1; i < max_quests; i++)
        {
                int q_idx = quest_num[i];
+               quest_type* const q_ptr = &quest[q_idx];
 
-               if ((quest[q_idx].status == QUEST_STATUS_FAILED_DONE) || (quest[q_idx].status == QUEST_STATUS_FAILED))
+               if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) &&
+                   do_cmd_knowledge_quests_aux(fff, q_idx))
                {
-                       if (is_fixed_quest_idx(q_idx))
-                       {
-                               /* Set the quest number temporary */
-                               int old_quest = p_ptr->inside_quest;
-
-                               p_ptr->inside_quest = q_idx;
-
-                               /* Get the quest text */
-                               init_flags = INIT_ASSIGN;
-
-                               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
-
-                               /* Reset the old quest number */
-                               p_ptr->inside_quest = old_quest;
-
-                               /* No info from "silent" quests */
-                               if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
-                       }
-
-                       total++;
-
-                       if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
-                       {
-                               /* Print the quest info */
-#ifdef JP
-                               sprintf(tmp_str, "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
-                                       r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#else
-                               sprintf(tmp_str, "  %-40s (Dungeon level: %3d) - level %2d\n",
-                                       r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#endif
-                       }
-                       else
-                       {
-                               /* Print the quest info */
-#ifdef JP
-                               sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
-                                       quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#else
-                               sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
-                                       quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
-#endif
-                       }
-                       fprintf(fff, tmp_str);
+                       ++ total;
                }
        }
 #ifdef JP
@@ -9355,7 +9677,7 @@ static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
                        sprintf(tmp_str, "  %s (%d, %s)\n",
                                quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
 #endif
-                       fprintf(fff, tmp_str);
+                       fputs(tmp_str, fff);
                }
        }
 #ifdef JP
@@ -9375,10 +9697,7 @@ bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
        /* Unused */
        (void)v;
 
-       if (qa->complev < qb->complev) return TRUE;
-       if (qa->complev > qb->complev) return FALSE;
-       if (qa->level <= qb->level) return TRUE;
-       return FALSE;
+       return (qa->comptime <= qb->comptime);
 }
 
 void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
@@ -9864,6 +10183,7 @@ void do_cmd_time(void)
        char desc[1024];
 
        char buf[1024];
+       char day_buf[10];
 
        FILE *fff;
 
@@ -9883,14 +10203,17 @@ void do_cmd_time(void)
 #endif
 
 
+       if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
+       else strcpy(day_buf, "*****");
+
        /* Message */
 #ifdef JP
-       msg_format("%d ÆüÌÜ,»þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
-                  day, (hour % 12 == 0) ? 12 : (hour % 12),
+       msg_format("%sÆüÌÜ, »þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
+                  day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
                   min, (hour < 12) ? "AM" : "PM");
 #else
-       msg_format("This is day %d. The time is %d:%02d %s.",
-                  day, (hour % 12 == 0) ? 12 : (hour % 12),
+       msg_format("This is day %s. The time is %d:%02d %s.",
+                  day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
                   min, (hour < 12) ? "AM" : "PM");
 #endif