OSDN Git Service

クエスト達成時に, 階段が鏡の上(下?)に作られるのを禁止.
[hengbandforosx/hengbandosx.git] / src / files.c
index 32034fa..801191e 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                                               }
 };
 
@@ -583,10 +587,20 @@ 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 (p_ptr->playing && 6 == option_info[i].o_page && !p_ptr->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;
@@ -595,7 +609,11 @@ errr process_pref_file_command(char *buf)
                }
 
                /* don't know that option. ignore it.*/
-               msg_format("Ignored wrong option %s.", buf+2);
+#ifdef JP
+               msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
+#else
+               msg_format("Ignored invalid option: %s", buf);
+#endif
                msg_print(NULL);
                return 0;
        }
@@ -609,10 +627,20 @@ 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 (p_ptr->playing && 6 == option_info[i].o_page && !p_ptr->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;
@@ -621,7 +649,11 @@ errr process_pref_file_command(char *buf)
                }
 
                /* don't know that option. ignore it.*/
-               msg_format("Ignored wrong option %s.", buf+2);
+#ifdef JP
+               msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
+#else
+               msg_format("Ignored invalid option: %s", buf);
+#endif
                msg_print(NULL);
                return 0;
        }
@@ -1012,10 +1044,12 @@ static cptr process_pref_file_expr(char **sp, char *fp)
  */
 static errr process_pickpref_file_line(char *buf)
 {
-       char *s, *s2;
+       autopick_type entry;
        int i;
-       byte act = 0;
 
+       if (max_autopick == MAX_AUTOPICK)
+               return 1;
+       
        /* Nuke illegal char */
        for(i = 0; buf[i]; i++)
        {
@@ -1031,71 +1065,15 @@ static errr process_pickpref_file_line(char *buf)
        }
        buf[i] = 0;
        
-       s = buf;
+       if (!autopick_new_entry(&entry, buf)) return 0;
 
-       act = DO_AUTOPICK | DO_DISPLAY;
-       while (1)
-       {
-               if (*s == '!')
-               {
-                       act &= ~DO_AUTOPICK;
-                       act |= DO_AUTODESTROY;
-                       s++;
-               }
-               else if (*s == '~')
-               {
-                       act &= ~DO_AUTOPICK;
-                       act |= DONT_AUTOPICK;
-                       s++;
-               }
-               else if (*s == '(')
-               {
-                       act &= ~DO_DISPLAY;
-                       s++;
-               }
-               else
-                       break;
-       }
-
-       /* don't mind upper or lower case */
-       s2 = NULL;
-       for (i = 0; s[i]; i++)
-       {
-#ifdef JP
-               if (iskanji(s[i]))
-               {
-                       i++;
-                       continue;
-               }
-#endif
-               if (isupper(s[i]))
-                       s[i] = tolower(s[i]);
-
-               /* Auto-inscription? */
-               if (s[i] == '#')
-               {
-                       s[i] = '\0';
-                       s2 = s + i + 1;
-                       break;
-               }
-       }
-       
-       /* Skip empty line */
-       if (*s == 0)
-               return 0;
-       if (max_autopick == MAX_AUTOPICK)
-               return 1;
-       
        /* Already has the same entry? */ 
        for(i = 0; i < max_autopick; i++)
-               if(!strcmp(s, autopick_name[i]))
-                       return 0;
+               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_name[max_autopick] = string_make(s);
-       autopick_action[max_autopick] = act;
-
-       autopick_insc[max_autopick] = string_make(s2);
-       max_autopick++;
+       autopick_list[max_autopick++] = entry;
        return 0;
 }
 
@@ -1235,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, FALSE);
+       /* 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, FALSE);
-       }
 
-       /* 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;
 }
 
 
@@ -1496,64 +1485,6 @@ 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)
-{
-       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);
-}
-
-
-/*
- * Print number with header at given row, column
- */
-static void prt_num(cptr header, 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);
-}
-
-
-#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 );
-}
-
-/*    ÆüËܸìÈ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);
-}
-#endif
-
 #define ENTRY_BARE_HAND 0
 #define ENTRY_TWO_HANDS 1
 #define ENTRY_RIGHT_HAND1 2
@@ -1734,9 +1665,6 @@ static void display_player_one_line(int entry, cptr val, byte attr)
 
 /*
  * 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)
 {
@@ -1825,7 +1753,10 @@ 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 += (p_ptr->weapon_exp[0][o_ptr->sval])/400;
+       else
+               show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval]-4000)/200;
 
        /* Range attacks */
        display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
@@ -1859,19 +1790,50 @@ static void display_player_middle(void)
                if (p_ptr->action == ACTION_SEARCH) i += 10;
 
                if (i > 0)
-                       attr = TERM_L_GREEN;
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_GREEN;
+                       else
+                               attr = TERM_GREEN;
+               }
                else if (i == 0)
-                       attr = TERM_L_BLUE;
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_BLUE;
+                       else
+                               attr = TERM_GREEN;
+               }
                else
-                       attr = TERM_L_UMBER;
+               {
+                       if (!p_ptr->riding)
+                               attr = TERM_L_UMBER;
+                       else
+                               attr = TERM_RED;
+               }
 
-               if (is_fast) tmp_speed += 10;
-               if (p_ptr->slow) tmp_speed -= 10;
-               if (p_ptr->lightspeed) tmp_speed = 99;
+               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;
+               }
 
                if (tmp_speed)
                {
-                       sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
+                       if (!p_ptr->riding)
+                               sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
+                       else
+#ifdef JP
+                               sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
+#else
+                               sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
+#endif
+
                        if (tmp_speed > 0)
                                attr = TERM_YELLOW;
                        else
@@ -1879,7 +1841,14 @@ static void display_player_middle(void)
                }
                else
                {
-                       sprintf(buf, "(%+d)", i);
+                       if (!p_ptr->riding)
+                               sprintf(buf, "(%+d)", i);
+                       else
+#ifdef JP
+                               sprintf(buf, "¾èÇÏÃæ (%+d)", i);
+#else
+                               sprintf(buf, "Riding (%+d)", i);
+#endif
                }
        
                display_player_one_line(ENTRY_SPEED, buf, attr);
@@ -1913,23 +1882,16 @@ static void display_player_middle(void)
 
        /* Dump Day */
        {
-               s32b len = 20L * TOWN_DAWN;
-               s32b tick = turn % len + len / 4;
+               int day, hour, min;
+               extract_day_hour_min(&day, &hour, &min);
 
                sprintf(buf, 
 #ifdef JP
-                       "%2ldÆüÌÜ  %ld:%02ld", 
+                       "%dÆüÌÜ %2d:%02d", 
 #else
-                       "Day %ld  %ld:%02ld", 
+                       "Day %d %2d:%02d", 
 #endif
-                       ((p_ptr->prace == RACE_VAMPIRE) ||
-                        (p_ptr->prace == RACE_SKELETON) ||
-                        (p_ptr->prace == RACE_ZOMBIE) ||
-                        (p_ptr->prace == RACE_SPECTRE))
-                       ? (turn - (15L * TOWN_DAWN)) / len + 1
-                       : (turn + (5L * TOWN_DAWN))/ len + 1,
-                       (24 * tick / len) % 24,
-                       (1440 * tick / len) % 60);
+                       day, hour, min);
        }
        display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
 
@@ -2178,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;
@@ -2190,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;
@@ -2947,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))
@@ -2968,13 +2930,14 @@ 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((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
@@ -2989,6 +2952,7 @@ 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((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
@@ -2998,6 +2962,7 @@ static void display_player_flag_aux(int row, int col, char *header,
 
        /* 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((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
@@ -3113,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]);
@@ -3124,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
 
 }
@@ -3225,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);
@@ -3279,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 */
@@ -3292,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));
 
@@ -3378,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;
                                }
                        }
 
@@ -3471,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;
                                }
                        }
                }
@@ -3698,9 +3666,9 @@ NULL,
 "¥Æ¥ì¥Ý¡¼¥È",
 "È¿´¶",
 "½ËÊ¡",
-"¼ö¤¤",
-"½Å¤¤¼ö¤¤",
-"±Ê±ó¤Î¼ö¤¤"
+NULL,
+NULL,
+NULL,
 #else
        "NoTeleport",
        "AntiMagic",
@@ -3727,9 +3695,9 @@ NULL,
        "Teleport",
        "Aggravate",
        "Blessed",
-       "Cursed",
-       "Hvy Curse",
-       "Prm Curse"
+       NULL,
+       NULL,
+       NULL,
 #endif
 
 };
@@ -3998,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);
@@ -4030,7 +3998,7 @@ void display_player(int mode)
                        display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
                }
 
-               if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
+               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 */
@@ -4094,13 +4062,19 @@ void display_player(int mode)
 
                        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
                        }
                }
 
                /* Display "history" info */
                if (mode == 1)
                {
+                       char statmsg[1000];
+
 #ifdef JP
                        put_str("(¥­¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
 #else
@@ -4109,40 +4083,103 @@ void display_player(int mode)
 
                        for (i = 0; i < 4; i++)
                        {
-                               put_str(history[i], i + 12, 10);
+                               put_str(p_ptr->history[i], i + 12, 10);
                        }
 
+                       *statmsg = '\0';
 
-                       if (death)
+                       if (p_ptr->is_dead && p_ptr->total_winner)
+                       {
+#ifdef JP
+                               strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
+#else
+                               strcpy(statmsg, "...You retired from the adventure after the winning.");
+#endif
+                       }
+                       else if (p_ptr->is_dead)
                        {
                                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, p_ptr->died_from);
+#else
+                                               sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
+#endif
+                                       }
+                                       else
+                                       {                                       
 #ifdef JP
-                                       put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Î %d ³¬¤Ç»à¤ó¤À¡£", map_name(), dun_level), 5 + 12, 10);
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
 #else
-                                       put_str(format("...You were dead at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
+                                               sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
 #endif
+                                       }
+                               }
                                else
 #ifdef JP
-                                       put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Ç»à¤ó¤À¡£", map_name()), 5 + 12, 10);
+                                       sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
 #else
-                                       put_str(format("...You were dead at %s.", map_name()), 5 + 12, 10);
+                                       sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
 #endif
                        }
-                       else
+                       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
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
+#else
+                                               sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
+#endif
+                                       }                                                       
+                                       else
+                                       {
 #ifdef JP
-                                       put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level), 5 + 12, 10);
+                                               sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
 #else
-                                       put_str(format("...Now, you are exploring at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
+                                               sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
 #endif
+                                       }
+                               }
                                else
 #ifdef JP
-                                       put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name()), 5 + 12, 10);
+                                       sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
 #else
-                                       put_str(format("...Now, you are in %s.", map_name()), 5 + 12, 10);
+                                       sprintf(statmsg, "...Now, you are in %s.", map_name());
 #endif
                        }
+
+                       if (*statmsg)
+                       {
+                               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 */
@@ -4193,11 +4230,6 @@ errr make_character_dump(FILE *fff)
        char            buf[1024];
 
 
-#ifndef FAKE_VERSION
-       /* Begin dump */
-       fprintf(fff, "  [Angband %d.%d.%d Character Dump]\n\n",
-               VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
-#else
 #ifdef JP
        fprintf(fff, "  [ÊѶòÈÚÅÜ %d.%d.%d ¥­¥ã¥é¥¯¥¿¾ðÊó]\n\n",
                FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
@@ -4206,8 +4238,6 @@ errr make_character_dump(FILE *fff)
                FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
 #endif
 
-#endif
-
        update_playtime();
 
        /* Display player */
@@ -4245,7 +4275,7 @@ errr make_character_dump(FILE *fff)
        display_player(1);
 
        /* Dump part of the screen */
-       for (y = 11; y < 18; y++)
+       for (y = 10; y < 19; y++)
        {
                /* Dump each row */
                for (x = 0; x < 79; x++)
@@ -4297,11 +4327,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;
 
@@ -4328,21 +4359,21 @@ errr make_character_dump(FILE *fff)
 #ifdef JP
                                fprintf(fff, " ¾èÇÏÃæ");
 #else
-                               fprintf(fff, " riding");
+                               fprintf(fff, " (riding)");
 #endif
                        fprintf(fff, "\n");
                }
                if (pet) fprintf(fff, "\n");
        }
 
-       if (death && !total_winner)
+       if (p_ptr->is_dead && !p_ptr->total_winner)
        {
 #ifdef JP
                fprintf(fff, "\n  [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
 #else
                fprintf(fff, "\n  [Last messages]\n\n");
 #endif
-               for (i = MIN(message_num(), 15); i >= 0; i--)
+               for (i = MIN(message_num(), 30); i >= 0; i--)
                {
                        fprintf(fff,"> %s\n",message_str((s16b)i));
                }
@@ -4553,7 +4584,7 @@ errr make_character_dump(FILE *fff)
 #endif
        }
 
-       if (noscore)
+       if (p_ptr->noscore)
 #ifdef JP
 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
 #else
@@ -4859,10 +4890,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)
        {
@@ -4884,6 +4911,8 @@ msg_format("
        /* Close it */
        my_fclose(fff);
 
+       /* Grab priv's */
+       safe_setuid_grab();
 
        /* Message */
 #ifdef JP
@@ -4975,6 +5004,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;
 
@@ -5022,6 +5054,11 @@ bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
 
        bool reverse = (line < 0);
 
+       int wid, hgt, rows;
+
+       Term_get_size(&wid, &hgt);
+       rows = hgt - 4;
+
        /* Wipe finder */
        strcpy(finder, "");
 
@@ -5149,35 +5186,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 */
-                                       strncpy(hook[k], buf + 10, 31);
+                                       strncpy(hook[k], str + 10, 31);
 
                                        /* Make sure it's null-terminated */
                                        hook[k][31] = '\0';
                                }
                        }
                        /* Notice "tag" requests */
-                       else if (buf[6] == '<')
+                       else if (str[6] == '<')
                        {
-                               buf[strlen(buf) - 1] = '\0';
-                               add_tag(&tags, buf + 7, next);
+                               str[strlen(str) - 1] = '\0';
+                               add_tag(&tags, str + 7, next);
                        }
 
                        /* Skip this */
@@ -5191,6 +5234,9 @@ msg_format("'%s'
        /* Save the number of "real" lines */
        size = next;
 
+       /* start from bottom when reverse mode */
+       if (line == -1) line = ((size-1)/rows)*rows;
+
        /* Go to the tagged line */
        if (tag) line = get_line(&tags, tag);
 
@@ -5201,8 +5247,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)
@@ -5233,9 +5279,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;
 
@@ -5245,11 +5294,23 @@ 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++)
                        {
@@ -5268,23 +5329,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;
                                }
                        }
 
@@ -5305,10 +5391,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,
@@ -5316,34 +5403,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
 
                }
@@ -5353,11 +5429,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
                }
 
@@ -5385,9 +5461,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);
@@ -5398,9 +5474,9 @@ prt("
                {
                        /* Get "finder" */
 #ifdef JP
-prt("¸¡º÷: ", 23, 0);
+prt("¸¡º÷: ", hgt - 1, 0);
 #else
-                       prt("Find: ", 23, 0);
+                       prt("Find: ", hgt - 1, 0);
 #endif
 
 
@@ -5432,9 +5508,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");
@@ -5450,10 +5526,10 @@ 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
 
@@ -5464,60 +5540,44 @@ strcpy(tmp, "jhelp.hlp");
                        }
                }
 
-               /* 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 = 'q';
-                                       break;
-                               }
-                               case FALSE:
-                               {
-                                       strcpy(tmp, "j_com_o.txt");
-                                       if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
-                                       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])
                        {
@@ -5537,27 +5597,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");
 
@@ -5567,7 +5623,7 @@ if (get_string("
                        if (!(fff && ffp))
                        {
 #ifdef JP
-msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
+msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
 #else
                                msg_print("Failed to open file.");
 #endif
@@ -5587,6 +5643,9 @@ msg_print("
                        my_fclose(fff);
                        my_fclose(ffp);
 
+                       /* Grab priv's */
+                       safe_setuid_grab();
+
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
                }
@@ -5737,7 +5796,7 @@ quit_fmt("'%s' 
 #endif
 
 
-#if defined(WINDOWS) || defined(MSDOS)
+#if defined(MSDOS)
 
        /* Hack -- max length */
        if (k > 8) k = 8;
@@ -5847,6 +5906,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 */
@@ -5866,13 +5926,13 @@ void do_cmd_suicide(void)
        flush();
 
        /* Verify Retirement */
-       if (total_winner)
+       if (p_ptr->total_winner)
        {
                /* 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
 
        }
@@ -5889,7 +5949,7 @@ if (!get_check("
        }
 
 
-       if (!noscore)
+       if (!p_ptr->noscore)
        {
                /* Special Verification for suicide */
 #ifdef JP
@@ -5905,15 +5965,15 @@ prt("
        }
 
        /* Stop playing */
-       alive = FALSE;
+       p_ptr->playing = FALSE;
 
        /* Kill the player */
-       death = TRUE;
+       p_ptr->is_dead = TRUE;
 
        /* Leaving */
        p_ptr->leaving = TRUE;
 
-       if (!total_winner)
+       if (!p_ptr->total_winner)
        {
 #ifdef JP
                do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
@@ -5927,9 +5987,9 @@ prt("
 
        /* Cause of death */
 #ifdef JP
-(void)strcpy(died_from, "ÅÓÃ潪λ");
+(void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
 #else
-       (void)strcpy(died_from, "Quitting");
+       (void)strcpy(p_ptr->died_from, "Quitting");
 #endif
 
 }
@@ -5976,9 +6036,9 @@ prt("
 
        /* The player is not dead */
 #ifdef JP
-(void)strcpy(died_from, "(¥»¡¼¥Ö)");
+(void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
 #else
-       (void)strcpy(died_from, "(saved)");
+       (void)strcpy(p_ptr->died_from, "(saved)");
 #endif
 
 
@@ -6015,9 +6075,9 @@ prt("
 
        /* Note that the player is not dead */
 #ifdef JP
-(void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤­¤Æ¤¤¤ë)");
+(void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤­¤Æ¤¤¤ë)");
 #else
-       (void)strcpy(died_from, "(alive and well)");
+       (void)strcpy(p_ptr->died_from, "(alive and well)");
 #endif
 
 }
@@ -6028,7 +6088,7 @@ prt("
  */
 void do_cmd_save_and_exit(void)
 {
-       alive = FALSE;
+       p_ptr->playing = FALSE;
 
        /* Leaving */
        p_ptr->leaving = TRUE;
@@ -6095,7 +6155,7 @@ long total_points(void)
        if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
        {
                point = 1;
-               if (total_winner) point = 2;
+               if (p_ptr->total_winner) point = 2;
        }
        if (easy_band) point = (0 - point);
 
@@ -6139,7 +6199,7 @@ static void make_bones(void)
 
 
        /* Ignore wizards and borgs */
-       if (!(noscore & 0x00FF))
+       if (!(p_ptr->noscore & 0x00FF))
        {
                /* Ignore people who die in town */
                if (dun_level)
@@ -6253,7 +6313,7 @@ static void print_tomb(void)
 
 
                /* King or Queen */
-               if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
+               if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
                {
 #ifdef JP
                 /* ±ÑÆüÀÚ¤êÂؤ¨ */
@@ -6315,34 +6375,34 @@ static void print_tomb(void)
 
 #ifdef JP
         /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
-        if (streq(died_from, "ÅÓÃ潪λ"))
+        if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
         {
                 strcpy(tmp, "<¼«»¦>");
         }
         else
         {
-                if (streq(died_from, "ripe"))
+                if (streq(p_ptr->died_from, "ripe"))
                 {
                         strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
                 }
-                else if (streq(died_from, "Seppuku"))
+                else if (streq(p_ptr->died_from, "Seppuku"))
                 {
                         strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
                 }
                 else
                 {
-                        strcpy(tmp, died_from);
+                        strcpy(tmp, p_ptr->died_from);
                 }
         }
         center_string(buf, tmp);
         put_str(buf, 14, 11);
 
-        if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
+        if(!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
         {
                 if( dun_level == 0 )
                 {
                        cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
-                        if(streq(died_from, "ÅÓÃ潪λ"))
+                        if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
                         {
                                 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
                         }
@@ -6353,7 +6413,7 @@ static void print_tomb(void)
                 }
                 else
                 {
-                        if(streq(died_from, "ÅÓÃ潪λ"))
+                        if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
                         {
                                 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
                         }
@@ -6371,14 +6431,14 @@ static void print_tomb(void)
                put_str(buf, 14, 11);
 
 
-               if (strlen(died_from) > 24)
+               if (strlen(p_ptr->died_from) > 24)
                {
-                       strncpy(dummy, died_from, 24);
+                       strncpy(dummy, p_ptr->died_from, 24);
                        dummy[24] = '\0';
                        (void)sprintf(tmp, "by %s.", dummy);
                }
                else
-                       (void)sprintf(tmp, "by %s.", died_from);
+                       (void)sprintf(tmp, "by %s.", p_ptr->died_from);
 
                center_string(buf, tmp);
                put_str(buf, 15, 11);
@@ -6612,7 +6672,7 @@ msg_print("
 
 #ifndef SCORE_WIZARDS
        /* Wizard-mode pre-empts scoring */
-       if (noscore & 0x000F)
+       if (p_ptr->noscore & 0x000F)
        {
 #ifdef JP
 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
@@ -6627,7 +6687,7 @@ msg_print("
 
 #ifndef SCORE_BORGS
        /* Borg-mode pre-empts scoring */
-       if (noscore & 0x00F0)
+       if (p_ptr->noscore & 0x00F0)
        {
 #ifdef JP
 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
@@ -6642,7 +6702,7 @@ msg_print("
 
 #ifndef SCORE_CHEATERS
        /* Cheaters are not scored */
-       if (noscore & 0xFF00)
+       if (p_ptr->noscore & 0xFF00)
        {
 #ifdef JP
 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
@@ -6657,9 +6717,9 @@ msg_print("
 
        /* Interupted */
 #ifdef JP
-if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
+if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
 #else
-       if (!total_winner && streq(died_from, "Interrupting"))
+       if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
 #endif
 
        {
@@ -6675,9 +6735,9 @@ msg_print("
 
        /* Quitter */
 #ifdef JP
-if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
+if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
 #else
-       if (!total_winner && streq(died_from, "Quitting"))
+       if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
 #endif
 
        {
@@ -6731,10 +6791,10 @@ void close_game(void)
 
 
        /* Handle death */
-       if (death)
+       if (p_ptr->is_dead)
        {
                /* Handle retirement */
-               if (total_winner) kingly();
+               if (p_ptr->total_winner) kingly();
 
                /* Save memories */
 #ifdef JP
@@ -6768,13 +6828,13 @@ 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;
-                                       death = FALSE;
+                                       p_ptr->wait_report_score = TRUE;
+                                       p_ptr->is_dead = FALSE;
 #ifdef JP
                                        if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
 #else
@@ -6782,7 +6842,7 @@ if (!save_player()) msg_print("
 #endif
                                }
                        }
-                       if (!wait_report_score)
+                       if (!p_ptr->wait_report_score)
                                (void)top_twenty();
                }
                else if (highscore_fd >= 0)
@@ -6855,19 +6915,19 @@ if (!character_generated || character_saved) quit("
        disturb(1, 0);
 
        /* Mega-Hack -- Delay death */
-       if (p_ptr->chp < 0) death = FALSE;
+       if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
 
        /* Hardcode panic save */
-       panic_save = 1;
+       p_ptr->panic_save = 1;
 
        /* Forbid suspend */
        signals_ignore_tstp();
 
        /* Indicate panic save */
 #ifdef JP
-(void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
+(void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
 #else
-       (void)strcpy(died_from, "(panic save)");
+       (void)strcpy(p_ptr->died_from, "(panic save)");
 #endif
 
 
@@ -7009,7 +7069,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++)
@@ -7081,11 +7141,17 @@ errr process_pickpref_file(cptr name)
 
        errr err = 0;
 
+       /* Drop priv's */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, name);
 
        err = process_pref_file_aux(buf, TRUE);
 
+       /* Grab priv's */
+       safe_setuid_grab();
+
        /* Result */
        return (err);
 }
@@ -7257,13 +7323,13 @@ static void handle_signal_simple(int sig)
 
 
        /* Terminate dead characters */
-       if (death)
+       if (p_ptr->is_dead)
        {
                /* Mark the savefile */
 #ifdef JP
-(void)strcpy(died_from, "¶¯À©½ªÎ»");
+(void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
 #else
-               (void)strcpy(died_from, "Abortion");
+               (void)strcpy(p_ptr->died_from, "Abortion");
 #endif
 
                forget_lite();
@@ -7287,9 +7353,9 @@ quit("
        {
                /* Cause of "death" */
 #ifdef JP
-(void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
+(void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
 #else
-               (void)strcpy(died_from, "Interrupting");
+               (void)strcpy(p_ptr->died_from, "Interrupting");
 #endif
 
 
@@ -7298,10 +7364,10 @@ quit("
                clear_mon_lite();
 
                /* Stop playing */
-               alive = FALSE;
+               p_ptr->playing = FALSE;
 
                /* Suicide */
-               death = TRUE;
+               p_ptr->is_dead = TRUE;
 
                /* Leaving */
                p_ptr->leaving = TRUE;
@@ -7356,6 +7422,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);
 
@@ -7369,10 +7440,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
@@ -7382,9 +7453,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
 
 
@@ -7392,13 +7463,13 @@ Term_putstr(45, 23, -1, TERM_RED, "
        Term_fresh();
 
        /* Panic Save */
-       panic_save = 1;
+       p_ptr->panic_save = 1;
 
        /* Panic save */
 #ifdef JP
-(void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
+(void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
 #else
-       (void)strcpy(died_from, "(panic save)");
+       (void)strcpy(p_ptr->died_from, "(panic save)");
 #endif
 
 
@@ -7409,9 +7480,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
 
        }
@@ -7420,9 +7491,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
 
        }