1 #include "io/read-pref-file.h"
2 #include "io/interpret-pref-file.h"
4 #include "files.h" // 暫定。コールバック化して後で消す.
7 // todo コールバック関数に変更するので、いずれ消す.
8 #define PREF_TYPE_NORMAL 0
9 #define PREF_TYPE_AUTOPICK 1
10 #define PREF_TYPE_HISTPREF 2
14 * @brief process_pref_fileのサブルーチン /
15 * Open the "user pref file" and parse it.
16 * @param creature_ptr プレーヤーへの参照ポインタ
17 * @param name 読み込むファイル名
18 * @param preftype prefファイルのタイプ
21 static errr process_pref_file_aux(player_type *creature_ptr, concptr name, int preftype)
24 fp = my_fopen(name, "r");
32 while (my_fgets(fp, buf, sizeof(buf)) == 0)
35 if (!buf[0]) continue;
40 if (iswspace(buf[0])) continue;
42 if (buf[0] == '#') continue;
45 /* Process "?:<expr>" */
46 if ((buf[0] == '?') && (buf[1] == ':'))
51 concptr v = process_pref_file_expr(creature_ptr, &s, &f);
52 bypass = streq(v, "0");
58 /* Process "%:<file>" */
61 static int depth_count = 0;
62 if (depth_count > 20) continue;
67 case PREF_TYPE_AUTOPICK:
68 (void)process_autopick_file(creature_ptr, buf + 2);
70 case PREF_TYPE_HISTPREF:
71 (void)process_histpref_file(creature_ptr, buf + 2);
74 (void)process_pref_file(creature_ptr, buf + 2);
82 err = interpret_pref_file(creature_ptr, buf);
85 if (preftype != PREF_TYPE_AUTOPICK)
88 process_autopick_file_command(buf);
95 /* Print error message */
96 /* ToDo: Add better error messages */
97 msg_format(_("ファイル'%s'の%d行でエラー番号%dのエラー。", "Error %d in line %d of file '%s'."),
98 _(name, err), line, _(err, name));
99 msg_format(_("('%s'を解析中)", "Parsing '%s'"), old);
109 * @brief pref設定ファイルを読み込み設定を反映させる /
110 * Process the "user pref file" with the given name
111 * @param creature_ptr プレーヤーへの参照ポインタ
112 * @param name 読み込むファイル名
116 * See the functions above for a list of legal "commands".
117 * We also accept the special "?" and "%" directives, which
118 * allow conditional evaluation and filename inclusion.
121 errr process_pref_file(player_type *creature_ptr, concptr name)
124 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
126 errr err1 = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_NORMAL);
127 if (err1 > 0) return err1;
129 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
130 errr err2 = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_NORMAL);
131 if (err2 < 0 && !err1)
139 * @brief 自動拾いファイルを読み込む /
140 * @param creature_ptr プレーヤーへの参照ポインタ
144 errr process_autopick_file(player_type *creature_ptr, concptr name)
147 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
148 errr err = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_AUTOPICK);
154 * @brief プレイヤーの生い立ちファイルを読み込む /
155 * Process file for player's history editor.
156 * @param creature_ptr プレーヤーへの参照ポインタ
161 errr process_histpref_file(player_type *creature_ptr, concptr name)
163 bool old_character_xtra = current_world_ptr->character_xtra;
165 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
167 /* Hack -- prevent modification birth options in this file */
168 current_world_ptr->character_xtra = TRUE;
169 errr err = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_HISTPREF);
170 current_world_ptr->character_xtra = old_character_xtra;