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, parse_info_txt_func parse_info_txt_line)
1184 /* Just before the first record */
1187 /* Just before the first line */
1191 /* Prepare the "fake" stuff */
1192 head->name_size = 0;
1193 head->text_size = 0;
1197 while (0 == my_fgets(fp, buf, 1024))
1199 /* Advance the line number */
1202 /* Skip comments and blank lines */
1203 if (!buf[0] || (buf[0] == '#')) continue;
1205 /* Verify correct "colon" format */
1206 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1209 /* Hack -- Process 'V' for "Version" */
1216 /* Mega Hack -- Calculate Check Sum */
1217 if (buf[0] != 'N' && buf[0] != 'D')
1220 for (i = 0; buf[i]; i++)
1222 head->v_extra += (byte)buf[i];
1223 head->v_extra ^= (1 << (i % 8));
1227 /* Parse the line */
1228 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1233 /* Complete the "name" and "text" sizes */
1234 if (head->name_size) head->name_size++;
1235 if (head->text_size) head->text_size++;
1243 * @brief Vault情報(v_info)のパース関数 /
1244 * Initialize the "v_info" array, by parsing an ascii "template" file
1246 * @param head ヘッダ構造体
1249 errr parse_v_info(char *buf, header *head)
1255 static vault_type *v_ptr = NULL;
1257 /* Process 'N' for "New/Number/Name" */
1260 /* Find the colon before the name */
1261 s = my_strchr(buf+2, ':');
1263 /* Verify that colon */
1266 /* Nuke the colon, advance to the name */
1269 /* Paranoia -- require a name */
1270 if (!*s) return (1);
1275 /* Verify information */
1276 if (i <= error_idx) return (4);
1278 /* Verify information */
1279 if (i >= head->info_num) return (2);
1281 /* Save the index */
1284 /* Point at the "info" */
1287 /* Store the name */
1288 if (!add_name(&v_ptr->name, head, s)) return (7);
1291 /* There better be a current v_ptr */
1292 else if (!v_ptr) return (3);
1294 /* Process 'D' for "Description" */
1295 else if (buf[0] == 'D')
1297 /* Acquire the text */
1300 /* Store the text */
1301 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1304 /* Process 'X' for "Extra info" (one line only) */
1305 else if (buf[0] == 'X')
1307 EFFECT_ID typ, rat, hgt, wid;
1309 /* Scan for the values */
1310 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1311 &typ, &rat, &hgt, &wid)) return (1);
1313 /* Save the values */
1314 v_ptr->typ = (ROOM_IDX)typ;
1315 v_ptr->rat = (PROB)rat;
1316 v_ptr->hgt = (POSITION)hgt;
1317 v_ptr->wid = (POSITION)wid;
1328 * @brief 職業技能情報(s_info)のパース関数 /
1329 * Initialize the "s_info" array, by parsing an ascii "template" file
1331 * @param head ヘッダ構造体
1334 errr parse_s_info(char *buf, header *head)
1339 static skill_table *s_ptr = NULL;
1342 /* Process 'N' for "New/Number/Name" */
1348 /* Verify information */
1349 if (i <= error_idx) return (4);
1351 /* Verify information */
1352 if (i >= head->info_num) return (2);
1354 /* Save the index */
1357 /* Point at the "info" */
1361 /* There better be a current s_ptr */
1362 else if (!s_ptr) return (3);
1364 /* Process 'W' for "Weapon exp" */
1365 else if (buf[0] == 'W')
1367 int tval, sval, start, max;
1368 const s16b exp_conv_table[] =
1370 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1371 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1374 /* Scan for the values */
1375 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1376 &tval, &sval, &start, &max)) return (1);
1378 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1379 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1381 /* Save the values */
1382 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1383 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1386 /* Process 'S' for "Skill exp" */
1387 else if (buf[0] == 'S')
1389 int num, start, max;
1391 /* Scan for the values */
1392 if (3 != sscanf(buf+2, "%d:%d:%d",
1393 &num, &start, &max)) return (1);
1395 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1396 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1398 /* Save the values */
1399 s_ptr->s_start[num] = (SUB_EXP)start;
1400 s_ptr->s_max[num] = (SUB_EXP)max;
1412 * @brief 職業魔法情報(m_info)のパース関数 /
1413 * Initialize the "m_info" array, by parsing an ascii "template" file
1415 * @param head ヘッダ構造体
1418 errr parse_m_info(char *buf, header *head)
1425 static player_magic *m_ptr = NULL;
1428 static int realm, magic_idx = 0, readable = 0;
1431 /* Process 'N' for "New/Number/Name" */
1437 /* Verify information */
1438 if (i <= error_idx) return (4);
1440 /* Verify information */
1441 if (i >= head->info_num) return (2);
1443 /* Save the index */
1446 /* Point at the "info" */
1450 /* There better be a current m_ptr */
1451 else if (!m_ptr) return (3);
1453 /* Process 'I' for "Info" (one line only) */
1454 else if (buf[0] == 'I')
1457 int xtra, type, first, weight;
1459 /* Find the colon before the name */
1460 s = my_strchr(buf+2, ':');
1462 /* Verify that colon */
1465 /* Nuke the colon, advance to the name */
1470 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1471 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1472 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1473 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1474 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1479 /* Find the colon before the name */
1480 s = my_strchr(s, ':');
1482 /* Verify that colon */
1485 /* Nuke the colon, advance to the name */
1488 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1489 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1490 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1491 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1492 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1493 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1497 /* Scan for the values */
1498 if (4 != sscanf(s, "%x:%d:%d:%d",
1499 (uint *)&xtra, &type, &first, &weight)) return (1);
1501 m_ptr->spell_xtra = xtra;
1502 m_ptr->spell_type = type;
1503 m_ptr->spell_first = first;
1504 m_ptr->spell_weight = weight;
1508 /* Process 'R' for "Realm" (one line only) */
1509 else if (buf[0] == 'R')
1511 /* Scan for the values */
1512 if (2 != sscanf(buf+2, "%d:%d",
1513 &realm, &readable)) return (1);
1518 else if (buf[0] == 'T')
1520 int level, mana, fail, exp;
1522 if (!readable) return (1);
1523 /* Scan for the values */
1524 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1525 &level, &mana, &fail, &exp)) return (1);
1527 m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level;
1528 m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana;
1529 m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail;
1530 m_ptr->info[realm][magic_idx].sexp = (EXP)exp;
1543 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1544 * Grab one flag from a textual string
1545 * @param flags ビットフラグを追加する先の参照ポインタ
1546 * @param names トークン定義配列
1547 * @param what 参照元の文字列ポインタ
1550 static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
1555 for (i = 0; i < 32; i++)
1557 if (streq(what, names[i]))
1559 *flags |= (1L << i);
1569 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1570 * Grab one flag in an feature_type from a textual string
1571 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1572 * @param what 参照元の文字列ポインタ
1575 static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
1580 for (i = 0; i < FF_FLAG_MAX; i++)
1582 if (streq(what, f_info_flags[i]))
1584 add_flag(f_ptr->flags, i);
1589 msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
1592 return PARSE_ERROR_GENERIC;
1597 * @brief テキストトークンを走査してフラグ(ステート)を一つ得る(地形情報向け2) /
1598 * Grab an action in an feature_type from a textual string
1599 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1600 * @param what 参照元の文字列ポインタ
1601 * @param count ステートの保存先ID
1604 static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
1609 for (i = 0; i < FF_FLAG_MAX; i++)
1611 if (streq(what, f_info_flags[i]))
1613 f_ptr->state[count].action = i;
1618 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1621 return PARSE_ERROR_GENERIC;
1626 * @brief 地形情報(f_info)のパース関数 /
1627 * Initialize the "f_info" array, by parsing an ascii "template" file
1629 * @param head ヘッダ構造体
1632 errr parse_f_info(char *buf, header *head)
1639 static feature_type *f_ptr = NULL;
1642 /* Process 'N' for "New/Number/Name" */
1645 /* Find the colon before the name */
1646 s = my_strchr(buf+2, ':');
1650 /* Nuke the colon, advance to the name */
1657 /* Verify information */
1658 if (i <= error_idx) return (4);
1660 /* Verify information */
1661 if (i >= head->info_num) return (2);
1663 /* Save the index */
1666 /* Point at the "info" */
1669 /* Tag name is given */
1673 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1676 /* Default "mimic" */
1677 f_ptr->mimic = (FEAT_IDX)i;
1679 /* Default "destroyed state" -- if not specified */
1680 f_ptr->destroyed = (FEAT_IDX)i;
1682 /* Default "states" */
1683 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1686 /* There better be a current f_ptr */
1687 else if (!f_ptr) return (3);
1690 else if (buf[0] == 'J')
1692 /* Store the name */
1693 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1696 else if (buf[0] == 'E')
1698 /* Ignore english name */
1701 else if (buf[0] == 'J')
1703 /* Ignore Japanese name */
1706 else if (buf[0] == 'E')
1708 /* Acquire the Text */
1711 /* Store the name */
1712 if (!add_name(&f_ptr->name, head, s)) return (7);
1717 /* Process 'M' for "Mimic" (one line only) */
1718 else if (buf[0] == 'M')
1722 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1724 /* Record a fake tag index */
1725 f_ptr->mimic_tag = offset;
1729 /* Process 'G' for "Graphics" (one line only) */
1730 else if (buf[0] == 'G')
1734 char char_tmp[F_LIT_MAX];
1737 if (buf[1] != ':') return (1);
1738 if (!buf[2]) return (1);
1739 if (buf[3] != ':') return (1);
1740 if (!buf[4]) return (1);
1742 /* Extract the char */
1743 char_tmp[F_LIT_STANDARD] = buf[2];
1745 /* Extract the color */
1746 s_attr = color_char_to_attr(buf[4]);
1749 if (s_attr > 127) return (1);
1751 /* Save the standard values */
1752 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1753 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1755 /* Is this feature supports lighting? */
1758 /* G:c:a:LIT (default) */
1759 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1761 /* G:c:a:lc:la:dc:da */
1762 if (!streq(buf + 6, "LIT"))
1764 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1766 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1767 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1768 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1769 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1771 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1773 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1776 /* Use default lighting */
1779 /* No lighting support */
1780 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1783 /* Extract the color */
1784 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1785 if (f_ptr->d_attr[j] > 127) return 1;
1788 f_ptr->d_char[j] = char_tmp[j];
1794 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1796 f_ptr->d_attr[j] = s_attr;
1797 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1803 /* Hack -- Process 'F' for flags */
1804 else if (buf[0] == 'F')
1806 /* Parse every entry textually */
1807 for (s = buf + 2; *s; )
1809 /* Find the end of this entry */
1810 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1812 /* Nuke and skip any dividers */
1816 while (*t == ' ' || *t == '|') t++;
1819 /* Hack -- Read feature subtype */
1820 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1822 /* Extract a "subtype" */
1823 f_ptr->subtype = (FEAT_SUBTYPE)i;
1825 /* Start at next entry */
1831 /* Hack -- Read feature power */
1832 if (1 == sscanf(s, "POWER_%d", &i))
1834 /* Extract a "power" */
1835 f_ptr->power = (FEAT_POWER)i;
1837 /* Start at next entry */
1842 /* Parse this entry */
1843 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1845 /* Start the next entry */
1850 /* Process 'W' for "More Info" (one line only) */
1851 else if (buf[0] == 'W')
1855 /* Scan for the value */
1856 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1858 /* Save the value */
1859 f_ptr->priority = (FEAT_PRIORITY)priority;
1862 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1863 else if (buf[0] == 'K')
1867 /* Find the next empty state slot (if any) */
1868 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1870 /* Oops, no more slots */
1871 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1873 /* Analyze the first field */
1874 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1876 /* Terminate the field (if necessary) */
1877 if (*t == ':') *t++ = '\0';
1879 /* Is this default entry? */
1880 if (streq(s, "DESTROYED"))
1882 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1884 /* Record a fake tag index */
1885 f_ptr->destroyed_tag = offset;
1890 f_ptr->state[i].action = 0;
1892 /* Parse this entry */
1893 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1895 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1897 /* Record a fake tag index */
1898 f_ptr->state[i].result_tag = offset;
1910 * @brief 地形タグからIDを得る /
1911 * Convert a fake tag to a real feat index
1915 s16b f_tag_to_index(cptr str)
1919 /* Search for real index corresponding to this fake tag */
1920 for (i = 0; i < f_head.info_num; i++)
1922 if (streq(f_tag + f_info[i].tag, str))
1924 /* Return the index */
1935 * @brief 地形タグからIDを得る /
1936 * Search for real index corresponding to this fake tag
1937 * @param feat タグ文字列のオフセット
1938 * @return 地形ID。該当がないなら-1
1940 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1944 /* Don't convert non-fake tag */
1950 /* Search for real index corresponding to this fake tag */
1951 for (i = 0; i < f_head.info_num; i++)
1953 if (feat == f_info[i].tag)
1955 /* Record real index */
1961 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1967 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1968 * Retouch fake tags of f_info
1969 * @param head ヘッダ構造体
1972 void retouch_f_info(header *head)
1976 /* Convert fake tags to real feat indices */
1977 for (i = 0; i < head->info_num; i++)
1979 feature_type *f_ptr = &f_info[i];
1982 k = search_real_feat(f_ptr->mimic_tag);
1983 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1984 k = search_real_feat(f_ptr->destroyed_tag);
1985 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1986 for (j = 0; j < MAX_FEAT_STATES; j++)
1988 k = search_real_feat(f_ptr->state[j].result_tag);
1989 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
1996 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
1997 * Grab one flag in an object_kind from a textual string
1998 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
1999 * @param what 参照元の文字列ポインタ
2002 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
2007 for (i = 0; i < TR_FLAG_MAX; i++)
2009 if (streq(what, k_info_flags[i]))
2011 add_flag(k_ptr->flags, i);
2016 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2019 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2026 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2027 * Grab one activation index flag
2028 * @param what 参照元の文字列ポインタ
2031 static byte grab_one_activation_flag(cptr what)
2037 if (activation_info[i].flag == NULL) break;
2039 if (streq(what, activation_info[i].flag))
2041 return activation_info[i].index;
2051 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2059 * @brief ベースアイテム(k_info)のパース関数 /
2060 * Initialize the "k_info" array, by parsing an ascii "template" file
2062 * @param head ヘッダ構造体
2065 errr parse_k_info(char *buf, header *head)
2072 static object_kind *k_ptr = NULL;
2075 /* Process 'N' for "New/Number/Name" */
2082 /* Find the colon before the name */
2083 s = my_strchr(buf+2, ':');
2085 /* Verify that colon */
2088 /* Nuke the colon, advance to the name */
2094 /* Verify information */
2095 if (i <= error_idx) return (4);
2097 /* Verify information */
2098 if (i >= head->info_num) return (2);
2100 /* Save the index */
2103 /* Point at the "info" */
2107 /* Paranoia -- require a name */
2108 if (!*s) return (1);
2110 /* Find the colon before the flavor */
2111 flavor = my_strchr(s, ':');
2113 /* Verify that colon */
2116 /* Nuke the colon, advance to the flavor */
2119 /* Store the flavor */
2120 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2123 /* Store the name */
2124 if (!add_name(&k_ptr->name, head, s)) return (7);
2128 /* There better be a current k_ptr */
2129 else if (!k_ptr) return (3);
2134 /* 'E' から始まる行は英語名としている */
2135 else if (buf[0] == 'E')
2140 else if (buf[0] == 'E')
2144 /* Acquire the name */
2147 /* Find the colon before the flavor */
2148 flavor = my_strchr(s, ':');
2150 /* Verify that colon */
2153 /* Nuke the colon, advance to the flavor */
2156 /* Store the flavor */
2157 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2160 /* Store the name */
2161 if (!add_name(&k_ptr->name, head, s)) return (7);
2165 /* Process 'D' for "Description" */
2166 else if (buf[0] == 'D')
2171 /* Acquire the text */
2176 /* Acquire the text */
2180 /* Store the text */
2181 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2184 /* Process 'G' for "Graphics" (one line only) */
2185 else if (buf[0] == 'G')
2191 if (buf[1] != ':') return (1);
2192 if (!buf[2]) return (1);
2193 if (buf[3] != ':') return (1);
2194 if (!buf[4]) return (1);
2196 /* Extract the char */
2199 /* Extract the attr */
2200 tmp = color_char_to_attr(buf[4]);
2203 if (tmp > 127) return (1);
2205 /* Save the values */
2206 k_ptr->d_attr = tmp;
2207 k_ptr->d_char = sym;
2210 /* Process 'I' for "Info" (one line only) */
2211 else if (buf[0] == 'I')
2213 int tval, sval, pval;
2215 /* Scan for the values */
2216 if (3 != sscanf(buf+2, "%d:%d:%d",
2217 &tval, &sval, &pval)) return (1);
2219 /* Save the values */
2220 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2221 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2222 k_ptr->pval = (PARAMETER_VALUE)pval;
2225 /* Process 'W' for "More Info" (one line only) */
2226 else if (buf[0] == 'W')
2228 int level, extra, wgt;
2231 /* Scan for the values */
2232 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2233 &level, &extra, &wgt, &cost)) return (1);
2235 /* Save the values */
2236 k_ptr->level = (DEPTH)level;
2237 k_ptr->extra = (BIT_FLAGS8)extra;
2238 k_ptr->weight = (WEIGHT)wgt;
2239 k_ptr->cost = (PRICE)cost;
2242 /* Process 'A' for "Allocation" (one line only) */
2243 else if (buf[0] == 'A')
2246 /* Simply read each number following a colon */
2247 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2249 /* Default chance */
2250 k_ptr->chance[i] = 1;
2252 /* Store the attack damage index */
2253 k_ptr->locale[i] = atoi(s+1);
2255 /* Find the slash */
2256 t = my_strchr(s+1, '/');
2258 /* Find the next colon */
2259 s = my_strchr(s+1, ':');
2261 /* If the slash is "nearby", use it */
2262 if (t && (!s || t < s))
2264 int chance = atoi(t+1);
2265 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2270 /* Hack -- Process 'P' for "power" and such */
2271 else if (buf[0] == 'P')
2273 int ac, hd1, hd2, th, td, ta;
2275 /* Scan for the values */
2276 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2277 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2279 k_ptr->ac = (ARMOUR_CLASS)ac;
2280 k_ptr->dd = (DICE_NUMBER)hd1;
2281 k_ptr->ds = (DICE_SID)hd2;
2282 k_ptr->to_h = (HIT_PROB)th;
2283 k_ptr->to_d = (HIT_POINT)td;
2284 k_ptr->to_a = (ARMOUR_CLASS)ta;
2287 /* Hack -- Process 'U' for activation index */
2288 else if (buf[0] == 'U')
2291 n = grab_one_activation_flag(buf + 2);
2302 /* Hack -- Process 'F' for flags */
2303 else if (buf[0] == 'F')
2305 /* Parse every entry textually */
2306 for (s = buf + 2; *s; )
2308 /* Find the end of this entry */
2309 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2311 /* Nuke and skip any dividers */
2315 while (*t == ' ' || *t == '|') t++;
2318 /* Parse this entry */
2319 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2321 /* Start the next entry */
2335 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2336 * Grab one activation index flag
2337 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2338 * @param what 参照元の文字列ポインタ
2339 * @return エラーがあった場合1、エラーがない場合0を返す
2341 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
2346 for (i = 0; i < TR_FLAG_MAX; i++)
2348 if (streq(what, k_info_flags[i]))
2350 add_flag(a_ptr->flags, i);
2355 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2358 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2366 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2367 * Initialize the "a_info" array, by parsing an ascii "template" file
2369 * @param head ヘッダ構造体
2372 errr parse_a_info(char *buf, header *head)
2379 static artifact_type *a_ptr = NULL;
2382 /* Process 'N' for "New/Number/Name" */
2385 /* Find the colon before the name */
2386 s = my_strchr(buf+2, ':');
2388 /* Verify that colon */
2391 /* Nuke the colon, advance to the name */
2394 /* Paranoia -- require a name */
2395 if (!*s) return (1);
2400 /* Verify information */
2401 if (i < error_idx) return (4);
2403 /* Verify information */
2404 if (i >= head->info_num) return (2);
2406 /* Save the index */
2409 /* Point at the "info" */
2412 /* Ignore everything */
2413 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2414 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2415 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2416 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2418 /* Store the name */
2419 if (!add_name(&a_ptr->name, head, s)) return (7);
2423 /* There better be a current a_ptr */
2424 else if (!a_ptr) return (3);
2429 /* 'E' から始まる行は英語名としている */
2430 else if (buf[0] == 'E')
2435 else if (buf[0] == 'E')
2437 /* Acquire the Text */
2440 /* Store the name */
2441 if (!add_name(&a_ptr->name, head, s)) return (7);
2445 /* Process 'D' for "Description" */
2446 else if (buf[0] == 'D')
2451 /* Acquire the text */
2456 /* Acquire the text */
2460 /* Store the text */
2461 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2465 /* Process 'I' for "Info" (one line only) */
2466 else if (buf[0] == 'I')
2468 int tval, sval, pval;
2470 /* Scan for the values */
2471 if (3 != sscanf(buf+2, "%d:%d:%d",
2472 &tval, &sval, &pval)) return (1);
2474 /* Save the values */
2475 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2476 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2477 a_ptr->pval = (PARAMETER_VALUE)pval;
2480 /* Process 'W' for "More Info" (one line only) */
2481 else if (buf[0] == 'W')
2483 int level, rarity, wgt;
2486 /* Scan for the values */
2487 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2488 &level, &rarity, &wgt, &cost)) return (1);
2490 /* Save the values */
2491 a_ptr->level = (DEPTH)level;
2492 a_ptr->rarity = (RARITY)rarity;
2493 a_ptr->weight = (WEIGHT)wgt;
2494 a_ptr->cost = (PRICE)cost;
2497 /* Hack -- Process 'P' for "power" and such */
2498 else if (buf[0] == 'P')
2500 int ac, hd1, hd2, th, td, ta;
2502 /* Scan for the values */
2503 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2504 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2506 a_ptr->ac = (ARMOUR_CLASS)ac;
2507 a_ptr->dd = (DICE_NUMBER)hd1;
2508 a_ptr->ds = (DICE_SID)hd2;
2509 a_ptr->to_h = (HIT_PROB)th;
2510 a_ptr->to_d = (HIT_POINT)td;
2511 a_ptr->to_a = (ARMOUR_CLASS)ta;
2514 /* Hack -- Process 'U' for activation index */
2515 else if (buf[0] == 'U')
2518 n = grab_one_activation_flag(buf + 2);
2529 /* Hack -- Process 'F' for flags */
2530 else if (buf[0] == 'F')
2532 /* Parse every entry textually */
2533 for (s = buf + 2; *s; )
2535 /* Find the end of this entry */
2536 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2538 /* Nuke and skip any dividers */
2542 while ((*t == ' ') || (*t == '|')) t++;
2545 /* Parse this entry */
2546 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2548 /* Start the next entry */
2563 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2564 * Grab one flag in a ego-item_type from a textual string
2565 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2566 * @param what 参照元の文字列ポインタ
2567 * @return エラーがあった場合1、エラーがない場合0を返す
2569 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
2574 for (i = 0; i < TR_FLAG_MAX; i++)
2576 if (streq(what, k_info_flags[i]))
2578 add_flag(e_ptr->flags, i);
2583 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2586 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2594 * @brief アイテムエゴ情報(e_info)のパース関数 /
2595 * Initialize the "e_info" array, by parsing an ascii "template" file
2597 * @param head ヘッダ構造体
2600 errr parse_e_info(char *buf, header *head)
2607 static ego_item_type *e_ptr = NULL;
2610 /* Just before the first record */
2613 /* Just before the first line */
2617 /* Process 'N' for "New/Number/Name" */
2620 /* Find the colon before the name */
2621 s = my_strchr(buf+2, ':');
2623 /* Verify that colon */
2626 /* Nuke the colon, advance to the name */
2629 /* Paranoia -- require a name */
2630 if (!*s) return (1);
2635 /* Verify information */
2636 if (i < error_idx) return (4);
2638 /* Verify information */
2639 if (i >= head->info_num) return (2);
2641 /* Save the index */
2644 /* Point at the "info" */
2647 /* Store the name */
2648 if (!add_name(&e_ptr->name, head, s)) return (7);
2652 /* There better be a current e_ptr */
2653 else if (!e_ptr) return (3);
2658 /* 'E' から始まる行は英語名 */
2659 else if (buf[0] == 'E')
2664 else if (buf[0] == 'E')
2666 /* Acquire the Text */
2669 /* Store the name */
2670 if (!add_name(&e_ptr->name, head, s)) return (7);
2675 /* Process 'D' for "Description" */
2676 else if (buf[0] == 'D')
2678 /* Acquire the text */
2681 /* Store the text */
2682 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2687 /* Process 'X' for "Xtra" (one line only) */
2688 else if (buf[0] == 'X')
2692 /* Scan for the values */
2693 if (2 != sscanf(buf+2, "%d:%d",
2694 &slot, &rating)) return (1);
2696 /* Save the values */
2697 e_ptr->slot = (INVENTORY_IDX)slot;
2698 e_ptr->rating = (PRICE)rating;
2701 /* Process 'W' for "More Info" (one line only) */
2702 else if (buf[0] == 'W')
2704 int level, rarity, pad2;
2707 /* Scan for the values */
2708 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2709 &level, &rarity, &pad2, &cost)) return (1);
2711 /* Save the values */
2712 e_ptr->level = level;
2713 e_ptr->rarity = (RARITY)rarity;
2714 /* e_ptr->weight = wgt; */
2718 /* Hack -- Process 'C' for "creation" */
2719 else if (buf[0] == 'C')
2721 int th, td, ta, pval;
2723 /* Scan for the values */
2724 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2725 &th, &td, &ta, &pval)) return (1);
2727 e_ptr->max_to_h = (HIT_PROB)th;
2728 e_ptr->max_to_d = (HIT_POINT)td;
2729 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2730 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2733 /* Hack -- Process 'U' for activation index */
2734 else if (buf[0] == 'U')
2737 n = grab_one_activation_flag(buf + 2);
2748 /* Hack -- Process 'F' for flags */
2749 else if (buf[0] == 'F')
2751 /* Parse every entry textually */
2752 for (s = buf + 2; *s; )
2754 /* Find the end of this entry */
2755 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2757 /* Nuke and skip any dividers */
2761 while ((*t == ' ') || (*t == '|')) t++;
2764 /* Parse this entry */
2765 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2767 /* Start the next entry */
2780 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2781 * Grab one (basic) flag in a monster_race from a textual string
2782 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2783 * @param what 参照元の文字列ポインタ
2786 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2788 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2791 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2794 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2797 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2800 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2803 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2806 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2809 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2817 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2818 * Grab one (spell) flag in a monster_race from a textual string
2819 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2820 * @param what 参照元の文字列ポインタ
2823 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2825 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2828 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2831 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2834 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2842 * @brief モンスター種族情報(r_info)のパース関数 /
2843 * Initialize the "r_info" array, by parsing an ascii "template" file
2845 * @param head ヘッダ構造体
2848 errr parse_r_info(char *buf, header *head)
2855 static monster_race *r_ptr = NULL;
2858 /* Process 'N' for "New/Number/Name" */
2861 /* Find the colon before the name */
2862 s = my_strchr(buf+2, ':');
2864 /* Verify that colon */
2867 /* Nuke the colon, advance to the name */
2870 /* Paranoia -- require a name */
2871 if (!*s) return (1);
2876 /* Verify information */
2877 if (i < error_idx) return (4);
2879 /* Verify information */
2880 if (i >= head->info_num) return (2);
2882 /* Save the index */
2885 /* Point at the "info" */
2888 /* Store the name */
2889 if (!add_name(&r_ptr->name, head, s)) return (7);
2893 /* There better be a current r_ptr */
2894 else if (!r_ptr) return (3);
2899 /* 'E' から始まる行は英語名 */
2900 else if (buf[0] == 'E')
2902 /* Acquire the Text */
2905 /* Store the name */
2906 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2909 else if (buf[0] == 'E')
2911 /* Acquire the Text */
2914 /* Store the name */
2915 if (!add_name(&r_ptr->name, head, s)) return (7);
2918 /* Process 'D' for "Description" */
2919 else if (buf[0] == 'D')
2924 /* Acquire the text */
2929 /* Acquire the text */
2933 /* Store the text */
2934 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2937 /* Process 'G' for "Graphics" (one line only) */
2938 else if (buf[0] == 'G')
2944 if (buf[1] != ':') return (1);
2945 if (!buf[2]) return (1);
2946 if (buf[3] != ':') return (1);
2947 if (!buf[4]) return (1);
2949 /* Extract the char */
2952 /* Extract the attr */
2953 tmp = color_char_to_attr(buf[4]);
2956 if (tmp > 127) return (1);
2958 /* Save the values */
2959 r_ptr->d_char = sym;
2960 r_ptr->d_attr = tmp;
2963 /* Process 'I' for "Info" (one line only) */
2964 else if (buf[0] == 'I')
2966 int spd, hp1, hp2, aaf, ac, slp;
2968 /* Scan for the other values */
2969 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2970 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2972 /* Save the values */
2973 r_ptr->speed = (SPEED)spd;
2974 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2975 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2976 r_ptr->aaf = (POSITION)aaf;
2977 r_ptr->ac = (ARMOUR_CLASS)ac;
2978 r_ptr->sleep = (SLEEP_DEGREE)slp;
2981 /* Process 'W' for "More Info" (one line only) */
2982 else if (buf[0] == 'W')
2989 /* Scan for the values */
2990 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2991 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2993 /* Save the values */
2994 r_ptr->level = (DEPTH)lev;
2995 r_ptr->rarity = (RARITY)rar;
2996 r_ptr->extra = (BIT_FLAGS16)pad;
2997 r_ptr->mexp = (EXP)exp;
2998 r_ptr->next_exp = (EXP)nextexp;
2999 r_ptr->next_r_idx = (IDX)nextmon;
3002 /* Process 'R' for "Reinforcement" (up to six lines) */
3003 else if (buf[0] == 'R')
3006 /* Find the next empty blow slot (if any) */
3007 for (i = 0; i < 6; i++) if (r_ptr->reinforce_id[i] == 0) break;
3009 /* Oops, no more slots */
3010 if (i == 6) return (1);
3012 /* Scan for the values */
3013 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3014 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3015 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3016 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3019 /* Process 'B' for "Blows" (up to four lines) */
3020 else if (buf[0] == 'B')
3024 /* Find the next empty blow slot (if any) */
3025 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3027 /* Oops, no more slots */
3028 if (i == 4) return (1);
3030 /* Analyze the first field */
3031 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3033 /* Terminate the field (if necessary) */
3034 if (*t == ':') *t++ = '\0';
3036 /* Analyze the method */
3037 for (n1 = 0; r_info_blow_method[n1]; n1++)
3039 if (streq(s, r_info_blow_method[n1])) break;
3042 /* Invalid method */
3043 if (!r_info_blow_method[n1]) return (1);
3045 /* Analyze the second field */
3046 for (s = t; *t && (*t != ':'); t++) /* loop */;
3048 /* Terminate the field (if necessary) */
3049 if (*t == ':') *t++ = '\0';
3051 /* Analyze effect */
3052 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3054 if (streq(s, r_info_blow_effect[n2])) break;
3057 /* Invalid effect */
3058 if (!r_info_blow_effect[n2]) return (1);
3060 /* Analyze the third field */
3061 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3063 /* Terminate the field (if necessary) */
3064 if (*t == 'd') *t++ = '\0';
3066 /* Save the method */
3067 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3069 /* Save the effect */
3070 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3072 /* Extract the damage dice and sides */
3073 r_ptr->blow[i].d_dice = atoi(s);
3074 r_ptr->blow[i].d_side = atoi(t);
3077 /* Process 'F' for "Basic Flags" (multiple lines) */
3078 else if (buf[0] == 'F')
3080 /* Parse every entry */
3081 for (s = buf + 2; *s; )
3083 /* Find the end of this entry */
3084 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3086 /* Nuke and skip any dividers */
3090 while (*t == ' ' || *t == '|') t++;
3093 /* Parse this entry */
3094 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3096 /* Start the next entry */
3101 /* Process 'S' for "Spell Flags" (multiple lines) */
3102 else if (buf[0] == 'S')
3104 /* Parse every entry */
3105 for (s = buf + 2; *s; )
3107 /* Find the end of this entry */
3108 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3110 /* Nuke and skip any dividers */
3114 while ((*t == ' ') || (*t == '|')) t++;
3117 /* Hack -- Read spell frequency */
3118 if (1 == sscanf(s, "1_IN_%d", &i))
3120 /* Extract a "frequency" */
3121 r_ptr->freq_spell = 100 / i;
3123 /* Start at next entry */
3128 /* Parse this entry */
3129 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3131 /* Start the next entry */
3136 /* Process 'A' for "Artifact Flags" (multiple lines) */
3137 else if (buf[0] == 'A')
3139 int id, per, rarity;
3141 /* Find the next empty blow slot (if any) */
3142 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3144 /* Oops, no more slots */
3145 if (i == 4) return (1);
3147 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3148 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3149 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3150 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3153 /* Process 'V' for "Arena power value ratio" */
3154 else if (buf[0] == 'V')
3157 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3158 r_ptr->arena_ratio = (PERCENTAGE)val;
3170 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3171 * Grab one flag for a dungeon type from a textual string
3172 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3173 * @param what 参照元の文字列ポインタ
3176 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
3178 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3181 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3188 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3189 * Grab one (basic) flag in a monster_race from a textual string
3190 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3191 * @param what 参照元の文字列ポインタ
3194 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
3196 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3199 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3202 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3205 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3208 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3211 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3214 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3217 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3224 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3225 * Grab one (spell) flag in a monster_race from a textual string
3226 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3227 * @param what 参照元の文字列ポインタ
3230 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
3232 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3235 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3238 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3241 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3248 * @brief ダンジョン情報(d_info)のパース関数 /
3249 * Initialize the "d_info" array, by parsing an ascii "template" file
3251 * @param head ヘッダ構造体
3254 errr parse_d_info(char *buf, header *head)
3261 static dungeon_info_type *d_ptr = NULL;
3264 /* Process 'N' for "New/Number/Name" */
3267 /* Find the colon before the name */
3268 s = my_strchr(buf+2, ':');
3270 /* Verify that colon */
3273 /* Nuke the colon, advance to the name */
3276 /* Paranoia -- require a name */
3277 if (!*s) return (1);
3282 /* Verify information */
3283 if (i < error_idx) return (4);
3285 /* Verify information */
3286 if (i >= head->info_num) return (2);
3288 /* Save the index */
3291 /* Point at the "info" */
3294 /* Store the name */
3295 if (!add_name(&d_ptr->name, head, s)) return (7);
3300 else if (buf[0] == 'E') return (0);
3302 else if (buf[0] == 'E')
3304 /* Acquire the Text */
3307 /* Store the name */
3308 if (!add_name(&d_ptr->name, head, s)) return (7);
3312 /* Process 'D' for "Description */
3313 else if (buf[0] == 'D')
3318 /* Acquire the text */
3323 /* Acquire the text */
3327 /* Store the text */
3328 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3331 /* Process 'W' for "More Info" (one line only) */
3332 else if (buf[0] == 'W')
3334 int min_lev, max_lev;
3336 int min_alloc, max_chance;
3337 int obj_good, obj_great;
3340 /* Scan for the values */
3341 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3342 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3344 /* Save the values */
3345 d_ptr->mindepth = (DEPTH)min_lev;
3346 d_ptr->maxdepth = (DEPTH)max_lev;
3347 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3348 d_ptr->mode = (BIT_FLAGS8)mode;
3349 d_ptr->min_m_alloc_level = min_alloc;
3350 d_ptr->max_m_alloc_chance = max_chance;
3351 d_ptr->obj_good = obj_good;
3352 d_ptr->obj_great = obj_great;
3353 d_ptr->pit = (BIT_FLAGS16)pit;
3354 d_ptr->nest = (BIT_FLAGS16)nest;
3357 /* Process 'P' for "Place Info" */
3358 else if (buf[0] == 'P')
3362 /* Scan for the values */
3363 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3365 /* Save the values */
3370 /* Process 'L' for "fLoor type" (one line only) */
3371 else if (buf[0] == 'L')
3375 /* Scan for the values */
3376 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3378 /* Save the values */
3379 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3381 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3382 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3384 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3386 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3389 /* Process 'A' for "wAll type" (one line only) */
3390 else if (buf[0] == 'A')
3394 /* Scan for the values */
3395 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3397 /* Save the values */
3398 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3400 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3401 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3403 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3406 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3407 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3409 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3410 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3412 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3413 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3415 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3416 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3419 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3420 else if (buf[0] == 'F')
3422 int artif = 0, monst = 0;
3424 /* Parse every entry */
3425 for (s = buf + 2; *s; )
3427 /* Find the end of this entry */
3428 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3430 /* Nuke and skip any dividers */
3434 while (*t == ' ' || *t == '|') t++;
3437 /* Hack -- Read Final Artifact */
3438 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3440 /* Extract a "Final Artifact" */
3441 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3443 /* Start at next entry */
3448 /* Hack -- Read Final Object */
3449 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3451 /* Extract a "Final Artifact" */
3452 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3454 /* Start at next entry */
3459 /* Hack -- Read Artifact Guardian */
3460 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3462 /* Extract a "Artifact Guardian" */
3463 d_ptr->final_guardian = (MONRACE_IDX)monst;
3465 /* Start at next entry */
3470 /* Hack -- Read Special Percentage */
3471 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3473 /* Extract a "Special %" */
3474 d_ptr->special_div = (PROB)monst;
3476 /* Start at next entry */
3481 /* Parse this entry */
3482 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3484 /* Start the next entry */
3489 /* Process 'M' for "Basic Flags" (multiple lines) */
3490 else if (buf[0] == 'M')
3492 /* Parse every entry */
3493 for (s = buf + 2; *s; )
3495 /* Find the end of this entry */
3496 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3498 /* Nuke and skip any dividers */
3502 while (*t == ' ' || *t == '|') t++;
3505 /* Hack -- Read monster symbols */
3506 if (!strncmp(s, "R_CHAR_", 7))
3508 /* Skip "R_CHAR_" */
3512 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3514 /* Start at next entry */
3519 /* Parse this entry */
3520 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3522 /* Start the next entry */
3527 /* Process 'S' for "Spell Flags" (multiple lines) */
3528 else if (buf[0] == 'S')
3530 /* Parse every entry */
3531 for (s = buf + 2; *s; )
3533 /* Find the end of this entry */
3534 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3536 /* Nuke and skip any dividers */
3540 while ((*t == ' ') || (*t == '|')) t++;
3543 /* Hack -- Read spell frequency */
3544 if (1 == sscanf(s, "1_IN_%d", &i))
3546 /* Start at next entry */
3551 /* Parse this entry */
3552 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3554 /* Start the next entry */
3566 #else /* ALLOW_TEMPLATES */
3572 #endif /* ALLOW_TEMPLATES */
3575 /* Random dungeon grid effects */
3576 #define RANDOM_NONE 0x00000000
3577 #define RANDOM_FEATURE 0x00000001
3578 #define RANDOM_MONSTER 0x00000002
3579 #define RANDOM_OBJECT 0x00000004
3580 #define RANDOM_EGO 0x00000008
3581 #define RANDOM_ARTIFACT 0x00000010
3582 #define RANDOM_TRAP 0x00000020
3585 typedef struct dungeon_grid dungeon_grid;
3589 FEAT_IDX feature; /* Terrain feature */
3590 MONSTER_IDX monster; /* Monster */
3591 OBJECT_IDX object; /* Object */
3592 EGO_IDX ego; /* Ego-Item */
3593 ARTIFACT_IDX artifact; /* Artifact */
3594 IDX trap; /* Trap */
3595 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3596 s16b special; /* Reserved for special terrain info */
3597 int random; /* Number of the random effect */
3601 static dungeon_grid letter[255];
3605 * @brief 地形情報の「F:」情報をパースする
3606 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3610 static errr parse_line_feature(char *buf)
3616 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3618 /* Tokenize the line */
3619 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3621 /* Letter to assign */
3622 int index = zz[0][0];
3624 /* Reset the info for the letter */
3625 letter[index].feature = feat_none;
3626 letter[index].monster = 0;
3627 letter[index].object = 0;
3628 letter[index].ego = 0;
3629 letter[index].artifact = 0;
3630 letter[index].trap = feat_none;
3631 letter[index].cave_info = 0;
3632 letter[index].special = 0;
3633 letter[index].random = RANDOM_NONE;
3639 letter[index].special = (s16b)atoi(zz[8]);
3643 if ((zz[7][0] == '*') && !zz[7][1])
3645 letter[index].random |= RANDOM_TRAP;
3649 letter[index].trap = f_tag_to_index(zz[7]);
3650 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3655 if (zz[6][0] == '*')
3657 letter[index].random |= RANDOM_ARTIFACT;
3658 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3660 else if (zz[6][0] == '!')
3662 if (p_ptr->inside_quest)
3664 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3669 letter[index].artifact = (IDX)atoi(zz[6]);
3674 if (zz[5][0] == '*')
3676 letter[index].random |= RANDOM_EGO;
3677 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3681 letter[index].ego = (IDX)atoi(zz[5]);
3686 if (zz[4][0] == '*')
3688 letter[index].random |= RANDOM_OBJECT;
3689 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3691 else if (zz[4][0] == '!')
3693 if (p_ptr->inside_quest)
3695 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3698 artifact_type *a_ptr = &a_info[a_idx];
3699 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3701 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3708 letter[index].object = (IDX)atoi(zz[4]);
3713 if (zz[3][0] == '*')
3715 letter[index].random |= RANDOM_MONSTER;
3716 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3718 else if (zz[3][0] == 'c')
3720 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3721 letter[index].monster = - atoi(zz[3] + 1);
3725 letter[index].monster = (IDX)atoi(zz[3]);
3730 letter[index].cave_info = atoi(zz[2]);
3734 if ((zz[1][0] == '*') && !zz[1][1])
3736 letter[index].random |= RANDOM_FEATURE;
3740 letter[index].feature = f_tag_to_index(zz[1]);
3741 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3754 * @brief 地形情報の「B:」情報をパースする
3755 * Process "B:<Index>:<Command>:..." -- Building definition
3759 static errr parse_line_building(char *buf)
3775 /* Get the building number */
3778 /* Find the colon after the building number */
3779 s = my_strchr(s, ':');
3781 /* Verify that colon */
3784 /* Nuke the colon, advance to the sub-index */
3787 /* Paranoia -- require a sub-index */
3788 if (!*s) return (1);
3790 /* Building definition sub-index */
3793 /* Building name, owner, race */
3796 if (tokenize(s + 2, 3, zz, 0) == 3)
3798 /* Name of the building */
3799 strcpy(building[index].name, zz[0]);
3801 /* Name of the owner */
3802 strcpy(building[index].owner_name, zz[1]);
3804 /* Race of the owner */
3805 strcpy(building[index].owner_race, zz[2]);
3810 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3813 /* Building Action */
3816 if (tokenize(s + 2, 8, zz, 0) >= 7)
3818 /* Index of the action */
3819 int action_index = atoi(zz[0]);
3821 /* Name of the action */
3822 strcpy(building[index].act_names[action_index], zz[1]);
3824 /* Cost of the action for members */
3825 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3827 /* Cost of the action for non-members */
3828 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3830 /* Letter assigned to the action */
3831 building[index].letters[action_index] = zz[4][0];
3834 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3836 /* Action restriction */
3837 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3842 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3845 /* Building Classes */
3848 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3850 for (i = 0; i < MAX_CLASS; i++)
3852 building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
3858 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3861 /* Building Races */
3864 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3866 for (i = 0; i < MAX_RACES; i++)
3868 building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
3874 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3877 /* Building Realms */
3880 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3882 for (i = 0; i < MAX_MAGIC; i++)
3884 building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
3890 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3895 /* Ignore scripts */
3901 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3910 * @brief フロアの所定のマスにオブジェクトを配置する
3911 * Place the object j_ptr to a grid
3912 * @param j_ptr オブジェクト構造体の参照ポインタ
3917 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3919 cave_type *c_ptr = &cave[y][x];
3922 /* Get new object */
3923 OBJECT_IDX o_idx = o_pop();
3925 /* Access new object */
3926 o_ptr = &o_list[o_idx];
3928 /* Structure copy */
3929 object_copy(o_ptr, j_ptr);
3937 o_ptr->held_m_idx = 0;
3940 o_ptr->next_o_idx = c_ptr->o_idx;
3942 /* Place the object */
3943 c_ptr->o_idx = o_idx;
3948 * @brief クエスト用固定ダンジョンをフロアに生成する
3949 * Parse a sub-file of the "extra info"
3959 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3964 /* Skip "empty" lines */
3965 if (!buf[0]) return (0);
3967 /* Skip "blank" lines */
3968 if (iswspace(buf[0])) return (0);
3971 if (buf[0] == '#') return (0);
3973 /* Require "?:*" format */
3974 if (buf[1] != ':') return (1);
3977 /* Process "%:<fname>" */
3980 /* Attempt to Process the given file */
3981 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3984 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3987 return parse_line_feature(buf);
3990 /* Process "D:<dungeon>" -- info for the cave grids */
3991 else if (buf[0] == 'D')
3993 object_type object_type_body;
3995 /* Acquire the text */
3998 /* Length of the text */
3999 int len = strlen(s);
4001 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
4003 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
4005 cave_type *c_ptr = &cave[*y][*x];
4009 IDX object_index = letter[idx].object;
4010 IDX monster_index = letter[idx].monster;
4011 int random = letter[idx].random;
4012 IDX artifact_index = letter[idx].artifact;
4014 /* Lay down a floor */
4015 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4017 /* Only the features */
4018 if (init_flags & INIT_ONLY_FEATURES) continue;
4021 c_ptr->info = letter[idx].cave_info;
4023 /* Create a monster */
4024 if (random & RANDOM_MONSTER)
4026 monster_level = base_level + monster_index;
4028 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4030 monster_level = base_level;
4032 else if (monster_index)
4034 int old_cur_num, old_max_num;
4037 if (monster_index < 0)
4039 monster_index = -monster_index;
4042 old_cur_num = r_info[monster_index].cur_num;
4043 old_max_num = r_info[monster_index].max_num;
4045 /* Make alive again */
4046 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4048 r_info[monster_index].cur_num = 0;
4049 r_info[monster_index].max_num = 1;
4052 /* Make alive again */
4053 /* Hack -- Non-unique Nazguls are semi-unique */
4054 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4056 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4058 r_info[monster_index].max_num++;
4063 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4067 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4069 /* Make alive again for real unique monster */
4070 r_info[monster_index].cur_num = old_cur_num;
4071 r_info[monster_index].max_num = old_max_num;
4075 /* Object (and possible trap) */
4076 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4078 object_level = base_level + object_index;
4081 * Random trap and random treasure defined
4082 * 25% chance for trap and 75% chance for object
4084 if (randint0(100) < 75)
4086 place_object(*y, *x, 0L);
4093 object_level = base_level;
4095 else if (random & RANDOM_OBJECT)
4097 object_level = base_level + object_index;
4099 /* Create an out of deep object */
4100 if (randint0(100) < 75)
4101 place_object(*y, *x, 0L);
4102 else if (randint0(100) < 80)
4103 place_object(*y, *x, AM_GOOD);
4105 place_object(*y, *x, AM_GOOD | AM_GREAT);
4107 object_level = base_level;
4110 else if (random & RANDOM_TRAP)
4114 /* Hidden trap (or door) */
4115 else if (letter[idx].trap)
4117 c_ptr->mimic = c_ptr->feat;
4118 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4120 else if (object_index)
4122 /* Get local object */
4123 object_type *o_ptr = &object_type_body;
4125 /* Create the item */
4126 object_prep(o_ptr, object_index);
4128 if (o_ptr->tval == TV_GOLD)
4130 coin_type = object_index - OBJ_GOLD_LIST;
4135 /* Apply magic (no messages, no artifacts) */
4136 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4138 drop_here(o_ptr, *y, *x);
4144 if (a_info[artifact_index].cur_num)
4146 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4148 object_type *q_ptr = &forge;
4150 object_prep(q_ptr, k_idx);
4152 /* Drop it in the dungeon */
4153 drop_here(q_ptr, *y, *x);
4157 /* Create the artifact */
4158 if (create_named_art(artifact_index, *y, *x))
4159 a_info[artifact_index].cur_num = 1;
4163 /* Terrain special */
4164 c_ptr->special = letter[idx].special;
4172 /* Process "Q:<number>:<command>:... -- quest info */
4173 else if (buf[0] == 'Q')
4180 num = tokenize(buf + 2, 33, zz, 0);
4184 num = tokenize(buf + 3, 33, zz, 0);
4187 /* Have we enough parameters? */
4188 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4191 q_ptr = &(quest[atoi(zz[0])]);
4193 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4194 if (zz[1][0] == 'Q')
4196 if (init_flags & INIT_ASSIGN)
4198 monster_race *r_ptr;
4199 artifact_type *a_ptr;
4201 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4203 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4204 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4205 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4206 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4207 q_ptr->level = (DEPTH)atoi(zz[6]);
4208 q_ptr->r_idx = (IDX)atoi(zz[7]);
4209 q_ptr->k_idx = (IDX)atoi(zz[8]);
4210 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4212 if (num > 10) q_ptr->flags = atoi(zz[10]);
4214 r_ptr = &r_info[q_ptr->r_idx];
4215 if (r_ptr->flags1 & RF1_UNIQUE)
4216 r_ptr->flags1 |= RF1_QUESTOR;
4218 a_ptr = &a_info[q_ptr->k_idx];
4219 a_ptr->gen_flags |= TRG_QUESTITEM;
4224 else if (zz[1][0] == 'R')
4226 if (init_flags & INIT_ASSIGN)
4229 IDX idx, reward_idx = 0;
4231 for (idx = 2; idx < num; idx++)
4233 IDX a_idx = (IDX)atoi(zz[idx]);
4234 if (a_idx < 1) continue;
4235 if (a_info[a_idx].cur_num > 0) continue;
4237 if (one_in_(count)) reward_idx = a_idx;
4242 /* Set quest's rewarding artifact */
4243 q_ptr->k_idx = reward_idx;
4244 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4248 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4249 q_ptr->type = QUEST_TYPE_KILL_ALL;
4256 /* Process "Q:<q_index>:N:<name>" -- quest name */
4257 else if (zz[1][0] == 'N')
4259 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4261 strcpy(q_ptr->name, zz[2]);
4267 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4268 else if (zz[1][0] == 'T')
4270 if (init_flags & INIT_SHOW_TEXT)
4272 strcpy(quest_text[quest_text_line], zz[2]);
4280 /* Process "W:<command>: ..." -- info for the wilderness */
4281 else if (buf[0] == 'W')
4283 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4286 /* Process "P:<y>:<x>" -- player position */
4287 else if (buf[0] == 'P')
4289 if (init_flags & INIT_CREATE_DUNGEON)
4291 if (tokenize(buf + 2, 2, zz, 0) == 2)
4293 int panels_x, panels_y;
4295 /* Hack - Set the dungeon size */
4296 panels_y = (*y / SCREEN_HGT);
4297 if (*y % SCREEN_HGT) panels_y++;
4298 cur_hgt = panels_y * SCREEN_HGT;
4300 panels_x = (*x / SCREEN_WID);
4301 if (*x % SCREEN_WID) panels_x++;
4302 cur_wid = panels_x * SCREEN_WID;
4304 /* Assume illegal panel */
4305 panel_row_min = cur_hgt;
4306 panel_col_min = cur_wid;
4308 /* Place player in a quest level */
4309 if (p_ptr->inside_quest)
4313 /* Delete the monster (if any) */
4314 delete_monster(p_ptr->y, p_ptr->x);
4322 /* Place player in the town */
4323 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4325 p_ptr->oldpy = atoi(zz[0]);
4326 p_ptr->oldpx = atoi(zz[1]);
4334 /* Process "B:<Index>:<Command>:..." -- Building definition */
4335 else if (buf[0] == 'B')
4337 return parse_line_building(buf);
4340 /* Process "M:<type>:<maximum>" -- set maximum values */
4341 else if (buf[0] == 'M')
4343 if (tokenize(buf+2, 2, zz, 0) == 2)
4346 if (zz[0][0] == 'T')
4348 max_towns = (IDX)atoi(zz[1]);
4351 /* Maximum quests */
4352 else if (zz[0][0] == 'Q')
4354 max_q_idx = (IDX)atoi(zz[1]);
4358 else if (zz[0][0] == 'R')
4360 max_r_idx = (IDX)atoi(zz[1]);
4364 else if (zz[0][0] == 'K')
4366 max_k_idx = (IDX)atoi(zz[1]);
4370 else if (zz[0][0] == 'V')
4372 max_v_idx = (IDX)atoi(zz[1]);
4376 else if (zz[0][0] == 'F')
4378 max_f_idx = (IDX)atoi(zz[1]);
4382 else if (zz[0][0] == 'A')
4384 max_a_idx = (IDX)atoi(zz[1]);
4388 else if (zz[0][0] == 'E')
4390 max_e_idx = (IDX)atoi(zz[1]);
4394 else if (zz[0][0] == 'D')
4396 max_d_idx = (IDX)atoi(zz[1]);
4400 else if (zz[0][0] == 'O')
4402 max_o_idx = (IDX)atoi(zz[1]);
4406 else if (zz[0][0] == 'M')
4408 max_m_idx = (IDX)atoi(zz[1]);
4411 /* Wilderness size */
4412 else if (zz[0][0] == 'W')
4414 /* Maximum wild_x_size */
4415 if (zz[0][1] == 'X')
4416 max_wild_x = atoi(zz[1]);
4417 /* Maximum wild_y_size */
4418 if (zz[0][1] == 'Y')
4419 max_wild_y = atoi(zz[1]);
4433 static cptr variant = "ZANGBAND";
4437 * @brief クエスト用固定ダンジョン生成時の分岐処理
4438 * Helper function for "process_dungeon_file()"
4443 static cptr process_dungeon_file_expr(char **sp, char *fp)
4459 while (iswspace(*s)) s++;
4477 t = process_dungeon_file_expr(&s, &f);
4485 else if (streq(t, "IOR"))
4488 while (*s && (f != b2))
4490 t = process_dungeon_file_expr(&s, &f);
4491 if (*t && !streq(t, "0")) v = "1";
4496 else if (streq(t, "AND"))
4499 while (*s && (f != b2))
4501 t = process_dungeon_file_expr(&s, &f);
4502 if (*t && streq(t, "0")) v = "0";
4507 else if (streq(t, "NOT"))
4510 while (*s && (f != b2))
4512 t = process_dungeon_file_expr(&s, &f);
4513 if (*t && streq(t, "1")) v = "0";
4518 else if (streq(t, "EQU"))
4521 if (*s && (f != b2))
4523 t = process_dungeon_file_expr(&s, &f);
4525 while (*s && (f != b2))
4527 p = process_dungeon_file_expr(&s, &f);
4528 if (streq(t, p)) v = "1";
4533 else if (streq(t, "LEQ"))
4536 if (*s && (f != b2))
4538 t = process_dungeon_file_expr(&s, &f);
4540 while (*s && (f != b2))
4543 t = process_dungeon_file_expr(&s, &f);
4544 if (*t && atoi(p) > atoi(t)) v = "0";
4549 else if (streq(t, "GEQ"))
4552 if (*s && (f != b2))
4554 t = process_dungeon_file_expr(&s, &f);
4556 while (*s && (f != b2))
4559 t = process_dungeon_file_expr(&s, &f);
4561 /* Compare two numbers instead of string */
4562 if (*t && atoi(p) < atoi(t)) v = "0";
4568 while (*s && (f != b2))
4570 t = process_dungeon_file_expr(&s, &f);
4575 if (f != b2) v = "?x?x?";
4577 /* Extract final and Terminate */
4578 if ((f = *s) != '\0') *s++ = '\0';
4584 /* Accept all printables except spaces and brackets */
4586 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4588 if (iskanji(*s)) s++;
4592 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4595 /* Extract final and Terminate */
4596 if ((f = *s) != '\0') *s++ = '\0';
4602 if (streq(b+1, "SYS"))
4608 else if (streq(b+1, "GRAF"))
4613 else if (streq(b+1, "MONOCHROME"))
4622 else if (streq(b+1, "RACE"))
4624 v = _(rp_ptr->E_title, rp_ptr->title);
4628 else if (streq(b+1, "CLASS"))
4630 v = _(cp_ptr->E_title, cp_ptr->title);
4634 else if (streq(b+1, "REALM1"))
4636 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4640 else if (streq(b+1, "REALM2"))
4642 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4646 else if (streq(b+1, "PLAYER"))
4648 static char tmp_player_name[32];
4650 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4660 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4663 v = tmp_player_name;
4667 else if (streq(b+1, "TOWN"))
4669 sprintf(tmp, "%d", p_ptr->town_num);
4674 else if (streq(b+1, "LEVEL"))
4676 sprintf(tmp, "%d", p_ptr->lev);
4680 /* Current quest number */
4681 else if (streq(b+1, "QUEST_NUMBER"))
4683 sprintf(tmp, "%d", p_ptr->inside_quest);
4687 /* Number of last quest */
4688 else if (streq(b+1, "LEAVING_QUEST"))
4690 sprintf(tmp, "%d", leaving_quest);
4695 else if (prefix(b+1, "QUEST_TYPE"))
4697 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4698 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4703 else if (prefix(b+1, "QUEST"))
4705 /* "QUEST" uses a special parameter to determine the number of the quest */
4706 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4711 else if (prefix(b+1, "RANDOM"))
4713 /* "RANDOM" uses a special parameter to determine the number of the quest */
4714 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4719 else if (streq(b+1, "VARIANT"))
4725 else if (streq(b+1, "WILDERNESS"))
4728 sprintf(tmp, "NONE");
4730 sprintf(tmp, "LITE");
4732 sprintf(tmp, "NORMAL");
4754 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4755 * Helper function for "process_dungeon_file()"
4763 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4769 bool bypass = FALSE;
4770 int x = xmin, y = ymin;
4773 /* Build the filename */
4774 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4777 fp = my_fopen(buf, "r");
4780 if (!fp) return (-1);
4783 /* Process the file */
4784 while (0 == my_fgets(fp, buf, sizeof(buf)))
4790 /* Skip "empty" lines */
4791 if (!buf[0]) continue;
4793 /* Skip "blank" lines */
4794 if (iswspace(buf[0])) continue;
4797 if (buf[0] == '#') continue;
4800 /* Process "?:<expr>" */
4801 if ((buf[0] == '?') && (buf[1] == ':'))
4810 /* Parse the expr */
4811 v = process_dungeon_file_expr(&s, &f);
4814 bypass = (streq(v, "0") ? TRUE : FALSE);
4818 /* Apply conditionals */
4819 if (bypass) continue;
4821 /* Process the line */
4822 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4833 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4835 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4836 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4842 /* Close the file */
4850 void write_r_info_txt(void)
4852 int i, j, z, fc, bc;
4855 cptr flags[32 * 10];
4860 monster_race *r_ptr;
4862 monster_blow *b_ptr;
4864 FILE *fff = fopen("output.txt", "wt");
4868 BIT_FLAGS mode = -1;
4872 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4874 fprintf(fff, "# Version stamp (required)\n\n");
4877 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4880 fprintf(fff, "##### The Player #####\n\n");
4882 for (z = -1; z < alloc_race_size; z++)
4884 /* Output the monsters in order */
4885 i = (z >= 0) ? alloc_race_table[z].index : 0;
4887 /* Acquire the monster */
4890 /* Ignore empty monsters */
4891 if (!strlen(r_name + r_ptr->name)) continue;
4893 /* Ignore useless monsters */
4894 if (i && !r_ptr->speed) continue;
4896 /* Write a note if necessary */
4897 if (i && (!r_ptr->level != !mode))
4902 fprintf(fff, "\n##### Town monsters #####\n\n");
4904 /* Note the dungeon */
4907 fprintf(fff, "\n##### Normal monsters #####\n\n");
4910 /* Record the change */
4911 mode = r_ptr->level;
4914 /* Acquire the flags */
4915 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4916 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4917 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4918 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4919 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4920 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4921 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4922 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4923 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4924 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4926 /* Write New/Number/Name */
4927 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4930 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4932 /* Write Information */
4933 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4934 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4936 /* Write more information */
4937 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4940 for(j = 0; j < 4; j++)
4942 b_ptr = &(r_ptr->blow[j]);
4944 /* Stop when done */
4945 if (!b_ptr->method) break;
4947 /* Write the blows */
4948 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4949 r_info_blow_effect[b_ptr->effect],
4950 b_ptr->d_dice, b_ptr->d_side);
4953 /* Extract the flags */
4954 for (fc = 0, j = 0; j < 32 * 3; j++)
4956 /* Check this flag */
4957 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4960 /* Extract the extra flags */
4961 for (j = 32 * 6; j < 32 * 10; j++)
4963 /* Check this flag */
4964 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4967 /* Write the flags */
4968 for (j = 0; j < fc;)
4972 /* Start the line */
4975 for (bc = 0; (bc < 60) && (j < fc); j++)
4979 /* Format the flag */
4980 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4982 /* Add it to the buffer */
4985 /* Note the length */
4989 /* Done with this line; write it */
4990 fprintf(fff, "%s\n", buf);
4993 /* Write Spells if applicable */
4994 if (r_ptr->freq_spell)
4996 /* Write the frequency */
4997 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4999 /* Extract the spell flags */
5000 for (fc = 0, j = 96; j < 192; j++)
5002 /* Check this flag */
5003 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5006 /* Write the flags */
5007 for (j = 0; j < fc;)
5011 /* Start the line */
5014 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5018 /* Format the flag */
5019 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5023 /* Note the length */
5030 /* Done with this line; write it */
5031 fprintf(fff, "%s\n", buf);
5035 /* Acquire the description */
5036 desc = r_text + r_ptr->text;
5037 dlen = strlen(desc);
5039 /* Write Description */
5040 for (j = 0; j < dlen;)
5044 /* Start the line */
5047 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5055 /* Done with this line; write it */
5056 fprintf(fff, "%s\n", buf);
5059 /* Space between entries */