1 #include "info-reader/ego-reader.h"
2 #include "info-reader/kind-info-tokens-table.h"
3 #include "object-enchant/object-ego.h"
4 #include "object-enchant/tr-types.h"
5 #include "util/bit-flags-calculator.h"
6 #include "util/string-processor.h"
7 #include "view/display-messages.h"
10 * @brief テキストトークンを走査してフラグを一つ得る(エゴ用) /
11 * Grab one flag in a ego-item_type from a textual string
12 * @param e_ptr 保管先のエゴ構造体参照ポインタ
13 * @param what 参照元の文字列ポインタ
14 * @return エラーがあった場合1、エラーがない場合0を返す
16 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
18 for (int i = 0; i < TR_FLAG_MAX; i++) {
19 if (streq(what, k_info_flags[i])) {
20 add_flag(e_ptr->flags, i);
25 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
28 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
33 * @brief アイテムエゴ情報(e_info)のパース関数 /
34 * Initialize the "e_info" array, by parsing an ascii "template" file
39 errr parse_e_info(char *buf, angband_header *head)
41 static ego_item_type *e_ptr = NULL;
46 s = angband_strchr(buf + 2, ':');
55 int i = atoi(buf + 2);
58 if (i >= head->info_num)
64 if (!add_name(&e_ptr->name, head, s))
73 else if (buf[0] == 'E') {
77 else if (buf[0] == 'E') {
79 if (!add_name(&e_ptr->name, head, s))
83 else if (buf[0] == 'X') {
85 if (2 != sscanf(buf + 2, "%d:%d", &slot, &rating))
88 e_ptr->slot = (INVENTORY_IDX)slot;
89 e_ptr->rating = (PRICE)rating;
90 } else if (buf[0] == 'W') {
91 int level, rarity, pad2;
94 if (4 != sscanf(buf + 2, "%d:%d:%d:%ld", &level, &rarity, &pad2, &cost))
98 e_ptr->rarity = (RARITY)rarity;
100 } else if (buf[0] == 'C') {
101 int th, td, ta, pval;
103 if (4 != sscanf(buf + 2, "%d:%d:%d:%d", &th, &td, &ta, &pval))
106 e_ptr->max_to_h = (HIT_PROB)th;
107 e_ptr->max_to_d = (HIT_POINT)td;
108 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
109 e_ptr->max_pval = (PARAMETER_VALUE)pval;
110 } else if (buf[0] == 'U') {
112 n = grab_one_activation_flag(buf + 2);
118 } else if (buf[0] == 'F') {
119 for (s = buf + 2; *s;) {
121 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
126 while ((*t == ' ') || (*t == '|'))
130 if (0 != grab_one_ego_item_flag(e_ptr, s))