1 #include "info-reader/ego-reader.h"
2 #include "info-reader/kind-info-tokens-table.h"
3 #include "main/angband-headers.h"
4 #include "object-enchant/object-ego.h"
5 #include "object-enchant/tr-types.h"
6 #include "util/bit-flags-calculator.h"
7 #include "util/string-processor.h"
8 #include "view/display-messages.h"
11 * @brief テキストトークンを走査してフラグを一つ得る(エゴ用) /
12 * Grab one flag in a ego-item_type from a textual string
13 * @param e_ptr 保管先のエゴ構造体参照ポインタ
14 * @param what 参照元の文字列ポインタ
15 * @return エラーがあった場合1、エラーがない場合0を返す
17 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
19 for (int i = 0; i < TR_FLAG_MAX; i++) {
20 if (streq(what, k_info_flags[i])) {
21 add_flag(e_ptr->flags, i);
26 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
29 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
34 * @brief アイテムエゴ情報(e_info)のパース関数 /
35 * Initialize the "e_info" array, by parsing an ascii "template" file
40 errr parse_e_info(char *buf, angband_header *head)
42 static ego_item_type *e_ptr = NULL;
47 s = angband_strchr(buf + 2, ':');
56 int i = atoi(buf + 2);
59 if (i >= head->info_num)
65 if (!add_name(&e_ptr->name, head, s))
74 else if (buf[0] == 'E') {
78 else if (buf[0] == 'E') {
80 if (!add_name(&e_ptr->name, head, s))
84 else if (buf[0] == 'X') {
86 if (2 != sscanf(buf + 2, "%d:%d", &slot, &rating))
89 e_ptr->slot = (INVENTORY_IDX)slot;
90 e_ptr->rating = (PRICE)rating;
91 } else if (buf[0] == 'W') {
92 int level, rarity, pad2;
95 if (4 != sscanf(buf + 2, "%d:%d:%d:%ld", &level, &rarity, &pad2, &cost))
99 e_ptr->rarity = (RARITY)rarity;
101 } else if (buf[0] == 'C') {
102 int th, td, ta, pval;
104 if (4 != sscanf(buf + 2, "%d:%d:%d:%d", &th, &td, &ta, &pval))
107 e_ptr->max_to_h = (HIT_PROB)th;
108 e_ptr->max_to_d = (HIT_POINT)td;
109 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
110 e_ptr->max_pval = (PARAMETER_VALUE)pval;
111 } else if (buf[0] == 'U') {
113 n = grab_one_activation_flag(buf + 2);
119 } else if (buf[0] == 'F') {
120 for (s = buf + 2; *s;) {
122 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
127 while ((*t == ' ') || (*t == '|'))
131 if (0 != grab_one_ego_item_flag(e_ptr, s))