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)
2606 static ego_item_type *e_ptr = NULL;
2608 /* Just before the first record */
2611 /* Just before the first line */
2614 /* Process 'N' for "New/Number/Name" */
2617 /* Find the colon before the name */
2618 s = my_strchr(buf+2, ':');
2620 /* Verify that colon */
2623 /* Nuke the colon, advance to the name */
2626 /* Paranoia -- require a name */
2627 if (!*s) return (1);
2632 /* Verify information */
2633 if (i < error_idx) return (4);
2635 /* Verify information */
2636 if (i >= head->info_num) return (2);
2638 /* Save the index */
2641 /* Point at the "info" */
2644 /* Store the name */
2645 if (!add_name(&e_ptr->name, head, s)) return (7);
2649 /* There better be a current e_ptr */
2650 else if (!e_ptr) return (3);
2655 /* 'E' から始まる行は英語名 */
2656 else if (buf[0] == 'E')
2661 else if (buf[0] == 'E')
2663 /* Acquire the Text */
2666 /* Store the name */
2667 if (!add_name(&e_ptr->name, head, s)) return (7);
2672 /* Process 'D' for "Description" */
2673 else if (buf[0] == 'D')
2675 /* Acquire the text */
2678 /* Store the text */
2679 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2684 /* Process 'X' for "Xtra" (one line only) */
2685 else if (buf[0] == 'X')
2689 /* Scan for the values */
2690 if (2 != sscanf(buf+2, "%d:%d",
2691 &slot, &rating)) return (1);
2693 /* Save the values */
2694 e_ptr->slot = (INVENTORY_IDX)slot;
2695 e_ptr->rating = (PRICE)rating;
2698 /* Process 'W' for "More Info" (one line only) */
2699 else if (buf[0] == 'W')
2701 int level, rarity, pad2;
2704 /* Scan for the values */
2705 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2706 &level, &rarity, &pad2, &cost)) return (1);
2708 /* Save the values */
2709 e_ptr->level = level;
2710 e_ptr->rarity = (RARITY)rarity;
2711 /* e_ptr->weight = wgt; */
2715 /* Hack -- Process 'C' for "creation" */
2716 else if (buf[0] == 'C')
2718 int th, td, ta, pval;
2720 /* Scan for the values */
2721 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2722 &th, &td, &ta, &pval)) return (1);
2724 e_ptr->max_to_h = (HIT_PROB)th;
2725 e_ptr->max_to_d = (HIT_POINT)td;
2726 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2727 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2730 /* Hack -- Process 'U' for activation index */
2731 else if (buf[0] == 'U')
2734 n = grab_one_activation_flag(buf + 2);
2745 /* Hack -- Process 'F' for flags */
2746 else if (buf[0] == 'F')
2748 /* Parse every entry textually */
2749 for (s = buf + 2; *s; )
2751 /* Find the end of this entry */
2752 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2754 /* Nuke and skip any dividers */
2758 while ((*t == ' ') || (*t == '|')) t++;
2761 /* Parse this entry */
2762 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2764 /* Start the next entry */
2777 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2778 * Grab one (basic) flag in a monster_race from a textual string
2779 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2780 * @param what 参照元の文字列ポインタ
2783 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2785 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2788 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2791 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2794 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2797 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2800 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2803 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2806 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2814 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2815 * Grab one (spell) flag in a monster_race from a textual string
2816 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2817 * @param what 参照元の文字列ポインタ
2820 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2822 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2825 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2828 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2831 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2839 * @brief モンスター種族情報(r_info)のパース関数 /
2840 * Initialize the "r_info" array, by parsing an ascii "template" file
2842 * @param head ヘッダ構造体
2845 errr parse_r_info(char *buf, header *head)
2851 static monster_race *r_ptr = NULL;
2854 /* Process 'N' for "New/Number/Name" */
2857 /* Find the colon before the name */
2858 s = my_strchr(buf+2, ':');
2860 /* Verify that colon */
2863 /* Nuke the colon, advance to the name */
2866 /* Paranoia -- require a name */
2867 if (!*s) return (1);
2872 /* Verify information */
2873 if (i < error_idx) return (4);
2875 /* Verify information */
2876 if (i >= head->info_num) return (2);
2878 /* Save the index */
2881 /* Point at the "info" */
2884 /* Store the name */
2885 if (!add_name(&r_ptr->name, head, s)) return (7);
2889 /* There better be a current r_ptr */
2890 else if (!r_ptr) return (3);
2895 /* 'E' から始まる行は英語名 */
2896 else if (buf[0] == 'E')
2898 /* Acquire the Text */
2901 /* Store the name */
2902 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2905 else if (buf[0] == 'E')
2907 /* Acquire the Text */
2910 /* Store the name */
2911 if (!add_name(&r_ptr->name, head, s)) return (7);
2914 /* Process 'D' for "Description" */
2915 else if (buf[0] == 'D')
2920 /* Acquire the text */
2925 /* Acquire the text */
2929 /* Store the text */
2930 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2933 /* Process 'G' for "Graphics" (one line only) */
2934 else if (buf[0] == 'G')
2940 if (buf[1] != ':') return (1);
2941 if (!buf[2]) return (1);
2942 if (buf[3] != ':') return (1);
2943 if (!buf[4]) return (1);
2945 /* Extract the char */
2948 /* Extract the attr */
2949 tmp = color_char_to_attr(buf[4]);
2952 if (tmp > 127) return (1);
2954 /* Save the values */
2955 r_ptr->d_char = sym;
2956 r_ptr->d_attr = tmp;
2959 /* Process 'I' for "Info" (one line only) */
2960 else if (buf[0] == 'I')
2962 int spd, hp1, hp2, aaf, ac, slp;
2964 /* Scan for the other values */
2965 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2966 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2968 /* Save the values */
2969 r_ptr->speed = (SPEED)spd;
2970 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2971 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2972 r_ptr->aaf = (POSITION)aaf;
2973 r_ptr->ac = (ARMOUR_CLASS)ac;
2974 r_ptr->sleep = (SLEEP_DEGREE)slp;
2977 /* Process 'W' for "More Info" (one line only) */
2978 else if (buf[0] == 'W')
2985 /* Scan for the values */
2986 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2987 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2989 /* Save the values */
2990 r_ptr->level = (DEPTH)lev;
2991 r_ptr->rarity = (RARITY)rar;
2992 r_ptr->extra = (BIT_FLAGS16)pad;
2993 r_ptr->mexp = (EXP)exp;
2994 r_ptr->next_exp = (EXP)nextexp;
2995 r_ptr->next_r_idx = (IDX)nextmon;
2998 /* Process 'R' for "Reinforcement" (up to six lines) */
2999 else if (buf[0] == 'R')
3002 /* Find the next empty blow slot (if any) */
3003 for (i = 0; i < A_MAX; i++) if (r_ptr->reinforce_id[i] == 0) break;
3005 /* Oops, no more slots */
3006 if (i == 6) return (1);
3008 /* Scan for the values */
3009 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3010 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3011 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3012 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3015 /* Process 'B' for "Blows" (up to four lines) */
3016 else if (buf[0] == 'B')
3020 /* Find the next empty blow slot (if any) */
3021 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3023 /* Oops, no more slots */
3024 if (i == 4) return (1);
3026 /* Analyze the first field */
3027 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3029 /* Terminate the field (if necessary) */
3030 if (*t == ':') *t++ = '\0';
3032 /* Analyze the method */
3033 for (n1 = 0; r_info_blow_method[n1]; n1++)
3035 if (streq(s, r_info_blow_method[n1])) break;
3038 /* Invalid method */
3039 if (!r_info_blow_method[n1]) return (1);
3041 /* Analyze the second field */
3042 for (s = t; *t && (*t != ':'); t++) /* loop */;
3044 /* Terminate the field (if necessary) */
3045 if (*t == ':') *t++ = '\0';
3047 /* Analyze effect */
3048 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3050 if (streq(s, r_info_blow_effect[n2])) break;
3053 /* Invalid effect */
3054 if (!r_info_blow_effect[n2]) return (1);
3056 /* Analyze the third field */
3057 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3059 /* Terminate the field (if necessary) */
3060 if (*t == 'd') *t++ = '\0';
3062 /* Save the method */
3063 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3065 /* Save the effect */
3066 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3068 /* Extract the damage dice and sides */
3069 r_ptr->blow[i].d_dice = atoi(s);
3070 r_ptr->blow[i].d_side = atoi(t);
3073 /* Process 'F' for "Basic Flags" (multiple lines) */
3074 else if (buf[0] == 'F')
3076 /* Parse every entry */
3077 for (s = buf + 2; *s; )
3079 /* Find the end of this entry */
3080 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3082 /* Nuke and skip any dividers */
3086 while (*t == ' ' || *t == '|') t++;
3089 /* Parse this entry */
3090 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3092 /* Start the next entry */
3097 /* Process 'S' for "Spell Flags" (multiple lines) */
3098 else if (buf[0] == 'S')
3100 /* Parse every entry */
3101 for (s = buf + 2; *s; )
3103 /* Find the end of this entry */
3104 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3106 /* Nuke and skip any dividers */
3110 while ((*t == ' ') || (*t == '|')) t++;
3113 /* Hack -- Read spell frequency */
3114 if (1 == sscanf(s, "1_IN_%d", &i))
3116 /* Extract a "frequency" */
3117 r_ptr->freq_spell = 100 / i;
3119 /* Start at next entry */
3124 /* Parse this entry */
3125 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3127 /* Start the next entry */
3132 /* Process 'A' for "Artifact Flags" (multiple lines) */
3133 else if (buf[0] == 'A')
3135 int id, per, rarity;
3137 /* Find the next empty blow slot (if any) */
3138 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3140 /* Oops, no more slots */
3141 if (i == 4) return (1);
3143 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3144 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3145 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3146 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3149 /* Process 'V' for "Arena power value ratio" */
3150 else if (buf[0] == 'V')
3153 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3154 r_ptr->arena_ratio = (PERCENTAGE)val;
3166 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3167 * Grab one flag for a dungeon type from a textual string
3168 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3169 * @param what 参照元の文字列ポインタ
3172 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
3174 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3177 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3184 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3185 * Grab one (basic) flag in a monster_race from a textual string
3186 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3187 * @param what 参照元の文字列ポインタ
3190 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
3192 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3195 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3198 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3201 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3204 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3207 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3210 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3213 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3220 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3221 * Grab one (spell) flag in a monster_race from a textual string
3222 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3223 * @param what 参照元の文字列ポインタ
3226 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
3228 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3231 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3234 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3237 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3244 * @brief ダンジョン情報(d_info)のパース関数 /
3245 * Initialize the "d_info" array, by parsing an ascii "template" file
3247 * @param head ヘッダ構造体
3250 errr parse_d_info(char *buf, header *head)
3256 static dungeon_info_type *d_ptr = NULL;
3258 /* Process 'N' for "New/Number/Name" */
3261 /* Find the colon before the name */
3262 s = my_strchr(buf+2, ':');
3264 /* Verify that colon */
3267 /* Nuke the colon, advance to the name */
3270 /* Paranoia -- require a name */
3271 if (!*s) return (1);
3276 /* Verify information */
3277 if (i < error_idx) return (4);
3279 /* Verify information */
3280 if (i >= head->info_num) return (2);
3282 /* Save the index */
3285 /* Point at the "info" */
3288 /* Store the name */
3289 if (!add_name(&d_ptr->name, head, s)) return (7);
3294 else if (buf[0] == 'E') return (0);
3296 else if (buf[0] == 'E')
3298 /* Acquire the Text */
3301 /* Store the name */
3302 if (!add_name(&d_ptr->name, head, s)) return (7);
3306 /* Process 'D' for "Description */
3307 else if (buf[0] == 'D')
3312 /* Acquire the text */
3317 /* Acquire the text */
3321 /* Store the text */
3322 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3325 /* Process 'W' for "More Info" (one line only) */
3326 else if (buf[0] == 'W')
3328 int min_lev, max_lev;
3330 int min_alloc, max_chance;
3331 int obj_good, obj_great;
3334 /* Scan for the values */
3335 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3336 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3338 /* Save the values */
3339 d_ptr->mindepth = (DEPTH)min_lev;
3340 d_ptr->maxdepth = (DEPTH)max_lev;
3341 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3342 d_ptr->mode = (BIT_FLAGS8)mode;
3343 d_ptr->min_m_alloc_level = min_alloc;
3344 d_ptr->max_m_alloc_chance = max_chance;
3345 d_ptr->obj_good = obj_good;
3346 d_ptr->obj_great = obj_great;
3347 d_ptr->pit = (BIT_FLAGS16)pit;
3348 d_ptr->nest = (BIT_FLAGS16)nest;
3351 /* Process 'P' for "Place Info" */
3352 else if (buf[0] == 'P')
3356 /* Scan for the values */
3357 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3359 /* Save the values */
3364 /* Process 'L' for "fLoor type" (one line only) */
3365 else if (buf[0] == 'L')
3369 /* Scan for the values */
3370 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3372 /* Save the values */
3373 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3375 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3376 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3378 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3380 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3383 /* Process 'A' for "wAll type" (one line only) */
3384 else if (buf[0] == 'A')
3388 /* Scan for the values */
3389 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3391 /* Save the values */
3392 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3394 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3395 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3397 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3400 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3401 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3403 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3404 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3406 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3407 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3409 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3410 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3413 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3414 else if (buf[0] == 'F')
3416 int artif = 0, monst = 0;
3418 /* Parse every entry */
3419 for (s = buf + 2; *s; )
3421 /* Find the end of this entry */
3422 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3424 /* Nuke and skip any dividers */
3428 while (*t == ' ' || *t == '|') t++;
3431 /* Hack -- Read Final Artifact */
3432 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3434 /* Extract a "Final Artifact" */
3435 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3437 /* Start at next entry */
3442 /* Hack -- Read Final Object */
3443 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3445 /* Extract a "Final Artifact" */
3446 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3448 /* Start at next entry */
3453 /* Hack -- Read Artifact Guardian */
3454 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3456 /* Extract a "Artifact Guardian" */
3457 d_ptr->final_guardian = (MONRACE_IDX)monst;
3459 /* Start at next entry */
3464 /* Hack -- Read Special Percentage */
3465 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3467 /* Extract a "Special %" */
3468 d_ptr->special_div = (PROB)monst;
3470 /* Start at next entry */
3475 /* Parse this entry */
3476 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3478 /* Start the next entry */
3483 /* Process 'M' for "Basic Flags" (multiple lines) */
3484 else if (buf[0] == 'M')
3486 /* Parse every entry */
3487 for (s = buf + 2; *s; )
3489 /* Find the end of this entry */
3490 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3492 /* Nuke and skip any dividers */
3496 while (*t == ' ' || *t == '|') t++;
3499 /* Hack -- Read monster symbols */
3500 if (!strncmp(s, "R_CHAR_", 7))
3502 /* Skip "R_CHAR_" */
3506 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3508 /* Start at next entry */
3513 /* Parse this entry */
3514 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3516 /* Start the next entry */
3521 /* Process 'S' for "Spell Flags" (multiple lines) */
3522 else if (buf[0] == 'S')
3524 /* Parse every entry */
3525 for (s = buf + 2; *s; )
3527 /* Find the end of this entry */
3528 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3530 /* Nuke and skip any dividers */
3534 while ((*t == ' ') || (*t == '|')) t++;
3537 /* Hack -- Read spell frequency */
3538 if (1 == sscanf(s, "1_IN_%d", &i))
3540 /* Start at next entry */
3545 /* Parse this entry */
3546 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3548 /* Start the next entry */
3560 #else /* ALLOW_TEMPLATES */
3566 #endif /* ALLOW_TEMPLATES */
3569 /* Random dungeon grid effects */
3570 #define RANDOM_NONE 0x00000000
3571 #define RANDOM_FEATURE 0x00000001
3572 #define RANDOM_MONSTER 0x00000002
3573 #define RANDOM_OBJECT 0x00000004
3574 #define RANDOM_EGO 0x00000008
3575 #define RANDOM_ARTIFACT 0x00000010
3576 #define RANDOM_TRAP 0x00000020
3579 typedef struct dungeon_grid dungeon_grid;
3583 FEAT_IDX feature; /* Terrain feature */
3584 MONSTER_IDX monster; /* Monster */
3585 OBJECT_IDX object; /* Object */
3586 EGO_IDX ego; /* Ego-Item */
3587 ARTIFACT_IDX artifact; /* Artifact */
3588 IDX trap; /* Trap */
3589 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3590 s16b special; /* Reserved for special terrain info */
3591 int random; /* Number of the random effect */
3595 static dungeon_grid letter[255];
3599 * @brief 地形情報の「F:」情報をパースする
3600 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3604 static errr parse_line_feature(char *buf)
3609 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3611 /* Tokenize the line */
3612 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3614 /* Letter to assign */
3615 int index = zz[0][0];
3617 /* Reset the info for the letter */
3618 letter[index].feature = feat_none;
3619 letter[index].monster = 0;
3620 letter[index].object = 0;
3621 letter[index].ego = 0;
3622 letter[index].artifact = 0;
3623 letter[index].trap = feat_none;
3624 letter[index].cave_info = 0;
3625 letter[index].special = 0;
3626 letter[index].random = RANDOM_NONE;
3632 letter[index].special = (s16b)atoi(zz[8]);
3636 if ((zz[7][0] == '*') && !zz[7][1])
3638 letter[index].random |= RANDOM_TRAP;
3642 letter[index].trap = f_tag_to_index(zz[7]);
3643 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3648 if (zz[6][0] == '*')
3650 letter[index].random |= RANDOM_ARTIFACT;
3651 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3653 else if (zz[6][0] == '!')
3655 if (p_ptr->inside_quest)
3657 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3662 letter[index].artifact = (IDX)atoi(zz[6]);
3667 if (zz[5][0] == '*')
3669 letter[index].random |= RANDOM_EGO;
3670 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3674 letter[index].ego = (IDX)atoi(zz[5]);
3679 if (zz[4][0] == '*')
3681 letter[index].random |= RANDOM_OBJECT;
3682 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3684 else if (zz[4][0] == '!')
3686 if (p_ptr->inside_quest)
3688 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3691 artifact_type *a_ptr = &a_info[a_idx];
3692 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3694 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3701 letter[index].object = (IDX)atoi(zz[4]);
3706 if (zz[3][0] == '*')
3708 letter[index].random |= RANDOM_MONSTER;
3709 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3711 else if (zz[3][0] == 'c')
3713 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3714 letter[index].monster = - atoi(zz[3] + 1);
3718 letter[index].monster = (IDX)atoi(zz[3]);
3723 letter[index].cave_info = atoi(zz[2]);
3727 if ((zz[1][0] == '*') && !zz[1][1])
3729 letter[index].random |= RANDOM_FEATURE;
3733 letter[index].feature = f_tag_to_index(zz[1]);
3734 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3747 * @brief 地形情報の「B:」情報をパースする
3748 * Process "B:<Index>:<Command>:..." -- Building definition
3752 static errr parse_line_building(char *buf)
3768 /* Get the building number */
3771 /* Find the colon after the building number */
3772 s = my_strchr(s, ':');
3774 /* Verify that colon */
3777 /* Nuke the colon, advance to the sub-index */
3780 /* Paranoia -- require a sub-index */
3781 if (!*s) return (1);
3783 /* Building definition sub-index */
3786 /* Building name, owner, race */
3789 if (tokenize(s + 2, 3, zz, 0) == 3)
3791 /* Name of the building */
3792 strcpy(building[index].name, zz[0]);
3794 /* Name of the owner */
3795 strcpy(building[index].owner_name, zz[1]);
3797 /* Race of the owner */
3798 strcpy(building[index].owner_race, zz[2]);
3803 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3806 /* Building Action */
3809 if (tokenize(s + 2, 8, zz, 0) >= 7)
3811 /* Index of the action */
3812 int action_index = atoi(zz[0]);
3814 /* Name of the action */
3815 strcpy(building[index].act_names[action_index], zz[1]);
3817 /* Cost of the action for members */
3818 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3820 /* Cost of the action for non-members */
3821 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3823 /* Letter assigned to the action */
3824 building[index].letters[action_index] = zz[4][0];
3827 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3829 /* Action restriction */
3830 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3835 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3838 /* Building Classes */
3841 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3843 for (i = 0; i < MAX_CLASS; i++)
3845 building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
3851 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3854 /* Building Races */
3857 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3859 for (i = 0; i < MAX_RACES; i++)
3861 building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
3867 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3870 /* Building Realms */
3873 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3875 for (i = 0; i < MAX_MAGIC; i++)
3877 building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
3883 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3888 /* Ignore scripts */
3894 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3903 * @brief フロアの所定のマスにオブジェクトを配置する
3904 * Place the object j_ptr to a grid
3905 * @param j_ptr オブジェクト構造体の参照ポインタ
3910 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3912 cave_type *c_ptr = &cave[y][x];
3915 /* Get new object */
3916 OBJECT_IDX o_idx = o_pop();
3918 /* Access new object */
3919 o_ptr = &o_list[o_idx];
3921 /* Structure copy */
3922 object_copy(o_ptr, j_ptr);
3929 o_ptr->held_m_idx = 0;
3932 o_ptr->next_o_idx = c_ptr->o_idx;
3934 /* Place the object */
3935 c_ptr->o_idx = o_idx;
3940 * @brief クエスト用固定ダンジョンをフロアに生成する
3941 * Parse a sub-file of the "extra info"
3951 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3956 /* Skip "empty" lines */
3957 if (!buf[0]) return (0);
3959 /* Skip "blank" lines */
3960 if (iswspace(buf[0])) return (0);
3963 if (buf[0] == '#') return (0);
3965 /* Require "?:*" format */
3966 if (buf[1] != ':') return (1);
3969 /* Process "%:<fname>" */
3972 /* Attempt to Process the given file */
3973 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3976 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3979 return parse_line_feature(buf);
3982 /* Process "D:<dungeon>" -- info for the cave grids */
3983 else if (buf[0] == 'D')
3985 object_type object_type_body;
3987 /* Acquire the text */
3990 /* Length of the text */
3991 int len = strlen(s);
3993 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3995 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3997 cave_type *c_ptr = &cave[*y][*x];
4001 OBJECT_IDX object_index = letter[idx].object;
4002 MONSTER_IDX monster_index = letter[idx].monster;
4003 int random = letter[idx].random;
4004 ARTIFACT_IDX artifact_index = letter[idx].artifact;
4006 /* Lay down a floor */
4007 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4009 /* Only the features */
4010 if (init_flags & INIT_ONLY_FEATURES) continue;
4013 c_ptr->info = letter[idx].cave_info;
4015 /* Create a monster */
4016 if (random & RANDOM_MONSTER)
4018 monster_level = base_level + monster_index;
4020 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4022 monster_level = base_level;
4024 else if (monster_index)
4026 int old_cur_num, old_max_num;
4029 if (monster_index < 0)
4031 monster_index = -monster_index;
4034 old_cur_num = r_info[monster_index].cur_num;
4035 old_max_num = r_info[monster_index].max_num;
4037 /* Make alive again */
4038 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4040 r_info[monster_index].cur_num = 0;
4041 r_info[monster_index].max_num = 1;
4044 /* Make alive again */
4045 /* Hack -- Non-unique Nazguls are semi-unique */
4046 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4048 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4050 r_info[monster_index].max_num++;
4055 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4059 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4061 /* Make alive again for real unique monster */
4062 r_info[monster_index].cur_num = old_cur_num;
4063 r_info[monster_index].max_num = old_max_num;
4067 /* Object (and possible trap) */
4068 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4070 object_level = base_level + object_index;
4073 * Random trap and random treasure defined
4074 * 25% chance for trap and 75% chance for object
4076 if (randint0(100) < 75)
4078 place_object(*y, *x, 0L);
4085 object_level = base_level;
4087 else if (random & RANDOM_OBJECT)
4089 object_level = base_level + object_index;
4091 /* Create an out of deep object */
4092 if (randint0(100) < 75)
4093 place_object(*y, *x, 0L);
4094 else if (randint0(100) < 80)
4095 place_object(*y, *x, AM_GOOD);
4097 place_object(*y, *x, AM_GOOD | AM_GREAT);
4099 object_level = base_level;
4102 else if (random & RANDOM_TRAP)
4106 /* Hidden trap (or door) */
4107 else if (letter[idx].trap)
4109 c_ptr->mimic = c_ptr->feat;
4110 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4112 else if (object_index)
4114 object_type *o_ptr = &object_type_body;
4115 object_prep(o_ptr, object_index);
4117 if (o_ptr->tval == TV_GOLD)
4119 coin_type = object_index - OBJ_GOLD_LIST;
4124 /* Apply magic (no messages, no artifacts) */
4125 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4127 drop_here(o_ptr, *y, *x);
4133 if (a_info[artifact_index].cur_num)
4135 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4137 object_type *q_ptr = &forge;
4139 object_prep(q_ptr, k_idx);
4140 drop_here(q_ptr, *y, *x);
4144 /* Create the artifact */
4145 if (create_named_art(artifact_index, *y, *x))
4146 a_info[artifact_index].cur_num = 1;
4150 /* Terrain special */
4151 c_ptr->special = letter[idx].special;
4159 /* Process "Q:<number>:<command>:... -- quest info */
4160 else if (buf[0] == 'Q')
4167 num = tokenize(buf + 2, 33, zz, 0);
4171 num = tokenize(buf + 3, 33, zz, 0);
4174 /* Have we enough parameters? */
4175 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4178 q_ptr = &(quest[atoi(zz[0])]);
4180 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4181 if (zz[1][0] == 'Q')
4183 if (init_flags & INIT_ASSIGN)
4185 monster_race *r_ptr;
4186 artifact_type *a_ptr;
4188 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4190 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4191 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4192 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4193 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4194 q_ptr->level = (DEPTH)atoi(zz[6]);
4195 q_ptr->r_idx = (IDX)atoi(zz[7]);
4196 q_ptr->k_idx = (IDX)atoi(zz[8]);
4197 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4199 if (num > 10) q_ptr->flags = atoi(zz[10]);
4201 r_ptr = &r_info[q_ptr->r_idx];
4202 if (r_ptr->flags1 & RF1_UNIQUE)
4203 r_ptr->flags1 |= RF1_QUESTOR;
4205 a_ptr = &a_info[q_ptr->k_idx];
4206 a_ptr->gen_flags |= TRG_QUESTITEM;
4211 else if (zz[1][0] == 'R')
4213 if (init_flags & INIT_ASSIGN)
4216 IDX idx, reward_idx = 0;
4218 for (idx = 2; idx < num; idx++)
4220 IDX a_idx = (IDX)atoi(zz[idx]);
4221 if (a_idx < 1) continue;
4222 if (a_info[a_idx].cur_num > 0) continue;
4224 if (one_in_(count)) reward_idx = a_idx;
4229 /* Set quest's rewarding artifact */
4230 q_ptr->k_idx = reward_idx;
4231 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4235 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4236 q_ptr->type = QUEST_TYPE_KILL_ALL;
4243 /* Process "Q:<q_index>:N:<name>" -- quest name */
4244 else if (zz[1][0] == 'N')
4246 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4248 strcpy(q_ptr->name, zz[2]);
4254 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4255 else if (zz[1][0] == 'T')
4257 if (init_flags & INIT_SHOW_TEXT)
4259 strcpy(quest_text[quest_text_line], zz[2]);
4267 /* Process "W:<command>: ..." -- info for the wilderness */
4268 else if (buf[0] == 'W')
4270 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4273 /* Process "P:<y>:<x>" -- player position */
4274 else if (buf[0] == 'P')
4276 if (init_flags & INIT_CREATE_DUNGEON)
4278 if (tokenize(buf + 2, 2, zz, 0) == 2)
4280 int panels_x, panels_y;
4282 /* Hack - Set the dungeon size */
4283 panels_y = (*y / SCREEN_HGT);
4284 if (*y % SCREEN_HGT) panels_y++;
4285 cur_hgt = panels_y * SCREEN_HGT;
4287 panels_x = (*x / SCREEN_WID);
4288 if (*x % SCREEN_WID) panels_x++;
4289 cur_wid = panels_x * SCREEN_WID;
4291 /* Assume illegal panel */
4292 panel_row_min = cur_hgt;
4293 panel_col_min = cur_wid;
4295 /* Place player in a quest level */
4296 if (p_ptr->inside_quest)
4300 /* Delete the monster (if any) */
4301 delete_monster(p_ptr->y, p_ptr->x);
4309 /* Place player in the town */
4310 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4312 p_ptr->oldpy = atoi(zz[0]);
4313 p_ptr->oldpx = atoi(zz[1]);
4321 /* Process "B:<Index>:<Command>:..." -- Building definition */
4322 else if (buf[0] == 'B')
4324 return parse_line_building(buf);
4327 /* Process "M:<type>:<maximum>" -- set maximum values */
4328 else if (buf[0] == 'M')
4330 if (tokenize(buf+2, 2, zz, 0) == 2)
4333 if (zz[0][0] == 'T')
4335 max_towns = (IDX)atoi(zz[1]);
4338 /* Maximum quests */
4339 else if (zz[0][0] == 'Q')
4341 max_q_idx = (IDX)atoi(zz[1]);
4345 else if (zz[0][0] == 'R')
4347 max_r_idx = (IDX)atoi(zz[1]);
4351 else if (zz[0][0] == 'K')
4353 max_k_idx = (IDX)atoi(zz[1]);
4357 else if (zz[0][0] == 'V')
4359 max_v_idx = (IDX)atoi(zz[1]);
4363 else if (zz[0][0] == 'F')
4365 max_f_idx = (IDX)atoi(zz[1]);
4369 else if (zz[0][0] == 'A')
4371 max_a_idx = (IDX)atoi(zz[1]);
4375 else if (zz[0][0] == 'E')
4377 max_e_idx = (IDX)atoi(zz[1]);
4381 else if (zz[0][0] == 'D')
4383 max_d_idx = (IDX)atoi(zz[1]);
4387 else if (zz[0][0] == 'O')
4389 max_o_idx = (IDX)atoi(zz[1]);
4393 else if (zz[0][0] == 'M')
4395 max_m_idx = (IDX)atoi(zz[1]);
4398 /* Wilderness size */
4399 else if (zz[0][0] == 'W')
4401 /* Maximum wild_x_size */
4402 if (zz[0][1] == 'X')
4403 max_wild_x = atoi(zz[1]);
4404 /* Maximum wild_y_size */
4405 if (zz[0][1] == 'Y')
4406 max_wild_y = atoi(zz[1]);
4420 static cptr variant = "ZANGBAND";
4424 * @brief クエスト用固定ダンジョン生成時の分岐処理
4425 * Helper function for "process_dungeon_file()"
4430 static cptr process_dungeon_file_expr(char **sp, char *fp)
4446 while (iswspace(*s)) s++;
4464 t = process_dungeon_file_expr(&s, &f);
4472 else if (streq(t, "IOR"))
4475 while (*s && (f != b2))
4477 t = process_dungeon_file_expr(&s, &f);
4478 if (*t && !streq(t, "0")) v = "1";
4483 else if (streq(t, "AND"))
4486 while (*s && (f != b2))
4488 t = process_dungeon_file_expr(&s, &f);
4489 if (*t && streq(t, "0")) v = "0";
4494 else if (streq(t, "NOT"))
4497 while (*s && (f != b2))
4499 t = process_dungeon_file_expr(&s, &f);
4500 if (*t && streq(t, "1")) v = "0";
4505 else if (streq(t, "EQU"))
4508 if (*s && (f != b2))
4510 t = process_dungeon_file_expr(&s, &f);
4512 while (*s && (f != b2))
4514 p = process_dungeon_file_expr(&s, &f);
4515 if (streq(t, p)) v = "1";
4520 else if (streq(t, "LEQ"))
4523 if (*s && (f != b2))
4525 t = process_dungeon_file_expr(&s, &f);
4527 while (*s && (f != b2))
4530 t = process_dungeon_file_expr(&s, &f);
4531 if (*t && atoi(p) > atoi(t)) v = "0";
4536 else if (streq(t, "GEQ"))
4539 if (*s && (f != b2))
4541 t = process_dungeon_file_expr(&s, &f);
4543 while (*s && (f != b2))
4546 t = process_dungeon_file_expr(&s, &f);
4548 /* Compare two numbers instead of string */
4549 if (*t && atoi(p) < atoi(t)) v = "0";
4555 while (*s && (f != b2))
4557 t = process_dungeon_file_expr(&s, &f);
4562 if (f != b2) v = "?x?x?";
4564 /* Extract final and Terminate */
4565 if ((f = *s) != '\0') *s++ = '\0';
4571 /* Accept all printables except spaces and brackets */
4573 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4575 if (iskanji(*s)) s++;
4579 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4582 /* Extract final and Terminate */
4583 if ((f = *s) != '\0') *s++ = '\0';
4589 if (streq(b+1, "SYS"))
4595 else if (streq(b+1, "GRAF"))
4600 else if (streq(b+1, "MONOCHROME"))
4609 else if (streq(b+1, "RACE"))
4611 v = _(rp_ptr->E_title, rp_ptr->title);
4615 else if (streq(b+1, "CLASS"))
4617 v = _(cp_ptr->E_title, cp_ptr->title);
4621 else if (streq(b+1, "REALM1"))
4623 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4627 else if (streq(b+1, "REALM2"))
4629 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4633 else if (streq(b+1, "PLAYER"))
4635 static char tmp_player_name[32];
4637 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4647 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4650 v = tmp_player_name;
4654 else if (streq(b+1, "TOWN"))
4656 sprintf(tmp, "%d", p_ptr->town_num);
4661 else if (streq(b+1, "LEVEL"))
4663 sprintf(tmp, "%d", p_ptr->lev);
4667 /* Current quest number */
4668 else if (streq(b+1, "QUEST_NUMBER"))
4670 sprintf(tmp, "%d", p_ptr->inside_quest);
4674 /* Number of last quest */
4675 else if (streq(b+1, "LEAVING_QUEST"))
4677 sprintf(tmp, "%d", leaving_quest);
4682 else if (prefix(b+1, "QUEST_TYPE"))
4684 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4685 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4690 else if (prefix(b+1, "QUEST"))
4692 /* "QUEST" uses a special parameter to determine the number of the quest */
4693 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4698 else if (prefix(b+1, "RANDOM"))
4700 /* "RANDOM" uses a special parameter to determine the number of the quest */
4701 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4706 else if (streq(b+1, "VARIANT"))
4712 else if (streq(b+1, "WILDERNESS"))
4715 sprintf(tmp, "NONE");
4717 sprintf(tmp, "LITE");
4719 sprintf(tmp, "NORMAL");
4741 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4742 * Helper function for "process_dungeon_file()"
4750 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4756 bool bypass = FALSE;
4757 int x = xmin, y = ymin;
4760 /* Build the filename */
4761 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4764 fp = my_fopen(buf, "r");
4767 if (!fp) return (-1);
4770 /* Process the file */
4771 while (0 == my_fgets(fp, buf, sizeof(buf)))
4777 /* Skip "empty" lines */
4778 if (!buf[0]) continue;
4780 /* Skip "blank" lines */
4781 if (iswspace(buf[0])) continue;
4784 if (buf[0] == '#') continue;
4787 /* Process "?:<expr>" */
4788 if ((buf[0] == '?') && (buf[1] == ':'))
4797 /* Parse the expr */
4798 v = process_dungeon_file_expr(&s, &f);
4801 bypass = (streq(v, "0") ? TRUE : FALSE);
4805 /* Apply conditionals */
4806 if (bypass) continue;
4808 /* Process the line */
4809 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4820 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4822 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4823 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4835 void write_r_info_txt(void)
4837 int i, j, z, fc, bc;
4840 cptr flags[32 * 10];
4845 monster_race *r_ptr;
4847 monster_blow *b_ptr;
4849 FILE *fff = fopen("output.txt", "wt");
4853 BIT_FLAGS mode = -1;
4857 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4859 fprintf(fff, "# Version stamp (required)\n\n");
4862 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4865 fprintf(fff, "##### The Player #####\n\n");
4867 for (z = -1; z < alloc_race_size; z++)
4869 /* Output the monsters in order */
4870 i = (z >= 0) ? alloc_race_table[z].index : 0;
4872 /* Acquire the monster */
4875 /* Ignore empty monsters */
4876 if (!strlen(r_name + r_ptr->name)) continue;
4878 /* Ignore useless monsters */
4879 if (i && !r_ptr->speed) continue;
4881 /* Write a note if necessary */
4882 if (i && (!r_ptr->level != !mode))
4887 fprintf(fff, "\n##### Town monsters #####\n\n");
4889 /* Note the dungeon */
4892 fprintf(fff, "\n##### Normal monsters #####\n\n");
4895 /* Record the change */
4896 mode = r_ptr->level;
4899 /* Acquire the flags */
4900 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4901 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4902 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4903 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4904 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4905 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4906 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4907 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4908 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4909 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4911 /* Write New/Number/Name */
4912 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4915 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4917 /* Write Information */
4918 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4919 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4921 /* Write more information */
4922 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4925 for(j = 0; j < 4; j++)
4927 b_ptr = &(r_ptr->blow[j]);
4929 /* Stop when done */
4930 if (!b_ptr->method) break;
4932 /* Write the blows */
4933 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4934 r_info_blow_effect[b_ptr->effect],
4935 b_ptr->d_dice, b_ptr->d_side);
4938 /* Extract the flags */
4939 for (fc = 0, j = 0; j < 32 * 3; j++)
4941 /* Check this flag */
4942 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4945 /* Extract the extra flags */
4946 for (j = 32 * 6; j < 32 * 10; j++)
4948 /* Check this flag */
4949 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4952 /* Write the flags */
4953 for (j = 0; j < fc;)
4957 /* Start the line */
4960 for (bc = 0; (bc < 60) && (j < fc); j++)
4964 /* Format the flag */
4965 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4967 /* Add it to the buffer */
4970 /* Note the length */
4974 /* Done with this line; write it */
4975 fprintf(fff, "%s\n", buf);
4978 /* Write Spells if applicable */
4979 if (r_ptr->freq_spell)
4981 /* Write the frequency */
4982 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4984 /* Extract the spell flags */
4985 for (fc = 0, j = 96; j < 192; j++)
4987 /* Check this flag */
4988 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4991 /* Write the flags */
4992 for (j = 0; j < fc;)
4996 /* Start the line */
4999 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5003 /* Format the flag */
5004 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5008 /* Note the length */
5015 /* Done with this line; write it */
5016 fprintf(fff, "%s\n", buf);
5020 /* Acquire the description */
5021 desc = r_text + r_ptr->text;
5022 dlen = strlen(desc);
5024 /* Write Description */
5025 for (j = 0; j < dlen;)
5029 /* Start the line */
5032 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5040 /* Done with this line; write it */
5041 fprintf(fff, "%s\n", buf);
5044 /* Space between entries */