1 #include "io/read-pref-file.h"
2 #include "io/process-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 = process_pref_file_command(creature_ptr, buf);
85 if (preftype != PREF_TYPE_AUTOPICK)
87 err = process_autopick_file_command(buf);
93 /* Print error message */
94 /* ToDo: Add better error messages */
95 msg_format(_("ファイル'%s'の%d行でエラー番号%dのエラー。", "Error %d in line %d of file '%s'."),
96 _(name, err), line, _(err, name));
97 msg_format(_("('%s'を解析中)", "Parsing '%s'"), old);
107 * @brief pref設定ファイルを読み込み設定を反映させる /
108 * Process the "user pref file" with the given name
109 * @param creature_ptr プレーヤーへの参照ポインタ
110 * @param name 読み込むファイル名
114 * See the functions above for a list of legal "commands".
115 * We also accept the special "?" and "%" directives, which
116 * allow conditional evaluation and filename inclusion.
119 errr process_pref_file(player_type *creature_ptr, concptr name)
122 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
124 errr err1 = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_NORMAL);
125 if (err1 > 0) return err1;
127 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
128 errr err2 = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_NORMAL);
129 if (err2 < 0 && !err1)
137 * @brief 自動拾いファイルを読み込む /
138 * @param creature_ptr プレーヤーへの参照ポインタ
142 errr process_autopick_file(player_type *creature_ptr, concptr name)
145 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
146 errr err = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_AUTOPICK);
152 * @brief プレイヤーの生い立ちファイルを読み込む /
153 * Process file for player's history editor.
154 * @param creature_ptr プレーヤーへの参照ポインタ
159 errr process_histpref_file(player_type *creature_ptr, concptr name)
161 bool old_character_xtra = current_world_ptr->character_xtra;
163 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
165 /* Hack -- prevent modification birth options in this file */
166 current_world_ptr->character_xtra = TRUE;
167 errr err = process_pref_file_aux(creature_ptr, buf, PREF_TYPE_HISTPREF);
168 current_world_ptr->character_xtra = old_character_xtra;