OSDN Git Service

カメレオンの処理の変更で、たぬきの処理に副作用が出てしまっていたので修正。
[hengbandforosx/hengbandosx.git] / src / files.c
index 49e575f..88f49d1 100644 (file)
@@ -327,6 +327,10 @@ static named_num gf_desc[] =
        {"GF_SEEKER",                   GF_SEEKER                       },
        {"GF_SUPER_RAY",                GF_SUPER_RAY                    },
        {"GF_STAR_HEAL",                GF_STAR_HEAL                    },
+       {"GF_WATER_FLOW",               GF_WATER_FLOW                   },
+       {"GF_CRUSADE",          GF_CRUSADE                      },
+       {"GF_STASIS_EVIL",                      GF_STASIS_EVIL          },
+       {"GF_WOUNDS",                   GF_WOUNDS               },
        {NULL,                                          0                                               }
 };
 
@@ -407,15 +411,6 @@ errr process_pref_file_command(char *buf)
        char *zz[16];
 
 
-       /* Skip "empty" lines */
-       if (!buf[0]) return (0);
-
-       /* Skip "blank" lines */
-       if (isspace(buf[0])) return (0);
-
-       /* Skip comments */
-       if (buf[0] == '#') return (0);
-
        /* Require "?:*" format */
        if (buf[1] != ':') return (1);
 
@@ -592,16 +587,35 @@ errr process_pref_file_command(char *buf)
                        int ob = option_info[i].o_bit;
 
                        if (option_info[i].o_var &&
-                                option_info[i].o_text &&
-                                streq(option_info[i].o_text, buf + 2) &&
-                               (!alive || option_info[i].o_page !=6))
+                           option_info[i].o_text &&
+                           streq(option_info[i].o_text, buf + 2))
                        {
+                               if (alive && 6 == option_info[i].o_page && !wizard)
+                               {
+#ifdef JP
+                                       msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤­¤Þ¤»¤ó! '%s'", buf);        
+#else
+                                       msg_format("Startup options can not changed! '%s'", buf);       
+#endif
+                                       msg_print(NULL);
+                                       return 0;
+                               }
+
                                /* Clear */
                                option_flag[os] &= ~(1L << ob);
                                (*option_info[i].o_var) = FALSE;
                                return (0);
                        }
                }
+
+               /* don't know that option. ignore it.*/
+#ifdef JP
+               msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
+#else
+               msg_format("Ignored invalid option: %s", buf);
+#endif
+               msg_print(NULL);
+               return 0;
        }
 
        /* Process "Y:<str>" -- turn option on */
@@ -613,16 +627,35 @@ errr process_pref_file_command(char *buf)
                        int ob = option_info[i].o_bit;
 
                        if (option_info[i].o_var &&
-                                option_info[i].o_text &&
-                                streq(option_info[i].o_text, buf + 2) &&
-                               (!alive || option_info[i].o_page !=6))
+                           option_info[i].o_text &&
+                           streq(option_info[i].o_text, buf + 2))
                        {
+                               if (alive && 6 == option_info[i].o_page && !wizard)
+                               {
+#ifdef JP
+                                       msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤­¤Þ¤»¤ó! '%s'", buf);        
+#else
+                                       msg_format("Startup options can not changed! '%s'", buf);       
+#endif
+                                       msg_print(NULL);
+                                       return 0;
+                               }
+
                                /* Set */
                                option_flag[os] |= (1L << ob);
                                (*option_info[i].o_var) = TRUE;
                                return (0);
                        }
                }
+
+               /* don't know that option. ignore it.*/
+#ifdef JP
+               msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
+#else
+               msg_format("Ignored invalid option: %s", buf);
+#endif
+               msg_print(NULL);
+               return 0;
        }
 
        /* Process "Z:<type>:<str>" -- set spell color */
@@ -953,26 +986,6 @@ static cptr process_pref_file_expr(char **sp, char *fp)
 #endif
                        }
 
-                       /* First realm */
-                       else if (streq(b+1, "REALM1"))
-                       {
-#ifdef JP
-                               v = E_realm_names[p_ptr->realm1];
-#else
-                                v = realm_names[p_ptr->realm1];
-#endif
-                       }
-
-                       /* Second realm */
-                       else if (streq(b+1, "REALM2"))
-                       {
-#ifdef JP
-                                v = E_realm_names[p_ptr->realm2];
-#else
-                               v = realm_names[p_ptr->realm2];
-#endif
-                       }
-
                        /* Player */
                        else if (streq(b+1, "PLAYER"))
                        {
@@ -1025,10 +1038,51 @@ static cptr process_pref_file_expr(char **sp, char *fp)
 }
 
 
+
+/*
+ *  Process line for auto picker/destroyer.
+ */
+static errr process_pickpref_file_line(char *buf)
+{
+       autopick_type entry;
+       int i;
+
+       if (max_autopick == MAX_AUTOPICK)
+               return 1;
+       
+       /* Nuke illegal char */
+       for(i = 0; buf[i]; i++)
+       {
+#ifdef JP
+               if (iskanji(buf[i]))
+               {
+                       i++;
+                       continue;
+               }
+#endif
+               if (isspace(buf[i]) && buf[i] != ' ')
+                       break;
+       }
+       buf[i] = 0;
+       
+       if (!autopick_new_entry(&entry, buf)) return 0;
+
+       /* Already has the same entry? */ 
+       for(i = 0; i < max_autopick; i++)
+               if(!strcmp(entry.name, autopick_list[i].name)
+                  && entry.flag[0] == autopick_list[i].flag[0]
+                  && entry.flag[1] == autopick_list[i].flag[1]) return 0;
+
+       autopick_list[max_autopick++] = entry;
+       return 0;
+}
+
+
+
 /*
  * Open the "user pref file" and parse it.
  */
-static errr process_pref_file_aux(cptr name)
+static errr process_pref_file_aux(cptr name, bool read_pickpref)
 {
        FILE *fp;
 
@@ -1055,11 +1109,13 @@ static errr process_pref_file_aux(cptr name)
                /* Count lines */
                line++;
 
-
                /* Skip "empty" lines */
                if (!buf[0]) continue;
 
                /* Skip "blank" lines */
+#ifdef JP
+               if (!iskanji(buf[0]))
+#endif
                if (isspace(buf[0])) continue;
 
                /* Skip comments */
@@ -1098,7 +1154,10 @@ static errr process_pref_file_aux(cptr name)
                if (buf[0] == '%')
                {
                        /* Process that file if allowed */
-                       (void)process_pref_file(buf + 2);
+                       if (read_pickpref)
+                               (void)process_pickpref_file(buf + 2);
+                       else
+                               (void)process_pref_file(buf + 2);
 
                        /* Continue */
                        continue;
@@ -1108,8 +1167,13 @@ static errr process_pref_file_aux(cptr name)
                /* Process the line */
                err = process_pref_file_command(buf);
 
-               /* Oops */
-               if (err) break;
+               /* This is not original pref line... */
+               if (err)
+               {
+                       if (!read_pickpref)
+                               break;
+                       err = process_pickpref_file_line(buf);
+               }
        }
 
 
@@ -1149,26 +1213,37 @@ errr process_pref_file(cptr name)
 {
        char buf[1024];
 
-       errr err = 0;
+       errr err1, err2;
 
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_PREF, name);
 
-       /* Process the pref file */
-       err = process_pref_file_aux(buf);
+       /* Process the system pref file */
+       err1 = process_pref_file_aux(buf, FALSE);
 
        /* Stop at parser errors, but not at non-existing file */
-       if (err < 1)
-       {
-               /* Build the filename */
-               path_build(buf, 1024, ANGBAND_DIR_USER, name);
+       if (err1 > 0) return err1;
 
-               /* Process the pref file */
-               err = process_pref_file_aux(buf);
-       }
 
-       /* Result */
-       return (err);
+       /* Drop priv's */
+       safe_setuid_drop();
+       
+       /* Build the filename */
+       path_build(buf, 1024, ANGBAND_DIR_USER, name);
+       
+       /* Process the user pref file */
+       err2 = process_pref_file_aux(buf, FALSE);
+
+       /* Grab priv's */
+       safe_setuid_grab();
+
+
+       /* User file does not exist, but read system pref file */
+       if (err2 < 0 && !err1)
+               return -2;
+
+       /* Result of user file processing */
+       return err2;
 }
 
 
@@ -1410,75 +1485,190 @@ errr check_load_init(void)
 }
 
 
-/*
- * Print long number with header at given row, column
- * Use the color for the number, not the header
- */
-static void prt_lnum(cptr header, s32b num, int row, int col, byte color)
+#define ENTRY_BARE_HAND 0
+#define ENTRY_TWO_HANDS 1
+#define ENTRY_RIGHT_HAND1 2
+#define ENTRY_LEFT_HAND1 3
+#define ENTRY_LEFT_HAND2 4
+#define ENTRY_RIGHT_HAND2 5
+#define ENTRY_POSTURE 6
+#define ENTRY_SHOOT_HIT_DAM 7
+#define ENTRY_SHOOT_POWER 8
+#define ENTRY_SPEED 9
+#define ENTRY_BASE_AC 10
+#define ENTRY_LEVEL 11
+#define ENTRY_CUR_EXP 12
+#define ENTRY_MAX_EXP 13
+#define ENTRY_EXP_TO_ADV 14
+#define ENTRY_GOLD 15
+#define ENTRY_DAY 16
+#define ENTRY_HP 17
+#define ENTRY_SP 18
+#define ENTRY_PLAY_TIME 19
+#define ENTRY_SKILL_FIGHT 20
+#define ENTRY_SKILL_SHOOT 21
+#define ENTRY_SKILL_SAVING 22
+#define ENTRY_SKILL_STEALTH 23
+#define ENTRY_SKILL_PERCEP 24
+#define ENTRY_SKILL_SEARCH 25
+#define ENTRY_SKILL_DISARM 26
+#define ENTRY_SKILL_DEVICE 27
+#define ENTRY_BLOWS 28
+#define ENTRY_SHOTS 29
+#define ENTRY_AVG_DMG 30
+#define ENTRY_INFRA 31
+
+#define ENTRY_NAME 32
+#define ENTRY_SEX 33
+#define ENTRY_RACE 34
+#define ENTRY_CLASS 35
+#define ENTRY_REALM 36
+#define ENTRY_PATRON 37
+#define ENTRY_AGE 38
+#define ENTRY_HEIGHT 39
+#define ENTRY_WEIGHT 40
+#define ENTRY_SOCIAL 41
+#define ENTRY_ALIGN 42
+
+
+static struct
 {
-       int len = strlen(header);
-       char out_val[32];
-       put_str(header, row, col);
-       (void)sprintf(out_val, "%9ld", (long)num);
-       c_put_str(color, out_val, row, col + len);
-}
-
+       int col;
+       int row;
+       int len;
+       char header[20];
+} disp_player_line[]
+#ifdef JP
+= {
+       { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
+       { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
+       { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
+       { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
+       { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
+       { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
+       { 1, 11, 25, ""},
+       { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
+       { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
+       {01, 20, 25, "²Ã®"},
+       { 1, 19, 25, "£Á£Ã"},
+       {29, 13, 21, "¥ì¥Ù¥ë"},
+       {29, 14, 21, "·Ð¸³ÃÍ"},
+       {29, 15, 21, "ºÇÂç·Ð¸³"},
+       {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
+       {29, 17, 21, "½ê»ý¶â"},
+       {29, 19, 21, "ÆüÉÕ"},
+       {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, "ÀÖ³°Àþ»ëÎÏ:"},
+       {26,  1, -1, "̾Á°  : "},
+       { 1,  3, -1, "À­ÊÌ     : "},
+       { 1,  4, -1, "¼ï²     : "},
+       { 1,  5, -1, "¿¦¶È     : "},
+       { 1,  6, -1, "ËâË¡     : "},
+       { 1,  7, -1, "¼é¸îËâ¿À : "},
+       {29,  3, 21, "ǯÎð"},
+       {29,  4, 21, "¿ÈĹ"},
+       {29,  5, 21, "ÂνÅ"},
+       {29,  6, 21, "¼Ò²ñŪÃÏ°Ì"},
+       {29,  7, 21, "°À­"},
+};
+#else
+= {
+       { 1, 10, 25, "Bare hand"},
+       { 1, 10, 25, "Two hands"},
+       { 1, 10, 25, "Right hand"},
+       { 1, 10, 25, "Left hand"},
+       { 1, 11, 25, "Left hand"},
+       { 1, 11, 25, "Right hand"},
+       { 1, 11, 25, "Posture"},
+       { 1, 15, 25, "Shooting"},
+       { 1, 16, 25, "Multiplier"},
+       {01, 20, 25, "Speed"},
+       { 1, 19, 25, "AC"},
+       {29, 13, 21, "Level"},
+       {29, 14, 21, "Experience"},
+       {29, 15, 21, "Max Exp"},
+       {29, 16, 21, "Exp to Adv"},
+       {29, 17, 21, "Gold"},
+       {29, 19, 21, "Time"},
+       {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: "},
+       {26,  1, -1, "Name  : "},
+       { 1,  3, -1, "Sex      : "},
+       { 1,  4, -1, "Race     : "},
+       { 1,  5, -1, "Class    : "},
+       { 1,  6, -1, "Magic    : "},
+       { 1,  7, -1, "Patron   : "},
+       {29,  3, 21, "Age"},
+       {29,  4, 21, "Height"},
+       {29,  5, 21, "Weight"},
+       {29,  6, 21, "Social Class"},
+       {29,  7, 21, "Align"},
+};
+#endif
 
-/*
- * Print number with header at given row, column
- */
-static void prt_num(cptr header, int num, int row, int col, byte color)
+static void display_player_one_line(int entry, cptr val, byte attr)
 {
-       int len = strlen(header);
-       char out_val[32];
-       put_str(header, row, col);
-       put_str("   ", row, col + len);
-       (void)sprintf(out_val, "%6ld", (long)num);
-       c_put_str(color, out_val, row, col + len + 3);
-}
+       char buf[40];
 
+       int row = disp_player_line[entry].row;
+       int col = disp_player_line[entry].col;
+       int len = disp_player_line[entry].len;
+       cptr head = disp_player_line[entry].header;
 
-#ifdef JP
-/*    ÆüËܸìÈdzÈÄ¥
- *         £È£Ð / ºÇÂ砤Τ褦¤Êɽ¼¨
- *        xxxxx / yyyyy
- */
-static void prt_num_max( int num, int max , int row, int col, byte color1, byte color2 )
-{
-       char out_val[32];
-       (void)sprintf(out_val, "%5ld", (long)num);
-       c_put_str(color1, out_val, row, col );
-       put_str("/",row, col+6);
-       (void)sprintf(out_val, "%5ld", (long)max);
-       c_put_str(color2, out_val, row, col+8 );
-}
+       int head_len = strlen(head);
 
-/*    ÆüËܸìÈdzÈÄ¥
- *    xx ºÐ  ¤È¤« xx kg ¤Ê¤É¤Îɽ¼¨ÍÑ cptr tailer ¤Ëñ°Ì¤¬Æþ¤ë¡£
- */
-static void prt_num2(cptr header, cptr tailer, int num, int row, int col, byte color)
-{
-       int len = strlen(header);
-       char out_val[32];
-       put_str(header, row, col);
-       put_str("   ", row, col + len);
-       (void)sprintf(out_val, "%6ld", (long)num);
-       c_put_str(color, out_val, row, col + len + 3);
-       put_str(tailer, row, col + len + 3+6);
+       Term_putstr(col, row, -1, TERM_WHITE, head);
+
+       if (!val)
+               return;
+
+       if (len > 0)
+       {
+               int val_len = len - head_len;
+               sprintf(buf, "%*.*s", val_len, val_len, val);
+               Term_putstr(col + head_len, row, -1, attr, buf);
+       }
+       else
+       {
+               Term_putstr(col + head_len, row, -1, attr, val);
+       }
+
+       return;
 }
-#endif
+
+
 /*
  * Prints the following information on the screen.
- *
- * For this to look right, the following should be spaced the
- * same as in the prt_lnum code... -CFT
  */
 static void display_player_middle(void)
 {
         char buf[160];
-#ifdef JP
-        byte statcolor;
-#endif
        int show_tohit, show_todam;
        object_type *o_ptr;
        int tmul = 0;
@@ -1498,22 +1688,14 @@ static void display_player_middle(void)
                sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
 
                /* Dump the bonuses to hit/dam */
-#ifdef JP
                if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
-                       Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(³ÊÆ®)");
+                       display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
                else if(p_ptr->ryoute)
-                       Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(ξ¼ê)");
+                       display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
+               else if (left_hander)
+                       display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
                else
-                       Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(º¸¼ê)" : "ÂǷ⽤Àµ(±¦¼ê)"));
-#else
-               if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
-                       Term_putstr(1, 9, -1, TERM_WHITE, "Melee(bare h.)");
-               else if(p_ptr->ryoute)
-                       Term_putstr(1, 9, -1, TERM_WHITE, "Melee(2hands)");
-               else
-                       Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "Melee(Left)" : "Melee(Right)"));
-#endif
-               Term_putstr(15, 9, -1, TERM_L_BLUE, format("%11s", buf));
+                       display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
        }
 
        if(p_ptr->hidarite)
@@ -1531,12 +1713,10 @@ static void display_player_middle(void)
                sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
 
                /* Dump the bonuses to hit/dam */
-#ifdef JP
-               Term_putstr(1, 10, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(±¦¼ê)" : "ÂǷ⽤Àµ(º¸¼ê)"));
-#else
-               Term_putstr(1, 10, -1, TERM_WHITE, "Melee(Left)");
-#endif
-               Term_putstr(15, 10, -1, TERM_L_BLUE, format("%11s", buf));
+               if (left_hander)
+                       display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
+               else
+                       display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
        }
        else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
        {
@@ -1547,17 +1727,18 @@ static void display_player_middle(void)
                        {
                                if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
                        }
+                       if (i < MAX_KAMAE)
 #ifdef JP
-                       if (i < MAX_KAMAE) Term_putstr(16, 10, -1, TERM_YELLOW, format("%s¤Î¹½¤¨", kamae_shurui[i].desc));
+                               display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
 #else
-                       if (i < MAX_KAMAE) Term_putstr(10, 10, -1, TERM_YELLOW, format("%11.11s form", kamae_shurui[i].desc));
+                               display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
 #endif
                }
                else
 #ifdef JP
-                       Term_putstr(18, 10, -1, TERM_YELLOW, "¹½¤¨¤Ê¤·");
+                               display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
 #else
-                       Term_putstr(16, 10, -1, TERM_YELLOW, "no posture");
+                               display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
 #endif
        }
 
@@ -1572,237 +1753,166 @@ static void display_player_middle(void)
        if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
        if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
 
-       show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
+       if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
+               show_tohit += (weapon_exp[0][o_ptr->sval])/400;
+       else
+               show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
 
        /* Range attacks */
-       sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
-#ifdef JP
-       Term_putstr(1, 11, -1, TERM_WHITE, "¼Í·â¹¶·â½¤Àµ");
-#else
-       Term_putstr(1, 11, -1, TERM_WHITE, "Shoot");
-#endif
-       Term_putstr(15, 11, -1, TERM_L_BLUE, format("%11s", buf));
-
+       display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
        
        if (inventory[INVEN_BOW].k_idx)
        {
-               switch (inventory[INVEN_BOW].sval)
-               {
-                       /* Sling and ammo */
-                       case SV_SLING:
-                       {
-                               tmul = 2;
-                               break;
-                       }
+               tmul = bow_tmul(inventory[INVEN_BOW].sval);
 
-                       /* Short Bow and Arrow */
-                       case SV_SHORT_BOW:
-                       {
-                               tmul = 2;
-                               break;
-                       }
+               /* Get extra "power" from "extra might" */
+               if (p_ptr->xtra_might) tmul++;
 
-                       /* Long Bow and Arrow */
-                       case SV_LONG_BOW:
-                       case SV_NAMAKE_BOW:
-                       {
-                               tmul = 3;
-                               break;
-                       }
+               tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
+       }
 
-                       /* Light Crossbow and Bolt */
-                       case SV_LIGHT_XBOW:
-                       {
-                               tmul = 3;
-                               break;
-                       }
+       /* shoot power */
+       display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
 
-                       /* Heavy Crossbow and Bolt */
-                       case SV_HEAVY_XBOW:
-                       {
-                               tmul = 4;
-                               break;
-                       }
+       /* Dump the armor class */
+       display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
 
-                       /* Long Bow and Arrow */
-                       {
-                               tmul = 5;
-                               break;
-                       }
-               }
+       /* Dump speed */
+       {
+               bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
+               int tmp_speed = 0;
+               byte attr;
+               int i;
 
-               /* Get extra "power" from "extra might" */
-               if (p_ptr->xtra_might) tmul++;
+               i = p_ptr->pspeed-110;
 
-               tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       }
-       sprintf(buf, "x%d.%02d", tmul/100, tmul%100);
-#ifdef JP
-       Term_putstr(1, 12, -1, TERM_WHITE, "¼Í·âÉð´ïÇÜΨ");
-#else
-       Term_putstr(1, 12, -1, TERM_WHITE, "Shoot Power");
-#endif
-       Term_putstr(15, 12, -1, TERM_L_BLUE, format("%11s", buf));
+               /* Hack -- Visually "undo" the Search Mode Slowdown */
+               if (p_ptr->action == ACTION_SEARCH) i += 10;
 
-       /* Dump the armor class bonus */
-#ifdef JP
-prt_num("AC ½¤Àµ         ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
-#else
-       prt_num("+ To AC         ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
-#endif
+               if (i > 0)
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_GREEN;
+                       else
+                               attr = TERM_GREEN;
+               }
+               else if (i == 0)
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_BLUE;
+                       else
+                               attr = TERM_GREEN;
+               }
+               else
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_UMBER;
+                       else
+                               attr = TERM_RED;
+               }
 
+               if (!p_ptr->riding)
+               {
+                       if (is_fast) tmp_speed += 10;
+                       if (p_ptr->slow) tmp_speed -= 10;
+                       if (p_ptr->lightspeed) tmp_speed = 99;
+               }
+               else
+               {
+                       if (m_list[p_ptr->riding].fast) tmp_speed += 10;
+                       if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
+               }
 
-       /* Dump the total armor class */
+               if (tmp_speed)
+               {
+                       if (!p_ptr->riding)
+                               sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
+                       else
 #ifdef JP
-prt_num("´ðËÜ AC         ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
+                               sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
 #else
-       prt_num("Base AC         ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
+                               sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
 #endif
 
+                       if (tmp_speed > 0)
+                               attr = TERM_YELLOW;
+                       else
+                               attr = TERM_VIOLET;
+               }
+               else
+               {
+                       if (!p_ptr->riding)
+                               sprintf(buf, "(%+d)", i);
+                       else
 #ifdef JP
-prt_num("¥ì¥Ù¥ë     ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
+                               sprintf(buf, "¾èÇÏÃæ (%+d)", i);
 #else
-       prt_num("Level      ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
+                               sprintf(buf, "Riding (%+d)", i);
 #endif
+               }
+       
+               display_player_one_line(ENTRY_SPEED, buf, attr);
+       }
+
+       /* Dump character level */
+       display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
 
+       /* Dump experience */
        if (p_ptr->prace == RACE_ANDROID)
-       {
-put_str("·Ð¸³ÃÍ   ", 10, 28);
-c_put_str(TERM_L_GREEN, "    *****", 10, 28+11);
-       }
+               display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
        else if (p_ptr->exp >= p_ptr->max_exp)
-       {
-#ifdef JP
-prt_lnum("·Ð¸³ÃÍ     ", p_ptr->exp, 10, 28, TERM_L_GREEN);
-#else
-               prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_L_GREEN);
-#endif
-
-       }
+               display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
        else
-       {
-#ifdef JP
-prt_lnum("·Ð¸³ÃÍ     ", p_ptr->exp, 10, 28, TERM_YELLOW);
-#else
-               prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_YELLOW);
-#endif
-
-       }
+               display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
 
+       /* Dump max experience */
        if (p_ptr->prace == RACE_ANDROID)
-       {
-put_str("ºÇÂç·Ð¸³ ", 11, 28);
-c_put_str(TERM_L_GREEN, "    *****", 11, 28+11);
-       }
+               display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
        else
-#ifdef JP
-prt_lnum("ºÇÂç·Ð¸³   ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
-#else
-       prt_lnum("Max Exp    ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
-#endif
-
+               display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
 
+       /* Dump exp to advance */
        if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
-       {
-#ifdef JP
-put_str("¼¡¥ì¥Ù¥ë   ", 12, 28);
-c_put_str(TERM_L_GREEN, "    *****", 12, 28+11);
-#else
-               put_str("Exp to Adv.", 12, 28);
-               c_put_str(TERM_L_GREEN, "    *****", 12, 28+11);
-#endif
-
-       }
+               display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
        else
-       {
-#ifdef JP
-prt_lnum("¼¡¥ì¥Ù¥ë   ",
-#else
-               prt_lnum("Exp to Adv.",
-#endif
+               display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
 
-                        (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L),
-                        12, 28, TERM_L_GREEN);
-       }
+       /* Dump gold */
+       display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
 
-#ifdef JP
-prt_lnum("½ê»ý¶â     ", p_ptr->au, 13, 28, TERM_L_GREEN);
-#else
-       prt_lnum("Gold       ", p_ptr->au, 13, 28, TERM_L_GREEN);
-#endif
+       /* Dump Day */
+       {
+               int day, hour, min;
+               extract_day_hour_min(&day, &hour, &min);
 
+               sprintf(buf, 
 #ifdef JP
-prt_lnum("¥¿¡¼¥ó¿ô   ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN  );
+                       "%dÆüÌÜ %2d:%02d", 
 #else
-prt_lnum("Total turn ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN  );
+                       "Day %d %2d:%02d", 
 #endif
+                       day, hour, min);
+       }
+       display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
 
-#ifdef JP
-/*           54321 / 54321   */
-put_str("     £È£Ð /  ºÇÂç    ", 9, 52);
+       /* Dump hit point */
        if (p_ptr->chp >= p_ptr->mhp) 
-         statcolor = TERM_L_GREEN;
-       else
-       if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10) 
-         statcolor = TERM_YELLOW;
-       else
-         statcolor=TERM_RED;
-prt_num_max( p_ptr->chp , p_ptr->mhp, 10, 56, statcolor , TERM_L_GREEN);
-
-#else
-       prt_num("Max Hit Points ", p_ptr->mhp, 9, 52, TERM_L_GREEN);
-
-       if (p_ptr->chp >= p_ptr->mhp)
-       {
-               prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_L_GREEN);
-       }
-       else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
-       {
-               prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_YELLOW);
-       }
+               display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
+       else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10) 
+               display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
        else
-       {
-               prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_RED);
-       }
-#endif
-
+               display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
 
-#ifdef JP
-/*           54321 / 54321   */
-put_str("     £Í£Ð /  ºÇÂç    ", 11, 52);
+       /* Dump mana power */
        if (p_ptr->csp >= p_ptr->msp) 
-         statcolor = TERM_L_GREEN;
+               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) 
+               display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
        else
-       if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10) 
-         statcolor = TERM_YELLOW;
-       else
-         statcolor=TERM_RED;
-prt_num_max( p_ptr->csp , p_ptr->msp, 12, 56, statcolor , TERM_L_GREEN);
-#else
-       prt_num("Max SP (Mana)  ", p_ptr->msp, 11, 52, TERM_L_GREEN);
-
-       if (p_ptr->csp >= p_ptr->msp)
-       {
-               prt_num("Cur SP (Mana)  ", p_ptr->csp, 12, 52, TERM_L_GREEN);
-       }
-       else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
-       {
-               prt_num("Cur SP (Mana)  ", p_ptr->csp, 12, 52, TERM_YELLOW);
-       }
-       else
-       {
-               prt_num("Cur SP (Mana)  ", p_ptr->csp, 12, 52, TERM_RED);
-       }
-#endif
-
-       sprintf(buf, "%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60);
-#ifdef JP
-       Term_putstr(52, 14, -1, TERM_WHITE, "¥×¥ì¥¤»þ´Ö");
-#else
-       Term_putstr(52, 14, -1, TERM_WHITE, "Playtime");
-#endif
-       Term_putstr(63, 14, -1, TERM_L_GREEN, format("%11s", buf));
+               display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
 
+       /* Dump play time */
+       display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
 }
 
 
@@ -1955,7 +2065,6 @@ static void display_player_various(void)
        cptr            desc;
        int         muta_att = 0;
        u32b        f1, f2, f3;
-       int             energy_fire = 100;
        int             shots, shot_frac;
 
        object_type             *o_ptr;
@@ -1976,50 +2085,8 @@ static void display_player_various(void)
        /* If the player is wielding one? */
        if (o_ptr->k_idx)
        {
-               /* Analyze the launcher */
-               switch (o_ptr->sval)
-               {
-                       /* Sling and ammo */
-                       case SV_SLING:
-                       {
-                               energy_fire = 8000;
-                               break;
-                       }
-
-                       /* Short Bow and Arrow */
-                       case SV_SHORT_BOW:
-                       {
-                               energy_fire = 10000;
-                               break;
-                       }
-
-                       /* Long Bow and Arrow */
-                       case SV_LONG_BOW:
-                       {
-                               energy_fire = 10000;
-                               break;
-                       }
-               
-                       case SV_NAMAKE_BOW:
-                       {
-                               energy_fire = 7777;
-                               break;
-                       }
-               
-                       /* Light Crossbow and Bolt */
-                       case SV_LIGHT_XBOW:
-                       {
-                               energy_fire = 12000;
-                               break;
-                       }
+               s16b energy_fire = bow_energy(o_ptr->sval);
 
-                       /* Heavy Crossbow and Bolt */
-                       case SV_HEAVY_XBOW:
-                       {               
-                               energy_fire = 13333;
-                               break;
-                       }
-               }
                /* Calculate shots per round */
                shots = p_ptr->num_fire * 100;
                shot_frac = (shots * 100 / energy_fire) % 100;
@@ -2073,7 +2140,7 @@ static void display_player_various(void)
                        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, &f1, &f2, &f3);
-                       if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
+                       if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
                        {
                                /* vorpal blade */
                                basedam *= 5;
@@ -2085,7 +2152,7 @@ static void display_player_various(void)
                                basedam *= 11;
                                basedam /= 9;
                        }
-                       if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
+                       if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_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;
@@ -2107,104 +2174,36 @@ static void display_player_various(void)
        xfos = p_ptr->skill_fos;
 
 
-#ifdef JP
-put_str("ÂǷ⹶·âǽÎÏ :", 17, 1);
-#else
-       put_str("Fighting    :", 17, 1);
-#endif
-
        desc = likert(xthn, 12);
-       c_put_str(likert_color, desc, 17, 15);
-
-#ifdef JP
-put_str("¼Í·â¹¶·âǽÎÏ :", 18, 1);
-#else
-       put_str("Bows/Throw  :", 18, 1);
-#endif
+       display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
 
        desc = likert(xthb, 12);
-       c_put_str(likert_color, desc, 18, 15);
-
-#ifdef JP
-put_str("ËâË¡ËɸæǽÎÏ :", 19, 1);
-#else
-       put_str("Saving Throw:", 19, 1);
-#endif
+       display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
 
        desc = likert(xsav, 7);
-       c_put_str(likert_color, desc, 19, 15);
-
-#ifdef JP
-put_str("±£Ì©¹ÔưǽÎÏ :", 20, 1);
-#else
-       put_str("Stealth     :", 20, 1);
-#endif
+       display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
 
        desc = likert(xstl, 1);
-       c_put_str(likert_color, desc, 20, 15);
-
-
-#ifdef JP
-put_str("ÃγÐǽÎÏ     :", 17, 28);
-#else
-       put_str("Perception  :", 17, 28);
-#endif
+       display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
 
        desc = likert(xfos, 6);
-       c_put_str(likert_color, desc, 17, 42);
-
-#ifdef JP
-put_str("õº÷ǽÎÏ     :", 18, 28);
-#else
-       put_str("Searching   :", 18, 28);
-#endif
+       display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
 
        desc = likert(xsrh, 6);
-       c_put_str(likert_color, desc, 18, 42);
-
-#ifdef JP
-put_str("²ò½üǽÎÏ     :", 19, 28);
-#else
-       put_str("Disarming   :", 19, 28);
-#endif
+       display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
 
        desc = likert(xdis, 8);
-       c_put_str(likert_color, desc, 19, 42);
-
-#ifdef JP
-put_str("ËâË¡Æ»¶ñ»ÈÍÑ :", 20, 28);
-#else
-       put_str("Magic Device:", 20, 28);
-#endif
+       display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
 
        desc = likert(xdev, 6);
-       c_put_str(likert_color, desc, 20, 42);
-
-
-#ifdef JP
-put_str("ÂÇ·â²ó¿ô    :", 17, 55);
-#else
-       put_str("Blows/Round:", 17, 55);
-#endif
+       display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
 
        if (!muta_att)
-               put_str(format("%d+%d", blows1, blows2), 17, 69);
+               display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
        else
-               put_str(format("%d+%d+%d", blows1, blows2, muta_att), 17, 69);
+               display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
 
-#ifdef JP
-put_str("¼Í·â²ó¿ô    :", 18, 55);
-#else
-       put_str("Shots/Round:", 18, 55);
-#endif
-
-       put_str(format("%d.%02d", shots, shot_frac), 18, 69);
-
-#ifdef JP
-put_str("Ê¿¶Ñ¥À¥á¡¼¥¸:", 19, 55);                           
-#else
-       put_str("Wpn.dmg/Rnd:", 19, 55);        /* From PsiAngband */
-#endif
+       display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
 
 
        if ((damage[0]+damage[1]) == 0)
@@ -2212,20 +2211,9 @@ put_str("ʿ
        else
                desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
 
-       put_str(desc, 19, 69);
-
-#ifdef JP
-put_str("ÀÖ³°Àþ»ëÎÏ  :", 20, 55);
-#else
-       put_str("Infra-Vision:", 20, 55);
-#endif
-
-#ifdef JP
-put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
-#else
-       put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
-#endif
+       display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
 
+       display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
 }
 
 
@@ -2921,12 +2909,12 @@ static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
 /*
  * Helper function, see below
  */
-static void display_player_flag_aux(int row, int col, char *header,
+static void display_player_flag_aux(int row, int col, cptr header,
                                    int n, u32b flag1, u32b flag2,
                                    u32b im_f[], u32b vul_f)
 {
        int     i;
-       u32b    f[3];
+       u32b    f[4];
        bool    vuln = FALSE;
 
        if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
@@ -2942,19 +2930,20 @@ static void display_player_flag_aux(int row, int col, char *header,
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
                object_type *o_ptr;
-               f[0] = f[1] = f[2] = 0L;
+               f[0] = f[1] = f[2] = f[3] = 0L;
 
                /* Object */
                o_ptr = &inventory[i];
 
                /* Known flags */
                object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
+               f[3] = o_ptr->curse_flags;
 
                /* Default */
-               c_put_str(vuln ? TERM_RED : TERM_SLATE, ".", row, col);
+               c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
 
                /* Check flags */
-               if (f[n - 1] & flag1) c_put_str(vuln ? TERM_L_RED : TERM_WHITE, "+", row, col);
+               if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
                if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
 
                /* Advance */
@@ -2963,18 +2952,20 @@ static void display_player_flag_aux(int row, int col, char *header,
 
        /* Player flags */
        player_flags(&f[0], &f[1], &f[2]);
+       f[3] = 0L;
 
        /* Default */
-       c_put_str(vuln ? TERM_RED : TERM_SLATE, ".", row, col);
+       c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
 
        /* Check flags */
-       if (f[n-1] & flag1) c_put_str(vuln ? TERM_L_RED : TERM_WHITE, "+", row, col);
+       if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
 
        /* Timed player flags */
        tim_player_flags(&f[0], &f[1], &f[2], TRUE);
+       f[3] = 0L;
 
        /* Check flags */
-       if (f[n-1] & flag1) c_put_str(vuln ? TERM_ORANGE : TERM_YELLOW, "#", row, col);
+       if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
 
        /* Immunity */
        if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
@@ -3087,7 +3078,7 @@ display_player_flag_aux(row+5, col, "
 display_player_flag_aux(row+6, col, "µÞ²óÉü    :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
 display_player_flag_aux(row+7, col, "ÉâÍ·      :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸»  :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
-display_player_flag_aux(row+9, col, "¼ö¤¤      :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
+display_player_flag_aux(row+9, col, "¼ö¤¤      :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
 #else
        display_player_flag_aux(row+0, col, "Speed     :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
        display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
@@ -3098,7 +3089,7 @@ display_player_flag_aux(row+9, col, "
        display_player_flag_aux(row+6, col, "Regene.   :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
        display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
        display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
-       display_player_flag_aux(row+9, col, "Cursed    :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
+       display_player_flag_aux(row+9, col, "Cursed    :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
 #endif
 
 }
@@ -3199,7 +3190,7 @@ c_put_str(TERM_WHITE, "ǽ
 c_put_str(TERM_BLUE, "  ´ðËÜ", row, stat_col+7);
 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À­ Áõ ", row, stat_col+13);
 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
-c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
+c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
 #else
        c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
        c_put_str(TERM_BLUE, "  Base", row, stat_col+7);
@@ -3253,12 +3244,11 @@ c_put_str(TERM_YELLOW, "
                e_adj -= cp_ptr->c_adj[i];
                e_adj -= ap_ptr->a_adj[i];
 
-               /* Reduced name of stat */
-#ifdef JP
-               c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
-#else
-               c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
-#endif
+               if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
+                       /* Reduced name of stat */
+                       c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
+               else
+                       c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
 
 
                /* Internal "natural" max value.  Maxes at 18/100 */
@@ -3266,7 +3256,11 @@ c_put_str(TERM_YELLOW, "
                cnv_stat(p_ptr->stat_max[i], buf);
                if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
                {
+#ifdef JP
                        c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
+#else
+                       c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
+#endif
                }
                c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
 
@@ -3352,7 +3346,7 @@ c_put_str(TERM_L_GREEN, "ǽ
                                        a = TERM_RED;
 
                                        /* Label boost */
-                                       if (o_ptr->pval 10) c = '0' - o_ptr->pval;
+                                       if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
                                }
                        }
 
@@ -3445,7 +3439,7 @@ c_put_str(TERM_L_GREEN, "ǽ
                                        a = TERM_RED;
 
                                        /* Label boost */
-                                       if (dummy 10) c = '0' - dummy;
+                                       if (dummy > -10) c = '0' - dummy;
                                }
                        }
                }
@@ -3672,9 +3666,9 @@ NULL,
 "¥Æ¥ì¥Ý¡¼¥È",
 "È¿´¶",
 "½ËÊ¡",
-"¼ö¤¤",
-"½Å¤¤¼ö¤¤",
-"±Ê±ó¤Î¼ö¤¤"
+NULL,
+NULL,
+NULL,
 #else
        "NoTeleport",
        "AntiMagic",
@@ -3701,9 +3695,9 @@ NULL,
        "Teleport",
        "Aggravate",
        "Blessed",
-       "Cursed",
-       "Hvy Curse",
-       "Prm Curse"
+       NULL,
+       NULL,
+       NULL,
 #endif
 
 };
@@ -3775,12 +3769,12 @@ static void display_player_ben(void)
        b[3] |= (f2 >> 16);
        b[4] |= (f3 & 0xFFFF);
        b[5] |= (f3 >> 16);
-       color[0] = (f1 & 0xFFFF);
-       color[1] = (f1 >> 16);
-       color[2] = (f2 & 0xFFFF);
-       color[3] = (f2 >> 16);
-       color[4] = (f3 & 0xFFFF);
-       color[5] = (f3 >> 16);
+       color[0] = (u16b)(f1 & 0xFFFF);
+       color[1] = (u16b)(f1 >> 16);
+       color[2] = (u16b)(f2 & 0xFFFF);
+       color[3] = (u16b)(f2 >> 16);
+       color[4] = (u16b)(f3 & 0xFFFF);
+       color[5] = (u16b)(f3 >> 16);
 
        /* Scan cols */
        for (x = 0; x < 6; x++)
@@ -3890,12 +3884,12 @@ static void display_player_ben_one(int mode)
        b[n][3] |= (f2 >> 16);
        b[n][4] |= (f3 & 0xFFFF);
        b[n][5] |= (f3 >> 16);
-       color[0] = (f1 & 0xFFFF);
-       color[1] = (f1 >> 16);
-       color[2] = (f2 & 0xFFFF);
-       color[3] = (f2 >> 16);
-       color[4] = (f3 & 0xFFFF);
-       color[5] = (f3 >> 16);
+       color[0] = (u16b)(f1 & 0xFFFF);
+       color[1] = (u16b)(f1 >> 16);
+       color[2] = (u16b)(f2 & 0xFFFF);
+       color[3] = (u16b)(f2 >> 16);
+       color[4] = (u16b)(f3 & 0xFFFF);
+       color[5] = (u16b)(f3 >> 16);
 
 
        /* Scan cols */
@@ -3972,7 +3966,7 @@ void display_player(int mode)
 
 
        /* XXX XXX XXX */
-       if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
+       if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
                mode = (mode % 7);
        else
                mode = (mode % 6);
@@ -3985,67 +3979,42 @@ void display_player(int mode)
        {
                /* Name, Sex, Race, Class */
 #ifdef JP
-put_str("̾Á°  :", 1,26);
-put_str("À­ÊÌ        :", 3, 1);
-put_str("¼ï²        :", 4, 1);
-put_str("¿¦¶È        :", 5, 1);
+               sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
 #else
-               put_str("Name  :", 1,26);
-               put_str("Sex         :", 3, 1);
-               put_str("Race        :", 4, 1);
-               put_str("Class       :", 5, 1);
+               sprintf(tmp, "%s %s", ap_ptr->title, player_name);
 #endif
 
-               if (p_ptr->realm1 || p_ptr->realm2)
-#ifdef JP
-put_str("ËâË¡        :", 6, 1);
-#else
-                       put_str("Magic       :", 6, 1);
-#endif
-
-               if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
-#ifdef JP
-put_str("¼é¸îËâ¿À    :", 7, 1);
-#else
-                       put_str("Patron      :", 7, 1);
-#endif
+               display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
+               display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
+               display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
+               display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
 
-               strcpy(tmp,ap_ptr->title);
-#ifdef JP
-       if(ap_ptr->no == 1)
-               strcat(tmp,"¤Î");
-#else
-               strcat(tmp," ");
-#endif
-               strcat(tmp,player_name);
-
-               c_put_str(TERM_L_BLUE, tmp, 1, 34);
-               c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 15);
-               c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 15);
-               c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 15);
                if (p_ptr->realm1)
-                       c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm1], 6, 15);
-               if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
-                       c_put_str(TERM_L_BLUE, chaos_patrons[p_ptr->chaos_patron], 7, 15);
+               {
+                       if (p_ptr->realm2)
+                               sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
+                       else
+                               strcpy(tmp, realm_names[p_ptr->realm1]);
+                       display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
+               }
 
-               else if (p_ptr->realm2)
-                       c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm2], 7, 15);
+               if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
+                       display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
 
                /* Age, Height, Weight, Social */
+               /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ­¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
 #ifdef JP
-        /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ­¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
-        /* ¹¹¤ËÆüËܸìÈǤÎÄɲäȤ·¤Æñ°Ì¤âɽ¼¨¤·¤Þ¤¹ */
-        /* Ãæ±û¤Î¥«¥é¥à¤ÏÆüËܸì¤òɽ¼¨¤¹¤ë¤Ë¤Ï¶¹¤¤¤Î¤Ç¡¢º¸¤Ë4¤ÄÆ°¤«¤·¤Þ¤¹¡£ */
-              prt_num2("ǯÎð         ", "ºÍ",(int)p_ptr->age, 3, 32-2, TERM_L_BLUE);
-              prt_num2("¿ÈĹ         ","cm",(int)((p_ptr->ht*254)/100) , 4, 32-2, TERM_L_BLUE);
-              prt_num2("ÂνŠ        ", "kg",(int)((p_ptr->wt*4536)/10000) , 5, 32-2, TERM_L_BLUE);
-               prt_num("¼Ò²ñŪÃÏ°Ì   ", (int)p_ptr->sc , 6, 32-2, TERM_L_BLUE);
+               display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
+               display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
+               display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
+               display_player_one_line(ENTRY_SOCIAL, format("%d  " ,(int)p_ptr->sc), TERM_L_BLUE);
 #else
-               prt_num("Age          ", (int)p_ptr->age, 3, 32, TERM_L_BLUE);
-               prt_num("Height       ", (int)p_ptr->ht , 4, 32, TERM_L_BLUE);
-               prt_num("Weight       ", (int)p_ptr->wt , 5, 32, TERM_L_BLUE);
-               prt_num("Social Class ", (int)p_ptr->sc , 6, 32, TERM_L_BLUE);
+               display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
+               display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
+               display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
+               display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
 #endif
+               display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
 
 
                /* Display the stats */
@@ -4057,7 +4026,7 @@ put_str("
                                int value;
 
                                /* Use lowercase stat name */
-                               put_str(stat_names_reduced[i], 2 + i, 59);
+                               put_str(stat_names_reduced[i], 3 + i, 54);
 
                                /* Get the current stat */
                                value = p_ptr->stat_use[i];
@@ -4066,7 +4035,7 @@ put_str("
                                cnv_stat(value, buf);
 
                                /* Display the current stat (modified) */
-                               c_put_str(TERM_YELLOW, buf, 2 + i, 66);
+                               c_put_str(TERM_YELLOW, buf, 3 + i, 61);
 
                                /* Acquire the max stat */
                                value = p_ptr->stat_top[i];
@@ -4075,57 +4044,148 @@ put_str("
                                cnv_stat(value, buf);
 
                                /* Display the maximum stat (modified) */
-                               c_put_str(TERM_L_GREEN, buf, 2 + i, 73);
+                               c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
                        }
 
                        /* Normal treatment of "normal" stats */
                        else
                        {
                                /* Assume uppercase stat name */
-                               put_str(stat_names[i], 2 + i, 59);
+                               put_str(stat_names[i], 3 + i, 54);
 
                                /* 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, 2 + i, 66);
+                               c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
                        }
 
                        if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
                        {
-                               c_put_str(TERM_WHITE, "!", 2+i, 64);
+#ifdef JP
+                               c_put_str(TERM_WHITE, "!", 3+i, 59);
+#else
+                               c_put_str(TERM_WHITE, "!", 3+i, 59-2);
+#endif
                        }
                }
 
-               /* Extra info */
-               display_player_middle();
-
                /* Display "history" info */
                if (mode == 1)
                {
+                       char statmsg[1000];
+
+#ifdef JP
+                       put_str("(¥­¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
+#else
+                       put_str("(Character Background)", 11, 25);
+#endif
+
+                       for (i = 0; i < 4; i++)
+                       {
+                               put_str(history[i], i + 12, 10);
+                       }
+
+                       *statmsg = '\0';
+
+                       if (death && total_winner)
+                       {
+#ifdef JP
+                               strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
+#else
+                               strcpy(statmsg, "...You retired from the adventure after the winning.");
+#endif
+                       }
+                       else if (death)
+                       {
+                               if (dun_level)
+                               {
+                                       if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
+                                       {
+                                               /* Get the quest text */
+                                               init_flags = INIT_ASSIGN;
+
+                                               process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+
+#ifdef JP
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, died_from);
+#else
+                                               sprintf(statmsg, "...You were killed by %s in the quest '%s'.", died_from, quest[p_ptr->inside_quest].name);
+#endif
+                                       }
+                                       else
+                                       {                                       
+#ifdef JP
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, died_from);
+#else
+                                               sprintf(statmsg, "...You were killed by %s on level %d of %s.", died_from, dun_level, map_name());
+#endif
+                                       }
+                               }
+                               else
+#ifdef JP
+                                       sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), died_from);
+#else
+                                       sprintf(statmsg, "...You were killed by %s in %s.", died_from, map_name());
+#endif
+                       }
+                       else if (character_dungeon)
+                       {
+                               if (dun_level)
+                               {
+                                       if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
+                                       {
+                                               /* Get the quest text */
+                                               init_flags = INIT_ASSIGN;
+
+                                               process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+
 #ifdef JP
-                       put_str("(¥­¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 16, 25);
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
 #else
-                       put_str("(Character Background)", 16, 25);
+                                               sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
 #endif
+                                       }                                                       
+                                       else
+                                       {
+#ifdef JP
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
+#else
+                                               sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
+#endif
+                                       }
+                               }
+                               else
+#ifdef JP
+                                       sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
+#else
+                                       sprintf(statmsg, "...Now, you are in %s.", map_name());
+#endif
+                       }
 
-
-                       for (i = 0; i < 4; i++)
+                       if (*statmsg)
                        {
-                               put_str(history[i], i + 17, 10);
+                               char temp[64*2], *t;
+                               roff_to_buf(statmsg, 60, temp);
+                               t = temp;
+                               for(i=0 ; i<2 ; i++)
+                               {
+                                       if(t[0]==0)
+                                               break; 
+                                       else
+                                       {
+                                               put_str(t, i + 5 + 12, 10);
+                                               t += strlen(t)+1;
+                                       }
+                               }
                        }
+
                }
 
                /* Display "various" info */
                else
                {
-#ifdef JP
-                       put_str("     (¤½¤Î¾¤ÎǽÎÏ)     ", 16, 25);
-#else
-                       put_str("(Miscellaneous Abilities)", 16, 25);
-#endif
-
-
+                       display_player_middle();
                        display_player_various();
                }
        }
@@ -4168,7 +4228,6 @@ errr make_character_dump(FILE *fff)
        store_type  *st_ptr;
        char            o_name[MAX_NLEN];
        char            buf[1024];
-       cptr            disp_align;
 
 
 #ifndef FAKE_VERSION
@@ -4223,7 +4282,7 @@ errr make_character_dump(FILE *fff)
        display_player(1);
 
        /* Dump part of the screen */
-       for (y = 16; y < 21; y++)
+       for (y = 10; y < 19; y++)
        {
                /* Dump each row */
                for (x = 0; x < 79; x++)
@@ -4258,8 +4317,11 @@ errr make_character_dump(FILE *fff)
                        /* Get the attr/char */
                        (void)(Term_what(x, y, &a, &c));
 
-                       /* Dump it */
-                       buf[x] = c;
+                       /* Dump it (Ignore equippy tile graphic) */
+                       if (a < 128)
+                               buf[x] = c;
+                       else
+                               buf[x] = ' ';
                }
 
                /* End the string */
@@ -4272,11 +4334,12 @@ errr make_character_dump(FILE *fff)
                fprintf(fff, "%s\n", buf);
        }
 
-       for (i = 0; i < p_ptr->count / 80; i++)
+       for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
                fprintf(fff, " ");
        fprintf(fff, "\n");
-       for (i = 0; i < p_ptr->count % 80; i++)
+       for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
                fprintf(fff, " ");
+
        {
                bool pet = FALSE;
 
@@ -4303,7 +4366,7 @@ errr make_character_dump(FILE *fff)
 #ifdef JP
                                fprintf(fff, " ¾èÇÏÃæ");
 #else
-                               fprintf(fff, " riding");
+                               fprintf(fff, " (riding)");
 #endif
                        fprintf(fff, "\n");
                }
@@ -4317,7 +4380,7 @@ errr make_character_dump(FILE *fff)
 #else
                fprintf(fff, "\n  [Last messages]\n\n");
 #endif
-               for (i = MIN(message_num(), 15); i >= 0; i--)
+               for (i = MIN(message_num(), 30); i >= 0; i--)
                {
                        fprintf(fff,"> %s\n",message_str((s16b)i));
                }
@@ -4650,23 +4713,9 @@ fprintf(fff, "\n\n  [
 #endif
 
 #ifdef JP
-       if (p_ptr->align > 150) disp_align = "ÂçÁ±";
-       else if (p_ptr->align > 50) disp_align = "ÃæÁ±";
-       else if (p_ptr->align > 10) disp_align = "¾®Á±";
-       else if (p_ptr->align > -11) disp_align = "ÃæΩ";
-       else if (p_ptr->align > -51) disp_align = "¾®°­";
-       else if (p_ptr->align > -151) disp_align = "Ãæ°­";
-       else disp_align = "Âç°­";
-       fprintf(fff, "°À­ : %s\n", disp_align);
+       fprintf(fff, "°À­ : %s\n", your_alignment());
 #else
-       if (p_ptr->align > 150) disp_align = "lawful";
-       else if (p_ptr->align > 50) disp_align = "good";
-       else if (p_ptr->align > 10) disp_align = "neutral good";
-       else if (p_ptr->align > -11) disp_align = "neutral";
-       else if (p_ptr->align > -51) disp_align = "neutral evil";
-       else if (p_ptr->align > -151) disp_align = "evil";
-       else disp_align = "chaotic";
-       fprintf(fff, "Your alighnment : %s\n", disp_align);
+       fprintf(fff, "Your alighnment : %s\n", your_alignment());
 #endif
        fprintf(fff, "\n");
        dump_virtues(fff);
@@ -4848,10 +4897,6 @@ errr file_character(cptr name, bool full)
        /* Open the non-existing file */
        if (fd < 0) fff = my_fopen(buf, "w");
 
-       /* Grab priv's */
-       safe_setuid_grab();
-
-
        /* Invalid file */
        if (!fff)
        {
@@ -4873,6 +4918,8 @@ msg_format("
        /* Close it */
        my_fclose(fff);
 
+       /* Grab priv's */
+       safe_setuid_grab();
 
        /* Message */
 #ifdef JP
@@ -4888,10 +4935,61 @@ msg_print("
 }
 
 
+typedef struct file_tag
+{
+       char name[32];
+       int line_number;
+} file_tag;
+
+
+typedef struct file_tags
+{
+       file_tag tags[64];
+       int index;
+} file_tags;
+
+
+static void add_tag(file_tags *the_tags, cptr name, int line)
+{
+       if (the_tags->index < 64)
+       {
+               file_tag *tag = &(the_tags->tags[the_tags->index]);
+
+               /* Set the name and end it with '\0' */
+               strncpy(tag->name, name, 31);
+               tag->name[31] = '\0';
+
+               /* Set the line-number */
+               tag->line_number = line;
+
+               /* Increase the number of tags */
+               the_tags->index++;
+       }
+}
+
+
+static int get_line(file_tags *the_tags, cptr name)
+{
+       int i;
+
+       /* Search for the tag */
+       for (i = 0; i < the_tags->index; i++)
+       {
+               if (streq(the_tags->tags[i].name, name))
+               {
+                       return the_tags->tags[i].line_number;
+               }
+       }
+
+       /* Not found */
+       return 0;
+}
+
+
 /*
  * Recursive file perusal.
  *
- * Return FALSE on "ESCAPE", otherwise TRUE.
+ * Return FALSE on 'Q', otherwise TRUE.
  *
  * Process various special text in the input file, including
  * the "menu" structures used by the "help file" system.
@@ -4913,6 +5011,9 @@ 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;
 
@@ -4956,10 +5057,15 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
        char hook[68][32];
 
        /* Tags for in-file references */
-       int tags[68];
+       file_tags tags;
 
        bool reverse = (line < 0);
 
+       int wid, hgt, rows;
+
+       Term_get_size(&wid, &hgt);
+       rows = hgt - 4;
+
        /* Wipe finder */
        strcpy(finder, "");
 
@@ -4975,6 +5081,9 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
                hook[i][0] = '\0';
        }
 
+       /* No tags yet */
+       tags.index = 0;
+
        /* Copy the filename */
        strcpy(filename, name);
 
@@ -5043,6 +5152,27 @@ sprintf(caption, "
                fff = my_fopen(path, "r");
        }
 
+       /* Look in "info" */
+       if (!fff)
+       {
+               /* Build the filename */
+               path_build(path, 1024, ANGBAND_DIR, name);
+
+               for (i = 0; path[i]; i++)
+                       if ('\\' == path[i])
+                               path[i] = PATH_SEP[0];
+
+               /* Caption */
+#ifdef JP
+sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
+#else
+               sprintf(caption, "Info file '%s'", name);
+#endif
+
+               /* Open the file */
+               fff = my_fopen(path, "r");
+       }
+
        /* Oops */
        if (!fff)
        {
@@ -5063,36 +5193,41 @@ msg_format("'%s'
        /* Pre-Parse the file */
        while (TRUE)
        {
+               char *str;
+
                /* Read a line or stop */
                if (my_fgets(fff, buf, 1024)) break;
 
+               /* Get a color */
+               if (prefix(buf, "#####")) str = &buf[6];
+               else str = buf;
+
                /* XXX Parse "menu" items */
-               if (prefix(buf, "***** "))
+               if (prefix(str, "***** "))
                {
                        /* Notice "menu" requests */
-                       if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
+                       if ((str[6] == '[') && isalpha(str[7]))
                        {
                                /* This is a menu file */
                                menu = TRUE;
 
                                /* Extract the menu item */
-                               k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
+                               k = str[7] - 'A';
 
-                               if ((buf[8] == ']') && (buf[9] == ' '))
+                               if ((str[8] == ']') && (str[9] == ' '))
                                {
                                        /* Extract the menu item */
-                                       strcpy(hook[k], buf + 10);
+                                       strncpy(hook[k], str + 10, 31);
+
+                                       /* Make sure it's null-terminated */
+                                       hook[k][31] = '\0';
                                }
                        }
                        /* Notice "tag" requests */
-                       else if ((buf[6] == '<') && (isdigit(buf[7]) || isalpha(buf[7])) &&
-                           (buf[8] == '>'))
+                       else if (str[6] == '<')
                        {
-                               /* Extract the menu item */
-                               k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
-
-                               /* Extract the menu item */
-                               tags[k] = next;
+                               str[strlen(str) - 1] = '\0';
+                               add_tag(&tags, str + 7, next);
                        }
 
                        /* Skip this */
@@ -5106,11 +5241,11 @@ msg_format("'%s'
        /* Save the number of "real" lines */
        size = next;
 
-       if (line == -1) line = ((size-1)/20)*20;
+       /* start from bottom when reverse mode */
+       if (line == -1) line = ((size-1)/rows)*rows;
 
        /* Go to the tagged line */
-       if (tag)
-               line = tags[isdigit(tag[0]) ? D2I(tag[0]) : tag[0] - 'A' + 10];
+       if (tag) line = get_line(&tags, tag);
 
        /* Display the file */
        while (TRUE)
@@ -5119,8 +5254,8 @@ msg_format("'%s'
                Term_clear();
 
                /* Restart when necessary */
-               if (line >= size) line = 0;
-
+               if (line >= size - rows) line = size - rows;
+               if (line < 0) line = 0;
 
                /* Re-open the file if needed */
                if (next > line)
@@ -5151,9 +5286,12 @@ msg_format("'%s'
                        next++;
                }
 
-               /* Dump the next 20 lines of the file */
-               for (i = 0; i < 20; )
+               /* Dump the next 20, or rows, lines of the file */
+               for (i = 0; i < rows; )
                {
+                       int print_x, x;
+                       cptr str;
+
                        /* Hack -- track the "first" line */
                        if (!i) line = next;
 
@@ -5163,15 +5301,32 @@ 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 buf for searching */
-                       strcpy(lc_buf, buf);
+                       /* 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++)
                        {
-                               lc_buf[lc_buf_ptr-lc_buf] = tolower(*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 */
@@ -5181,23 +5336,48 @@ msg_format("'%s'
                        find = NULL;
 
                        /* Dump the line */
-                       Term_putstr(0, i+2, -1, TERM_WHITE, buf);
+                       x = 0;
+                       print_x = 0;
+                       while (str[x])
+                       {
+                               /* Color ? */
+                               if (prefix(str + x, "[[[[["))
+                               {
+                                       byte c = color_char_to_attr(str[x + 5]);
+                                       x += 6;
+
+                                       /* 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++;
+                               }
+
+                               x++;
+                       }
 
                        /* Hilite "shower" */
                        if (shower[0])
                        {
-                               cptr str = lc_buf;
+                               cptr s2 = lc_buf;
 
                                /* Display matches */
-                               while ((str = strstr(str, shower)) != NULL)
+                               while ((s2 = strstr(s2, shower)) != NULL)
                                {
                                        int len = strlen(shower);
 
                                        /* Display the match */
-                                       Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
+                                       Term_putstr(s2-lc_buf, i+2, len, TERM_YELLOW, &str[s2-lc_buf]);
 
                                        /* Advance */
-                                       str += len;
+                                       s2 += len;
                                }
                        }
 
@@ -5218,10 +5398,11 @@ msg_format("'%s'
                /* Show a general "title" */
                if (show_version)
                {
+                       prt(format(
 #ifdef JP
-prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
+                               "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
 #else
-               prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
+                               "[Hengband %d.%d.%d, %s, Line %d/%d]",
 #endif
 
                           FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
@@ -5229,34 +5410,23 @@ prt(format("[
                }
                else
                {
+                       prt(format(
 #ifdef JP
-prt(format("[%s, %d/%d]",
+                               "[%s, %d/%d]",
 #else
-                       prt(format("[%s, Line %d/%d]",
+                               "[%s, Line %d/%d]",
 #endif
-                                  caption, line, size), 0, 0);
-               }
-
-               /* Prompt -- menu screen */
-               if (menu)
-               {
-                       /* Wait for it */
-#ifdef JP
-prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
-#else
-                       prt("[Press a Number, or ESC to exit.]", 23, 0);
-#endif
-
+                               caption, line, size), 0, 0);
                }
 
                /* Prompt -- small files */
-               else if (size <= 20)
+               if (size <= rows)
                {
                        /* Wait for it */
 #ifdef JP
-prt("[¥­¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
+prt("[¥­¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
 #else
-                       prt("[Press ESC to exit.]", 23, 0);
+                       prt("[Press ESC to exit.]", hgt - 1, 0);
 #endif
 
                }
@@ -5266,11 +5436,11 @@ prt("[
                {
 #ifdef JP
                        if(reverse)
-                               prt("[¥­¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢­ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
+                               prt("[¥­¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢­ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
                        else
-                               prt("[¥­¡¼:(RET/¥¹¥Ú¡¼¥¹)¢­ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
+                               prt("[¥­¡¼:(RET/¥¹¥Ú¡¼¥¹)¢­ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
 #else
-                       prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
+                       prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
 #endif
                }
 
@@ -5298,9 +5468,9 @@ prt("[
                {
                        /* Get "shower" */
 #ifdef JP
-prt("¶¯Ä´: ", 23, 0);
+prt("¶¯Ä´: ", hgt - 1, 0);
 #else
-                       prt("Show: ", 23, 0);
+                       prt("Show: ", hgt - 1, 0);
 #endif
 
                        (void)askfor_aux(shower, 80);
@@ -5311,9 +5481,9 @@ prt("
                {
                        /* Get "finder" */
 #ifdef JP
-prt("¸¡º÷: ", 23, 0);
+prt("¸¡º÷: ", hgt - 1, 0);
 #else
-                       prt("Find: ", 23, 0);
+                       prt("Find: ", hgt - 1, 0);
 #endif
 
 
@@ -5327,7 +5497,12 @@ prt("
                                /* Make finder lowercase */
                                for (cnt = 0; finder[cnt] != 0; cnt++)
                                {
-                                       finder[cnt] = tolower(finder[cnt]);
+#ifdef JP
+                                       if (iskanji(finder[cnt]))
+                                               cnt++;
+                                       else
+#endif
+                                               finder[cnt] = tolower(finder[cnt]);
                                }
 
                                /* Show it */
@@ -5340,9 +5515,9 @@ prt("
                {
                        char tmp[81];
 #ifdef JP
-prt("¹Ô: ", 23, 0);
+prt("¹Ô: ", hgt - 1, 0);
 #else
-                       prt("Goto Line: ", 23, 0);
+                       prt("Goto Line: ", hgt - 1, 0);
 #endif
 
                        strcpy(tmp, "0");
@@ -5358,80 +5533,64 @@ prt("
                {
                        char tmp[81];
 #ifdef JP
-prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
+prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
 strcpy(tmp, "jhelp.hlp");
 #else
-                       prt("Goto File: ", 23, 0);
+                       prt("Goto File: ", hgt - 1, 0);
                        strcpy(tmp, "help.hlp");
 #endif
 
 
                        if (askfor_aux(tmp, 80))
                        {
-                               if (!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
+                               if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
                        }
                }
 
-               /* Hack -- Allow backing up */
+               /* Allow backing up */
                if (k == '-')
                {
-                       line = line + (reverse ? 20 : -20);
-                       if (line < 0) line = ((size-1)/20)*20;
+                       line = line + (reverse ? rows : -rows);
+                       if (line < 0) line = 0;
                }
 
-               /* Hack -- Advance a single line */
+               /* Advance a single line */
                if ((k == '\n') || (k == '\r'))
                {
                        line = line + (reverse ? -1 : 1);
-                       if (line < 0) line = ((size-1)/20)*20;
+                       if (line < 0) line = 0;
                }
 
-               /* Advance one page */
-               if (k == ' ')
+
+               /* Move up / down */
+               if (k == '8')
                {
-                       line = line + (reverse ? -20 : 20);
-                       if (line < 0) line = ((size-1)/20)*20;
+                       line--;
+                       if (line < 0) line = 0;
                }
 
-#ifdef JP_FALSE
-               /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
-               /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
+               if (k == '2') line++;
 
-               /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
-               if (menu && (k == 'c' || k == 'C'))
+               /* Advance one page */
+               if (k == ' ')
                {
-                       char tmp[80];
-                       switch (rogue_like_commands)
-                       {
-                               case TRUE:
-                               {
-                                       strcpy(tmp, "j_com_r.txt");
-                                       if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
-                                       break;
-                               }
-                               case FALSE:
-                               {
-                                       strcpy(tmp, "j_com_o.txt");
-                                       if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
-                                       break;
-                               }
-                       }
+                       line = line + (reverse ? -rows : rows);
+                       if (line < 0) line = ((size-1)/rows)*rows;
                }
 
-#endif
                /* Recurse on numbers */
                if (menu)
                {
                        int key = -1;
 
-                       if (isdigit(k)) key = D2I(k);
-                       else if (isalpha(k)) key = k - 'A' + 10;
+                       if (isalpha(k))
+                               key = k - 'A';
 
                        if ((key > -1) && hook[key][0])
                        {
                                /* Recurse on that file */
                                if (!show_file(TRUE, hook[key], NULL, 0, mode))
-                                       k = ESCAPE;
+                                       k = 'q';
                        }
                }
 
@@ -5445,27 +5604,23 @@ strcpy(tmp, "jhelp.hlp");
                        strcpy (xtmp, "");
 
 #ifdef JP
-if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
+                       if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
 #else
-                       if (get_string("File name: ", xtmp, 80))
+                       if (!get_string("File name: ", xtmp, 80))
 #endif
-
-                       {
-                               if (xtmp[0] && (xtmp[0] != ' '))
-                               {
-                               }
-                       }
-                       else
                        {
                                continue;
                        }
+                       /* Close it */
+                       my_fclose(fff);
+
+                        /* Drop priv's */
+                       safe_setuid_drop();
 
                        /* Build the filename */
                        path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
 
-                       /* Close it */
-                       my_fclose(fff);
-
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
 
@@ -5475,7 +5630,7 @@ if (get_string("
                        if (!(fff && ffp))
                        {
 #ifdef JP
-msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
+msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
 #else
                                msg_print("Failed to open file.");
 #endif
@@ -5495,19 +5650,23 @@ msg_print("
                        my_fclose(fff);
                        my_fclose(ffp);
 
+                       /* Grab priv's */
+                       safe_setuid_grab();
+
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
                }
 
                /* Exit on escape */
                if (k == ESCAPE) break;
+               if (k == 'q') break;
        }
 
        /* Close the file */
        my_fclose(fff);
 
        /* Escape */
-       if (k == ESCAPE) return (FALSE);
+       if (k == 'q') return (FALSE);
 
        /* Normal return */
        return (TRUE);
@@ -5644,7 +5803,7 @@ quit_fmt("'%s' 
 #endif
 
 
-#if defined(WINDOWS) || defined(MSDOS)
+#if defined(MSDOS)
 
        /* Hack -- max length */
        if (k > 8) k = 8;
@@ -5734,16 +5893,16 @@ void get_name(void)
        {
                /* Use the name */
                strcpy(player_name, tmp);
-
-               /* Process the player name */
-               process_player_name(FALSE);
        }
-       else if (strlen(player_name))
+       else if (0 == strlen(player_name))
        {
-               /* Process the player name */
-               process_player_name(FALSE);
+               /* Use default name */
+               strcpy(player_name, "PLAYER");
        }
 
+       /* Process the player name */
+       process_player_name(FALSE);
+
        strcpy(tmp,ap_ptr->title);
 #ifdef JP
        if(ap_ptr->no == 1)
@@ -5754,6 +5913,7 @@ void get_name(void)
        strcat(tmp,player_name);
 
        /* Re-Draw the name (in light blue) */
+       Term_erase(34, 1, 255);
        c_put_str(TERM_L_BLUE, tmp, 1, 34);
 
        /* Erase the prompt, etc */
@@ -5777,9 +5937,9 @@ void do_cmd_suicide(void)
        {
                /* Verify */
 #ifdef JP
-if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
+if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
 #else
-               if (!get_check("Do you want to retire? ")) return;
+               if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
 #endif
 
        }
@@ -6675,9 +6835,9 @@ if (!save_player()) msg_print("
                        if ((!send_world_score(do_send)))
                        {
 #ifdef JP
-                               if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
+                               if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
 #else
-                               if (get_check("Stand by for later score registration? "))
+                               if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
 #endif
                                {
                                        wait_report_score = TRUE;
@@ -6881,7 +7041,7 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
                }
 
        }
-
+       
        /* Get the number of entries */
        while (TRUE)
        {
@@ -6916,7 +7076,7 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
        if (numentries > 0)
        {
                /* Grab an appropriate line number */
-               line = rand_int(numentries);
+               line = randint0(numentries);
 
                /* Get the random line */
                for (counter = 0; counter <= line; counter++)
@@ -6924,18 +7084,15 @@ errr get_rnd_line(cptr file_name, int entry, char *output)
                        /* Count the lines */
                        line_num++;
 
-#ifdef JP
-                      while(TRUE){
-                      test=my_fgets(fp, buf, 1024);
-                      if(test || buf[0]!='#')break;
-                                 }
-                        if (test==0){
-#else
-                       /* Try to read the line */
-                       if (my_fgets(fp, buf, 1024) == 0)
+                       while(TRUE)
                        {
-#endif
+                               test = my_fgets(fp, buf, 1024);
+                               if(test || buf[0] != '#')
+                                       break;
+                       }
 
+                        if (test==0)
+                       {
                                /* Found the line */
                                if (counter == line) break;
                        }
@@ -6975,166 +7132,42 @@ errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
     result=get_rnd_line(file_name, entry, output);
     if(result)break;
     kanji=0;
-    for(j=0 ; j<strlen(output) ; j++) kanji|=iskanji( output[j] );
+    for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
     if(kanji)break;
   }
   return(result);
 }
 #endif
 
-
-/*AUTOPICK*/
+/*
+ * Process file for auto picker/destroyer.
+ */
 errr process_pickpref_file(cptr name)
 {
-       FILE *fp;
-
-       char buf[1024] , *s, *s2, isnew;
-
-       int i;
-
-       int num = -1;
+       char buf[1024];
 
        errr err = 0;
 
-       bool bypass = FALSE;
+       /* Drop priv's */
+       safe_setuid_drop();
 
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, name);
 
-       /* Open the file */
-       fp = my_fopen(buf, "r");
-
-       /* No such file */
-       if (!fp) return (-1);
-
-
-       /* Process the file */
-       while (0 == my_fgets(fp, buf, 1024))
-       {
-               /* Count lines */
-               num++;
-
-               /* Skip "empty" lines */
-               if (buf[0] == '\0') continue;
-
-               /* Skip comments */
-               if (buf[0] == '#') continue;
-
-               /* Process "?:<expr>" */
-               if ((buf[0] == '?') && (buf[1] == ':'))
-               {
-                       char f;
-                       cptr v;
-                       char *s;
-
-                       /* Start */
-                       s = buf + 2;
-
-                       /* Parse the expr */
-                       v = process_pref_file_expr(&s, &f);
-
-                       /* Set flag */
-                       bypass = (streq(v, "0") ? TRUE : FALSE);
-
-                       /* Continue */
-                       continue;
-               }
-
-               /* Apply conditionals */
-               if (bypass) continue;
-
-               /* Process "%:<file>" */
-               if (buf[0] == '%')
-               {
-                       /* Process that file if allowed */
-                       (void)process_pickpref_file(buf + 2);
-
-                       /* Continue */
-                       continue;
-               }
-
-                /* Nuke illegal char */
-                for(i=0 ; buf[i]; i++)
-               {
-#ifdef JP
-                       if (iskanji(buf[i]))
-                       {
-                               i++;
-                               continue;
-                       }
-#endif
-                       if (isspace(buf[i]) && buf[i] != ' ')
-                               break;
-               }
-               buf[i]=0;
-
-                s = buf;
-                /* Skip '!','~' */
-                if(buf[0] == '!' || buf[0] == '~') s++;
+       err = process_pref_file_aux(buf, TRUE);
 
-                /* Auto-inscription? */
-                s2=strchr(s,'#');
-                if (s2) {*s2=0; s2++;}
-
-                /* Skip empty line */
-                if (*s == 0) continue;
-
-               /* don't mind upper or lower case */
-               for (i = 0; s[i]; i++)
-               {
-#ifdef JP
-                       if (iskanji(s[i]))
-                       {
-                               i++;
-                               continue;
-                       }
-#endif
-                       if ('#' == s[i])
-                               break;
-                       else if (isupper(s[i]))
-                               s[i] = tolower(s[i]);
-               }
-                /* Already has the same entry? */ 
-               isnew=1;
-                for(i=0;i<max_autopick;i++)
-                       if( !strcmp(s,autopick_name[i]) ){isnew=0;break;} 
-
-               if(isnew==0) continue;
-               autopick_name [max_autopick] = malloc(strlen(s) + 1);
-               strcpy(autopick_name [max_autopick], s);
-               switch(buf[0]){
-               case '~':
-                       autopick_action[max_autopick] = DONT_AUTOPICK;
-                       break;
-               case '!':
-                       autopick_action[max_autopick] = DO_AUTODESTROY;
-                       break;
-               default:
-                       autopick_action[max_autopick] = DO_AUTOPICK;
-                       break;
-               }
-                if( s2 ) {
-                    autopick_insc[max_autopick] = malloc(strlen(s2) + 1);
-                    strcpy(autopick_insc[max_autopick], s2);
-                } else {
-                    autopick_insc[max_autopick]=NULL;
-               }
-               max_autopick++;
-               if(max_autopick==MAX_AUTOPICK) break;
-       }
+       /* Grab priv's */
+       safe_setuid_grab();
 
-       /* Close the file */
-       my_fclose(fp);
        /* Result */
        return (err);
 }
 
-static errr counts_seek(int fd, s32b where, bool flag)
+static errr counts_seek(int fd, u32b where, bool flag)
 {
        huge seekpoint;
        char temp1[128], temp2[128];
-       s32b zero_header[3] = {0L, 0L, 0L};
+       u32b zero_header[3] = {0L, 0L, 0L};
        int i;
 
 #ifdef SAVEFILE_USE_UID
@@ -7148,7 +7181,7 @@ static errr counts_seek(int fd, s32b where, bool flag)
        seekpoint = 0;
        while (1)
        {
-               if (fd_seek(fd, seekpoint + 3 * sizeof(s32b)))
+               if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
                        return 1;
                if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
                {
@@ -7156,7 +7189,7 @@ static errr counts_seek(int fd, s32b where, bool flag)
                                return 1;
                        /* add new name */
                        fd_seek(fd, seekpoint);
-                       fd_write(fd, (char*)zero_header, 3*sizeof(s32b));
+                       fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
                        fd_write(fd, (char*)(temp1), sizeof(temp1));
                        break;
                }
@@ -7164,16 +7197,16 @@ static errr counts_seek(int fd, s32b where, bool flag)
                if (strcmp(temp1, temp2) == 0)
                        break;
 
-               seekpoint += 128 + 3 * sizeof(s32b);
+               seekpoint += 128 + 3 * sizeof(u32b);
        }
 
-       return fd_seek(fd, seekpoint + where * sizeof(s32b));
+       return fd_seek(fd, seekpoint + where * sizeof(u32b));
 }
 
-s32b counts_read(int where)
+u32b counts_read(int where)
 {
        int fd;
-       s32b count = 0;
+       u32b count = 0;
        char buf[1024];
 
 #ifdef JP
@@ -7184,7 +7217,7 @@ s32b counts_read(int where)
        fd = fd_open(buf, O_RDONLY);
 
        if (counts_seek(fd, where, FALSE) ||
-           fd_read(fd, (char*)(&count), sizeof(s32b)))
+           fd_read(fd, (char*)(&count), sizeof(u32b)))
                count = 0;
 
        (void)fd_close(fd);
@@ -7192,7 +7225,7 @@ s32b counts_read(int where)
        return count;
 }
 
-errr counts_write(int where, s32b count)
+errr counts_write(int where, u32b count)
 {
        int fd;
        char buf[1024];
@@ -7215,7 +7248,7 @@ errr counts_write(int where, s32b count)
        if (fd_lock(fd, F_WRLCK)) return 1;
 
        counts_seek(fd, where, TRUE);
-       fd_write(fd, (char*)(&count), sizeof(s32b));
+       fd_write(fd, (char*)(&count), sizeof(u32b));
 
        if (fd_lock(fd, F_UNLCK)) return 1;
 
@@ -7396,6 +7429,11 @@ Term_putstr(0, 0, -1, TERM_WHITE, "
  */
 static void handle_signal_abort(int sig)
 {
+       int wid, hgt, rows;
+
+       Term_get_size(&wid, &hgt);
+       rows = hgt - 4;
+
        /* Disable handler */
        (void)signal(sig, SIG_IGN);
 
@@ -7409,10 +7447,10 @@ static void handle_signal_abort(int sig)
        clear_mon_lite();
 
        /* Clear the bottom line */
-       Term_erase(0, 23, 255);
+       Term_erase(0, hgt - 1, 255);
 
        /* Give a warning */
-       Term_putstr(0, 23, -1, TERM_RED,
+       Term_putstr(0, hgt - 1, -1, TERM_RED,
 #ifdef JP
 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤­¤¿¡ª");
 #else
@@ -7422,9 +7460,9 @@ static void handle_signal_abort(int sig)
 
        /* Message */
 #ifdef JP
-Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
+Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
 #else
-       Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
+       Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
 #endif
 
 
@@ -7449,9 +7487,9 @@ Term_putstr(45, 23, -1, TERM_RED, "
        if (save_player())
        {
 #ifdef JP
-Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
+Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
 #else
-               Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
+               Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
 #endif
 
        }
@@ -7460,9 +7498,9 @@ Term_putstr(45, 23, -1, TERM_RED, "
        else
        {
 #ifdef JP
-Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
+Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
 #else
-               Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
+               Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
 #endif
 
        }