OSDN Git Service

- '@'コマンドでファイルを読み込むときに pref ディレクトリから読み
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 25 Jan 2002 07:34:26 +0000 (07:34 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 25 Jan 2002 07:34:26 +0000 (07:34 +0000)
  込んでからユーザーディレクトリから読み込むが、エラーはユーザー
  ディレクトリのものだけを返すので、実際はprefのファイルを読んで
  いてもエラーメッセージが出ていた。それを修正して、両方失敗したの
  か pref からだけ読めたのかわかるようにした。
- ついてに、設定ファイルによるオプション変更に失敗したときのエラー
  メッセージ修正。

src/cmd4.c
src/files.c

index d6e9dfa..86a0277 100644 (file)
@@ -2796,6 +2796,8 @@ void do_cmd_macros(void)
                /* Load a 'macro' file */
                else if (i == '1')
                {
+                       errr err;
+
                        /* Prompt */
 #ifdef JP
                        prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 16, 0);
@@ -2819,15 +2821,31 @@ void do_cmd_macros(void)
                        if (!askfor_aux(tmp, 80)) continue;
 
                        /* Process the given filename */
-                       if (0 != process_pref_file(tmp))
+                       err = process_pref_file(tmp);
+                       if (-2 == err)
+                       {
+#ifdef JP
+                               msg_format("ɸ½à¤ÎÀßÄê¥Õ¥¡¥¤¥ë'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
+#else
+                               msg_format("Loaded default '%s'.", tmp);
+#endif
+                       }
+                       else if (err)
                        {
                                /* Prompt */
 #ifdef JP
-                               msg_print("¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤á¤Þ¤»¤ó¤Ç¤·¤¿¡ª");
+                               msg_format("'%s'¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", tmp);
 #else
-                               msg_print("Could not load file!");
+                               msg_format("Failed to load '%s'!");
+#endif
+                       }
+                       else
+                       {
+#ifdef JP
+                               msg_format("'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
+#else
+                               msg_format("Loaded '%s'.", tmp);
 #endif
-
                        }
                }
 
index d3b590a..7621fb1 100644 (file)
@@ -583,10 +583,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 (alive && 6 == option_info[i].o_page)
+                               {
+#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 +605,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 +623,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 (alive && 6 == option_info[i].o_page)
+                               {
+#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 +645,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;
        }
@@ -1235,32 +1263,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)
-       {
-               /* Drop priv's */
-               safe_setuid_drop();
+       if (err1 > 0) return err1;
 
-               /* Build the filename */
-               path_build(buf, 1024, ANGBAND_DIR_USER, name);
 
-               /* Process the pref file */
-               err = process_pref_file_aux(buf, FALSE);
+       /* 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();
-       }
+       /* Grab priv's */
+       safe_setuid_grab();
 
-       /* Result */
-       return (err);
+
+       /* User file does not exist, but read system pref file */
+       if (err2 < 0 && !err1)
+               return -2;
+
+       /* Result of user file processing */
+       return err2;
 }