1 #include "info-reader/info-reader-util.h"
2 #include "main/angband-headers.h"
3 #include "object-enchant/activation-info-table.h"
4 #include "view/display-messages.h"
7 * @brief データの可変文字列情報をテキストとして保管する /
8 * Add a text to the text-storage and store offset to it.
9 * @param offset 文字列保管ポインタからのオフセット
10 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
12 * @param normal_text テキストの正規化を行う
15 * Returns FALSE when there isn't enough space available to store
18 bool add_text(u32b *offset, angband_header *head, concptr buf, bool normal_text)
20 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
24 *offset = ++head->text_size;
25 } else if (normal_text) {
27 * If neither the end of the last line nor
28 * the beginning of current line is not a space,
29 * fill up a space as a correct separator of two words.
31 if (head->text_size > 0 &&
33 (*(head->text_ptr + head->text_size - 1) != ' ') && ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) && (buf[0] != ' ')
36 (*(head->text_ptr + head->text_size - 1) != ' ') && (buf[0] != ' ')
39 *(head->text_ptr + head->text_size) = ' ';
44 strcpy(head->text_ptr + head->text_size, buf);
45 head->text_size += strlen(buf);
50 * @brief データの可変文字列情報を名前として保管する /
51 * Add a name to the name-storage and return an offset to it.
52 * @param offset 文字列保管ポインタからのオフセット
53 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
57 * Returns FALSE when there isn't enough space available to store
60 bool add_name(u32b *offset, angband_header *head, concptr buf)
62 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
66 *offset = ++head->name_size;
69 strcpy(head->name_ptr + head->name_size, buf);
70 head->name_size += strlen(buf);
75 * @brief データの可変文字列情報をタグとして保管する /
76 * Add a tag to the tag-storage and return an offset to it.
77 * @param offset 文字列保管ポインタからのオフセット
78 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
82 * Returns FALSE when there isn't enough space available to store
85 bool add_tag(STR_OFFSET *offset, angband_header *head, concptr buf)
88 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1) {
89 if (streq(&head->tag_ptr[i], buf))
93 if (i >= head->tag_size) {
94 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
97 strcpy(head->tag_ptr + head->tag_size, buf);
99 head->tag_size += strlen(buf) + 1;
107 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
108 * Grab one flag from a textual string
109 * @param flags ビットフラグを追加する先の参照ポインタ
110 * @param names トークン定義配列
111 * @param what 参照元の文字列ポインタ
114 errr grab_one_flag(u32b *flags, concptr names[], concptr what)
116 for (int i = 0; i < 32; i++) {
117 if (streq(what, names[i])) {
127 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
128 * Grab one activation index flag
129 * @param what 参照元の文字列ポインタ
132 byte grab_one_activation_flag(concptr what)
134 for (int i = 0;; i++) {
135 if (activation_info[i].flag == NULL)
138 if (streq(what, activation_info[i].flag)) {
139 return activation_info[i].index;
148 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);