3 * @brief ゲームデータ初期化1 / Initialization (part 1) -BEN-
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 * This file is used to initialize various variables and arrays for the
16 * Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
17 * the common limitation of "read()" and "write()" to only 32767 bytes
19 * Several of the arrays for Angband are built from "template" files in
20 * the "lib/file" directory, from which quick-load binary "image" files
21 * are constructed whenever they are not present in the "lib/data"
22 * directory, or if those files become obsolete, if we are allowed.
23 * Warning -- the "ascii" file parsers use a minor hack to collect the
24 * name and text information in a single pass. Thus, the game will not
25 * be able to load any template file with more than 20K of names or 60K
26 * of text, even though technically, up to 64K should be legal.
28 * Note that if "ALLOW_TEMPLATES" is not defined, then a lot of the code
29 * in this file is compiled out, and the game will not run unless valid
30 * "binary template files" already exist in "lib/data". Thus, one can
31 * compile Angband with ALLOW_TEMPLATES defined, run once to create the
32 * "*.raw" files in "lib/data", and then quit, and recompile without
33 * defining ALLOW_TEMPLATES, which will both save 20K and prevent people
34 * from changing the ascii template files in potentially dangerous ways.
35 * ノートとして記録:ALLOW_TEMPLATESが定義されていない場合、
36 * このファイルのコードの多くはコンパイル出力され、本ゲームは
37 * 正規の「バイナリテンプレートファイル」がlib/dataファイル内に
38 * 存在しない限り起動しなくなる。一方ALLOW_TEMPLATESが定義されている
39 * ならば1度ゲームが起動するごとに*.rawファイル群が作成され、終了時には
40 * ALLOW_TEMPLATEの定義に関係なくリコンパイルされる。これにより20K(バイト?)
41 * のデータが保存され、プレイヤーが潜在的に危険な方法でascii文字の
42 * テンプレートファイルを変更することを妨げることができる。
43 * The code could actually be removed and placed into a "stand-alone"
44 * program, but that feels a little silly, especially considering some
45 * of the platforms that we currently support.
54 #ifdef ALLOW_TEMPLATES
59 /*** Helper arrays for parsing ascii template files ***/
63 * Monster Blow Methods
65 static cptr r_info_blow_method[] =
99 * Monster Blow Effects
101 static cptr r_info_blow_effect[] =
146 static cptr f_info_flags[] =
271 static cptr r_info_flags1[] =
311 static cptr r_info_flags2[] =
351 static cptr r_info_flags3[] =
391 static cptr r_info_flags4[] =
428 * モンスター特性トークン(発動型能力1) /
431 static cptr r_a_ability_flags1[] =
468 * モンスター特性トークン(発動型能力2) /
471 static cptr r_a_ability_flags2[] =
488 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
509 * モンスター特性トークン(発動型能力3) /
512 static cptr r_a_ability_flags3[] =
551 * モンスター特性トークン(発動型能力4) /
554 static cptr r_a_ability_flags4[] =
596 static cptr r_info_flags7[] =
636 static cptr r_info_flags8[] =
668 "WILD_SWAMP", /* ToDo: Implement Swamp */
677 static cptr r_info_flags9[] =
716 * モンスター特性トークンの定義R(耐性) /
719 static cptr r_info_flagsr[] =
757 * オブジェクト基本特性トークンの定義 /
760 static cptr k_info_flags[] =
857 "XXX3", /* Fake flag for Smith */
858 "XXX4", /* Fake flag for Smith */
908 * オブジェクト生成特性トークンの定義 /
911 static cptr k_info_gen_flags[] =
951 static cptr d_info_flags1[] =
989 * @brief データの可変文字列情報をテキストとして保管する /
990 * Add a text to the text-storage and store offset to it.
991 * @param offset 文字列保管ポインタからのオフセット
992 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
994 * @param normal_text テキストの正規化を行う
997 * Returns FALSE when there isn't enough space available to store
1000 static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
1002 /* Hack -- Verify space */
1003 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
1009 /* Advance and save the text index */
1010 *offset = ++head->text_size;
1013 /* Additional text */
1014 else if (normal_text)
1017 * If neither the end of the last line nor
1018 * the beginning of current line is not a space,
1019 * fill up a space as a correct separator of two words.
1021 if (head->text_size > 0 &&
1023 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1024 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
1025 (buf[0] != ' ') && !iskanji(buf[0])
1027 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1032 /* Append a space */
1033 *(head->text_ptr + head->text_size) = ' ';
1035 /* Advance the index */
1040 /* Append chars to the text */
1041 strcpy(head->text_ptr + head->text_size, buf);
1043 /* Advance the index */
1044 head->text_size += strlen(buf);
1052 * @brief データの可変文字列情報を名前として保管する /
1053 * Add a name to the name-storage and return an offset to it.
1054 * @param offset 文字列保管ポインタからのオフセット
1055 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1059 * Returns FALSE when there isn't enough space available to store
1062 static bool add_name(u32b *offset, header *head, cptr buf)
1064 /* Hack -- Verify space */
1065 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
1071 /* Advance and save the name index */
1072 *offset = ++head->name_size;
1075 /* Append chars to the names */
1076 strcpy(head->name_ptr + head->name_size, buf);
1078 /* Advance the index */
1079 head->name_size += strlen(buf);
1087 * @brief データの可変文字列情報をタグとして保管する /
1088 * Add a tag to the tag-storage and return an offset to it.
1089 * @param offset 文字列保管ポインタからのオフセット
1090 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1094 * Returns FALSE when there isn't enough space available to store
1097 static bool add_tag(STR_OFFSET *offset, header *head, cptr buf)
1101 /* Search for an existing (fake) tag */
1102 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1105 if (streq(&head->tag_ptr[i], buf)) break;
1108 /* There was no existing tag */
1109 if (i >= head->tag_size)
1111 /* Hack -- Verify space */
1112 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1115 /* Append chars to the tags */
1116 strcpy(head->tag_ptr + head->tag_size, buf);
1118 /* Point the new tag */
1121 /* Advance the index */
1122 head->tag_size += strlen(buf) + 1;
1125 /* Return offset of the tag */
1134 * @brief シンボル1文字をカラーIDに変更する /
1135 * Convert a "color letter" into an "actual" color
1136 * The colors are: dwsorgbuDWvyRGBU, as shown below
1140 byte color_char_to_attr(char c)
1144 case 'd': return (TERM_DARK);
1145 case 'w': return (TERM_WHITE);
1146 case 's': return (TERM_SLATE);
1147 case 'o': return (TERM_ORANGE);
1148 case 'r': return (TERM_RED);
1149 case 'g': return (TERM_GREEN);
1150 case 'b': return (TERM_BLUE);
1151 case 'u': return (TERM_UMBER);
1153 case 'D': return (TERM_L_DARK);
1154 case 'W': return (TERM_L_WHITE);
1155 case 'v': return (TERM_VIOLET);
1156 case 'y': return (TERM_YELLOW);
1157 case 'R': return (TERM_L_RED);
1158 case 'G': return (TERM_L_GREEN);
1159 case 'B': return (TERM_L_BLUE);
1160 case 'U': return (TERM_L_UMBER);
1168 /*** Initialize from ascii template files ***/
1172 * @brief パース関数に基づいてデータファイルからデータを読み取る /
1173 * Initialize an "*_info" array, by parsing an ascii "template" file
1174 * @param fp 読み取りに使うファイルポインタ
1175 * @param buf 読み取りに使うバッファ領域
1176 * @param head ヘッダ構造体
1177 * @param parse_info_txt_line パース関数
1180 errr init_info_txt(FILE *fp, char *buf, header *head,
1181 parse_info_txt_func parse_info_txt_line)
1185 /* Just before the first record */
1188 /* Just before the first line */
1192 /* Prepare the "fake" stuff */
1193 head->name_size = 0;
1194 head->text_size = 0;
1198 while (0 == my_fgets(fp, buf, 1024))
1200 /* Advance the line number */
1203 /* Skip comments and blank lines */
1204 if (!buf[0] || (buf[0] == '#')) continue;
1206 /* Verify correct "colon" format */
1207 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1210 /* Hack -- Process 'V' for "Version" */
1217 /* Mega Hack -- Calculate Check Sum */
1218 if (buf[0] != 'N' && buf[0] != 'D')
1221 for (i = 0; buf[i]; i++)
1223 head->v_extra += (byte)buf[i];
1224 head->v_extra ^= (1 << (i % 8));
1228 /* Parse the line */
1229 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1234 /* Complete the "name" and "text" sizes */
1235 if (head->name_size) head->name_size++;
1236 if (head->text_size) head->text_size++;
1244 * @brief Vault情報(v_info)のパース関数 /
1245 * Initialize the "v_info" array, by parsing an ascii "template" file
1247 * @param head ヘッダ構造体
1250 errr parse_v_info(char *buf, header *head)
1256 static vault_type *v_ptr = NULL;
1258 /* Process 'N' for "New/Number/Name" */
1261 /* Find the colon before the name */
1262 s = my_strchr(buf+2, ':');
1264 /* Verify that colon */
1267 /* Nuke the colon, advance to the name */
1270 /* Paranoia -- require a name */
1271 if (!*s) return (1);
1276 /* Verify information */
1277 if (i <= error_idx) return (4);
1279 /* Verify information */
1280 if (i >= head->info_num) return (2);
1282 /* Save the index */
1285 /* Point at the "info" */
1288 /* Store the name */
1289 if (!add_name(&v_ptr->name, head, s)) return (7);
1292 /* There better be a current v_ptr */
1293 else if (!v_ptr) return (3);
1295 /* Process 'D' for "Description" */
1296 else if (buf[0] == 'D')
1298 /* Acquire the text */
1301 /* Store the text */
1302 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1305 /* Process 'X' for "Extra info" (one line only) */
1306 else if (buf[0] == 'X')
1308 EFFECT_ID typ, rat, hgt, wid;
1310 /* Scan for the values */
1311 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1312 &typ, &rat, &hgt, &wid)) return (1);
1314 /* Save the values */
1315 v_ptr->typ = (ROOM_IDX)typ;
1316 v_ptr->rat = (PROB)rat;
1317 v_ptr->hgt = (POSITION)hgt;
1318 v_ptr->wid = (POSITION)wid;
1330 * @brief 職業技能情報(s_info)のパース関数 /
1331 * Initialize the "s_info" array, by parsing an ascii "template" file
1333 * @param head ヘッダ構造体
1336 errr parse_s_info(char *buf, header *head)
1341 static skill_table *s_ptr = NULL;
1344 /* Process 'N' for "New/Number/Name" */
1350 /* Verify information */
1351 if (i <= error_idx) return (4);
1353 /* Verify information */
1354 if (i >= head->info_num) return (2);
1356 /* Save the index */
1359 /* Point at the "info" */
1363 /* There better be a current s_ptr */
1364 else if (!s_ptr) return (3);
1366 /* Process 'W' for "Weapon exp" */
1367 else if (buf[0] == 'W')
1369 int tval, sval, start, max;
1370 const s16b exp_conv_table[] =
1372 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1373 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1376 /* Scan for the values */
1377 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1378 &tval, &sval, &start, &max)) return (1);
1380 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1381 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1383 /* Save the values */
1384 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1385 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1388 /* Process 'S' for "Skill exp" */
1389 else if (buf[0] == 'S')
1391 int num, start, max;
1393 /* Scan for the values */
1394 if (3 != sscanf(buf+2, "%d:%d:%d",
1395 &num, &start, &max)) return (1);
1397 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1398 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1400 /* Save the values */
1401 s_ptr->s_start[num] = (SUB_EXP)start;
1402 s_ptr->s_max[num] = (SUB_EXP)max;
1415 * @brief 職業魔法情報(m_info)のパース関数 /
1416 * Initialize the "m_info" array, by parsing an ascii "template" file
1418 * @param head ヘッダ構造体
1421 errr parse_m_info(char *buf, header *head)
1428 static player_magic *m_ptr = NULL;
1431 static int realm, magic_idx = 0, readable = 0;
1434 /* Process 'N' for "New/Number/Name" */
1440 /* Verify information */
1441 if (i <= error_idx) return (4);
1443 /* Verify information */
1444 if (i >= head->info_num) return (2);
1446 /* Save the index */
1449 /* Point at the "info" */
1453 /* There better be a current m_ptr */
1454 else if (!m_ptr) return (3);
1456 /* Process 'I' for "Info" (one line only) */
1457 else if (buf[0] == 'I')
1460 int xtra, type, first, weight;
1462 /* Find the colon before the name */
1463 s = my_strchr(buf+2, ':');
1465 /* Verify that colon */
1468 /* Nuke the colon, advance to the name */
1473 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1474 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1475 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1476 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1477 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1482 /* Find the colon before the name */
1483 s = my_strchr(s, ':');
1485 /* Verify that colon */
1488 /* Nuke the colon, advance to the name */
1491 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1492 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1493 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1494 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1495 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1496 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1500 /* Scan for the values */
1501 if (4 != sscanf(s, "%x:%d:%d:%d",
1502 (uint *)&xtra, &type, &first, &weight)) return (1);
1504 m_ptr->spell_xtra = xtra;
1505 m_ptr->spell_type = type;
1506 m_ptr->spell_first = first;
1507 m_ptr->spell_weight = weight;
1511 /* Process 'R' for "Realm" (one line only) */
1512 else if (buf[0] == 'R')
1514 /* Scan for the values */
1515 if (2 != sscanf(buf+2, "%d:%d",
1516 &realm, &readable)) return (1);
1521 else if (buf[0] == 'T')
1523 int level, mana, fail, exp;
1525 if (!readable) return (1);
1526 /* Scan for the values */
1527 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1528 &level, &mana, &fail, &exp)) return (1);
1530 m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level;
1531 m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana;
1532 m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail;
1533 m_ptr->info[realm][magic_idx].sexp = (EXP)exp;
1547 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1548 * Grab one flag from a textual string
1549 * @param flags ビットフラグを追加する先の参照ポインタ
1550 * @param names トークン定義配列
1551 * @param what 参照元の文字列ポインタ
1554 static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
1559 for (i = 0; i < 32; i++)
1561 if (streq(what, names[i]))
1563 *flags |= (1L << i);
1573 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1574 * Grab one flag in an feature_type from a textual string
1575 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1576 * @param what 参照元の文字列ポインタ
1579 static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
1584 for (i = 0; i < FF_FLAG_MAX; i++)
1586 if (streq(what, f_info_flags[i]))
1588 add_flag(f_ptr->flags, i);
1594 msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
1597 return PARSE_ERROR_GENERIC;
1602 * @brief テキストトークンを走査してフラグ(ステート)を一つ得る(地形情報向け2) /
1603 * Grab an action in an feature_type from a textual string
1604 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1605 * @param what 参照元の文字列ポインタ
1606 * @param count ステートの保存先ID
1609 static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
1614 for (i = 0; i < FF_FLAG_MAX; i++)
1616 if (streq(what, f_info_flags[i]))
1618 f_ptr->state[count].action = i;
1624 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1627 return PARSE_ERROR_GENERIC;
1632 * @brief 地形情報(f_info)のパース関数 /
1633 * Initialize the "f_info" array, by parsing an ascii "template" file
1635 * @param head ヘッダ構造体
1638 errr parse_f_info(char *buf, header *head)
1645 static feature_type *f_ptr = NULL;
1648 /* Process 'N' for "New/Number/Name" */
1651 /* Find the colon before the name */
1652 s = my_strchr(buf+2, ':');
1656 /* Nuke the colon, advance to the name */
1663 /* Verify information */
1664 if (i <= error_idx) return (4);
1666 /* Verify information */
1667 if (i >= head->info_num) return (2);
1669 /* Save the index */
1672 /* Point at the "info" */
1675 /* Tag name is given */
1679 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1682 /* Default "mimic" */
1683 f_ptr->mimic = (FEAT_IDX)i;
1685 /* Default "destroyed state" -- if not specified */
1686 f_ptr->destroyed = (FEAT_IDX)i;
1688 /* Default "states" */
1689 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1692 /* There better be a current f_ptr */
1693 else if (!f_ptr) return (3);
1696 else if (buf[0] == 'J')
1698 /* Store the name */
1699 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1702 else if (buf[0] == 'E')
1704 /* Ignore english name */
1707 else if (buf[0] == 'J')
1709 /* Ignore Japanese name */
1712 else if (buf[0] == 'E')
1714 /* Acquire the Text */
1717 /* Store the name */
1718 if (!add_name(&f_ptr->name, head, s)) return (7);
1723 /* Process 'M' for "Mimic" (one line only) */
1724 else if (buf[0] == 'M')
1728 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1730 /* Record a fake tag index */
1731 f_ptr->mimic_tag = offset;
1735 /* Process 'G' for "Graphics" (one line only) */
1736 else if (buf[0] == 'G')
1740 char char_tmp[F_LIT_MAX];
1743 if (buf[1] != ':') return (1);
1744 if (!buf[2]) return (1);
1745 if (buf[3] != ':') return (1);
1746 if (!buf[4]) return (1);
1748 /* Extract the char */
1749 char_tmp[F_LIT_STANDARD] = buf[2];
1751 /* Extract the color */
1752 s_attr = color_char_to_attr(buf[4]);
1755 if (s_attr > 127) return (1);
1757 /* Save the standard values */
1758 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1759 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1761 /* Is this feature supports lighting? */
1764 /* G:c:a:LIT (default) */
1765 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1767 /* G:c:a:lc:la:dc:da */
1768 if (!streq(buf + 6, "LIT"))
1770 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1772 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1773 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1774 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1775 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1777 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1779 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1782 /* Use default lighting */
1785 /* No lighting support */
1786 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1789 /* Extract the color */
1790 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1791 if (f_ptr->d_attr[j] > 127) return 1;
1794 f_ptr->d_char[j] = char_tmp[j];
1800 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1802 f_ptr->d_attr[j] = s_attr;
1803 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1809 /* Hack -- Process 'F' for flags */
1810 else if (buf[0] == 'F')
1812 /* Parse every entry textually */
1813 for (s = buf + 2; *s; )
1815 /* Find the end of this entry */
1816 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1818 /* Nuke and skip any dividers */
1822 while (*t == ' ' || *t == '|') t++;
1825 /* XXX XXX XXX Hack -- Read feature subtype */
1826 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1828 /* Extract a "subtype" */
1829 f_ptr->subtype = (FEAT_SUBTYPE)i;
1831 /* Start at next entry */
1838 /* XXX XXX XXX Hack -- Read feature power */
1839 if (1 == sscanf(s, "POWER_%d", &i))
1841 /* Extract a "power" */
1842 f_ptr->power = (FEAT_POWER)i;
1844 /* Start at next entry */
1851 /* Parse this entry */
1852 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1854 /* Start the next entry */
1859 /* Process 'W' for "More Info" (one line only) */
1860 else if (buf[0] == 'W')
1864 /* Scan for the value */
1865 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1867 /* Save the value */
1868 f_ptr->priority = (FEAT_PRIORITY)priority;
1871 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1872 else if (buf[0] == 'K')
1876 /* Find the next empty state slot (if any) */
1877 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1879 /* Oops, no more slots */
1880 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1882 /* Analyze the first field */
1883 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1885 /* Terminate the field (if necessary) */
1886 if (*t == ':') *t++ = '\0';
1888 /* Is this default entry? */
1889 if (streq(s, "DESTROYED"))
1891 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1893 /* Record a fake tag index */
1894 f_ptr->destroyed_tag = offset;
1899 f_ptr->state[i].action = 0;
1901 /* Parse this entry */
1902 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1904 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1906 /* Record a fake tag index */
1907 f_ptr->state[i].result_tag = offset;
1920 * @brief 地形タグからIDを得る /
1921 * Convert a fake tag to a real feat index
1925 s16b f_tag_to_index(cptr str)
1929 /* Search for real index corresponding to this fake tag */
1930 for (i = 0; i < f_head.info_num; i++)
1932 if (streq(f_tag + f_info[i].tag, str))
1934 /* Return the index */
1945 * @brief 地形タグからIDを得る /
1946 * Search for real index corresponding to this fake tag
1947 * @param feat タグ文字列のオフセット
1948 * @return 地形ID。該当がないなら-1
1950 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1954 /* Don't convert non-fake tag */
1960 /* Search for real index corresponding to this fake tag */
1961 for (i = 0; i < f_head.info_num; i++)
1963 if (feat == f_info[i].tag)
1965 /* Record real index */
1971 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1977 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1978 * Retouch fake tags of f_info
1979 * @param head ヘッダ構造体
1982 void retouch_f_info(header *head)
1986 /* Convert fake tags to real feat indices */
1987 for (i = 0; i < head->info_num; i++)
1989 feature_type *f_ptr = &f_info[i];
1992 k = search_real_feat(f_ptr->mimic_tag);
1993 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1994 k = search_real_feat(f_ptr->destroyed_tag);
1995 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1996 for (j = 0; j < MAX_FEAT_STATES; j++)
1998 k = search_real_feat(f_ptr->state[j].result_tag);
1999 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
2006 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
2007 * Grab one flag in an object_kind from a textual string
2008 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
2009 * @param what 参照元の文字列ポインタ
2012 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
2017 for (i = 0; i < TR_FLAG_MAX; i++)
2019 if (streq(what, k_info_flags[i]))
2021 add_flag(k_ptr->flags, i);
2026 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2030 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2037 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2038 * Grab one activation index flag
2039 * @param what 参照元の文字列ポインタ
2042 static byte grab_one_activation_flag(cptr what)
2048 if (activation_info[i].flag == NULL) break;
2050 if (streq(what, activation_info[i].flag))
2052 return activation_info[i].index;
2063 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2071 * @brief ベースアイテム(k_info)のパース関数 /
2072 * Initialize the "k_info" array, by parsing an ascii "template" file
2074 * @param head ヘッダ構造体
2077 errr parse_k_info(char *buf, header *head)
2084 static object_kind *k_ptr = NULL;
2087 /* Process 'N' for "New/Number/Name" */
2094 /* Find the colon before the name */
2095 s = my_strchr(buf+2, ':');
2097 /* Verify that colon */
2100 /* Nuke the colon, advance to the name */
2106 /* Verify information */
2107 if (i <= error_idx) return (4);
2109 /* Verify information */
2110 if (i >= head->info_num) return (2);
2112 /* Save the index */
2115 /* Point at the "info" */
2119 /* Paranoia -- require a name */
2120 if (!*s) return (1);
2122 /* Find the colon before the flavor */
2123 flavor = my_strchr(s, ':');
2125 /* Verify that colon */
2128 /* Nuke the colon, advance to the flavor */
2131 /* Store the flavor */
2132 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2135 /* Store the name */
2136 if (!add_name(&k_ptr->name, head, s)) return (7);
2140 /* There better be a current k_ptr */
2141 else if (!k_ptr) return (3);
2146 /* 'E' から始まる行は英語名としている */
2147 else if (buf[0] == 'E')
2152 else if (buf[0] == 'E')
2156 /* Acquire the name */
2159 /* Find the colon before the flavor */
2160 flavor = my_strchr(s, ':');
2162 /* Verify that colon */
2165 /* Nuke the colon, advance to the flavor */
2168 /* Store the flavor */
2169 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2172 /* Store the name */
2173 if (!add_name(&k_ptr->name, head, s)) return (7);
2177 /* Process 'D' for "Description" */
2178 else if (buf[0] == 'D')
2183 /* Acquire the text */
2188 /* Acquire the text */
2192 /* Store the text */
2193 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2196 /* Process 'G' for "Graphics" (one line only) */
2197 else if (buf[0] == 'G')
2203 if (buf[1] != ':') return (1);
2204 if (!buf[2]) return (1);
2205 if (buf[3] != ':') return (1);
2206 if (!buf[4]) return (1);
2208 /* Extract the char */
2211 /* Extract the attr */
2212 tmp = color_char_to_attr(buf[4]);
2215 if (tmp > 127) return (1);
2217 /* Save the values */
2218 k_ptr->d_attr = tmp;
2219 k_ptr->d_char = sym;
2222 /* Process 'I' for "Info" (one line only) */
2223 else if (buf[0] == 'I')
2225 int tval, sval, pval;
2227 /* Scan for the values */
2228 if (3 != sscanf(buf+2, "%d:%d:%d",
2229 &tval, &sval, &pval)) return (1);
2231 /* Save the values */
2232 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2233 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2234 k_ptr->pval = (PARAMETER_VALUE)pval;
2237 /* Process 'W' for "More Info" (one line only) */
2238 else if (buf[0] == 'W')
2240 int level, extra, wgt;
2243 /* Scan for the values */
2244 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2245 &level, &extra, &wgt, &cost)) return (1);
2247 /* Save the values */
2248 k_ptr->level = (DEPTH)level;
2249 k_ptr->extra = (BIT_FLAGS8)extra;
2250 k_ptr->weight = (WEIGHT)wgt;
2251 k_ptr->cost = (PRICE)cost;
2254 /* Process 'A' for "Allocation" (one line only) */
2255 else if (buf[0] == 'A')
2258 /* XXX XXX XXX Simply read each number following a colon */
2259 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2261 /* Default chance */
2262 k_ptr->chance[i] = 1;
2264 /* Store the attack damage index */
2265 k_ptr->locale[i] = atoi(s+1);
2267 /* Find the slash */
2268 t = my_strchr(s+1, '/');
2270 /* Find the next colon */
2271 s = my_strchr(s+1, ':');
2273 /* If the slash is "nearby", use it */
2274 if (t && (!s || t < s))
2276 int chance = atoi(t+1);
2277 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2282 /* Hack -- Process 'P' for "power" and such */
2283 else if (buf[0] == 'P')
2285 int ac, hd1, hd2, th, td, ta;
2287 /* Scan for the values */
2288 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2289 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2291 k_ptr->ac = (ARMOUR_CLASS)ac;
2292 k_ptr->dd = (DICE_NUMBER)hd1;
2293 k_ptr->ds = (DICE_SID)hd2;
2294 k_ptr->to_h = (HIT_PROB)th;
2295 k_ptr->to_d = (HIT_POINT)td;
2296 k_ptr->to_a = (ARMOUR_CLASS)ta;
2299 /* Hack -- Process 'U' for activation index */
2300 else if (buf[0] == 'U')
2303 n = grab_one_activation_flag(buf + 2);
2314 /* Hack -- Process 'F' for flags */
2315 else if (buf[0] == 'F')
2317 /* Parse every entry textually */
2318 for (s = buf + 2; *s; )
2320 /* Find the end of this entry */
2321 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2323 /* Nuke and skip any dividers */
2327 while (*t == ' ' || *t == '|') t++;
2330 /* Parse this entry */
2331 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2333 /* Start the next entry */
2348 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2349 * Grab one activation index flag
2350 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2351 * @param what 参照元の文字列ポインタ
2352 * @return エラーがあった場合1、エラーがない場合0を返す
2354 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
2359 for (i = 0; i < TR_FLAG_MAX; i++)
2361 if (streq(what, k_info_flags[i]))
2363 add_flag(a_ptr->flags, i);
2368 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2372 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2380 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2381 * Initialize the "a_info" array, by parsing an ascii "template" file
2383 * @param head ヘッダ構造体
2386 errr parse_a_info(char *buf, header *head)
2393 static artifact_type *a_ptr = NULL;
2396 /* Process 'N' for "New/Number/Name" */
2399 /* Find the colon before the name */
2400 s = my_strchr(buf+2, ':');
2402 /* Verify that colon */
2405 /* Nuke the colon, advance to the name */
2408 /* Paranoia -- require a name */
2409 if (!*s) return (1);
2414 /* Verify information */
2415 if (i < error_idx) return (4);
2417 /* Verify information */
2418 if (i >= head->info_num) return (2);
2420 /* Save the index */
2423 /* Point at the "info" */
2426 /* Ignore everything */
2427 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2428 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2429 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2430 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2432 /* Store the name */
2433 if (!add_name(&a_ptr->name, head, s)) return (7);
2437 /* There better be a current a_ptr */
2438 else if (!a_ptr) return (3);
2443 /* 'E' から始まる行は英語名としている */
2444 else if (buf[0] == 'E')
2449 else if (buf[0] == 'E')
2451 /* Acquire the Text */
2454 /* Store the name */
2455 if (!add_name(&a_ptr->name, head, s)) return (7);
2459 /* Process 'D' for "Description" */
2460 else if (buf[0] == 'D')
2465 /* Acquire the text */
2470 /* Acquire the text */
2474 /* Store the text */
2475 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2479 /* Process 'I' for "Info" (one line only) */
2480 else if (buf[0] == 'I')
2482 int tval, sval, pval;
2484 /* Scan for the values */
2485 if (3 != sscanf(buf+2, "%d:%d:%d",
2486 &tval, &sval, &pval)) return (1);
2488 /* Save the values */
2489 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2490 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2491 a_ptr->pval = (PARAMETER_VALUE)pval;
2494 /* Process 'W' for "More Info" (one line only) */
2495 else if (buf[0] == 'W')
2497 int level, rarity, wgt;
2500 /* Scan for the values */
2501 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2502 &level, &rarity, &wgt, &cost)) return (1);
2504 /* Save the values */
2505 a_ptr->level = (DEPTH)level;
2506 a_ptr->rarity = (RARITY)rarity;
2507 a_ptr->weight = (WEIGHT)wgt;
2508 a_ptr->cost = (PRICE)cost;
2511 /* Hack -- Process 'P' for "power" and such */
2512 else if (buf[0] == 'P')
2514 int ac, hd1, hd2, th, td, ta;
2516 /* Scan for the values */
2517 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2518 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2520 a_ptr->ac = (ARMOUR_CLASS)ac;
2521 a_ptr->dd = (DICE_NUMBER)hd1;
2522 a_ptr->ds = (DICE_SID)hd2;
2523 a_ptr->to_h = (HIT_PROB)th;
2524 a_ptr->to_d = (HIT_POINT)td;
2525 a_ptr->to_a = (ARMOUR_CLASS)ta;
2528 /* Hack -- Process 'U' for activation index */
2529 else if (buf[0] == 'U')
2532 n = grab_one_activation_flag(buf + 2);
2543 /* Hack -- Process 'F' for flags */
2544 else if (buf[0] == 'F')
2546 /* Parse every entry textually */
2547 for (s = buf + 2; *s; )
2549 /* Find the end of this entry */
2550 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2552 /* Nuke and skip any dividers */
2556 while ((*t == ' ') || (*t == '|')) t++;
2559 /* Parse this entry */
2560 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2562 /* Start the next entry */
2578 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2579 * Grab one flag in a ego-item_type from a textual string
2580 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2581 * @param what 参照元の文字列ポインタ
2582 * @return エラーがあった場合1、エラーがない場合0を返す
2584 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
2589 for (i = 0; i < TR_FLAG_MAX; i++)
2591 if (streq(what, k_info_flags[i]))
2593 add_flag(e_ptr->flags, i);
2598 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2602 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2610 * @brief アイテムエゴ情報(e_info)のパース関数 /
2611 * Initialize the "e_info" array, by parsing an ascii "template" file
2613 * @param head ヘッダ構造体
2616 errr parse_e_info(char *buf, header *head)
2623 static ego_item_type *e_ptr = NULL;
2626 /* Just before the first record */
2629 /* Just before the first line */
2633 /* Process 'N' for "New/Number/Name" */
2636 /* Find the colon before the name */
2637 s = my_strchr(buf+2, ':');
2639 /* Verify that colon */
2642 /* Nuke the colon, advance to the name */
2645 /* Paranoia -- require a name */
2646 if (!*s) return (1);
2651 /* Verify information */
2652 if (i < error_idx) return (4);
2654 /* Verify information */
2655 if (i >= head->info_num) return (2);
2657 /* Save the index */
2660 /* Point at the "info" */
2663 /* Store the name */
2664 if (!add_name(&e_ptr->name, head, s)) return (7);
2668 /* There better be a current e_ptr */
2669 else if (!e_ptr) return (3);
2674 /* 'E' から始まる行は英語名 */
2675 else if (buf[0] == 'E')
2680 else if (buf[0] == 'E')
2682 /* Acquire the Text */
2685 /* Store the name */
2686 if (!add_name(&e_ptr->name, head, s)) return (7);
2691 /* Process 'D' for "Description" */
2692 else if (buf[0] == 'D')
2694 /* Acquire the text */
2697 /* Store the text */
2698 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2703 /* Process 'X' for "Xtra" (one line only) */
2704 else if (buf[0] == 'X')
2708 /* Scan for the values */
2709 if (2 != sscanf(buf+2, "%d:%d",
2710 &slot, &rating)) return (1);
2712 /* Save the values */
2713 e_ptr->slot = (INVENTORY_IDX)slot;
2714 e_ptr->rating = (PRICE)rating;
2717 /* Process 'W' for "More Info" (one line only) */
2718 else if (buf[0] == 'W')
2720 int level, rarity, pad2;
2723 /* Scan for the values */
2724 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2725 &level, &rarity, &pad2, &cost)) return (1);
2727 /* Save the values */
2728 e_ptr->level = level;
2729 e_ptr->rarity = (RARITY)rarity;
2730 /* e_ptr->weight = wgt; */
2734 /* Hack -- Process 'C' for "creation" */
2735 else if (buf[0] == 'C')
2737 int th, td, ta, pval;
2739 /* Scan for the values */
2740 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2741 &th, &td, &ta, &pval)) return (1);
2743 e_ptr->max_to_h = (HIT_PROB)th;
2744 e_ptr->max_to_d = (HIT_POINT)td;
2745 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2746 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2749 /* Hack -- Process 'U' for activation index */
2750 else if (buf[0] == 'U')
2753 n = grab_one_activation_flag(buf + 2);
2764 /* Hack -- Process 'F' for flags */
2765 else if (buf[0] == 'F')
2767 /* Parse every entry textually */
2768 for (s = buf + 2; *s; )
2770 /* Find the end of this entry */
2771 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2773 /* Nuke and skip any dividers */
2777 while ((*t == ' ') || (*t == '|')) t++;
2780 /* Parse this entry */
2781 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2783 /* Start the next entry */
2797 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2798 * Grab one (basic) flag in a monster_race from a textual string
2799 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2800 * @param what 参照元の文字列ポインタ
2803 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2805 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2808 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2811 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2814 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2817 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2820 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2823 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2827 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2835 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2836 * Grab one (spell) flag in a monster_race from a textual string
2837 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2838 * @param what 参照元の文字列ポインタ
2841 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2843 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2846 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2849 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2853 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2861 * @brief モンスター種族情報(r_info)のパース関数 /
2862 * Initialize the "r_info" array, by parsing an ascii "template" file
2864 * @param head ヘッダ構造体
2867 errr parse_r_info(char *buf, header *head)
2874 static monster_race *r_ptr = NULL;
2877 /* Process 'N' for "New/Number/Name" */
2880 /* Find the colon before the name */
2881 s = my_strchr(buf+2, ':');
2883 /* Verify that colon */
2886 /* Nuke the colon, advance to the name */
2889 /* Paranoia -- require a name */
2890 if (!*s) return (1);
2895 /* Verify information */
2896 if (i < error_idx) return (4);
2898 /* Verify information */
2899 if (i >= head->info_num) return (2);
2901 /* Save the index */
2904 /* Point at the "info" */
2907 /* Store the name */
2908 if (!add_name(&r_ptr->name, head, s)) return (7);
2912 /* There better be a current r_ptr */
2913 else if (!r_ptr) return (3);
2918 /* 'E' から始まる行は英語名 */
2919 else if (buf[0] == 'E')
2921 /* Acquire the Text */
2924 /* Store the name */
2925 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2928 else if (buf[0] == 'E')
2930 /* Acquire the Text */
2933 /* Store the name */
2934 if (!add_name(&r_ptr->name, head, s)) return (7);
2937 /* Process 'D' for "Description" */
2938 else if (buf[0] == 'D')
2943 /* Acquire the text */
2948 /* Acquire the text */
2952 /* Store the text */
2953 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2956 /* Process 'G' for "Graphics" (one line only) */
2957 else if (buf[0] == 'G')
2963 if (buf[1] != ':') return (1);
2964 if (!buf[2]) return (1);
2965 if (buf[3] != ':') return (1);
2966 if (!buf[4]) return (1);
2968 /* Extract the char */
2971 /* Extract the attr */
2972 tmp = color_char_to_attr(buf[4]);
2975 if (tmp > 127) return (1);
2977 /* Save the values */
2978 r_ptr->d_char = sym;
2979 r_ptr->d_attr = tmp;
2982 /* Process 'I' for "Info" (one line only) */
2983 else if (buf[0] == 'I')
2985 int spd, hp1, hp2, aaf, ac, slp;
2987 /* Scan for the other values */
2988 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2989 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2991 /* Save the values */
2992 r_ptr->speed = (SPEED)spd;
2993 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2994 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2995 r_ptr->aaf = (POSITION)aaf;
2996 r_ptr->ac = (ARMOUR_CLASS)ac;
2997 r_ptr->sleep = (SLEEP_DEGREE)slp;
3000 /* Process 'W' for "More Info" (one line only) */
3001 else if (buf[0] == 'W')
3008 /* Scan for the values */
3009 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
3010 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
3012 /* Save the values */
3013 r_ptr->level = (DEPTH)lev;
3014 r_ptr->rarity = (RARITY)rar;
3015 r_ptr->extra = (BIT_FLAGS16)pad;
3016 r_ptr->mexp = (EXP)exp;
3017 r_ptr->next_exp = (EXP)nextexp;
3018 r_ptr->next_r_idx = (IDX)nextmon;
3021 /* Process 'R' for "Reinforcement" (up to six lines) */
3022 else if (buf[0] == 'R')
3025 /* Find the next empty blow slot (if any) */
3026 for (i = 0; i < 6; i++) if (r_ptr->reinforce_id[i] == 0) break;
3028 /* Oops, no more slots */
3029 if (i == 6) return (1);
3031 /* Scan for the values */
3032 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3033 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3034 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3035 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3038 /* Process 'B' for "Blows" (up to four lines) */
3039 else if (buf[0] == 'B')
3043 /* Find the next empty blow slot (if any) */
3044 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3046 /* Oops, no more slots */
3047 if (i == 4) return (1);
3049 /* Analyze the first field */
3050 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3052 /* Terminate the field (if necessary) */
3053 if (*t == ':') *t++ = '\0';
3055 /* Analyze the method */
3056 for (n1 = 0; r_info_blow_method[n1]; n1++)
3058 if (streq(s, r_info_blow_method[n1])) break;
3061 /* Invalid method */
3062 if (!r_info_blow_method[n1]) return (1);
3064 /* Analyze the second field */
3065 for (s = t; *t && (*t != ':'); t++) /* loop */;
3067 /* Terminate the field (if necessary) */
3068 if (*t == ':') *t++ = '\0';
3070 /* Analyze effect */
3071 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3073 if (streq(s, r_info_blow_effect[n2])) break;
3076 /* Invalid effect */
3077 if (!r_info_blow_effect[n2]) return (1);
3079 /* Analyze the third field */
3080 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3082 /* Terminate the field (if necessary) */
3083 if (*t == 'd') *t++ = '\0';
3085 /* Save the method */
3086 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3088 /* Save the effect */
3089 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3091 /* Extract the damage dice and sides */
3092 r_ptr->blow[i].d_dice = atoi(s);
3093 r_ptr->blow[i].d_side = atoi(t);
3096 /* Process 'F' for "Basic Flags" (multiple lines) */
3097 else if (buf[0] == 'F')
3099 /* Parse every entry */
3100 for (s = buf + 2; *s; )
3102 /* Find the end of this entry */
3103 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3105 /* Nuke and skip any dividers */
3109 while (*t == ' ' || *t == '|') t++;
3112 /* Parse this entry */
3113 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3115 /* Start the next entry */
3120 /* Process 'S' for "Spell Flags" (multiple lines) */
3121 else if (buf[0] == 'S')
3123 /* Parse every entry */
3124 for (s = buf + 2; *s; )
3126 /* Find the end of this entry */
3127 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3129 /* Nuke and skip any dividers */
3133 while ((*t == ' ') || (*t == '|')) t++;
3136 /* XXX XXX XXX Hack -- Read spell frequency */
3137 if (1 == sscanf(s, "1_IN_%d", &i))
3139 /* Extract a "frequency" */
3140 r_ptr->freq_spell = 100 / i;
3142 /* Start at next entry */
3149 /* Parse this entry */
3150 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3152 /* Start the next entry */
3157 /* Process 'A' for "Artifact Flags" (multiple lines) */
3158 else if (buf[0] == 'A')
3160 int id, per, rarity;
3162 /* Find the next empty blow slot (if any) */
3163 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3165 /* Oops, no more slots */
3166 if (i == 4) return (1);
3168 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3169 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3170 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3171 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3174 /* Process 'V' for "Arena power value ratio" */
3175 else if (buf[0] == 'V')
3178 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3179 r_ptr->arena_ratio = (PERCENTAGE)val;
3192 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3193 * Grab one flag for a dungeon type from a textual string
3194 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3195 * @param what 参照元の文字列ポインタ
3198 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
3200 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3204 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3211 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3212 * Grab one (basic) flag in a monster_race from a textual string
3213 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3214 * @param what 参照元の文字列ポインタ
3217 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
3219 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3222 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3225 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3228 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3231 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3234 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3237 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3241 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3248 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3249 * Grab one (spell) flag in a monster_race from a textual string
3250 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3251 * @param what 参照元の文字列ポインタ
3254 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
3256 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3259 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3262 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3266 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3273 * @brief ダンジョン情報(d_info)のパース関数 /
3274 * Initialize the "d_info" array, by parsing an ascii "template" file
3276 * @param head ヘッダ構造体
3279 errr parse_d_info(char *buf, header *head)
3286 static dungeon_info_type *d_ptr = NULL;
3289 /* Process 'N' for "New/Number/Name" */
3292 /* Find the colon before the name */
3293 s = my_strchr(buf+2, ':');
3295 /* Verify that colon */
3298 /* Nuke the colon, advance to the name */
3301 /* Paranoia -- require a name */
3302 if (!*s) return (1);
3307 /* Verify information */
3308 if (i < error_idx) return (4);
3310 /* Verify information */
3311 if (i >= head->info_num) return (2);
3313 /* Save the index */
3316 /* Point at the "info" */
3319 /* Store the name */
3320 if (!add_name(&d_ptr->name, head, s)) return (7);
3325 else if (buf[0] == 'E') return (0);
3327 else if (buf[0] == 'E')
3329 /* Acquire the Text */
3332 /* Store the name */
3333 if (!add_name(&d_ptr->name, head, s)) return (7);
3337 /* Process 'D' for "Description */
3338 else if (buf[0] == 'D')
3343 /* Acquire the text */
3348 /* Acquire the text */
3352 /* Store the text */
3353 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3356 /* Process 'W' for "More Info" (one line only) */
3357 else if (buf[0] == 'W')
3359 int min_lev, max_lev;
3361 int min_alloc, max_chance;
3362 int obj_good, obj_great;
3365 /* Scan for the values */
3366 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3367 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3369 /* Save the values */
3370 d_ptr->mindepth = (DEPTH)min_lev;
3371 d_ptr->maxdepth = (DEPTH)max_lev;
3372 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3373 d_ptr->mode = (BIT_FLAGS8)mode;
3374 d_ptr->min_m_alloc_level = min_alloc;
3375 d_ptr->max_m_alloc_chance = max_chance;
3376 d_ptr->obj_good = obj_good;
3377 d_ptr->obj_great = obj_great;
3378 d_ptr->pit = (BIT_FLAGS16)pit;
3379 d_ptr->nest = (BIT_FLAGS16)nest;
3382 /* Process 'P' for "Place Info" */
3383 else if (buf[0] == 'P')
3387 /* Scan for the values */
3388 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3390 /* Save the values */
3395 /* Process 'L' for "fLoor type" (one line only) */
3396 else if (buf[0] == 'L')
3400 /* Scan for the values */
3401 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3403 /* Save the values */
3404 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3406 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3407 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3409 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3411 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3414 /* Process 'A' for "wAll type" (one line only) */
3415 else if (buf[0] == 'A')
3419 /* Scan for the values */
3420 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3422 /* Save the values */
3423 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3425 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3426 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3428 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3431 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3432 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3434 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3435 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3437 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3438 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3440 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3441 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3444 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3445 else if (buf[0] == 'F')
3447 int artif = 0, monst = 0;
3449 /* Parse every entry */
3450 for (s = buf + 2; *s; )
3452 /* Find the end of this entry */
3453 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3455 /* Nuke and skip any dividers */
3459 while (*t == ' ' || *t == '|') t++;
3462 /* XXX XXX XXX Hack -- Read Final Artifact */
3463 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3465 /* Extract a "Final Artifact" */
3466 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3468 /* Start at next entry */
3475 /* XXX XXX XXX Hack -- Read Final Object */
3476 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3478 /* Extract a "Final Artifact" */
3479 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3481 /* Start at next entry */
3488 /* XXX XXX XXX Hack -- Read Artifact Guardian */
3489 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3491 /* Extract a "Artifact Guardian" */
3492 d_ptr->final_guardian = (MONRACE_IDX)monst;
3494 /* Start at next entry */
3501 /* XXX XXX XXX Hack -- Read Special Percentage */
3502 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3504 /* Extract a "Special %" */
3505 d_ptr->special_div = (PROB)monst;
3507 /* Start at next entry */
3514 /* Parse this entry */
3515 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3517 /* Start the next entry */
3522 /* Process 'M' for "Basic Flags" (multiple lines) */
3523 else if (buf[0] == 'M')
3525 /* Parse every entry */
3526 for (s = buf + 2; *s; )
3528 /* Find the end of this entry */
3529 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3531 /* Nuke and skip any dividers */
3535 while (*t == ' ' || *t == '|') t++;
3538 /* Hack -- Read monster symbols */
3539 if (!strncmp(s, "R_CHAR_", 7))
3541 /* Skip "R_CHAR_" */
3545 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3547 /* Start at next entry */
3554 /* Parse this entry */
3555 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3557 /* Start the next entry */
3562 /* Process 'S' for "Spell Flags" (multiple lines) */
3563 else if (buf[0] == 'S')
3565 /* Parse every entry */
3566 for (s = buf + 2; *s; )
3568 /* Find the end of this entry */
3569 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3571 /* Nuke and skip any dividers */
3575 while ((*t == ' ') || (*t == '|')) t++;
3578 /* XXX XXX XXX Hack -- Read spell frequency */
3579 if (1 == sscanf(s, "1_IN_%d", &i))
3581 /* Start at next entry */
3588 /* Parse this entry */
3589 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3591 /* Start the next entry */
3604 #else /* ALLOW_TEMPLATES */
3610 #endif /* ALLOW_TEMPLATES */
3613 /* Random dungeon grid effects */
3614 #define RANDOM_NONE 0x00000000
3615 #define RANDOM_FEATURE 0x00000001
3616 #define RANDOM_MONSTER 0x00000002
3617 #define RANDOM_OBJECT 0x00000004
3618 #define RANDOM_EGO 0x00000008
3619 #define RANDOM_ARTIFACT 0x00000010
3620 #define RANDOM_TRAP 0x00000020
3623 typedef struct dungeon_grid dungeon_grid;
3627 FEAT_IDX feature; /* Terrain feature */
3628 MONSTER_IDX monster; /* Monster */
3629 OBJECT_IDX object; /* Object */
3630 EGO_IDX ego; /* Ego-Item */
3631 ARTIFACT_IDX artifact; /* Artifact */
3632 IDX trap; /* Trap */
3633 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3634 s16b special; /* Reserved for special terrain info */
3635 int random; /* Number of the random effect */
3639 static dungeon_grid letter[255];
3643 * @brief 地形情報の「F:」情報をパースする
3644 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3648 static errr parse_line_feature(char *buf)
3654 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3656 /* Tokenize the line */
3657 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3659 /* Letter to assign */
3660 int index = zz[0][0];
3662 /* Reset the info for the letter */
3663 letter[index].feature = feat_none;
3664 letter[index].monster = 0;
3665 letter[index].object = 0;
3666 letter[index].ego = 0;
3667 letter[index].artifact = 0;
3668 letter[index].trap = feat_none;
3669 letter[index].cave_info = 0;
3670 letter[index].special = 0;
3671 letter[index].random = RANDOM_NONE;
3677 letter[index].special = (s16b)atoi(zz[8]);
3681 if ((zz[7][0] == '*') && !zz[7][1])
3683 letter[index].random |= RANDOM_TRAP;
3687 letter[index].trap = f_tag_to_index(zz[7]);
3688 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3693 if (zz[6][0] == '*')
3695 letter[index].random |= RANDOM_ARTIFACT;
3696 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3698 else if (zz[6][0] == '!')
3700 if (p_ptr->inside_quest)
3702 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3707 letter[index].artifact = (IDX)atoi(zz[6]);
3712 if (zz[5][0] == '*')
3714 letter[index].random |= RANDOM_EGO;
3715 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3719 letter[index].ego = (IDX)atoi(zz[5]);
3724 if (zz[4][0] == '*')
3726 letter[index].random |= RANDOM_OBJECT;
3727 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3729 else if (zz[4][0] == '!')
3731 if (p_ptr->inside_quest)
3733 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3736 artifact_type *a_ptr = &a_info[a_idx];
3737 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3739 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3746 letter[index].object = (IDX)atoi(zz[4]);
3751 if (zz[3][0] == '*')
3753 letter[index].random |= RANDOM_MONSTER;
3754 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3756 else if (zz[3][0] == 'c')
3758 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3759 letter[index].monster = - atoi(zz[3] + 1);
3763 letter[index].monster = (IDX)atoi(zz[3]);
3768 letter[index].cave_info = atoi(zz[2]);
3772 if ((zz[1][0] == '*') && !zz[1][1])
3774 letter[index].random |= RANDOM_FEATURE;
3778 letter[index].feature = f_tag_to_index(zz[1]);
3779 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3792 * @brief 地形情報の「B:」情報をパースする
3793 * Process "B:<Index>:<Command>:..." -- Building definition
3797 static errr parse_line_building(char *buf)
3813 /* Get the building number */
3816 /* Find the colon after the building number */
3817 s = my_strchr(s, ':');
3819 /* Verify that colon */
3822 /* Nuke the colon, advance to the sub-index */
3825 /* Paranoia -- require a sub-index */
3826 if (!*s) return (1);
3828 /* Building definition sub-index */
3831 /* Building name, owner, race */
3834 if (tokenize(s + 2, 3, zz, 0) == 3)
3836 /* Name of the building */
3837 strcpy(building[index].name, zz[0]);
3839 /* Name of the owner */
3840 strcpy(building[index].owner_name, zz[1]);
3842 /* Race of the owner */
3843 strcpy(building[index].owner_race, zz[2]);
3848 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3851 /* Building Action */
3854 if (tokenize(s + 2, 8, zz, 0) >= 7)
3856 /* Index of the action */
3857 int action_index = atoi(zz[0]);
3859 /* Name of the action */
3860 strcpy(building[index].act_names[action_index], zz[1]);
3862 /* Cost of the action for members */
3863 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3865 /* Cost of the action for non-members */
3866 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3868 /* Letter assigned to the action */
3869 building[index].letters[action_index] = zz[4][0];
3872 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3874 /* Action restriction */
3875 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3880 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3883 /* Building Classes */
3886 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3888 for (i = 0; i < MAX_CLASS; i++)
3890 building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
3896 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3899 /* Building Races */
3902 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3904 for (i = 0; i < MAX_RACES; i++)
3906 building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
3912 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3915 /* Building Realms */
3918 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3920 for (i = 0; i < MAX_MAGIC; i++)
3922 building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
3928 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3933 /* Ignore scripts */
3939 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3948 * @brief フロアの所定のマスにオブジェクトを配置する
3949 * Place the object j_ptr to a grid
3950 * @param j_ptr オブジェクト構造体の参照ポインタ
3955 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3957 cave_type *c_ptr = &cave[y][x];
3960 /* Get new object */
3961 OBJECT_IDX o_idx = o_pop();
3963 /* Access new object */
3964 o_ptr = &o_list[o_idx];
3966 /* Structure copy */
3967 object_copy(o_ptr, j_ptr);
3975 o_ptr->held_m_idx = 0;
3978 o_ptr->next_o_idx = c_ptr->o_idx;
3980 /* Place the object */
3981 c_ptr->o_idx = o_idx;
3986 * @brief クエスト用固定ダンジョンをフロアに生成する
3987 * Parse a sub-file of the "extra info"
3997 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
4004 /* Skip "empty" lines */
4005 if (!buf[0]) return (0);
4007 /* Skip "blank" lines */
4008 if (iswspace(buf[0])) return (0);
4011 if (buf[0] == '#') return (0);
4013 /* Require "?:*" format */
4014 if (buf[1] != ':') return (1);
4017 /* Process "%:<fname>" */
4020 /* Attempt to Process the given file */
4021 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
4024 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
4027 return parse_line_feature(buf);
4030 /* Process "D:<dungeon>" -- info for the cave grids */
4031 else if (buf[0] == 'D')
4033 object_type object_type_body;
4035 /* Acquire the text */
4038 /* Length of the text */
4039 int len = strlen(s);
4041 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
4043 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
4045 /* Access the grid */
4046 cave_type *c_ptr = &cave[*y][*x];
4050 IDX object_index = letter[idx].object;
4051 IDX monster_index = letter[idx].monster;
4052 int random = letter[idx].random;
4053 IDX artifact_index = letter[idx].artifact;
4055 /* Lay down a floor */
4056 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4058 /* Only the features */
4059 if (init_flags & INIT_ONLY_FEATURES) continue;
4062 c_ptr->info = letter[idx].cave_info;
4064 /* Create a monster */
4065 if (random & RANDOM_MONSTER)
4067 monster_level = base_level + monster_index;
4069 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4071 monster_level = base_level;
4073 else if (monster_index)
4075 int old_cur_num, old_max_num;
4078 if (monster_index < 0)
4080 monster_index = -monster_index;
4083 old_cur_num = r_info[monster_index].cur_num;
4084 old_max_num = r_info[monster_index].max_num;
4086 /* Make alive again */
4087 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4089 r_info[monster_index].cur_num = 0;
4090 r_info[monster_index].max_num = 1;
4093 /* Make alive again */
4094 /* Hack -- Non-unique Nazguls are semi-unique */
4095 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4097 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4099 r_info[monster_index].max_num++;
4104 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4108 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4110 /* Make alive again for real unique monster */
4111 r_info[monster_index].cur_num = old_cur_num;
4112 r_info[monster_index].max_num = old_max_num;
4116 /* Object (and possible trap) */
4117 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4119 object_level = base_level + object_index;
4122 * Random trap and random treasure defined
4123 * 25% chance for trap and 75% chance for object
4125 if (randint0(100) < 75)
4127 place_object(*y, *x, 0L);
4134 object_level = base_level;
4136 else if (random & RANDOM_OBJECT)
4138 object_level = base_level + object_index;
4140 /* Create an out of deep object */
4141 if (randint0(100) < 75)
4142 place_object(*y, *x, 0L);
4143 else if (randint0(100) < 80)
4144 place_object(*y, *x, AM_GOOD);
4146 place_object(*y, *x, AM_GOOD | AM_GREAT);
4148 object_level = base_level;
4151 else if (random & RANDOM_TRAP)
4155 /* Hidden trap (or door) */
4156 else if (letter[idx].trap)
4158 c_ptr->mimic = c_ptr->feat;
4159 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4161 else if (object_index)
4163 /* Get local object */
4164 object_type *o_ptr = &object_type_body;
4166 /* Create the item */
4167 object_prep(o_ptr, object_index);
4169 if (o_ptr->tval == TV_GOLD)
4171 coin_type = object_index - OBJ_GOLD_LIST;
4176 /* Apply magic (no messages, no artifacts) */
4177 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4179 drop_here(o_ptr, *y, *x);
4185 if (a_info[artifact_index].cur_num)
4187 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4189 object_type *q_ptr = &forge;
4191 object_prep(q_ptr, k_idx);
4193 /* Drop it in the dungeon */
4194 drop_here(q_ptr, *y, *x);
4198 /* Create the artifact */
4199 if (create_named_art(artifact_index, *y, *x))
4200 a_info[artifact_index].cur_num = 1;
4204 /* Terrain special */
4205 c_ptr->special = letter[idx].special;
4213 /* Process "Q:<number>:<command>:... -- quest info */
4214 else if (buf[0] == 'Q')
4221 num = tokenize(buf + 2, 33, zz, 0);
4225 num = tokenize(buf + 3, 33, zz, 0);
4228 /* Have we enough parameters? */
4229 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4232 q_ptr = &(quest[atoi(zz[0])]);
4234 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4235 if (zz[1][0] == 'Q')
4237 if (init_flags & INIT_ASSIGN)
4239 monster_race *r_ptr;
4240 artifact_type *a_ptr;
4242 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4244 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4245 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4246 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4247 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4248 q_ptr->level = (DEPTH)atoi(zz[6]);
4249 q_ptr->r_idx = (IDX)atoi(zz[7]);
4250 q_ptr->k_idx = (IDX)atoi(zz[8]);
4251 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4253 if (num > 10) q_ptr->flags = atoi(zz[10]);
4255 r_ptr = &r_info[q_ptr->r_idx];
4256 if (r_ptr->flags1 & RF1_UNIQUE)
4257 r_ptr->flags1 |= RF1_QUESTOR;
4259 a_ptr = &a_info[q_ptr->k_idx];
4260 a_ptr->gen_flags |= TRG_QUESTITEM;
4265 else if (zz[1][0] == 'R')
4267 if (init_flags & INIT_ASSIGN)
4270 IDX idx, reward_idx = 0;
4272 for (idx = 2; idx < num; idx++)
4274 IDX a_idx = (IDX)atoi(zz[idx]);
4275 if (a_idx < 1) continue;
4276 if (a_info[a_idx].cur_num > 0) continue;
4278 if (one_in_(count)) reward_idx = a_idx;
4283 /* Set quest's rewarding artifact */
4284 q_ptr->k_idx = reward_idx;
4285 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4289 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4290 q_ptr->type = QUEST_TYPE_KILL_ALL;
4297 /* Process "Q:<q_index>:N:<name>" -- quest name */
4298 else if (zz[1][0] == 'N')
4300 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4302 strcpy(q_ptr->name, zz[2]);
4308 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4309 else if (zz[1][0] == 'T')
4311 if (init_flags & INIT_SHOW_TEXT)
4313 strcpy(quest_text[quest_text_line], zz[2]);
4321 /* Process "W:<command>: ..." -- info for the wilderness */
4322 else if (buf[0] == 'W')
4324 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4327 /* Process "P:<y>:<x>" -- player position */
4328 else if (buf[0] == 'P')
4330 if (init_flags & INIT_CREATE_DUNGEON)
4332 if (tokenize(buf + 2, 2, zz, 0) == 2)
4334 int panels_x, panels_y;
4336 /* Hack - Set the dungeon size */
4337 panels_y = (*y / SCREEN_HGT);
4338 if (*y % SCREEN_HGT) panels_y++;
4339 cur_hgt = panels_y * SCREEN_HGT;
4341 panels_x = (*x / SCREEN_WID);
4342 if (*x % SCREEN_WID) panels_x++;
4343 cur_wid = panels_x * SCREEN_WID;
4345 /* Assume illegal panel */
4346 panel_row_min = cur_hgt;
4347 panel_col_min = cur_wid;
4349 /* Place player in a quest level */
4350 if (p_ptr->inside_quest)
4354 /* Delete the monster (if any) */
4355 delete_monster(p_ptr->y, p_ptr->x);
4363 /* Place player in the town */
4364 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4366 p_ptr->oldpy = atoi(zz[0]);
4367 p_ptr->oldpx = atoi(zz[1]);
4375 /* Process "B:<Index>:<Command>:..." -- Building definition */
4376 else if (buf[0] == 'B')
4378 return parse_line_building(buf);
4381 /* Process "M:<type>:<maximum>" -- set maximum values */
4382 else if (buf[0] == 'M')
4384 if (tokenize(buf+2, 2, zz, 0) == 2)
4387 if (zz[0][0] == 'T')
4389 max_towns = (IDX)atoi(zz[1]);
4392 /* Maximum quests */
4393 else if (zz[0][0] == 'Q')
4395 max_q_idx = (IDX)atoi(zz[1]);
4399 else if (zz[0][0] == 'R')
4401 max_r_idx = (IDX)atoi(zz[1]);
4405 else if (zz[0][0] == 'K')
4407 max_k_idx = (IDX)atoi(zz[1]);
4411 else if (zz[0][0] == 'V')
4413 max_v_idx = (IDX)atoi(zz[1]);
4417 else if (zz[0][0] == 'F')
4419 max_f_idx = (IDX)atoi(zz[1]);
4423 else if (zz[0][0] == 'A')
4425 max_a_idx = (IDX)atoi(zz[1]);
4429 else if (zz[0][0] == 'E')
4431 max_e_idx = (IDX)atoi(zz[1]);
4435 else if (zz[0][0] == 'D')
4437 max_d_idx = (IDX)atoi(zz[1]);
4441 else if (zz[0][0] == 'O')
4443 max_o_idx = (IDX)atoi(zz[1]);
4447 else if (zz[0][0] == 'M')
4449 max_m_idx = (IDX)atoi(zz[1]);
4452 /* Wilderness size */
4453 else if (zz[0][0] == 'W')
4455 /* Maximum wild_x_size */
4456 if (zz[0][1] == 'X')
4457 max_wild_x = atoi(zz[1]);
4458 /* Maximum wild_y_size */
4459 if (zz[0][1] == 'Y')
4460 max_wild_y = atoi(zz[1]);
4474 static cptr variant = "ZANGBAND";
4478 * @brief クエスト用固定ダンジョン生成時の分岐処理
4479 * Helper function for "process_dungeon_file()"
4484 static cptr process_dungeon_file_expr(char **sp, char *fp)
4500 while (iswspace(*s)) s++;
4518 t = process_dungeon_file_expr(&s, &f);
4527 else if (streq(t, "IOR"))
4530 while (*s && (f != b2))
4532 t = process_dungeon_file_expr(&s, &f);
4533 if (*t && !streq(t, "0")) v = "1";
4538 else if (streq(t, "AND"))
4541 while (*s && (f != b2))
4543 t = process_dungeon_file_expr(&s, &f);
4544 if (*t && streq(t, "0")) v = "0";
4549 else if (streq(t, "NOT"))
4552 while (*s && (f != b2))
4554 t = process_dungeon_file_expr(&s, &f);
4555 if (*t && streq(t, "1")) v = "0";
4560 else if (streq(t, "EQU"))
4563 if (*s && (f != b2))
4565 t = process_dungeon_file_expr(&s, &f);
4567 while (*s && (f != b2))
4569 p = process_dungeon_file_expr(&s, &f);
4570 if (streq(t, p)) v = "1";
4575 else if (streq(t, "LEQ"))
4578 if (*s && (f != b2))
4580 t = process_dungeon_file_expr(&s, &f);
4582 while (*s && (f != b2))
4585 t = process_dungeon_file_expr(&s, &f);
4586 if (*t && atoi(p) > atoi(t)) v = "0";
4591 else if (streq(t, "GEQ"))
4594 if (*s && (f != b2))
4596 t = process_dungeon_file_expr(&s, &f);
4598 while (*s && (f != b2))
4601 t = process_dungeon_file_expr(&s, &f);
4603 /* Compare two numbers instead of string */
4604 if (*t && atoi(p) < atoi(t)) v = "0";
4611 while (*s && (f != b2))
4613 t = process_dungeon_file_expr(&s, &f);
4618 if (f != b2) v = "?x?x?";
4620 /* Extract final and Terminate */
4621 if ((f = *s) != '\0') *s++ = '\0';
4627 /* Accept all printables except spaces and brackets */
4629 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4631 if (iskanji(*s)) s++;
4635 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4638 /* Extract final and Terminate */
4639 if ((f = *s) != '\0') *s++ = '\0';
4645 if (streq(b+1, "SYS"))
4651 else if (streq(b+1, "GRAF"))
4656 else if (streq(b+1, "MONOCHROME"))
4665 else if (streq(b+1, "RACE"))
4667 v = _(rp_ptr->E_title, rp_ptr->title);
4671 else if (streq(b+1, "CLASS"))
4673 v = _(cp_ptr->E_title, cp_ptr->title);
4677 else if (streq(b+1, "REALM1"))
4679 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4683 else if (streq(b+1, "REALM2"))
4685 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4689 else if (streq(b+1, "PLAYER"))
4691 static char tmp_player_name[32];
4693 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4703 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4706 v = tmp_player_name;
4710 else if (streq(b+1, "TOWN"))
4712 sprintf(tmp, "%d", p_ptr->town_num);
4717 else if (streq(b+1, "LEVEL"))
4719 sprintf(tmp, "%d", p_ptr->lev);
4723 /* Current quest number */
4724 else if (streq(b+1, "QUEST_NUMBER"))
4726 sprintf(tmp, "%d", p_ptr->inside_quest);
4730 /* Number of last quest */
4731 else if (streq(b+1, "LEAVING_QUEST"))
4733 sprintf(tmp, "%d", leaving_quest);
4738 else if (prefix(b+1, "QUEST_TYPE"))
4740 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4741 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4746 else if (prefix(b+1, "QUEST"))
4748 /* "QUEST" uses a special parameter to determine the number of the quest */
4749 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4754 else if (prefix(b+1, "RANDOM"))
4756 /* "RANDOM" uses a special parameter to determine the number of the quest */
4757 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4762 else if (streq(b+1, "VARIANT"))
4768 else if (streq(b+1, "WILDERNESS"))
4771 sprintf(tmp, "NONE");
4773 sprintf(tmp, "LITE");
4775 sprintf(tmp, "NORMAL");
4799 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4800 * Helper function for "process_dungeon_file()"
4808 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4814 bool bypass = FALSE;
4815 int x = xmin, y = ymin;
4818 /* Build the filename */
4819 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4822 fp = my_fopen(buf, "r");
4825 if (!fp) return (-1);
4828 /* Process the file */
4829 while (0 == my_fgets(fp, buf, sizeof(buf)))
4835 /* Skip "empty" lines */
4836 if (!buf[0]) continue;
4838 /* Skip "blank" lines */
4839 if (iswspace(buf[0])) continue;
4842 if (buf[0] == '#') continue;
4845 /* Process "?:<expr>" */
4846 if ((buf[0] == '?') && (buf[1] == ':'))
4855 /* Parse the expr */
4856 v = process_dungeon_file_expr(&s, &f);
4859 bypass = (streq(v, "0") ? TRUE : FALSE);
4865 /* Apply conditionals */
4866 if (bypass) continue;
4868 /* Process the line */
4869 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4881 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4884 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4885 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4891 /* Close the file */
4901 void write_r_info_txt(void)
4903 int i, j, z, fc, bc;
4906 cptr flags[32 * 10];
4911 monster_race *r_ptr;
4913 monster_blow *b_ptr;
4915 FILE *fff = fopen("output.txt", "wt");
4919 BIT_FLAGS mode = -1;
4923 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4925 fprintf(fff, "# Version stamp (required)\n\n");
4928 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4931 fprintf(fff, "##### The Player #####\n\n");
4933 for (z = -1; z < alloc_race_size; z++)
4935 /* Output the monsters in order */
4936 i = (z >= 0) ? alloc_race_table[z].index : 0;
4938 /* Acquire the monster */
4941 /* Ignore empty monsters */
4942 if (!strlen(r_name + r_ptr->name)) continue;
4944 /* Ignore useless monsters */
4945 if (i && !r_ptr->speed) continue;
4947 /* Write a note if necessary */
4948 if (i && (!r_ptr->level != !mode))
4953 fprintf(fff, "\n##### Town monsters #####\n\n");
4955 /* Note the dungeon */
4958 fprintf(fff, "\n##### Normal monsters #####\n\n");
4961 /* Record the change */
4962 mode = r_ptr->level;
4965 /* Acquire the flags */
4966 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4967 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4968 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4969 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4970 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4971 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4972 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4973 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4974 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4975 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4977 /* Write New/Number/Name */
4978 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4981 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4983 /* Write Information */
4984 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4985 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4987 /* Write more information */
4988 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4991 for(j = 0; j < 4; j++)
4993 b_ptr = &(r_ptr->blow[j]);
4995 /* Stop when done */
4996 if (!b_ptr->method) break;
4998 /* Write the blows */
4999 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
5000 r_info_blow_effect[b_ptr->effect],
5001 b_ptr->d_dice, b_ptr->d_side);
5004 /* Extract the flags */
5005 for (fc = 0, j = 0; j < 32 * 3; j++)
5007 /* Check this flag */
5008 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5011 /* Extract the extra flags */
5012 for (j = 32 * 6; j < 32 * 10; j++)
5014 /* Check this flag */
5015 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5018 /* Write the flags */
5019 for (j = 0; j < fc;)
5023 /* Start the line */
5026 for (bc = 0; (bc < 60) && (j < fc); j++)
5030 /* Format the flag */
5031 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5033 /* Add it to the buffer */
5036 /* Note the length */
5040 /* Done with this line; write it */
5041 fprintf(fff, "%s\n", buf);
5044 /* Write Spells if applicable */
5045 if (r_ptr->freq_spell)
5047 /* Write the frequency */
5048 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
5050 /* Extract the spell flags */
5051 for (fc = 0, j = 96; j < 192; j++)
5053 /* Check this flag */
5054 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5057 /* Write the flags */
5058 for (j = 0; j < fc;)
5062 /* Start the line */
5065 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5069 /* Format the flag */
5070 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5074 /* Note the length */
5081 /* Done with this line; write it */
5082 fprintf(fff, "%s\n", buf);
5086 /* Acquire the description */
5087 desc = r_text + r_ptr->text;
5088 dlen = strlen(desc);
5090 /* Write Description */
5091 for (j = 0; j < dlen;)
5095 /* Start the line */
5098 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5106 /* Done with this line; write it */
5107 fprintf(fff, "%s\n", buf);
5110 /* Space between entries */