OSDN Git Service

branch-nothere-terrainflags、゙。シ・ク.
[hengband/hengband.git] / src / files.c
index 1ad8392..a2d45eb 100644 (file)
@@ -417,11 +417,6 @@ errr process_pref_file_command(char *buf)
 
        switch (buf[0])
        {
-       /* Process "%:<fname>" */
-       case '%':
-               /* Attempt to Process the given file */
-               return process_pref_file(buf + 2);
-
        /* Mega-Hack -- read external player's history file */
        /* Process "H:<history>" */
        case 'H':
@@ -438,7 +433,7 @@ errr process_pref_file_command(char *buf)
                        n2 = strtol(zz[2], NULL, 0);
                        if (i >= max_r_idx) return 1;
                        r_ptr = &r_info[i];
-                       if (n1) r_ptr->x_attr = n1;
+                       if (n1 || (!(n2 & 0x80) && n2)) r_ptr->x_attr = n1; /* Allow ATTR_DARK text */
                        if (n2) r_ptr->x_char = n2;
                        return 0;
                }
@@ -454,27 +449,75 @@ errr process_pref_file_command(char *buf)
                        n2 = strtol(zz[2], NULL, 0);
                        if (i >= max_k_idx) return 1;
                        k_ptr = &k_info[i];
-                       if (n1) k_ptr->x_attr = n1;
+                       if (n1 || (!(n2 & 0x80) && n2)) k_ptr->x_attr = n1; /* Allow ATTR_DARK text */
                        if (n2) k_ptr->x_char = n2;
                        return 0;
                }
                break;
 
        /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
+       /* "F:<num>:<a>/<c>" */
+       /* "F:<num>:<a>/<c>:LIT" */
+       /* "F:<num>:<a>/<c>:<la>/<lc>:<da>/<dc>:<Da>/<Dc>" */
        case 'F':
-               if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
                {
                        feature_type *f_ptr;
+                       int num = tokenize(buf + 2, 9, zz, TOKENIZE_CHECKQUOTE);
+
+                       if ((num != 3) && (num != 4) && (num != 9)) return 1;
+                       else if ((num == 4) && !streq(zz[3], "LIT")) return 1;
+
                        i = (huge)strtol(zz[0], NULL, 0);
-                       n1 = strtol(zz[1], NULL, 0);
-                       n2 = strtol(zz[2], NULL, 0);
                        if (i >= max_f_idx) return 1;
                        f_ptr = &f_info[i];
-                       if (n1) f_ptr->x_attr = n1;
-                       if (n2) f_ptr->x_char = n2;
-                       return 0;
+
+                       n1 = strtol(zz[1], NULL, 0);
+                       n2 = strtol(zz[2], NULL, 0);
+                       if (n1 || (!(n2 & 0x80) && n2)) /* Allow ATTR_DARK text */
+                       {
+                               for (j = 0; j < F_LIT_MAX; j++) f_ptr->x_attr[j] = n1;
+                       }
+                       if (n2)
+                       {
+                               for (j = 0; j < F_LIT_MAX; j++) f_ptr->x_char[j] = n2;
+                       }
+
+                       /* Mega-hack -- feat supports lighting */
+                       switch (num)
+                       {
+                       /* No lighting support */
+                       case 3:
+                               break;
+
+                       /* Use default lighting */
+                       case 4:
+                               if (is_ascii_graphics(f_ptr->x_attr[F_LIT_STANDARD]))
+                               {
+                                       f_ptr->x_attr[F_LIT_LITE] = lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][0];
+                                       f_ptr->x_attr[F_LIT_DARK] = lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][1];
+                                       f_ptr->x_attr[F_LIT_DARKDARK] = lighting_colours[lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][1]][1];
+                               }
+                               else
+                               {
+                                       f_ptr->x_char[F_LIT_LITE] += 2;
+                                       f_ptr->x_char[F_LIT_DARK]++;
+                                       f_ptr->x_char[F_LIT_DARKDARK]++;
+                               }
+                               break;
+
+                       /* Use desired lighting */
+                       case 9:
+                               for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
+                               {
+                                       n1 = strtol(zz[j * 2 + 1], NULL, 0);
+                                       n2 = strtol(zz[j * 2 + 2], NULL, 0);
+                                       if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[j] = n1; /* Allow ATTR_DARK text */
+                                       if (n2) f_ptr->x_char[j] = n2;
+                               }
+                               break;
+                       }
                }
-               break;
+               return 0;
 
        /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
        case 'S':
@@ -583,12 +626,13 @@ errr process_pref_file_command(char *buf)
                                int os = option_info[i].o_set;
                                int ob = option_info[i].o_bit;
 
-                               if (p_ptr->playing && 6 == option_info[i].o_page && !p_ptr->wizard)
+                               if ((p_ptr->playing || character_xtra) &&
+                                       (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard)
                                {
 #ifdef JP
                                        msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤­¤Þ¤»¤ó! '%s'", buf);
 #else
-                                       msg_format("Startup options can not changed! '%s'", buf);
+                                       msg_format("Birth options can not changed! '%s'", buf);
 #endif
                                        msg_print(NULL);
                                        return 0;
@@ -623,7 +667,7 @@ errr process_pref_file_command(char *buf)
        case 'Z':
        {
                /* Find the colon */
-               char *t = strchr(buf + 2, ':');
+               char *t = my_strchr(buf + 2, ':');
 
                /* Oops */
                if (!t) return 1;
@@ -777,12 +821,11 @@ errr process_pref_file_command(char *buf)
  * Output:
  *   result
  */
-static cptr process_pref_file_expr(char **sp, char *fp)
+cptr process_pref_file_expr(cptr *sp, char *fp)
 {
        cptr v;
 
-       char *b;
-       char *s;
+       cptr s;
 
        char b1 = '[';
        char b2 = ']';
@@ -796,9 +839,6 @@ static cptr process_pref_file_expr(char **sp, char *fp)
        /* Skip spaces */
        while (isspace(*s)) s++;
 
-       /* Save start */
-       b = s;
-
        /* Default */
        v = "?o?o?";
 
@@ -856,16 +896,15 @@ static cptr process_pref_file_expr(char **sp, char *fp)
                /* Function: EQU */
                else if (streq(t, "EQU"))
                {
-                       v = "1";
+                       v = "0";
                        if (*s && (f != b2))
                        {
                                t = process_pref_file_expr(&s, &f);
                        }
                        while (*s && (f != b2))
                        {
-                               p = t;
-                               t = process_pref_file_expr(&s, &f);
-                               if (*t && !streq(p, t)) v = "0";
+                               p = process_pref_file_expr(&s, &f);
+                               if (streq(t, p)) v = "1";
                        }
                }
 
@@ -881,7 +920,7 @@ static cptr process_pref_file_expr(char **sp, char *fp)
                        {
                                p = t;
                                t = process_pref_file_expr(&s, &f);
-                               if (*t && (strcmp(p, t) > 0)) v = "0";
+                               if (*t && atoi(p) > atoi(t)) v = "0";
                        }
                }
 
@@ -897,7 +936,9 @@ static cptr process_pref_file_expr(char **sp, char *fp)
                        {
                                p = t;
                                t = process_pref_file_expr(&s, &f);
-                               if (*t && (strcmp(p, t) < 0)) v = "0";
+
+                               /* Compare two numbers instead of string */
+                               if (*t && atoi(p) < atoi(t)) v = "0";
                        }
                }
 
@@ -914,17 +955,24 @@ static cptr process_pref_file_expr(char **sp, char *fp)
                if (f != b2) v = "?x?x?";
 
                /* Extract final and Terminate */
-               if ((f = *s) != '\0') *s++ = '\0';
+               if ((f = *s) != '\0') s++;
        }
 
        /* Other */
        else
        {
+               char b[1024];
+               int i;
+
                /* Accept all printables except spaces and brackets */
-               while (isprint(*s) && !strchr(" []", *s)) ++s;
+               for (i = 0; isprint(*s) && !my_strchr(" []", *s); i++)
+                       b[i] = *s++;
+
+               /* Terminate */
+               b[i] = '\0';
 
                /* Extract final and Terminate */
-               if ((f = *s) != '\0') *s++ = '\0';
+               if ((f = *s) != '\0') s++;
 
                /* Variable */
                if (*b == '$')
@@ -1007,6 +1055,15 @@ static cptr process_pref_file_expr(char **sp, char *fp)
                                sprintf(tmp, "%02d", p_ptr->lev);
                                v = tmp;
                        }
+
+                       /* Autopick auto-register is in-use or not? */
+                       else if (streq(b+1, "AUTOREGISTER"))
+                       {
+                               if (p_ptr->autopick_autoregister)
+                                       v = "1";
+                               else
+                                       v = "0";
+                       }
                }
 
                /* Constant */
@@ -1028,7 +1085,7 @@ static cptr process_pref_file_expr(char **sp, char *fp)
 
 
 #define PREF_TYPE_NORMAL   0
-#define PREF_TYPE_PICKPREF 1
+#define PREF_TYPE_AUTOPICK 1
 #define PREF_TYPE_HISTPREF 2
 
 /*
@@ -1083,7 +1140,7 @@ static errr process_pref_file_aux(cptr name, int preftype)
                {
                        char f;
                        cptr v;
-                       char *s;
+                       cptr s;
 
                        /* Start */
                        s = buf + 2;
@@ -1105,11 +1162,19 @@ static errr process_pref_file_aux(cptr name, int preftype)
                /* Process "%:<file>" */
                if (buf[0] == '%')
                {
+                       static int depth_count = 0;
+
+                       /* Ignore if deeper than 20 level */
+                       if (depth_count > 20) continue;
+
+                       /* Count depth level */
+                       depth_count++;
+
                        /* Process that file if allowed */
                        switch (preftype)
                        {
-                       case PREF_TYPE_PICKPREF:
-                               (void)process_pickpref_file(buf + 2);
+                       case PREF_TYPE_AUTOPICK:
+                               (void)process_autopick_file(buf + 2);
                                break;
                        case PREF_TYPE_HISTPREF:
                                (void)process_histpref_file(buf + 2);
@@ -1119,6 +1184,9 @@ static errr process_pref_file_aux(cptr name, int preftype)
                                break;
                        }
 
+                       /* Set back depth level */
+                       depth_count--;
+
                        /* Continue */
                        continue;
                }
@@ -1130,9 +1198,9 @@ static errr process_pref_file_aux(cptr name, int preftype)
                /* This is not original pref line... */
                if (err)
                {
-                       if (preftype != PREF_TYPE_PICKPREF)
+                       if (preftype != PREF_TYPE_AUTOPICK)
                                break;
-                       err = process_pickpref_file_line(buf);
+                       err = process_autopick_file_command(buf);
                }
        }
 
@@ -1485,6 +1553,7 @@ errr check_load_init(void)
 #define ENTRY_ALIGN 42
 
 #define ENTRY_EXP_ANDR 43
+#define ENTRY_EXP_TO_ADV_ANDR 44
 
 
 static struct
@@ -1505,7 +1574,7 @@ static struct
        { 1, 11, 25, ""},
        { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
        { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
-       {01, 20, 25, "²Ã®"},
+       { 1, 20, 25, "²Ã®"},
        { 1, 19, 25, "£Á£Ã"},
        {29, 13, 21, "¥ì¥Ù¥ë"},
        {29, 14, 21, "·Ð¸³ÃÍ"},
@@ -1516,18 +1585,18 @@ static struct
        {29, 10, 21, "£È£Ð"},
        {29, 11, 21, "£Í£Ð"},
        {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
-       {54, 10, -1, "ÂǷ⹶·â  :"},
-       {54, 11, -1, "¼Í·â¹¶·â  :"},
-       {54, 12, -1, "ËâË¡Ëɸ栠:"},
-       {54, 13, -1, "±£Ì©¹ÔÆ°  :"},
-       {54, 15, -1, "ÃγР     :"},
-       {54, 16, -1, "õº÷      :"},
-       {54, 17, -1, "²ò½ü      :"},
-       {54, 18, -1, "ËâË¡Æ»¶ñ  :"},
-       {01, 12, 25, "ÂÇ·â²ó¿ô"},
-       {01, 17, 25, "¼Í·â²ó¿ô"},
-       {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
-       {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
+       {53, 10, -1, "ÂǷ⹶·â  :"},
+       {53, 11, -1, "¼Í·â¹¶·â  :"},
+       {53, 12, -1, "ËâË¡Ëɸ栠:"},
+       {53, 13, -1, "±£Ì©¹ÔÆ°  :"},
+       {53, 15, -1, "ÃγР     :"},
+       {53, 16, -1, "õº÷      :"},
+       {53, 17, -1, "²ò½ü      :"},
+       {53, 18, -1, "ËâË¡Æ»¶ñ  :"},
+       { 1, 12, 25, "ÂÇ·â²ó¿ô"},
+       { 1, 17, 25, "¼Í·â²ó¿ô"},
+       { 1, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
+       {53, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
        {26,  1, -1, "̾Á°  : "},
        { 1,  3, -1, "À­ÊÌ     : "},
        { 1,  4, -1, "¼ï²     : "},
@@ -1540,6 +1609,7 @@ static struct
        {29,  6, 21, "¼Ò²ñŪÃÏ°Ì"},
        {29,  7, 21, "°À­"},
        {29, 14, 21, "¶¯²½ÅÙ"},
+       {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
 };
 #else
 = {
@@ -1552,7 +1622,7 @@ static struct
        { 1, 11, 25, "Posture"},
        { 1, 15, 25, "Shooting"},
        { 1, 16, 25, "Multiplier"},
-       {01, 20, 25, "Speed"},
+       { 1, 20, 25, "Speed"},
        { 1, 19, 25, "AC"},
        {29, 13, 21, "Level"},
        {29, 14, 21, "Experience"},
@@ -1563,18 +1633,18 @@ static struct
        {29, 10, 21, "Hit point"},
        {29, 11, 21, "SP (Mana)"},
        {29, 20, 21, "Play time"},
-       {54, 10, -1, "Fighting    : "},
-       {54, 11, -1, "Bows/Throw  : "},
-       {54, 12, -1, "Saving Throw: "},
-       {54, 13, -1, "Stealth     : "},
-       {54, 15, -1, "Perception  : "},
-       {54, 16, -1, "Searching   : "},
-       {54, 17, -1, "Disarming   : "},
-       {54, 18, -1, "Magic Device: "},
-       {01, 12, 25, "Blows/Round"},
-       {01, 17, 25, "Shots/Round"},
-       {01, 13, 25, "AverageDmg/Rnd"},
-       {54, 20, -1, "Infra-Vision: "},
+       {53, 10, -1, "Fighting   : "},
+       {53, 11, -1, "Bows/Throw : "},
+       {53, 12, -1, "SavingThrow: "},
+       {53, 13, -1, "Stealth    : "},
+       {53, 15, -1, "Perception : "},
+       {53, 16, -1, "Searching  : "},
+       {53, 17, -1, "Disarming  : "},
+       {53, 18, -1, "MagicDevice: "},
+       { 1, 12, 25, "Blows/Round"},
+       { 1, 17, 25, "Shots/Round"},
+       { 1, 13, 25, "AverageDmg/Rnd"},
+       {53, 20, -1, "Infra-Vision: "},
        {26,  1, -1, "Name  : "},
        { 1,  3, -1, "Sex      : "},
        { 1,  4, -1, "Race     : "},
@@ -1587,6 +1657,7 @@ static struct
        {29,  6, 21, "Social Class"},
        {29,  7, 21, "Align"},
        {29, 14, 21, "Construction"},
+       {29, 16, 21, "Const to Adv"},
 };
 #endif
 
@@ -1677,7 +1748,7 @@ static void display_player_middle(void)
                else
                        display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
        }
-       else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
+       else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
        {
                int i;
                if (p_ptr->special_defense & KAMAE_MASK)
@@ -1738,7 +1809,6 @@ static void display_player_middle(void)
 
        /* Dump speed */
        {
-               bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
                int tmp_speed = 0;
                byte attr;
                int i;
@@ -1772,7 +1842,7 @@ static void display_player_middle(void)
 
                if (!p_ptr->riding)
                {
-                       if (is_fast) tmp_speed += 10;
+                       if (IS_FAST()) tmp_speed += 10;
                        if (p_ptr->slow) tmp_speed -= 10;
                        if (p_ptr->lightspeed) tmp_speed = 99;
                }
@@ -1832,12 +1902,15 @@ static void display_player_middle(void)
                display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
 
        /* Dump exp to advance */
+       if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
+       else e = ENTRY_EXP_TO_ADV;
+
        if (p_ptr->lev >= PY_MAX_LEVEL)
-               display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
+               display_player_one_line(e, "*****", TERM_L_GREEN);
        else if (p_ptr->prace == RACE_ANDROID)
-               display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
+               display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
        else
-               display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
+               display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
 
        /* Dump gold */
        display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
@@ -1868,7 +1941,7 @@ static void display_player_middle(void)
        /* Dump mana power */
        if (p_ptr->csp >= p_ptr->msp) 
                display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
-       else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10) 
+       else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10) 
                display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
        else
                display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
@@ -1899,117 +1972,97 @@ static cptr likert(int x, int y)
        {
                likert_color = TERM_L_DARK;
 #ifdef JP
-return ("ºÇÄã");
+               return "ºÇÄã";
 #else
-               return ("Very Bad");
+               return "Very Bad";
 #endif
-
        }
 
        /* Analyze the value */
        switch ((x / y))
        {
-               case 0:
-               case 1:
-               {
-                       likert_color = TERM_RED;
+       case 0:
+       case 1:
+               likert_color = TERM_RED;
 #ifdef JP
-return ("°­¤¤");
+               return "°­¤¤";
 #else
-                       return ("Bad");
+               return "Bad";
 #endif
 
-               }
-               case 2:
-               {
-                       likert_color = TERM_L_RED;
+       case 2:
+               likert_color = TERM_L_RED;
 #ifdef JP
-return ("Îô¤ë");
+               return "Îô¤ë";
 #else
-                       return ("Poor");
+               return "Poor";
 #endif
 
-               }
-               case 3:
-               case 4:
-               {
-                       likert_color = TERM_ORANGE;
+       case 3:
+       case 4:
+               likert_color = TERM_ORANGE;
 #ifdef JP
-return ("ÉáÄÌ");
+               return "ÉáÄÌ";
 #else
-                       return ("Fair");
+               return "Fair";
 #endif
 
-               }
-               case 5:
-               {
-                       likert_color = TERM_YELLOW;
+       case 5:
+               likert_color = TERM_YELLOW;
 #ifdef JP
-return ("Îɤ¤");
+               return "Îɤ¤";
 #else
-                       return ("Good");
+               return "Good";
 #endif
 
-               }
-               case 6:
-               {
-                       likert_color = TERM_YELLOW;
+       case 6:
+               likert_color = TERM_YELLOW;
 #ifdef JP
-return ("ÂçÊÑÎɤ¤");
+               return "ÂçÊÑÎɤ¤";
 #else
-                       return ("Very Good");
+               return "Very Good";
 #endif
 
-               }
-               case 7:
-               case 8:
-               {
-                       likert_color = TERM_L_GREEN;
+       case 7:
+       case 8:
+               likert_color = TERM_L_GREEN;
 #ifdef JP
-return ("Âî±Û");
+               return "Âî±Û";
 #else
-                       return ("Excellent");
+               return "Excellent";
 #endif
 
-               }
-               case 9:
-               case 10:
-               case 11:
-               case 12:
-               case 13:
-               {
-                       likert_color = TERM_GREEN;
+       case 9:
+       case 10:
+       case 11:
+       case 12:
+       case 13:
+               likert_color = TERM_GREEN;
 #ifdef JP
-return ("Ķ±Û");
+               return "Ķ±Û";
 #else
-                       return ("Superb");
+               return "Superb";
 #endif
 
-               }
-               case 14:
-               case 15:
-               case 16:
-               case 17:
-               {
-                       likert_color = TERM_BLUE;
+       case 14:
+       case 15:
+       case 16:
+       case 17:
+               likert_color = TERM_BLUE;
 #ifdef JP
-return ("¥«¥ª¥¹¥é¥ó¥¯");
+               return "±ÑͺŪ";
 #else
-                       return ("Chaos Rank");
+               return "Heroic";
 #endif
 
-               }
-               default:
-               {
-                       likert_color = TERM_VIOLET;
+       default:
+               likert_color = TERM_VIOLET;
 #ifdef JP
-sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
+               sprintf(dummy, "ÅÁÀâŪ[%d]", (int)((((x / y) - 17) * 5) / 2));
 #else
-                       sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
+               sprintf(dummy, "Legendary[%d]", (int)((((x / y) - 17) * 5) / 2));
 #endif
-
-                       return dummy;
-               }
+               return dummy;
        }
 }
 
@@ -2076,10 +2129,10 @@ static void display_player_various(void)
                shot_frac = 0;
        }
 
-       for(i = 0; i< 2; i++)
+       for(i = 0; i < 2; i++)
        {
-               damage[i] = p_ptr->dis_to_d[i]*100;
-               if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
+               damage[i] = p_ptr->dis_to_d[i] * 100;
+               if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
                {
                        int level = p_ptr->lev;
                        if (i)
@@ -2097,27 +2150,30 @@ static void display_player_various(void)
                }
                else
                {
+                       o_ptr = &inventory[INVEN_RARM + i];
+
                        /* Average damage per round */
-                       o_ptr = &inventory[INVEN_RARM+i];
-                       if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
-                       basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
-                       object_flags(o_ptr, flgs);
-                       if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
+                       if (o_ptr->k_idx)
                        {
-                               /* vorpal blade */
-                               basedam *= 5;
-                               basedam /= 3;
-                       }
-                       else if (object_known_p(o_ptr) && (have_flag(flgs, TR_VORPAL)))
-                       {
-                               /* vorpal flag only */
-                               basedam *= 11;
-                               basedam /= 9;
+                               if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d * 100;
+                               basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
+                               object_flags_known(o_ptr, flgs);
+                               if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
+                               {
+                                       /* vorpal blade */
+                                       basedam *= 5;
+                                       basedam /= 3;
+                               }
+                               else if (have_flag(flgs, TR_VORPAL))
+                               {
+                                       /* vorpal flag only */
+                                       basedam *= 11;
+                                       basedam /= 9;
+                               }
+                               if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
+                                       basedam = basedam * 7 / 2;
                        }
-                       if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
-                               basedam = basedam * 7 / 2;
-                       if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
-                               basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
+                       else basedam = 0;
                }
                damage[i] += basedam;
                if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
@@ -2145,7 +2201,8 @@ static void display_player_various(void)
        desc = likert(xsav, 7);
        display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
 
-       desc = likert(xstl, 1);
+       /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
+       desc = likert((xstl > 0) ? xstl : -1, 1);
        display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
 
        desc = likert(xfos, 6);
@@ -2316,7 +2373,7 @@ static void player_flags(u32b flgs[TR_FLAG_SIZE])
                add_flag(flgs, TR_RES_LITE);
                break;
        case RACE_HOBBIT:
-               add_flag(flgs, TR_SUST_DEX);
+               add_flag(flgs, TR_HOLD_LIFE);
                break;
        case RACE_GNOME:
                add_flag(flgs, TR_FREE_ACT);
@@ -2565,7 +2622,7 @@ static void player_flags(u32b flgs[TR_FLAG_SIZE])
                add_flag(flgs, TR_RES_BLIND);
                add_flag(flgs, TR_RES_CONF);
                add_flag(flgs, TR_HOLD_LIFE);
-               add_flag(flgs, TR_LITE);
+               if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
                if (p_ptr->lev > 9)
                        add_flag(flgs, TR_SPEED);
        }
@@ -2622,7 +2679,7 @@ static void player_flags(u32b flgs[TR_FLAG_SIZE])
 }
 
 
-static void tim_player_flags(u32b flgs[TR_FLAG_SIZE], bool im_and_res)
+static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
 {
        int i;
 
@@ -2630,48 +2687,28 @@ static void tim_player_flags(u32b flgs[TR_FLAG_SIZE], bool im_and_res)
        for (i = 0; i < TR_FLAG_SIZE; i++)
                flgs[i] = 0L;
 
-       if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
+       if (IS_HERO() || p_ptr->shero)
                add_flag(flgs, TR_RES_FEAR);
        if (p_ptr->tim_invis)
                add_flag(flgs, TR_SEE_INVIS);
        if (p_ptr->tim_regen)
                add_flag(flgs, TR_REGEN);
-       if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
+       if (IS_TIM_ESP())
                add_flag(flgs, TR_TELEPATHY);
-       if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
+       if (IS_FAST() || p_ptr->slow)
                add_flag(flgs, TR_SPEED);
-       if  ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
-       {
-               add_flag(flgs, TR_RES_FIRE);
-               add_flag(flgs, TR_RES_COLD);
+
+       if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
                add_flag(flgs, TR_RES_ACID);
+       if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
                add_flag(flgs, TR_RES_ELEC);
+       if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
+               add_flag(flgs, TR_RES_FIRE);
+       if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
+               add_flag(flgs, TR_RES_COLD);
+       if (IS_OPPOSE_POIS())
                add_flag(flgs, TR_RES_POIS);
-       }
-       if (im_and_res)
-       {
-               if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
-                       add_flag(flgs, TR_RES_ACID);
-               if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
-                       add_flag(flgs, TR_RES_ELEC);
-               if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
-                       add_flag(flgs, TR_RES_FIRE);
-               if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
-                       add_flag(flgs, TR_RES_COLD);
-       }
-       else
-       {
-               if (p_ptr->oppose_acid)
-                       add_flag(flgs, TR_RES_ACID);
-               if (p_ptr->oppose_elec)
-                       add_flag(flgs, TR_RES_ELEC);
-               if (p_ptr->oppose_fire)
-                       add_flag(flgs, TR_RES_FIRE);
-               if (p_ptr->oppose_cold)
-                       add_flag(flgs, TR_RES_COLD);
-       }
-       if (p_ptr->oppose_pois)
-               add_flag(flgs, TR_RES_POIS);
+
        if (p_ptr->special_attack & ATTACK_ACID)
                add_flag(flgs, TR_BRAND_ACID);
        if (p_ptr->special_attack & ATTACK_ELEC)
@@ -2693,9 +2730,8 @@ static void tim_player_flags(u32b flgs[TR_FLAG_SIZE], bool im_and_res)
        if (p_ptr->wraith_form)
                add_flag(flgs, TR_REFLECT);
        /* by henkma */
-       if (p_ptr->tim_reflect){
+       if (p_ptr->tim_reflect)
                add_flag(flgs, TR_REFLECT);
-       }
 
        if (p_ptr->magicdef)
        {
@@ -2824,10 +2860,10 @@ static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
                /* Known flags */
                object_flags_known(o_ptr, o_flgs);
 
-               if (have_flag(flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
-               if (have_flag(flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
-               if (have_flag(flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
-               if (have_flag(flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
+               if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
+               if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
+               if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
+               if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
        }
 }
 
@@ -3001,7 +3037,7 @@ static void display_player_flag_info(void)
 
        /* Extract flags and store */
        player_flags(f.player_flags);
-       tim_player_flags(f.tim_player_flags, TRUE);
+       tim_player_flags(f.tim_player_flags);
        player_immunity(f.player_imm);
        tim_player_immunity(f.tim_player_imm);
        known_obj_immunity(f.known_obj_imm);
@@ -3130,7 +3166,7 @@ static void display_player_other_flag_info(void)
 
        /* Extract flags and store */
        player_flags(f.player_flags);
-       tim_player_flags(f.tim_player_flags, TRUE);
+       tim_player_flags(f.tim_player_flags);
        player_immunity(f.player_imm);
        tim_player_immunity(f.tim_player_imm);
        known_obj_immunity(f.known_obj_imm);
@@ -3200,8 +3236,8 @@ static void display_player_other_flag_info(void)
        display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
        display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
        display_flag_aux(row+15, col, "Quake     :", TR_IMPACT, &f, DP_WP);
-       display_flag_aux(row+16, col, "Vampicic  :", TR_VAMPIRIC, &f, DP_WP);
-       display_flag_aux(row+17, col, "Chatic    :", TR_CHAOTIC, &f, DP_WP);
+       display_flag_aux(row+16, col, "Vampiric  :", TR_VAMPIRIC, &f, DP_WP);
+       display_flag_aux(row+17, col, "Chaotic   :", TR_CHAOTIC, &f, DP_WP);
        display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
 #endif
 
@@ -3750,7 +3786,7 @@ void display_player(int mode)
                                int value;
 
                                /* Use lowercase stat name */
-                               put_str(stat_names_reduced[i], 3 + i, 54);
+                               put_str(stat_names_reduced[i], 3 + i, 53);
 
                                /* Get the current stat */
                                value = p_ptr->stat_use[i];
@@ -3759,7 +3795,7 @@ void display_player(int mode)
                                cnv_stat(value, buf);
 
                                /* Display the current stat (modified) */
-                               c_put_str(TERM_YELLOW, buf, 3 + i, 61);
+                               c_put_str(TERM_YELLOW, buf, 3 + i, 60);
 
                                /* Acquire the max stat */
                                value = p_ptr->stat_top[i];
@@ -3768,28 +3804,28 @@ void display_player(int mode)
                                cnv_stat(value, buf);
 
                                /* Display the maximum stat (modified) */
-                               c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
+                               c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
                        }
 
                        /* Normal treatment of "normal" stats */
                        else
                        {
                                /* Assume uppercase stat name */
-                               put_str(stat_names[i], 3 + i, 54);
+                               put_str(stat_names[i], 3 + i, 53);
 
                                /* Obtain the current stat (modified) */
                                cnv_stat(p_ptr->stat_use[i], buf);
 
                                /* Display the current stat (modified) */
-                               c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
+                               c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
                        }
 
                        if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
                        {
 #ifdef JP
-                               c_put_str(TERM_WHITE, "!", 3+i, 59);
+                               c_put_str(TERM_WHITE, "!", 3 + i, 58);
 #else
-                               c_put_str(TERM_WHITE, "!", 3+i, 59-2);
+                               c_put_str(TERM_WHITE, "!", 3 + i, 58-2);
 #endif
                        }
                }
@@ -3830,7 +3866,7 @@ void display_player(int mode)
                                        sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
 #endif
                                }
-                               else if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
+                               else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
                                {
                                        /* Get the quest text */
                                        /* Bewere that INIT_ASSIGN resets the cur_num. */
@@ -3845,7 +3881,7 @@ void display_player(int mode)
 #endif
                                }
                                else
-                               {                                       
+                               {
 #ifdef JP
                                        sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
 #else
@@ -3863,7 +3899,7 @@ void display_player(int mode)
                                        sprintf(statmsg, "...Now, you are in %s.", map_name());
 #endif
                                }
-                               else if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
+                               else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
                                {
                                        /* Clear the text */
                                        /* Must be done before doing INIT_SHOW_TEXT */
@@ -3883,7 +3919,7 @@ void display_player(int mode)
 #else
                                        sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
 #endif
-                               }                                                       
+                               }
                                else
                                {
 #ifdef JP
@@ -3944,56 +3980,16 @@ void display_player(int mode)
        }
 }
 
-static bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
-{
-       int *q_num = (int *)u;
-       quest_type *qa = &quest[q_num[a]];
-       quest_type *qb = &quest[q_num[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;
-}
-
-static void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
-{
-       int *q_num = (int *)u;
-       int tmp;
-
-       /* Unused */
-       (void)v;
-
-       tmp = q_num[a];
-       q_num[a] = q_num[b];
-       q_num[b] = tmp;
-}
 
-errr make_character_dump(FILE *fff)
+/*
+ *
+ */
+static void dump_aux_display_player(FILE *fff)
 {
-       int             i, x, y;
-       byte            a;
-       char            c;
-       cptr            paren = ")";
-       store_type  *st_ptr;
-       char            o_name[MAX_NLEN];
+       int x, y, i;
+       byte a;
+       char c;
        char            buf[1024];
-       int             total;
-       int             *quest_num;
-       int             dummy;
-
-#ifdef JP
-       fprintf(fff, "  [ÊѶòÈÚÅÜ %d.%d.%d ¥­¥ã¥é¥¯¥¿¾ðÊó]\n\n",
-               FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
-#else
-       fprintf(fff, "  [Hengband %d.%d.%d Character Dump]\n\n",
-               FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
-#endif
-
-       update_playtime();
 
        /* Display player */
        display_player(0);
@@ -4019,7 +4015,7 @@ errr make_character_dump(FILE *fff)
 
                /* End the row */
 #ifdef JP
-                       fprintf(fff, "%s\n", buf);
+               fprintf(fff, "%s\n", buf);
 #else
                fprintf(fff, "%s\n", buf);
 #endif
@@ -4119,235 +4115,269 @@ errr make_character_dump(FILE *fff)
        fprintf(fff, "\n");
        for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
                fprintf(fff, " ");
+}
+
 
+/*
+ *
+ */
+static void dump_aux_pet(FILE *fff)
+{
+       int i;
+       bool pet = FALSE;
+       char pet_name[80];
+
+       for (i = m_max - 1; i >= 1; i--)
        {
-               bool pet = FALSE;
+               monster_type *m_ptr = &m_list[i];
 
-               for (i = m_max - 1; i >= 1; i--)
+               if (!m_ptr->r_idx) continue;
+               if (!is_pet(m_ptr)) continue;
+               if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
+               if (!pet)
                {
-                       monster_type *m_ptr = &m_list[i];
-                       char pet_name[80];
-
-                       if (!m_ptr->r_idx) continue;
-                       if (!is_pet(m_ptr)) continue;
-                       if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
-                       if (!pet)
-                       {
 #ifdef JP
-                               fprintf(fff, "\n  [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
+                       fprintf(fff, "\n  [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
 #else
-                               fprintf(fff, "\n  [leading pets]\n\n");
+                       fprintf(fff, "\n  [leading pets]\n\n");
 #endif
-                               pet = TRUE;
-                       }
-                       monster_desc(pet_name, m_ptr, 0x88);
-                       fprintf(fff, "%s", pet_name);
-                       if (p_ptr->riding == i)
-#ifdef JP
-                               fprintf(fff, " ¾èÇÏÃæ");
-#else
-                               fprintf(fff, " (riding)");
-#endif
-                       fprintf(fff, "\n");
+                       pet = TRUE;
                }
-               if (pet) fprintf(fff, "\n");
+               monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+               fprintf(fff, "%s\n", pet_name);
        }
 
-#ifdef JP
-       fprintf(fff, "\n  [¥¯¥¨¥¹¥È¾ðÊó]\n");
-#else
-       fprintf(fff, "\n  [Quest information]\n");
-#endif
-
-#ifdef JP
-       fprintf(fff, "\n¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
-#else
-       fprintf(fff, "\n< Completed Quest >\n");
-#endif
-
-       /* Allocate Memory */
-       C_MAKE(quest_num, max_quests, int);
+       if (pet) fprintf(fff, "\n");
+}
 
-       /* Sort by compete level */
-       for (i = 1; i < max_quests; i++)
-       {
-               quest_num[i] = i;
-       }
-       ang_sort_comp = ang_sort_comp_quest_num;
-       ang_sort_swap = ang_sort_swap_quest_num;
-       ang_sort(quest_num, &dummy, max_quests);
 
-       /* Dump Quest Information */
-       total = 0;
-       for (i = 1; i < max_quests; i++)
+/*
+ *
+ */
+static void dump_aux_class_special(FILE *fff)
+{
+       if (p_ptr->pclass == CLASS_BLUE_MAGE)
        {
-               int num = quest_num[i];
-
-               if (quest[num].status == QUEST_STATUS_FINISHED)
-               {
-                       if (num < MIN_RANDOM_QUEST)
-                       {
-                               int old_quest;
-                       
-                               /* Set the quest number temporary */
-                               old_quest = p_ptr->inside_quest;
-                               p_ptr->inside_quest = num;
-
-                               /* Get the quest */
-                               init_flags = INIT_ASSIGN;
+               int i = 0;
+               int j = 0;
+               int l1 = 0;
+               int l2 = 0;
+               int num = 0;
+               int spellnum[MAX_MONSPELLS];
+               s32b f4 = 0, f5 = 0, f6 = 0;
+               char p[60][80];
+               int col = 0;
+               bool pcol = FALSE;
 
-                               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+               for (i=0;i<60;i++) { p[i][0] = '\0'; }
 
-                               /* Reset the old quest number */
-                               p_ptr->inside_quest = old_quest;
-
-                               /* No info from "silent" quests */
-                               if (quest[num].flags & QUEST_FLAG_SILENT) continue;
-                       }
+#ifdef JP
+               strcat(p[col], "\n  [³Ø½¬ºÑ¤ß¤ÎÀÄËâË¡]\n");
+#else
+               strcat(p[col], "\n  [Learned blue magic]\n");
+#endif
 
-                       total++;
 
-                       if ((num >= MIN_RANDOM_QUEST) && quest[num].r_idx)
+               for (j=1;j<6;j++)
+               {
+                       col++;
+                       set_rf_masks(&f4, &f5, &f6, j);
+                       switch(j)
                        {
-                               /* Print the quest info */
-
-                               if (quest[num].complev == 0)
-                               {
-                                       fprintf(fff, 
+                               case MONSPELL_TYPE_BOLT:
 #ifdef JP
-                                               "  %s (%d³¬) - ÉÔÀᄀ\n",
+                                       strcat(p[col], "\n     [¥Ü¥ë¥È·¿]\n");
 #else
-                                               "  %s (Dungeon level: %d) - (Cancelled)\n",
+                                       strcat(p[col], "\n     [Bolt  type]\n");
 #endif
-                                               r_name+r_info[quest[num].r_idx].name,
-                                               quest[num].level);
-                               }
-                               else
-                               {
-                                       fprintf(fff, 
+                                       break;
+
+                               case MONSPELL_TYPE_BALL:
 #ifdef JP
-                                               "  %s (%d³¬) - ¥ì¥Ù¥ë%d\n",
+                                       strcat(p[col], "\n     [¥Ü¡¼¥ë·¿]\n");
 #else
-                                               "  %s (Dungeon level: %d) - level %d\n",
+                                       strcat(p[col], "\n     [Ball  type]\n");
 #endif
-                                               r_name+r_info[quest[num].r_idx].name,
-                                               quest[num].level,
-                                               quest[num].complev);
-                               }
-                       }
-                       else
-                       {
-                               /* Print the quest info */
+                                       break;
+
+                               case MONSPELL_TYPE_BREATH:
 #ifdef JP
-                               fprintf(fff, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
+                                       strcat(p[col], "\n     [¥Ö¥ì¥¹·¿]\n");
 #else
-                               fprintf(fff, "  %s (Danger level: %d) - level %d\n",
+                                       strcat(p[col], "\n     [  Breath  ]\n");
 #endif
+                                       break;
 
-                                       quest[num].name, quest[num].level, quest[num].complev);
-                       }
-               }
-       }
+                               case MONSPELL_TYPE_SUMMON:
 #ifdef JP
-       if (!total) fprintf(fff, "  ¤Ê¤·\n");
+                                       strcat(p[col], "\n     [¾¤´­ËâË¡]\n");
 #else
-       if (!total) fprintf(fff, "  Nothing.\n");
+                                       strcat(p[col], "\n     [Summonning]\n");
 #endif
+                                       break;
 
+                               case MONSPELL_TYPE_OTHER:
 #ifdef JP
-       fprintf(fff, "\n¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
+                                       strcat(p[col], "\n     [ ¤½¤Î¾ ]\n");
 #else
-       fprintf(fff, "\n< Failed Quest >\n");
+                                       strcat(p[col], "\n     [Other type]\n");
 #endif
-       total = 0;
-       for (i = 1; i < max_quests; i++)
-       {
-               int num = quest_num[i];
+                                       break;
+                       }
 
-               if ((quest[num].status == QUEST_STATUS_FAILED_DONE) || (quest[num].status == QUEST_STATUS_FAILED))
-               {
-                       if (num < MIN_RANDOM_QUEST)
+                       for (i = 0, num = 0; i < 32; i++)
                        {
-                               int old_quest;
-
-                               /* Set the quest number temporary */
-                               old_quest = p_ptr->inside_quest;
-                               p_ptr->inside_quest = num;
-
-                               /* 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[num].flags & QUEST_FLAG_SILENT) continue;
+                               if ((0x00000001 << i) & f4) spellnum[num++] = i;
+                       }
+                       for (; i < 64; i++)
+                       {
+                               if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
+                       }
+                       for (; i < 96; i++)
+                       {
+                               if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
                        }
 
-                       total++;
+                       col++;
+                       pcol = FALSE;
+                       strcat(p[col], "       ");
 
-                       if ((num >= MIN_RANDOM_QUEST) && quest[num].r_idx)
+                       for (i = 0; i < num; i++)
+                       {
+                               if (p_ptr->magic_num2[spellnum[i]])
+                               {
+                                       pcol = TRUE;
+                                       /* Dump blue magic */
+                                       l1 = strlen(p[col]);
+                                       l2 = strlen(monster_powers_short[spellnum[i]]);
+                                       if ((l1 + l2) >= 75)
+                                       {
+                                               strcat(p[col], "\n");
+                                               col++;
+                                               strcat(p[col], "       ");
+                                       }
+                                       strcat(p[col], monster_powers_short[spellnum[i]]);
+                                       strcat(p[col], ", ");
+                               }
+                       }
+                       
+                       if (!pcol)
                        {
-                               /* Print the quest info */
 #ifdef JP
-                               fprintf(fff, "  %s (%d³¬) - ¥ì¥Ù¥ë%d\n",
+                               strcat(p[col], "¤Ê¤·");
 #else
-                               fprintf(fff, "  %s (Dungeon level: %d) - level %d\n",
+                               strcat(p[col], "None");
 #endif
-
-                                       r_name+r_info[quest[num].r_idx].name, quest[num].level, quest[num].complev);
                        }
                        else
                        {
-                               /* Print the quest info */
-#ifdef JP
-                               fprintf(fff, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
-#else
-                               fprintf(fff, "  %s (Danger level: %d) - level %d\n",
-#endif
-
-                                       quest[num].name, quest[num].level, quest[num].complev);
+                               if (p[col][strlen(p[col])-2] == ',')
+                               {
+                                       p[col][strlen(p[col])-2] = '\0';
+                               }
+                               else
+                               {
+                                       p[col][strlen(p[col])-10] = '\0';
+                               }
                        }
+                       
+                       strcat(p[col], "\n");
                }
-       }
-
-#ifdef JP
-       if (!total) fprintf(fff, "  ¤Ê¤·\n");
-#else
-       if (!total) fprintf(fff, "  Nothing.\n");
-#endif
-       fprintf(fff, "\n");
-
-       /* Free Memory */
-       C_KILL(quest_num, max_quests, int);
 
-       if (p_ptr->is_dead && !p_ptr->total_winner)
-       {
-#ifdef JP
-               fprintf(fff, "\n  [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
-#else
-               fprintf(fff, "\n  [Last messages]\n\n");
-#endif
-               for (i = MIN(message_num(), 30); i >= 0; i--)
+               for (i=0;i<=col;i++)
                {
-                       fprintf(fff,"> %s\n",message_str((s16b)i));
+                       fprintf(fff, p[i]);
                }
-               fprintf(fff, "\n");
        }
+}
+
+
+/*
+ *
+ */
+static void dump_aux_quest(FILE *fff)
+{
+       int i;
+       int *quest_num;
+       int dummy;
 
-#ifdef JP
-       fprintf(fff, "\n  [¤½¤Î¾¤Î¾ðÊó]\n");
-#else
-       fprintf(fff, "\n  [Miscellaneous information]\n");
-#endif
 
 #ifdef JP
-       fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
+       fprintf(fff, "\n\n  [¥¯¥¨¥¹¥È¾ðÊó]\n");
 #else
-       fprintf(fff, "\n Recall Depth:\n");
+       fprintf(fff, "\n\n  [Quest information]\n");
 #endif
+
+       /* Allocate Memory */
+       C_MAKE(quest_num, max_quests, int);
+
+       /* Sort by compete level */
+       for (i = 1; i < max_quests; i++) quest_num[i] = i;
+       ang_sort_comp = ang_sort_comp_quest_num;
+       ang_sort_swap = ang_sort_swap_quest_num;
+       ang_sort(quest_num, &dummy, max_quests);
+
+       /* Dump Quest Information */
+       fputc('\n', fff);
+       do_cmd_knowledge_quests_completed(fff, quest_num);
+       fputc('\n', fff);
+       do_cmd_knowledge_quests_failed(fff, quest_num);
+
+       /* Free Memory */
+       C_KILL(quest_num, max_quests, int);
+}
+
+
+/*
+ *
+ */
+static void dump_aux_last_message(FILE *fff)
+{
+       if (p_ptr->is_dead)
+       {
+               if (!p_ptr->total_winner)
+               {
+                       int i;
+
+#ifdef JP
+                       fprintf(fff, "\n  [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
+#else
+                       fprintf(fff, "\n  [Last messages]\n\n");
+#endif
+                       for (i = MIN(message_num(), 30); i >= 0; i--)
+                       {
+                               fprintf(fff,"> %s\n",message_str((s16b)i));
+                       }
+                       fprintf(fff, "\n");
+               }
+
+               /* Hack -- *Winning* message */
+               else if (p_ptr->last_message)
+               {
+#ifdef JP
+                       fprintf(fff, "\n  [*¾¡Íø*¥á¥Ã¥»¡¼¥¸]\n\n");
+#else
+                       fprintf(fff, "\n  [*Winning* message]\n\n");
+#endif
+                       fprintf(fff,"  %s\n", p_ptr->last_message);
+               }
+       }
+}
+
+
+/*
+ *
+ */
+static void dump_aux_recall(FILE *fff)
+{
+       int y;
+
+#ifdef JP
+       fprintf(fff, "\n\n  [µ¢´Ô¾ì½ê]\n\n");
+#else
+       fprintf(fff, "\n\n  [Recall Depth]\n\n");
+#endif
+
        for (y = 1; y < max_d_idx; y++)
        {
                bool seiha = FALSE;
@@ -4366,41 +4396,33 @@ errr make_character_dump(FILE *fff)
                fprintf(fff, "   %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
 #endif
        }
+}
 
-       if (preserve_mode)
-#ifdef JP
-               fprintf(fff, "\n Êݸ¥â¡¼¥É:         ON");
-#else
-               fprintf(fff, "\n Preserve Mode:      ON");
-#endif
 
-       else
+/*
+ *
+ */
+static void dump_aux_options(FILE *fff)
+{
 #ifdef JP
-               fprintf(fff, "\n Êݸ¥â¡¼¥É:         OFF");
+       fprintf(fff, "\n  [¥ª¥×¥·¥ç¥óÀßÄê]\n");
 #else
-               fprintf(fff, "\n Preserve Mode:      OFF");
+       fprintf(fff, "\n  [Option settings]\n");
 #endif
 
 
-       if (ironman_autoscum)
-#ifdef JP
-               fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß  :     ALWAYS");
-#else
-               fprintf(fff, "\n Autoscum:           ALWAYS");
-#endif
-
-       else if (auto_scum)
+       if (preserve_mode)
 #ifdef JP
-               fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß  :     ON");
+               fprintf(fff, "\n Êݸ¥â¡¼¥É:         ON");
 #else
-               fprintf(fff, "\n Autoscum:           ON");
+               fprintf(fff, "\n Preserve Mode:      ON");
 #endif
 
        else
 #ifdef JP
-               fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß  :     OFF");
+               fprintf(fff, "\n Êݸ¥â¡¼¥É:         OFF");
 #else
-               fprintf(fff, "\n Autoscum:           OFF");
+               fprintf(fff, "\n Preserve Mode:      OFF");
 #endif
 
 
@@ -4435,7 +4457,7 @@ errr make_character_dump(FILE *fff)
 
        if (vanilla_town)
 #ifdef JP
-               fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
+               fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß:       ON");
 #else
                fprintf(fff, "\n Vanilla Town:       ON");
 #endif
@@ -4460,15 +4482,15 @@ errr make_character_dump(FILE *fff)
 #ifdef JP
                fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤:   ON");
 #else
-               fprintf(fff, "\n Diving only:        ON");
+               fprintf(fff, "\n Diving Only:        ON");
 #endif
 
 
        if (ironman_rooms)
 #ifdef JP
-               fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®:         ON");
+               fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°:     ON");
 #else
-               fprintf(fff, "\n Unusual rooms:      ON");
+               fprintf(fff, "\n Unusual Rooms:      ON");
 #endif
 
 
@@ -4489,7 +4511,7 @@ errr make_character_dump(FILE *fff)
 
        else if (empty_levels)
 #ifdef JP
-               fprintf(fff, "\n ¥¢¥ê¡¼¥Ê:           ON");
+               fprintf(fff, "\n ¥¢¥ê¡¼¥Ê:           ENABLED");
 #else
                fprintf(fff, "\n Arena Levels:       ENABLED");
 #endif
@@ -4502,21 +4524,49 @@ errr make_character_dump(FILE *fff)
 #endif
 
 
+       fprintf(fff,"\n");
+
+       if (p_ptr->noscore)
 #ifdef JP
-       fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
+               fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤¤¤Þ¤¹¡£");
 #else
-       fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
+               fprintf(fff, "\n You have done something illegal.");
 #endif
 
-       if (p_ptr->arena_number == 99)
+       fprintf(fff,"\n");
+}
+
+
+/*
+ *
+ */
+static void dump_aux_arena(FILE *fff)
+{
+       if (lite_town || vanilla_town) return;
+
+       if (p_ptr->arena_number < 0)
        {
+               if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
+               {
+#ifdef JP
+                       fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
+#else
+                       fprintf(fff, "\n Arena: Defeated\n");
+#endif
+               }
+               else
+               {
 #ifdef JP
-               fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
+                       fprintf(fff, "\n Æ®µ»¾ì: %d²óÀï¤Ç%s¤ÎÁ°¤ËÇÔËÌ\n", -p_ptr->arena_number,
+                               r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
 #else
-               fprintf(fff, "\n Arena: defeated\n");
+                       fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
+                               r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
+                               -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
 #endif
+               }
        }
-       else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
+       else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
        {
 #ifdef JP
                fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
@@ -4524,7 +4574,7 @@ errr make_character_dump(FILE *fff)
                fprintf(fff, "\n Arena: True Champion\n");
 #endif
        }
-       else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
+       else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
        {
 #ifdef JP
                fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
@@ -4535,75 +4585,143 @@ errr make_character_dump(FILE *fff)
        else
        {
 #ifdef JP
-               fprintf(fff, "\n Æ®µ»¾ì:   %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
+               fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
 #else
-               fprintf(fff, "\n Arena:   %2d victor%s\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number), (p_ptr->arena_number>1) ? "ies" : "y");
+               fprintf(fff, "\n Arena: %2d Victor%s\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number), (p_ptr->arena_number > 1) ? "ies" : "y");
 #endif
        }
 
-       if (p_ptr->noscore)
+       fprintf(fff, "\n");
+}
+
+
+/*
+ *
+ */
+static void dump_aux_monsters(FILE *fff)
+{
+       /* Monsters slain */
+
+       int k;
+       unsigned long uniq_total = 0;
+       unsigned long norm_total = 0;
+       s16b *who;
+
+       /* Sort by monster level */
+       u16b why = 2;
+
 #ifdef JP
-fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
+       fprintf(fff, "\n  [Åݤ·¤¿¥â¥ó¥¹¥¿¡¼]\n\n");
 #else
-               fprintf(fff, "\n You have done something illegal.");
+       fprintf(fff, "\n  [Defeated monsters]\n\n");
 #endif
 
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, s16b);
 
-       fprintf(fff,"\n");
-
-       /* Monsters slain */
+       /* Count monster kills */
+       for (k = 1; k < max_r_idx; k++)
        {
-               int k;
-               s32b Total = 0;
+               monster_race *r_ptr = &r_info[k];
 
-               for (k = 1; k < max_r_idx; k++)
-               {
-                       monster_race *r_ptr = &r_info[k];
+               /* Ignore unused index */
+               if (!r_ptr->name) continue;
 
-                       if (r_ptr->flags1 & RF1_UNIQUE)
+               /* Unique monsters */
+               if (r_ptr->flags1 & RF1_UNIQUE)
+               {
+                       bool dead = (r_ptr->max_num == 0);
+                       if (dead)
                        {
-                               bool dead = (r_ptr->max_num == 0);
-                               if (dead)
-                               {
-                                       Total++;
-                               }
+                               norm_total++;
+
+                               /* Add a unique monster to the list */
+                               who[uniq_total++] = k;
                        }
-                       else
+               }
+
+               /* Normal monsters */
+               else
+               {
+                       if (r_ptr->r_pkills > 0)
                        {
-                               s16b This = r_ptr->r_pkills;
-                               if (This > 0)
-                               {
-                                       Total += This;
-                               }
+                               norm_total += r_ptr->r_pkills;
                        }
                }
+       }
+
+
+       /* No monsters is defeated */
+       if (norm_total < 1)
+       {
+#ifdef JP
+               fprintf(fff,"¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
+#else
+               fprintf(fff,"You have defeated no enemies yet.\n");
+#endif
+       }
 
-               if (Total < 1)
+       /* Defeated more than one normal monsters */
+       else if (uniq_total == 0)
+       {
 #ifdef JP
-fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
+               fprintf(fff,"%luÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", norm_total);
 #else
-                       fprintf(fff,"\n You have defeated no enemies yet.\n");
+               fprintf(fff,"You have defeated %lu %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
 #endif
+       }
 
-               else if (Total == 1)
+       /* Defeated more than one unique monsters */
+       else /* if (uniq_total > 0) */
+       {
 #ifdef JP
-fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
+               fprintf(fff, "%luÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ò´Þ¤à¡¢¹ç·×%luÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", uniq_total, norm_total); 
 #else
-                       fprintf(fff,"\n You have defeated one enemy.\n");
+               fprintf(fff, "You have defeated %lu %s including %lu unique monster%s in total.\n", norm_total, norm_total == 1 ? "enemy" : "enemies", uniq_total, (uniq_total == 1 ? "" : "s"));
 #endif
 
-               else
+
+               /* Select the sort method */
+               ang_sort_comp = ang_sort_comp_hook;
+               ang_sort_swap = ang_sort_swap_hook;
+
+               /* Sort the array by dungeon depth of monsters */
+               ang_sort(who, &why, uniq_total);
+
+#ifdef JP
+               fprintf(fff, "\n¡Ô¾å°Ì%luÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¡Õ\n", MIN(uniq_total, 10));
+#else
+               fprintf(fff, "\n< Unique monsters top %lu >\n", MIN(uniq_total, 10));
+#endif
+
+               /* Print top 10 */
+               for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
+               {
+                       monster_race *r_ptr = &r_info[who[k]];
+
 #ifdef JP
-fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
+                       fprintf(fff, "  %-40s (¥ì¥Ù¥ë%3d)\n", (r_name + r_ptr->name), r_ptr->level); 
 #else
-                       fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
+                       fprintf(fff, "  %-40s (level %3d)\n", (r_name + r_ptr->name), r_ptr->level); 
 #endif
+               }
 
        }
 
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, s16b);
+}
 
+
+/*
+ *
+ */
+static void dump_aux_race_history(FILE *fff)
+{
        if (p_ptr->old_race1 || p_ptr->old_race2)
        {
+               int i;
+
 #ifdef JP
                fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
 #else
@@ -4627,9 +4745,18 @@ fprintf(fff,"\n %lu 
 #endif
                }
        }
+}
+
 
+/*
+ *
+ */
+static void dump_aux_realm_history(FILE *fff)
+{
        if (p_ptr->old_realm)
        {
+               int i;
+
                for (i = 0; i < MAX_MAGIC; i++)
                {
                        if (!(p_ptr->old_realm & 1L << i)) continue;
@@ -4640,9 +4767,16 @@ fprintf(fff,"\n %lu 
 #endif
                }
        }
+}
 
+
+/*
+ *
+ */
+static void dump_aux_virtues(FILE *fff)
+{
 #ifdef JP
-fprintf(fff, "\n\n  [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
+       fprintf(fff, "\n\n  [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
 #else
        fprintf(fff, "\n\n  [Virtues]\n\n");
 #endif
@@ -4652,13 +4786,21 @@ fprintf(fff, "\n\n  [
 #else
        fprintf(fff, "Your alighnment : %s\n", your_alignment());
 #endif
+
        fprintf(fff, "\n");
        dump_virtues(fff);
+}
+
 
+/*
+ *
+ */
+static void dump_aux_mutations(FILE *fff)
+{
        if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
        {
 #ifdef JP
-fprintf(fff, "\n\n  [ÆÍÁ³ÊÑ°Û]\n\n");
+               fprintf(fff, "\n\n  [ÆÍÁ³ÊÑ°Û]\n\n");
 #else
                fprintf(fff, "\n\n  [Mutations]\n\n");
 #endif
@@ -4666,38 +4808,47 @@ fprintf(fff, "\n\n  [
                dump_mutations(fff);
        }
 
-
        /* Skip some lines */
        fprintf(fff, "\n\n");
+}
+
 
+/*
+ *
+ */
+static void dump_aux_equipment_inventory(FILE *fff)
+{
+       int i;
+       char o_name[MAX_NLEN];
 
        /* Dump the equipment */
        if (equip_cnt)
        {
 #ifdef JP
-fprintf(fff, "  [ ¥­¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
+               fprintf(fff, "  [¥­¥ã¥é¥¯¥¿¤ÎÁõÈ÷]\n\n");
 #else
                fprintf(fff, "  [Character Equipment]\n\n");
 #endif
 
                for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                {
-                       object_desc(o_name, &inventory[i], TRUE, 3);
+                       object_desc(o_name, &inventory[i], 0);
                        if ((i == INVEN_LARM) && p_ptr->ryoute)
 #ifdef JP
                                strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
 #else
                                strcpy(o_name, "(wielding with two-hands)");
 #endif
-                       fprintf(fff, "%c%s %s\n",
-                               index_to_label(i), paren, o_name);
+
+                       fprintf(fff, "%c) %s\n",
+                               index_to_label(i), o_name);
                }
                fprintf(fff, "\n\n");
        }
 
        /* Dump the inventory */
 #ifdef JP
-fprintf(fff, "  [ ¥­¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
+       fprintf(fff, "  [¥­¥ã¥é¥¯¥¿¤Î»ý¤Áʪ]\n\n");
 #else
        fprintf(fff, "  [Character Inventory]\n\n");
 #endif
@@ -4708,28 +4859,40 @@ fprintf(fff, "  [ 
                if (!inventory[i].k_idx) break;
 
                /* Dump the inventory slots */
-               object_desc(o_name, &inventory[i], TRUE, 3);
-               fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
+               object_desc(o_name, &inventory[i], 0);
+               fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
        }
 
        /* Add an empty line */
        fprintf(fff, "\n\n");
+}
 
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
 
-       /* Print all homes in the different towns */
+/*
+ *
+ */
+static void dump_aux_home_museum(FILE *fff)
+{
+       char o_name[MAX_NLEN];
+       store_type  *st_ptr;
+
+       /* Do we need it?? */
+       /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
+
+       /* Print the home */
        st_ptr = &town[1].store[STORE_HOME];
 
        /* Home -- if anything there */
        if (st_ptr->stock_num)
        {
-               /* Header with name of the town */
+               int i;
+               int x = 1;
+
 #ifdef JP
-               fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
+               fprintf(fff, "  [²æ¤¬²È¤Î¥¢¥¤¥Æ¥à]\n");
 #else
                fprintf(fff, "  [Home Inventory]\n");
 #endif
-               x=1;
 
                /* Dump all available items */
                for (i = 0; i < st_ptr->stock_num; i++)
@@ -4740,8 +4903,8 @@ fprintf(fff, "  [ 
 #else
                                fprintf(fff, "\n ( page %d )\n", x++);
 #endif
-                       object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
-                       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\n", I2A(i%12), o_name);
                }
 
                /* Add an empty line */
@@ -4749,31 +4912,32 @@ fprintf(fff, "  [ 
        }
 
 
-       /* Print all homes in the different towns */
+       /* Print the home */
        st_ptr = &town[1].store[STORE_MUSEUM];
 
        /* Home -- if anything there */
        if (st_ptr->stock_num)
        {
-               /* Header with name of the town */
+               int i;
+               int x = 1;
+
 #ifdef JP
-               fprintf(fff, "  [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
+               fprintf(fff, "  [Çîʪ´Û¤Î¥¢¥¤¥Æ¥à]\n");
 #else
                fprintf(fff, "  [Museum]\n");
 #endif
-               x=1;
 
                /* Dump all available items */
                for (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], TRUE, 3);
-                       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\n", I2A(i%12), o_name);
 #else
                if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
-                       object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
-                       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\n", I2A(i%12), o_name);
 #endif
 
                }
@@ -4781,6 +4945,39 @@ fprintf(fff, "  [ 
                /* Add an empty line */
                fprintf(fff, "\n\n");
        }
+}
+
+
+/*
+ * Output the character dump to a file
+ */
+errr make_character_dump(FILE *fff)
+{
+#ifdef JP
+       fprintf(fff, "  [ÊѶòÈÚÅÜ %d.%d.%d ¥­¥ã¥é¥¯¥¿¾ðÊó]\n\n",
+               FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+#else
+       fprintf(fff, "  [Hengband %d.%d.%d Character Dump]\n\n",
+               FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+#endif
+
+       update_playtime();
+
+       dump_aux_display_player(fff);
+       dump_aux_last_message(fff);
+       dump_aux_options(fff);
+       dump_aux_recall(fff);
+       dump_aux_quest(fff);
+       dump_aux_arena(fff);
+       dump_aux_monsters(fff);
+       dump_aux_virtues(fff);
+       dump_aux_race_history(fff);
+       dump_aux_realm_history(fff);
+       dump_aux_class_special(fff);
+       dump_aux_mutations(fff);
+       dump_aux_pet(fff);
+       dump_aux_equipment_inventory(fff);
+       dump_aux_home_museum(fff);
 
 #ifdef JP
        fprintf(fff, "  [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
@@ -4872,20 +5069,139 @@ msg_print("
 
 
 /*
- * Recursive file perusal.
+ * Display single line of on-line help file
+ *
+ * You can insert some special color tag to change text color.
+ * Such as...
+ * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
  *
- * Return FALSE on 'Q', otherwise TRUE.
+ * A colored segment is between "[[[[y|" and the last "|".
+ * You can use any single character in place of the "|".
+ */
+static void show_file_aux_line(cptr str, int cy, cptr shower)
+{
+       static const char tag_str[] = "[[[[";
+       byte color = TERM_WHITE;
+       char in_tag = '\0';
+       int cx = 0;
+       int i;
+       char lcstr[1024];
+
+       if (shower)
+       {
+               /* Make a lower case version of str for searching */
+               strcpy(lcstr, str);
+               str_tolower(lcstr);
+       }
+
+       /* Initial cursor position */
+       Term_gotoxy(cx, cy);
+
+       for (i = 0; str[i];)
+       {
+               int len = strlen(&str[i]);
+               int showercol = len + 1;
+               int bracketcol = len + 1;
+               int endcol = len;
+               cptr ptr;
+
+               /* Search for a shower string in the line */
+               if (shower)
+               {
+                       ptr = my_strstr(&lcstr[i], shower);
+                       if (ptr) showercol = ptr - &lcstr[i];
+               }
+
+               /* Search for a color segment tag */
+               ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
+               if (ptr) bracketcol = ptr - &str[i];
+
+               /* A color tag is found */
+               if (bracketcol < endcol) endcol = bracketcol;
+
+               /* The shower string is found before the color tag */
+               if (showercol < endcol) endcol = showercol;
+
+               /* Print a segment of the line */
+               Term_addstr(endcol, color, &str[i]);
+               cx += endcol;
+               i += endcol;
+
+               /* Shower string? */
+               if (endcol == showercol)
+               {
+                       int showerlen = strlen(shower);
+
+                       /* Print the shower string in yellow */
+                       Term_addstr(showerlen, TERM_YELLOW, &str[i]);
+                       cx += showerlen;
+                       i += showerlen;
+               }
+
+               /* Colored segment? */
+               else if (endcol == bracketcol)
+               {
+                       if (in_tag)
+                       {
+                               /* Found the end of colored segment */
+                               i++;
+
+                               /* Now looking for an another tag_str */
+                               in_tag = '\0';
+
+                               /* Set back to the default color */
+                               color = TERM_WHITE;
+                       }
+                       else
+                       {
+                               /* Found a tag_str, and get a tag color */
+                               i += sizeof(tag_str)-1;
+
+                               /* Get tag color */
+                               color = color_char_to_attr(str[i]);
+
+                               /* Illegal color tag */
+                               if (color == 255 || str[i+1] == '\0')
+                               {
+                                       /* Illegal color tag */
+                                       color = TERM_WHITE;
+
+                                       /* Print the broken tag as a string */
+                                       Term_addstr(-1, TERM_WHITE, tag_str);
+                                       cx += sizeof(tag_str)-1;
+                               }
+                               else
+                               {
+                                       /* Skip the color tag */
+                                       i++;
+
+                                       /* Now looking for a close tag */
+                                       in_tag = str[i];
+
+                                       /* Skip the close-tag-indicator */
+                                       i++;
+                               }
+                       }
+               }
+
+       } /* for (i = 0; str[i];) */
+
+       /* Clear rest of line */
+       Term_erase(cx, cy, 255);
+}
+
+
+/*
+ * Recursive file perusal.
  *
  * Process various special text in the input file, including
  * the "menu" structures used by the "help file" system.
  *
- * XXX XXX XXX Consider using a temporary file.
- *
- * XXX XXX XXX Allow the user to "save" the current file.
+ * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
  */
 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
 {
-       int i, n, k;
+       int i, n, skey;
 
        /* Number of "real" lines passed by */
        int next = 0;
@@ -4896,12 +5212,6 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
        /* Backup value for "line" */
        int back = 0;
 
-       /* Color of the next line */
-       byte color = TERM_WHITE;
-
-       /* Loop counter */
-       int cnt;
-
        /* This screen has sub-screens */
        bool menu = FALSE;
 
@@ -4914,11 +5224,12 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
        /* Jump to this tag */
        cptr tag = NULL;
 
-       /* Hold a string to find */
-       char finder[81];
+       /* Hold strings to find/show */
+       char finder_str[81];
+       char shower_str[81];
 
-       /* Hold a string to show */
-       char shower[81];
+       /* String to show */
+       cptr shower = NULL;
 
        /* Filename */
        char filename[1024];
@@ -4932,12 +5243,6 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
        /* General buffer */
        char buf[1024];
 
-       /* Lower case version of the buffer, for searching */
-       char lc_buf[1024];
-
-       /* Aux pointer for making lc_buf (and find!) lowercase */
-       cptr lc_buf_ptr;
-
        /* Sub-menu information */
        char hook[68][32];
 
@@ -4949,10 +5254,10 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
        rows = hgt - 4;
 
        /* Wipe finder */
-       strcpy(finder, "");
+       strcpy(finder_str, "");
 
        /* Wipe shower */
-       strcpy(shower, "");
+       strcpy(shower_str, "");
 
        /* Wipe caption */
        strcpy(caption, "");
@@ -5072,27 +5377,23 @@ msg_format("'%s'
        /* Pre-Parse the file */
        while (TRUE)
        {
-               char *str;
+               char *str = buf;
 
                /* Read a line or stop */
                if (my_fgets(fff, buf, sizeof(buf))) break;
 
-               /* Get a color */
-               if (prefix(buf, "#####")) str = &buf[6];
-               else str = buf;
-
                /* XXX Parse "menu" items */
                if (prefix(str, "***** "))
                {
                        /* Notice "menu" requests */
                        if ((str[6] == '[') && isalpha(str[7]))
                        {
+                               /* Extract the menu item */
+                               int k = str[7] - 'A';
+
                                /* This is a menu file */
                                menu = TRUE;
 
-                               /* Extract the menu item */
-                               k = str[7] - 'A';
-
                                if ((str[8] == ']') && (str[9] == ' '))
                                {
                                        /* Extract the menu item */
@@ -5105,8 +5406,13 @@ msg_format("'%s'
                        /* Notice "tag" requests */
                        else if (str[6] == '<')
                        {
-                               str[strlen(str) - 1] = '\0';
-                               if (tag && streq(str + 7, tag)) line = next;
+                               size_t len = strlen(str);
+
+                               if (str[len - 1] == '>')
+                               {
+                                       str[len - 1] = '\0';
+                                       if (tag && streq(str + 7, tag)) line = next;
+                               }
                        }
 
                        /* Skip this */
@@ -5123,12 +5429,12 @@ msg_format("'%s'
        /* start from bottom when reverse mode */
        if (line == -1) line = ((size-1)/rows)*rows;
 
+       /* Clear screen */
+       Term_clear();
+
        /* Display the file */
        while (TRUE)
        {
-               /* Clear screen */
-               Term_clear();
-
                /* Restart when necessary */
                if (line >= size - rows) line = size - rows;
                if (line < 0) line = 0;
@@ -5165,8 +5471,7 @@ msg_format("'%s'
                /* Dump the next 20, or rows, lines of the file */
                for (i = 0; i < rows; )
                {
-                       int print_x, x;
-                       cptr str;
+                       cptr str = buf;
 
                        /* Hack -- track the "first" line */
                        if (!i) line = next;
@@ -5177,87 +5482,36 @@ msg_format("'%s'
                        /* Hack -- skip "special" lines */
                        if (prefix(buf, "***** ")) continue;
 
-                       /* Get a color */
-                       if (prefix(buf, "#####"))
-                       {
-                               color = color_char_to_attr(buf[5]);
-                               str = &buf[6];
-                       }
-                       else
-                       {
-                               color = TERM_WHITE;
-                               str = buf;
-                       }
-
                        /* Count the "real" lines */
                        next++;
 
-                       /* Make a lower case version of str for searching */
-                       strcpy(lc_buf, str);
-
-                       for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
-                       {
-#ifdef JP
-                               if (iskanji(*lc_buf_ptr))
-                                       lc_buf_ptr++;
-                               else
-#endif
-                                       lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
-                       }
-
                        /* Hack -- keep searching */
-                       if (find && !i && !strstr(lc_buf, find)) continue;
-
-                       /* Hack -- stop searching */
-                       find = NULL;
-
-                       /* Dump the line */
-                       x = 0;
-                       print_x = 0;
-                       while (str[x])
+                       if (find && !i)
                        {
-                               /* Color ? */
-                               if (prefix(str + x, "[[[[["))
-                               {
-                                       byte c = color_char_to_attr(str[x + 5]);
-                                       x += 6;
+                               char lc_buf[1024];
 
-                                       /* Ok print the link name */
-                                       while (str[x] != ']')
-                                       {
-                                               Term_putch(print_x, i + 2, c, str[x]);
-                                               x++;
-                                               print_x++;
-                                       }
-                               }
-                               else
-                               {
-                                       Term_putch(print_x, i + 2, color, str[x]);
-                                       print_x++;
-                               }
+                               /* Make a lower case version of str for searching */
+                               strcpy(lc_buf, str);
+                               str_tolower(lc_buf);
 
-                               x++;
+                               if (!my_strstr(lc_buf, find)) continue;
                        }
 
-                       /* Hilite "shower" */
-                       if (shower[0])
-                       {
-                               cptr s2 = lc_buf;
+                       /* Hack -- stop searching */
+                       find = NULL;
 
-                               /* Display matches */
-                               while ((s2 = strstr(s2, shower)) != NULL)
-                               {
-                                       int len = strlen(shower);
+                       /* Dump the line */
+                       show_file_aux_line(str, i + 2, shower);
 
-                                       /* Display the match */
-                                       Term_putstr(s2-lc_buf, i+2, len, TERM_YELLOW, &str[s2-lc_buf]);
+                       /* Count the printed lines */
+                       i++;
+               }
 
-                                       /* Advance */
-                                       s2 += len;
-                               }
-                       }
+               while (i < rows)
+               {
+                       /* Clear rest of line */
+                       Term_erase(0, i + 2, 255);
 
-                       /* Count the printed lines */
                        i++;
                }
 
@@ -5320,14 +5574,11 @@ prt("[
 #endif
                }
 
-               /* Get a keypress */
-               k = inkey();
-
-               /* Hack -- return to last screen */
-               if (k == '<') break;
+               /* Get a special key code */
+               skey = inkey_special(TRUE);
 
                /* Show the help for the help */
-               if (k == '?')
+               if (skey == '?')
                {
                        /* Hack - prevent silly recursion */
 #ifdef JP
@@ -5340,54 +5591,52 @@ prt("[
                }
 
                /* Hack -- try showing */
-               if (k == '=')
+               if (skey == '=')
                {
                        /* Get "shower" */
 #ifdef JP
-prt("¶¯Ä´: ", hgt - 1, 0);
+                       prt("¶¯Ä´: ", hgt - 1, 0);
 #else
                        prt("Show: ", hgt - 1, 0);
 #endif
 
-                       (void)askfor_aux(shower, 80);
+                       (void)askfor(shower_str, 80);
+
+                       /* Make it lowercase */
+                       str_tolower(shower_str);
+
+                       /* Show it */
+                       shower = shower_str;
                }
 
                /* Hack -- try finding */
-               if (k == '/')
+               if (skey == '/' || skey == KTRL('s'))
                {
                        /* Get "finder" */
 #ifdef JP
-prt("¸¡º÷: ", hgt - 1, 0);
+                       prt("¸¡º÷: ", hgt - 1, 0);
 #else
                        prt("Find: ", hgt - 1, 0);
 #endif
 
 
-                       if (askfor_aux(finder, 80))
+                       if (askfor(finder_str, 80))
                        {
                                /* Find it */
-                               find = finder;
+                               find = finder_str;
                                back = line;
                                line = line + 1;
 
                                /* Make finder lowercase */
-                               for (cnt = 0; finder[cnt] != 0; cnt++)
-                               {
-#ifdef JP
-                                       if (iskanji(finder[cnt]))
-                                               cnt++;
-                                       else
-#endif
-                                               finder[cnt] = tolower(finder[cnt]);
-                               }
+                               str_tolower(finder_str);
 
                                /* Show it */
-                               strcpy(shower, finder);
+                               shower = finder_str;
                        }
                }
 
                /* Hack -- go to a specific line */
-               if (k == '#')
+               if (skey == '#')
                {
                        char tmp[81];
 #ifdef JP
@@ -5398,14 +5647,26 @@ prt("
 
                        strcpy(tmp, "0");
 
-                       if (askfor_aux(tmp, 80))
+                       if (askfor(tmp, 80))
                        {
                                line = atoi(tmp);
                        }
                }
 
+               /* Hack -- go to the top line */
+               if (skey == SKEY_TOP)
+               {
+                       line = 0;
+               }
+
+               /* Hack -- go to the bottom line */
+               if (skey == SKEY_BOTTOM)
+               {
+                       line = ((size-1)/rows)*rows;
+               }
+
                /* Hack -- go to a specific file */
-               if (k == '%')
+               if (skey == '%')
                {
                        char tmp[81];
 #ifdef JP
@@ -5417,21 +5678,28 @@ strcpy(tmp, "jhelp.hlp");
 #endif
 
 
-                       if (askfor_aux(tmp, 80))
+                       if (askfor(tmp, 80))
                        {
-                               if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
+                               if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
                        }
                }
 
                /* Allow backing up */
-               if (k == '-')
+               if (skey == '-')
                {
                        line = line + (reverse ? rows : -rows);
                        if (line < 0) line = 0;
                }
 
+               /* One page up */
+               if (skey == SKEY_PGUP)
+               {
+                       line = line - rows;
+                       if (line < 0) line = 0;
+               }
+
                /* Advance a single line */
-               if ((k == '\n') || (k == '\r'))
+               if ((skey == '\n') || (skey == '\r'))
                {
                        line = line + (reverse ? -1 : 1);
                        if (line < 0) line = 0;
@@ -5439,19 +5707,25 @@ strcpy(tmp, "jhelp.hlp");
 
 
                /* Move up / down */
-               if (k == '8')
+               if (skey == '8' || skey == SKEY_UP)
                {
                        line--;
                        if (line < 0) line = 0;
                }
 
-               if (k == '2') line++;
+               if (skey == '2' || skey == SKEY_DOWN) line++;
 
                /* Advance one page */
-               if (k == ' ')
+               if (skey == ' ')
                {
                        line = line + (reverse ? -rows : rows);
-                       if (line < 0) line = ((size-1)/rows)*rows;
+                       if (line < 0) line = 0;
+               }
+
+               /* One page down */
+               if (skey == SKEY_PGDOWN)
+               {
+                       line = line + rows;
                }
 
                /* Recurse on numbers */
@@ -5459,19 +5733,19 @@ strcpy(tmp, "jhelp.hlp");
                {
                        int key = -1;
 
-                       if (isalpha(k))
-                               key = k - 'A';
+                       if (!(skey & SKEY_MASK) && isalpha(skey))
+                               key = skey - 'A';
 
                        if ((key > -1) && hook[key][0])
                        {
                                /* Recurse on that file */
                                if (!show_file(TRUE, hook[key], NULL, 0, mode))
-                                       k = 'q';
+                                       skey = 'q';
                        }
                }
 
                /* Hack, dump to file */
-               if (k == '|')
+               if (skey == '|')
                {
                        FILE *ffp;
                        char buff[1024];
@@ -5508,7 +5782,7 @@ msg_print("
                                msg_print("Failed to open file.");
 #endif
 
-                               k = ESCAPE;
+                               skey = ESCAPE;
                                break;
                        }
 
@@ -5527,16 +5801,22 @@ msg_print("
                        fff = my_fopen(path, "r");
                }
 
-               /* Exit on escape */
-               if (k == ESCAPE) break;
-               if (k == 'q') break;
+               /* Return to last screen */
+               if (skey == ESCAPE) break;
+               if (skey == '<') break;
+
+               /* Exit on the ^q */
+               if (skey == KTRL('q')) skey = 'q';
+
+               /* Exit on the q key */
+               if (skey == 'q') break;
        }
 
        /* Close the file */
        my_fclose(fff);
 
        /* Escape */
-       if (k == 'q') return (FALSE);
+       if (skey == 'q') return (FALSE);
 
        /* Normal return */
        return (TRUE);
@@ -5665,7 +5945,7 @@ quit_fmt("'%s' 
                }
 #ifdef MSDOS
                /* Convert space, dot, and underscore to underscore */
-               else if (strchr(". _", c)) player_base[k++] = '_';
+               else if (my_strchr(". _", c)) player_base[k++] = '_';
 #endif
                else if (isprint(c)) player_base[k++] = c;
        }
@@ -5700,7 +5980,7 @@ quit_fmt("'%s' 
                while (1)
                {
                        cptr t;
-                       t = strstr(s, PATH_SEP);
+                       t = my_strstr(s, PATH_SEP);
                        if (!t)
                                break;
                        s = t+1;
@@ -5838,6 +6118,28 @@ prt("
                if (i != '@') return;
        }
 
+       /* Initialize "last message" buffer */
+       if (p_ptr->last_message) string_free(p_ptr->last_message);
+       p_ptr->last_message = NULL;
+
+       /* Hack -- Note *winning* message */
+       if (p_ptr->total_winner && last_words)
+       {
+               char buf[1024] = "";
+
+#ifdef JP
+               while (!get_string("*¾¡Íø*¥á¥Ã¥»¡¼¥¸: ", buf, sizeof buf)) ;
+#else
+               while (!get_string("*Winning* message: ", buf, sizeof buf)) ;
+#endif
+
+               if (buf[0])
+               {
+                       p_ptr->last_message = string_make(buf);
+                       msg_print(p_ptr->last_message);
+               }
+       }
+
        /* Stop playing */
        p_ptr->playing = FALSE;
 
@@ -5954,6 +6256,11 @@ prt("
        (void)strcpy(p_ptr->died_from, "(alive and well)");
 #endif
 
+       /* Update some things */
+       p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_DISTANCE);
+
+       /* Update stuff */
+       update_stuff();
 }
 
 
@@ -6001,7 +6308,7 @@ long total_points(void)
                if(max_dlv[i] > max_dl)
                        max_dl = max_dlv[i];
 
-       point_l = (p_ptr->max_exp + (100 * max_dl));
+       point_l = (p_ptr->max_max_exp + (100 * max_dl));
        point_h = point_l / 0x10000L;
        point_l = point_l % 0x10000L;
        point_h *= mult;
@@ -6014,7 +6321,7 @@ long total_points(void)
        point_l /= 100;
 
        point = (point_h << 16) + (point_l);
-       if (p_ptr->arena_number < 99)
+       if (p_ptr->arena_number >= 0)
                point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
 
        if (ironman_downward) point *= 2;
@@ -6418,7 +6725,7 @@ put_str("
                strcpy(out_val, "");
 
                /* Ask for filename (or abort) */
-               if (!askfor_aux(out_val, 60)) return;
+               if (!askfor(out_val, 60)) return;
 
                /* Return means "show on screen" */
                if (!out_val[0]) break;
@@ -6510,7 +6817,7 @@ prt("
                                        prt(tmp_val, j+2, 4);
 
                                        /* Display object description */
-                                       object_desc(o_name, o_ptr, TRUE, 3);
+                                       object_desc(o_name, o_ptr, 0);
                                        c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
                                }
 
@@ -6842,7 +7149,7 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
 {
        FILE    *fp;
        char    buf[1024];
-       int     line, counter, test, numentries = 0;
+       int     counter, test;
        int     line_num = 0;
 
 
@@ -6853,7 +7160,7 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
        fp = my_fopen(buf, "r");
 
        /* Failed */
-       if (!fp) return (-1);
+       if (!fp) return -1;
 
        /* Find the entry of the monster */
        while (TRUE)
@@ -6875,34 +7182,24 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
                                }
                                else if (buf[2] == 'M')
                                {
-                                       if (r_info[entry].flags1 & RF1_MALE)
-                                       {
-                                               break;
-                                       }
+                                       if (r_info[entry].flags1 & RF1_MALE) break;
                                }
                                else if (buf[2] == 'F')
                                {
-                                       if (r_info[entry].flags1 & RF1_FEMALE)
-                                       {
-                                               break;
-                                       }
+                                       if (r_info[entry].flags1 & RF1_FEMALE) break;
                                }
                                /* Get the monster number */
                                else if (sscanf(&(buf[2]), "%d", &test) != EOF)
                                {
-                                       /* Is it the right monster? */
-                                       if (test == entry)
-                                       {
-                                               break;
-                                       }
+                                       /* Is it the right number? */
+                                       if (test == entry) break;
                                }
                                else
                                {
-                                       /* Error while converting the monster number */
-                                       msg_format("Error in line %d of %s!",
-                                                 line_num, file_name);
+                                       /* Error while converting the number */
+                                       msg_format("Error in line %d of %s!", line_num, file_name);
                                        my_fclose(fp);
-                                       return (-1);
+                                       return -1;
                                }
                        }
                }
@@ -6910,126 +7207,67 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
                {
                        /* Reached end of file */
                        my_fclose(fp);
-                       return (-1);
+                       return -1;
                }
        }
 
-       /* Get the number of entries */
-       while (TRUE)
+       /* Get the random line */
+       for (counter = 0; ; counter++)
        {
-               /* Get the line */
-               if (my_fgets(fp, buf, sizeof(buf)) == 0)
-               {
-                       /* Count the lines */
-                       line_num++;
-
-                       /* Look for the number of entries */
-                       if (isdigit(buf[0]))
-                       {
-                               int i;
-                               bool digit = TRUE;
-
-                               for (i = 1; buf[i] && (buf[i] != '\n') && (buf[i] != '\r'); i++)
-                               {
-                                       if (!isdigit(buf[i]))
-                                       {
-                                               digit = FALSE;
-                                               break;
-                                       }
-                               }
-
-                               /* Get the number of entries */
-                               if (digit)
-                               {
-                                       numentries = atoi(buf);
-                                       break;
-                               }
-                       }
-               }
-               else
+               while (TRUE)
                {
-                       /* Count the lines */
-                       line_num++;
-
-                       /* Reached end of file without finding the number */
-                       msg_format("Error in line %d of %s!",
-                                 line_num, file_name);
-
-                       my_fclose(fp);
-                       return (-1);
-               }
-       }
-
-       if (numentries > 0)
-       {
-               /* Grab an appropriate line number */
-               line = randint0(numentries);
+                       test = my_fgets(fp, buf, sizeof(buf));
 
-               /* Get the random line */
-               for (counter = 0; counter <= line; counter++)
-               {
                        /* Count the lines */
-                       line_num++;
+                       /* line_num++; No more needed */
 
-                       while(TRUE)
+                       if (!test)
                        {
-                               test = my_fgets(fp, buf, sizeof(buf));
-                               if(test || buf[0] != '#')
-                                       break;
-                       }
+                               /* Ignore lines starting with 'N:' */
+                               if ((buf[0] == 'N') && (buf[1] == ':')) continue;
 
-                       if (test==0)
-                       {
-                               /* Found the line */
-                               if (counter == line) break;
-                       }
-                       else
-                       {
-                               /* Error - End of file */
-                               msg_format("Error in line %d of %s!",
-                                         line_num, file_name);
-
-                               my_fclose(fp);
-                               return (-1);
+                               if (buf[0] != '#') break;
                        }
+                       else break;
                }
 
+               /* Abort */
+               if (!buf[0]) break;
+
                /* Copy the line */
-               strcpy(output, buf);
-       }
-       else
-       {
-               return (-1);
+               if (one_in_(counter + 1)) strcpy(output, buf);
        }
 
        /* Close the file */
        my_fclose(fp);
 
        /* Success */
-       return (0);
+       return counter ? 0 : -1;
 }
 
 
 #ifdef JP
 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
 {
-  int i,j,kanji;
-  errr result=1;
-  for (i=0;i<count;i++){
-    result=get_rnd_line(file_name, entry, output);
-    if(result)break;
-    kanji=0;
-    for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
-    if(kanji)break;
-  }
-  return(result);
+       int  i, j, kanji;
+       errr result = 1;
+
+       for (i = 0; i < count; i++)
+       {
+               result = get_rnd_line(file_name, entry, output);
+               if (result) break;
+               kanji = 0;
+               for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
+               if (kanji) break;
+       }
+       return result;
 }
 #endif
 
 /*
  * Process file for auto picker/destroyer.
  */
-errr process_pickpref_file(cptr name)
+errr process_autopick_file(cptr name)
 {
        char buf[1024];
 
@@ -7038,7 +7276,7 @@ errr process_pickpref_file(cptr name)
        /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
 
-       err = process_pref_file_aux(buf, PREF_TYPE_PICKPREF);
+       err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
 
        /* Result */
        return (err);
@@ -7051,14 +7289,19 @@ errr process_pickpref_file(cptr name)
 errr process_histpref_file(cptr name)
 {
        char buf[1024];
-
        errr err = 0;
+       bool old_character_xtra = character_xtra;
 
        /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
 
+       /* Hack -- prevent modification birth options in this file */
+       character_xtra = TRUE;
+
        err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
 
+       character_xtra = old_character_xtra;
+
        /* Result */
        return (err);
 }
@@ -7151,8 +7394,14 @@ errr counts_write(int where, u32b count)
                /* File type is "DATA" */
                FILE_TYPE(FILE_TYPE_DATA);
 
+               /* Grab permissions */
+               safe_setuid_grab();
+
                /* Create a new high score file */
                fd = fd_make(buf, 0644);
+
+               /* Drop permissions */
+               safe_setuid_drop();
        }
 
        /* Grab permissions */