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.
53 #ifdef ALLOW_TEMPLATES
58 /*** Helper arrays for parsing ascii template files ***/
62 * Monster Blow Methods
64 static cptr r_info_blow_method[] =
98 * Monster Blow Effects
100 static cptr r_info_blow_effect[] =
145 static cptr f_info_flags[] =
270 static cptr r_info_flags1[] =
310 static cptr r_info_flags2[] =
350 static cptr r_info_flags3[] =
390 static cptr r_info_flags4[] =
427 * モンスター特性トークン(発動型能力1) /
430 static cptr r_a_ability_flags1[] =
467 * モンスター特性トークン(発動型能力2) /
470 static cptr r_a_ability_flags2[] =
487 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
508 * モンスター特性トークン(発動型能力3) /
511 static cptr r_a_ability_flags3[] =
550 * モンスター特性トークン(発動型能力4) /
553 static cptr r_a_ability_flags4[] =
595 static cptr r_info_flags7[] =
635 static cptr r_info_flags8[] =
667 "WILD_SWAMP", /* ToDo: Implement Swamp */
676 static cptr r_info_flags9[] =
715 * モンスター特性トークンの定義R(耐性) /
718 static cptr r_info_flagsr[] =
756 * オブジェクト基本特性トークンの定義 /
759 static cptr k_info_flags[] =
856 "XXX3", /* Fake flag for Smith */
857 "XXX4", /* Fake flag for Smith */
907 * オブジェクト生成特性トークンの定義 /
910 static cptr k_info_gen_flags[] =
950 static cptr d_info_flags1[] =
988 * @brief データの可変文字列情報をテキストとして保管する /
989 * Add a text to the text-storage and store offset to it.
990 * @param offset 文字列保管ポインタからのオフセット
991 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
993 * @param normal_text テキストの正規化を行う
996 * Returns FALSE when there isn't enough space available to store
999 static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
1001 /* Hack -- Verify space */
1002 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
1008 /* Advance and save the text index */
1009 *offset = ++head->text_size;
1012 /* Additional text */
1013 else if (normal_text)
1016 * If neither the end of the last line nor
1017 * the beginning of current line is not a space,
1018 * fill up a space as a correct separator of two words.
1020 if (head->text_size > 0 &&
1022 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1023 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
1024 (buf[0] != ' ') && !iskanji(buf[0])
1026 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1031 /* Append a space */
1032 *(head->text_ptr + head->text_size) = ' ';
1034 /* Advance the index */
1039 /* Append chars to the text */
1040 strcpy(head->text_ptr + head->text_size, buf);
1042 /* Advance the index */
1043 head->text_size += strlen(buf);
1051 * @brief データの可変文字列情報を名前として保管する /
1052 * Add a name to the name-storage and return an offset to it.
1053 * @param offset 文字列保管ポインタからのオフセット
1054 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1058 * Returns FALSE when there isn't enough space available to store
1061 static bool add_name(u32b *offset, header *head, cptr buf)
1063 /* Hack -- Verify space */
1064 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
1070 /* Advance and save the name index */
1071 *offset = ++head->name_size;
1074 /* Append chars to the names */
1075 strcpy(head->name_ptr + head->name_size, buf);
1077 /* Advance the index */
1078 head->name_size += strlen(buf);
1086 * @brief データの可変文字列情報をタグとして保管する /
1087 * Add a tag to the tag-storage and return an offset to it.
1088 * @param offset 文字列保管ポインタからのオフセット
1089 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1093 * Returns FALSE when there isn't enough space available to store
1096 static bool add_tag(STR_OFFSET *offset, header *head, cptr buf)
1100 /* Search for an existing (fake) tag */
1101 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1104 if (streq(&head->tag_ptr[i], buf)) break;
1107 /* There was no existing tag */
1108 if (i >= head->tag_size)
1110 /* Hack -- Verify space */
1111 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1114 /* Append chars to the tags */
1115 strcpy(head->tag_ptr + head->tag_size, buf);
1117 /* Point the new tag */
1120 /* Advance the index */
1121 head->tag_size += strlen(buf) + 1;
1124 /* Return offset of the tag */
1133 * @brief シンボル1文字をカラーIDに変更する /
1134 * Convert a "color letter" into an "actual" color
1135 * The colors are: dwsorgbuDWvyRGBU, as shown below
1139 byte color_char_to_attr(char c)
1143 case 'd': return (TERM_DARK);
1144 case 'w': return (TERM_WHITE);
1145 case 's': return (TERM_SLATE);
1146 case 'o': return (TERM_ORANGE);
1147 case 'r': return (TERM_RED);
1148 case 'g': return (TERM_GREEN);
1149 case 'b': return (TERM_BLUE);
1150 case 'u': return (TERM_UMBER);
1152 case 'D': return (TERM_L_DARK);
1153 case 'W': return (TERM_L_WHITE);
1154 case 'v': return (TERM_VIOLET);
1155 case 'y': return (TERM_YELLOW);
1156 case 'R': return (TERM_L_RED);
1157 case 'G': return (TERM_L_GREEN);
1158 case 'B': return (TERM_L_BLUE);
1159 case 'U': return (TERM_L_UMBER);
1167 /*** Initialize from ascii template files ***/
1171 * @brief パース関数に基づいてデータファイルからデータを読み取る /
1172 * Initialize an "*_info" array, by parsing an ascii "template" file
1173 * @param fp 読み取りに使うファイルポインタ
1174 * @param buf 読み取りに使うバッファ領域
1175 * @param head ヘッダ構造体
1176 * @param parse_info_txt_line パース関数
1179 errr init_info_txt(FILE *fp, char *buf, header *head,
1180 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 int 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;
1329 * @brief 職業技能情報(s_info)のパース関数 /
1330 * Initialize the "s_info" array, by parsing an ascii "template" file
1332 * @param head ヘッダ構造体
1335 errr parse_s_info(char *buf, header *head)
1340 static skill_table *s_ptr = NULL;
1343 /* Process 'N' for "New/Number/Name" */
1349 /* Verify information */
1350 if (i <= error_idx) return (4);
1352 /* Verify information */
1353 if (i >= head->info_num) return (2);
1355 /* Save the index */
1358 /* Point at the "info" */
1362 /* There better be a current s_ptr */
1363 else if (!s_ptr) return (3);
1365 /* Process 'W' for "Weapon exp" */
1366 else if (buf[0] == 'W')
1368 int tval, sval, start, max;
1369 const s16b exp_conv_table[] =
1371 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1372 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1375 /* Scan for the values */
1376 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1377 &tval, &sval, &start, &max)) return (1);
1379 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1380 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1382 /* Save the values */
1383 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1384 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1387 /* Process 'S' for "Skill exp" */
1388 else if (buf[0] == 'S')
1390 int num, start, max;
1392 /* Scan for the values */
1393 if (3 != sscanf(buf+2, "%d:%d:%d",
1394 &num, &start, &max)) return (1);
1396 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1397 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1399 /* Save the values */
1400 s_ptr->s_start[num] = (SUB_EXP)start;
1401 s_ptr->s_max[num] = (SUB_EXP)max;
1414 * @brief 職業魔法情報(m_info)のパース関数 /
1415 * Initialize the "m_info" array, by parsing an ascii "template" file
1417 * @param head ヘッダ構造体
1420 errr parse_m_info(char *buf, header *head)
1427 static player_magic *m_ptr = NULL;
1430 static int realm, magic_idx = 0, readable = 0;
1433 /* Process 'N' for "New/Number/Name" */
1439 /* Verify information */
1440 if (i <= error_idx) return (4);
1442 /* Verify information */
1443 if (i >= head->info_num) return (2);
1445 /* Save the index */
1448 /* Point at the "info" */
1452 /* There better be a current m_ptr */
1453 else if (!m_ptr) return (3);
1455 /* Process 'I' for "Info" (one line only) */
1456 else if (buf[0] == 'I')
1459 int xtra, type, first, weight;
1461 /* Find the colon before the name */
1462 s = my_strchr(buf+2, ':');
1464 /* Verify that colon */
1467 /* Nuke the colon, advance to the name */
1472 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1473 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1474 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1475 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1476 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1481 /* Find the colon before the name */
1482 s = my_strchr(s, ':');
1484 /* Verify that colon */
1487 /* Nuke the colon, advance to the name */
1490 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1491 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1492 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1493 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1494 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1495 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1499 /* Scan for the values */
1500 if (4 != sscanf(s, "%x:%d:%d:%d",
1501 (uint *)&xtra, &type, &first, &weight)) return (1);
1503 m_ptr->spell_xtra = xtra;
1504 m_ptr->spell_type = type;
1505 m_ptr->spell_first = first;
1506 m_ptr->spell_weight = weight;
1510 /* Process 'R' for "Realm" (one line only) */
1511 else if (buf[0] == 'R')
1513 /* Scan for the values */
1514 if (2 != sscanf(buf+2, "%d:%d",
1515 &realm, &readable)) return (1);
1520 else if (buf[0] == 'T')
1522 int level, mana, fail, exp;
1524 if (!readable) return (1);
1525 /* Scan for the values */
1526 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1527 &level, &mana, &fail, &exp)) return (1);
1529 m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level;
1530 m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana;
1531 m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail;
1532 m_ptr->info[realm][magic_idx].sexp = (EXP)exp;
1546 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1547 * Grab one flag from a textual string
1548 * @param flags ビットフラグを追加する先の参照ポインタ
1549 * @param names トークン定義配列
1550 * @param what 参照元の文字列ポインタ
1553 static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
1558 for (i = 0; i < 32; i++)
1560 if (streq(what, names[i]))
1562 *flags |= (1L << i);
1572 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1573 * Grab one flag in an feature_type from a textual string
1574 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1575 * @param what 参照元の文字列ポインタ
1578 static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
1583 for (i = 0; i < FF_FLAG_MAX; i++)
1585 if (streq(what, f_info_flags[i]))
1587 add_flag(f_ptr->flags, i);
1593 msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
1596 return PARSE_ERROR_GENERIC;
1601 * @brief テキストトークンを走査してフラグ(ステート)を一つ得る(地形情報向け2) /
1602 * Grab an action in an feature_type from a textual string
1603 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1604 * @param what 参照元の文字列ポインタ
1605 * @param count ステートの保存先ID
1608 static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
1613 for (i = 0; i < FF_FLAG_MAX; i++)
1615 if (streq(what, f_info_flags[i]))
1617 f_ptr->state[count].action = i;
1623 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1626 return PARSE_ERROR_GENERIC;
1631 * @brief 地形情報(f_info)のパース関数 /
1632 * Initialize the "f_info" array, by parsing an ascii "template" file
1634 * @param head ヘッダ構造体
1637 errr parse_f_info(char *buf, header *head)
1644 static feature_type *f_ptr = NULL;
1647 /* Process 'N' for "New/Number/Name" */
1650 /* Find the colon before the name */
1651 s = my_strchr(buf+2, ':');
1655 /* Nuke the colon, advance to the name */
1662 /* Verify information */
1663 if (i <= error_idx) return (4);
1665 /* Verify information */
1666 if (i >= head->info_num) return (2);
1668 /* Save the index */
1671 /* Point at the "info" */
1674 /* Tag name is given */
1678 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1681 /* Default "mimic" */
1682 f_ptr->mimic = (FEAT_IDX)i;
1684 /* Default "destroyed state" -- if not specified */
1685 f_ptr->destroyed = (FEAT_IDX)i;
1687 /* Default "states" */
1688 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1691 /* There better be a current f_ptr */
1692 else if (!f_ptr) return (3);
1695 else if (buf[0] == 'J')
1697 /* Store the name */
1698 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1701 else if (buf[0] == 'E')
1703 /* Ignore english name */
1706 else if (buf[0] == 'J')
1708 /* Ignore Japanese name */
1711 else if (buf[0] == 'E')
1713 /* Acquire the Text */
1716 /* Store the name */
1717 if (!add_name(&f_ptr->name, head, s)) return (7);
1722 /* Process 'M' for "Mimic" (one line only) */
1723 else if (buf[0] == 'M')
1727 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1729 /* Record a fake tag index */
1730 f_ptr->mimic_tag = offset;
1734 /* Process 'G' for "Graphics" (one line only) */
1735 else if (buf[0] == 'G')
1739 char char_tmp[F_LIT_MAX];
1742 if (buf[1] != ':') return (1);
1743 if (!buf[2]) return (1);
1744 if (buf[3] != ':') return (1);
1745 if (!buf[4]) return (1);
1747 /* Extract the char */
1748 char_tmp[F_LIT_STANDARD] = buf[2];
1750 /* Extract the color */
1751 s_attr = color_char_to_attr(buf[4]);
1754 if (s_attr > 127) return (1);
1756 /* Save the standard values */
1757 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1758 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1760 /* Is this feature supports lighting? */
1763 /* G:c:a:LIT (default) */
1764 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1766 /* G:c:a:lc:la:dc:da */
1767 if (!streq(buf + 6, "LIT"))
1769 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1771 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1772 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1773 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1774 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1776 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1778 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1781 /* Use default lighting */
1784 /* No lighting support */
1785 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1788 /* Extract the color */
1789 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1790 if (f_ptr->d_attr[j] > 127) return 1;
1793 f_ptr->d_char[j] = char_tmp[j];
1799 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1801 f_ptr->d_attr[j] = s_attr;
1802 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1808 /* Hack -- Process 'F' for flags */
1809 else if (buf[0] == 'F')
1811 /* Parse every entry textually */
1812 for (s = buf + 2; *s; )
1814 /* Find the end of this entry */
1815 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1817 /* Nuke and skip any dividers */
1821 while (*t == ' ' || *t == '|') t++;
1824 /* XXX XXX XXX Hack -- Read feature subtype */
1825 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1827 /* Extract a "subtype" */
1828 f_ptr->subtype = (FEAT_SUBTYPE)i;
1830 /* Start at next entry */
1837 /* XXX XXX XXX Hack -- Read feature power */
1838 if (1 == sscanf(s, "POWER_%d", &i))
1840 /* Extract a "power" */
1841 f_ptr->power = (FEAT_POWER)i;
1843 /* Start at next entry */
1850 /* Parse this entry */
1851 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1853 /* Start the next entry */
1858 /* Process 'W' for "More Info" (one line only) */
1859 else if (buf[0] == 'W')
1863 /* Scan for the value */
1864 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1866 /* Save the value */
1867 f_ptr->priority = (FEAT_PRIORITY)priority;
1870 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1871 else if (buf[0] == 'K')
1875 /* Find the next empty state slot (if any) */
1876 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1878 /* Oops, no more slots */
1879 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1881 /* Analyze the first field */
1882 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1884 /* Terminate the field (if necessary) */
1885 if (*t == ':') *t++ = '\0';
1887 /* Is this default entry? */
1888 if (streq(s, "DESTROYED"))
1890 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1892 /* Record a fake tag index */
1893 f_ptr->destroyed_tag = offset;
1898 f_ptr->state[i].action = 0;
1900 /* Parse this entry */
1901 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1903 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1905 /* Record a fake tag index */
1906 f_ptr->state[i].result_tag = offset;
1919 * @brief 地形タグからIDを得る /
1920 * Convert a fake tag to a real feat index
1924 s16b f_tag_to_index(cptr str)
1928 /* Search for real index corresponding to this fake tag */
1929 for (i = 0; i < f_head.info_num; i++)
1931 if (streq(f_tag + f_info[i].tag, str))
1933 /* Return the index */
1944 * @brief 地形タグからIDを得る /
1945 * Search for real index corresponding to this fake tag
1946 * @param feat タグ文字列のオフセット
1947 * @return 地形ID。該当がないなら-1
1949 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1953 /* Don't convert non-fake tag */
1959 /* Search for real index corresponding to this fake tag */
1960 for (i = 0; i < f_head.info_num; i++)
1962 if (feat == f_info[i].tag)
1964 /* Record real index */
1970 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1976 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1977 * Retouch fake tags of f_info
1978 * @param head ヘッダ構造体
1981 void retouch_f_info(header *head)
1985 /* Convert fake tags to real feat indices */
1986 for (i = 0; i < head->info_num; i++)
1988 feature_type *f_ptr = &f_info[i];
1991 k = search_real_feat(f_ptr->mimic_tag);
1992 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1993 k = search_real_feat(f_ptr->destroyed_tag);
1994 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1995 for (j = 0; j < MAX_FEAT_STATES; j++)
1997 k = search_real_feat(f_ptr->state[j].result_tag);
1998 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
2005 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
2006 * Grab one flag in an object_kind from a textual string
2007 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
2008 * @param what 参照元の文字列ポインタ
2011 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
2016 for (i = 0; i < TR_FLAG_MAX; i++)
2018 if (streq(what, k_info_flags[i]))
2020 add_flag(k_ptr->flags, i);
2025 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2029 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2036 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2037 * Grab one activation index flag
2038 * @param what 参照元の文字列ポインタ
2041 static byte grab_one_activation_flag(cptr what)
2047 if (activation_info[i].flag == NULL) break;
2049 if (streq(what, activation_info[i].flag))
2051 return activation_info[i].index;
2062 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2070 * @brief ベースアイテム(k_info)のパース関数 /
2071 * Initialize the "k_info" array, by parsing an ascii "template" file
2073 * @param head ヘッダ構造体
2076 errr parse_k_info(char *buf, header *head)
2083 static object_kind *k_ptr = NULL;
2086 /* Process 'N' for "New/Number/Name" */
2093 /* Find the colon before the name */
2094 s = my_strchr(buf+2, ':');
2096 /* Verify that colon */
2099 /* Nuke the colon, advance to the name */
2105 /* Verify information */
2106 if (i <= error_idx) return (4);
2108 /* Verify information */
2109 if (i >= head->info_num) return (2);
2111 /* Save the index */
2114 /* Point at the "info" */
2118 /* Paranoia -- require a name */
2119 if (!*s) return (1);
2121 /* Find the colon before the flavor */
2122 flavor = my_strchr(s, ':');
2124 /* Verify that colon */
2127 /* Nuke the colon, advance to the flavor */
2130 /* Store the flavor */
2131 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2134 /* Store the name */
2135 if (!add_name(&k_ptr->name, head, s)) return (7);
2139 /* There better be a current k_ptr */
2140 else if (!k_ptr) return (3);
2145 /* 'E' から始まる行は英語名としている */
2146 else if (buf[0] == 'E')
2151 else if (buf[0] == 'E')
2155 /* Acquire the name */
2158 /* Find the colon before the flavor */
2159 flavor = my_strchr(s, ':');
2161 /* Verify that colon */
2164 /* Nuke the colon, advance to the flavor */
2167 /* Store the flavor */
2168 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2171 /* Store the name */
2172 if (!add_name(&k_ptr->name, head, s)) return (7);
2176 /* Process 'D' for "Description" */
2177 else if (buf[0] == 'D')
2182 /* Acquire the text */
2187 /* Acquire the text */
2191 /* Store the text */
2192 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2195 /* Process 'G' for "Graphics" (one line only) */
2196 else if (buf[0] == 'G')
2202 if (buf[1] != ':') return (1);
2203 if (!buf[2]) return (1);
2204 if (buf[3] != ':') return (1);
2205 if (!buf[4]) return (1);
2207 /* Extract the char */
2210 /* Extract the attr */
2211 tmp = color_char_to_attr(buf[4]);
2214 if (tmp > 127) return (1);
2216 /* Save the values */
2217 k_ptr->d_attr = tmp;
2218 k_ptr->d_char = sym;
2221 /* Process 'I' for "Info" (one line only) */
2222 else if (buf[0] == 'I')
2224 int tval, sval, pval;
2226 /* Scan for the values */
2227 if (3 != sscanf(buf+2, "%d:%d:%d",
2228 &tval, &sval, &pval)) return (1);
2230 /* Save the values */
2231 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2232 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2233 k_ptr->pval = (PARAMETER_VALUE)pval;
2236 /* Process 'W' for "More Info" (one line only) */
2237 else if (buf[0] == 'W')
2239 int level, extra, wgt;
2242 /* Scan for the values */
2243 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2244 &level, &extra, &wgt, &cost)) return (1);
2246 /* Save the values */
2247 k_ptr->level = (DEPTH)level;
2248 k_ptr->extra = (BIT_FLAGS8)extra;
2249 k_ptr->weight = (WEIGHT)wgt;
2250 k_ptr->cost = (PRICE)cost;
2253 /* Process 'A' for "Allocation" (one line only) */
2254 else if (buf[0] == 'A')
2257 /* XXX XXX XXX Simply read each number following a colon */
2258 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2260 /* Default chance */
2261 k_ptr->chance[i] = 1;
2263 /* Store the attack damage index */
2264 k_ptr->locale[i] = atoi(s+1);
2266 /* Find the slash */
2267 t = my_strchr(s+1, '/');
2269 /* Find the next colon */
2270 s = my_strchr(s+1, ':');
2272 /* If the slash is "nearby", use it */
2273 if (t && (!s || t < s))
2275 int chance = atoi(t+1);
2276 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2281 /* Hack -- Process 'P' for "power" and such */
2282 else if (buf[0] == 'P')
2284 int ac, hd1, hd2, th, td, ta;
2286 /* Scan for the values */
2287 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2288 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2290 k_ptr->ac = (ARMOUR_CLASS)ac;
2291 k_ptr->dd = (DICE_NUMBER)hd1;
2292 k_ptr->ds = (DICE_SID)hd2;
2293 k_ptr->to_h = (HIT_PROB)th;
2294 k_ptr->to_d = (HIT_POINT)td;
2295 k_ptr->to_a = (ARMOUR_CLASS)ta;
2298 /* Hack -- Process 'U' for activation index */
2299 else if (buf[0] == 'U')
2302 n = grab_one_activation_flag(buf + 2);
2313 /* Hack -- Process 'F' for flags */
2314 else if (buf[0] == 'F')
2316 /* Parse every entry textually */
2317 for (s = buf + 2; *s; )
2319 /* Find the end of this entry */
2320 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2322 /* Nuke and skip any dividers */
2326 while (*t == ' ' || *t == '|') t++;
2329 /* Parse this entry */
2330 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2332 /* Start the next entry */
2347 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2348 * Grab one activation index flag
2349 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2350 * @param what 参照元の文字列ポインタ
2351 * @return エラーがあった場合1、エラーがない場合0を返す
2353 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
2358 for (i = 0; i < TR_FLAG_MAX; i++)
2360 if (streq(what, k_info_flags[i]))
2362 add_flag(a_ptr->flags, i);
2367 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2371 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2379 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2380 * Initialize the "a_info" array, by parsing an ascii "template" file
2382 * @param head ヘッダ構造体
2385 errr parse_a_info(char *buf, header *head)
2392 static artifact_type *a_ptr = NULL;
2395 /* Process 'N' for "New/Number/Name" */
2398 /* Find the colon before the name */
2399 s = my_strchr(buf+2, ':');
2401 /* Verify that colon */
2404 /* Nuke the colon, advance to the name */
2407 /* Paranoia -- require a name */
2408 if (!*s) return (1);
2413 /* Verify information */
2414 if (i < error_idx) return (4);
2416 /* Verify information */
2417 if (i >= head->info_num) return (2);
2419 /* Save the index */
2422 /* Point at the "info" */
2425 /* Ignore everything */
2426 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2427 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2428 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2429 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2431 /* Store the name */
2432 if (!add_name(&a_ptr->name, head, s)) return (7);
2436 /* There better be a current a_ptr */
2437 else if (!a_ptr) return (3);
2442 /* 'E' から始まる行は英語名としている */
2443 else if (buf[0] == 'E')
2448 else if (buf[0] == 'E')
2450 /* Acquire the Text */
2453 /* Store the name */
2454 if (!add_name(&a_ptr->name, head, s)) return (7);
2458 /* Process 'D' for "Description" */
2459 else if (buf[0] == 'D')
2464 /* Acquire the text */
2469 /* Acquire the text */
2473 /* Store the text */
2474 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2478 /* Process 'I' for "Info" (one line only) */
2479 else if (buf[0] == 'I')
2481 int tval, sval, pval;
2483 /* Scan for the values */
2484 if (3 != sscanf(buf+2, "%d:%d:%d",
2485 &tval, &sval, &pval)) return (1);
2487 /* Save the values */
2488 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2489 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2490 a_ptr->pval = (PARAMETER_VALUE)pval;
2493 /* Process 'W' for "More Info" (one line only) */
2494 else if (buf[0] == 'W')
2496 int level, rarity, wgt;
2499 /* Scan for the values */
2500 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2501 &level, &rarity, &wgt, &cost)) return (1);
2503 /* Save the values */
2504 a_ptr->level = (DEPTH)level;
2505 a_ptr->rarity = (RARITY)rarity;
2506 a_ptr->weight = (WEIGHT)wgt;
2507 a_ptr->cost = (PRICE)cost;
2510 /* Hack -- Process 'P' for "power" and such */
2511 else if (buf[0] == 'P')
2513 int ac, hd1, hd2, th, td, ta;
2515 /* Scan for the values */
2516 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2517 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2519 a_ptr->ac = (ARMOUR_CLASS)ac;
2520 a_ptr->dd = (DICE_NUMBER)hd1;
2521 a_ptr->ds = (DICE_SID)hd2;
2522 a_ptr->to_h = (HIT_PROB)th;
2523 a_ptr->to_d = (HIT_POINT)td;
2524 a_ptr->to_a = (ARMOUR_CLASS)ta;
2527 /* Hack -- Process 'U' for activation index */
2528 else if (buf[0] == 'U')
2531 n = grab_one_activation_flag(buf + 2);
2542 /* Hack -- Process 'F' for flags */
2543 else if (buf[0] == 'F')
2545 /* Parse every entry textually */
2546 for (s = buf + 2; *s; )
2548 /* Find the end of this entry */
2549 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2551 /* Nuke and skip any dividers */
2555 while ((*t == ' ') || (*t == '|')) t++;
2558 /* Parse this entry */
2559 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2561 /* Start the next entry */
2577 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2578 * Grab one flag in a ego-item_type from a textual string
2579 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2580 * @param what 参照元の文字列ポインタ
2581 * @return エラーがあった場合1、エラーがない場合0を返す
2583 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
2588 for (i = 0; i < TR_FLAG_MAX; i++)
2590 if (streq(what, k_info_flags[i]))
2592 add_flag(e_ptr->flags, i);
2597 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2601 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2609 * @brief アイテムエゴ情報(e_info)のパース関数 /
2610 * Initialize the "e_info" array, by parsing an ascii "template" file
2612 * @param head ヘッダ構造体
2615 errr parse_e_info(char *buf, header *head)
2622 static ego_item_type *e_ptr = NULL;
2625 /* Just before the first record */
2628 /* Just before the first line */
2632 /* Process 'N' for "New/Number/Name" */
2635 /* Find the colon before the name */
2636 s = my_strchr(buf+2, ':');
2638 /* Verify that colon */
2641 /* Nuke the colon, advance to the name */
2644 /* Paranoia -- require a name */
2645 if (!*s) return (1);
2650 /* Verify information */
2651 if (i < error_idx) return (4);
2653 /* Verify information */
2654 if (i >= head->info_num) return (2);
2656 /* Save the index */
2659 /* Point at the "info" */
2662 /* Store the name */
2663 if (!add_name(&e_ptr->name, head, s)) return (7);
2667 /* There better be a current e_ptr */
2668 else if (!e_ptr) return (3);
2673 /* 'E' から始まる行は英語名 */
2674 else if (buf[0] == 'E')
2679 else if (buf[0] == 'E')
2681 /* Acquire the Text */
2684 /* Store the name */
2685 if (!add_name(&e_ptr->name, head, s)) return (7);
2690 /* Process 'D' for "Description" */
2691 else if (buf[0] == 'D')
2693 /* Acquire the text */
2696 /* Store the text */
2697 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2702 /* Process 'X' for "Xtra" (one line only) */
2703 else if (buf[0] == 'X')
2707 /* Scan for the values */
2708 if (2 != sscanf(buf+2, "%d:%d",
2709 &slot, &rating)) return (1);
2711 /* Save the values */
2712 e_ptr->slot = (INVENTORY_IDX)slot;
2713 e_ptr->rating = (PRICE)rating;
2716 /* Process 'W' for "More Info" (one line only) */
2717 else if (buf[0] == 'W')
2719 int level, rarity, pad2;
2722 /* Scan for the values */
2723 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2724 &level, &rarity, &pad2, &cost)) return (1);
2726 /* Save the values */
2727 e_ptr->level = level;
2728 e_ptr->rarity = (RARITY)rarity;
2729 /* e_ptr->weight = wgt; */
2733 /* Hack -- Process 'C' for "creation" */
2734 else if (buf[0] == 'C')
2736 int th, td, ta, pval;
2738 /* Scan for the values */
2739 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2740 &th, &td, &ta, &pval)) return (1);
2742 e_ptr->max_to_h = (HIT_PROB)th;
2743 e_ptr->max_to_d = (HIT_POINT)td;
2744 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2745 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2748 /* Hack -- Process 'U' for activation index */
2749 else if (buf[0] == 'U')
2752 n = grab_one_activation_flag(buf + 2);
2763 /* Hack -- Process 'F' for flags */
2764 else if (buf[0] == 'F')
2766 /* Parse every entry textually */
2767 for (s = buf + 2; *s; )
2769 /* Find the end of this entry */
2770 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2772 /* Nuke and skip any dividers */
2776 while ((*t == ' ') || (*t == '|')) t++;
2779 /* Parse this entry */
2780 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2782 /* Start the next entry */
2796 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2797 * Grab one (basic) flag in a monster_race from a textual string
2798 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2799 * @param what 参照元の文字列ポインタ
2802 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2804 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2807 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2810 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2813 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2816 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2819 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2822 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2826 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2834 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2835 * Grab one (spell) flag in a monster_race from a textual string
2836 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2837 * @param what 参照元の文字列ポインタ
2840 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2842 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2845 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2848 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2852 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2860 * @brief モンスター種族情報(r_info)のパース関数 /
2861 * Initialize the "r_info" array, by parsing an ascii "template" file
2863 * @param head ヘッダ構造体
2866 errr parse_r_info(char *buf, header *head)
2873 static monster_race *r_ptr = NULL;
2876 /* Process 'N' for "New/Number/Name" */
2879 /* Find the colon before the name */
2880 s = my_strchr(buf+2, ':');
2882 /* Verify that colon */
2885 /* Nuke the colon, advance to the name */
2888 /* Paranoia -- require a name */
2889 if (!*s) return (1);
2894 /* Verify information */
2895 if (i < error_idx) return (4);
2897 /* Verify information */
2898 if (i >= head->info_num) return (2);
2900 /* Save the index */
2903 /* Point at the "info" */
2906 /* Store the name */
2907 if (!add_name(&r_ptr->name, head, s)) return (7);
2911 /* There better be a current r_ptr */
2912 else if (!r_ptr) return (3);
2917 /* 'E' から始まる行は英語名 */
2918 else if (buf[0] == 'E')
2920 /* Acquire the Text */
2923 /* Store the name */
2924 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2927 else if (buf[0] == 'E')
2929 /* Acquire the Text */
2932 /* Store the name */
2933 if (!add_name(&r_ptr->name, head, s)) return (7);
2936 /* Process 'D' for "Description" */
2937 else if (buf[0] == 'D')
2942 /* Acquire the text */
2947 /* Acquire the text */
2951 /* Store the text */
2952 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2955 /* Process 'G' for "Graphics" (one line only) */
2956 else if (buf[0] == 'G')
2962 if (buf[1] != ':') return (1);
2963 if (!buf[2]) return (1);
2964 if (buf[3] != ':') return (1);
2965 if (!buf[4]) return (1);
2967 /* Extract the char */
2970 /* Extract the attr */
2971 tmp = color_char_to_attr(buf[4]);
2974 if (tmp > 127) return (1);
2976 /* Save the values */
2977 r_ptr->d_char = sym;
2978 r_ptr->d_attr = tmp;
2981 /* Process 'I' for "Info" (one line only) */
2982 else if (buf[0] == 'I')
2984 int spd, hp1, hp2, aaf, ac, slp;
2986 /* Scan for the other values */
2987 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2988 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2990 /* Save the values */
2991 r_ptr->speed = (SPEED)spd;
2992 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2993 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2994 r_ptr->aaf = (POSITION)aaf;
2995 r_ptr->ac = (ARMOUR_CLASS)ac;
2996 r_ptr->sleep = (SLEEP_DEGREE)slp;
2999 /* Process 'W' for "More Info" (one line only) */
3000 else if (buf[0] == 'W')
3007 /* Scan for the values */
3008 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
3009 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
3011 /* Save the values */
3012 r_ptr->level = (DEPTH)lev;
3013 r_ptr->rarity = (RARITY)rar;
3014 r_ptr->extra = (BIT_FLAGS16)pad;
3015 r_ptr->mexp = (EXP)exp;
3016 r_ptr->next_exp = (EXP)nextexp;
3017 r_ptr->next_r_idx = (IDX)nextmon;
3020 /* Process 'R' for "Reinforcement" (up to six lines) */
3021 else if (buf[0] == 'R')
3024 /* Find the next empty blow slot (if any) */
3025 for (i = 0; i < 6; i++) if (r_ptr->reinforce_id[i] == 0) break;
3027 /* Oops, no more slots */
3028 if (i == 6) return (1);
3030 /* Scan for the values */
3031 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3032 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3033 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3034 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3037 /* Process 'B' for "Blows" (up to four lines) */
3038 else if (buf[0] == 'B')
3042 /* Find the next empty blow slot (if any) */
3043 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3045 /* Oops, no more slots */
3046 if (i == 4) return (1);
3048 /* Analyze the first field */
3049 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3051 /* Terminate the field (if necessary) */
3052 if (*t == ':') *t++ = '\0';
3054 /* Analyze the method */
3055 for (n1 = 0; r_info_blow_method[n1]; n1++)
3057 if (streq(s, r_info_blow_method[n1])) break;
3060 /* Invalid method */
3061 if (!r_info_blow_method[n1]) return (1);
3063 /* Analyze the second field */
3064 for (s = t; *t && (*t != ':'); t++) /* loop */;
3066 /* Terminate the field (if necessary) */
3067 if (*t == ':') *t++ = '\0';
3069 /* Analyze effect */
3070 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3072 if (streq(s, r_info_blow_effect[n2])) break;
3075 /* Invalid effect */
3076 if (!r_info_blow_effect[n2]) return (1);
3078 /* Analyze the third field */
3079 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3081 /* Terminate the field (if necessary) */
3082 if (*t == 'd') *t++ = '\0';
3084 /* Save the method */
3085 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3087 /* Save the effect */
3088 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3090 /* Extract the damage dice and sides */
3091 r_ptr->blow[i].d_dice = atoi(s);
3092 r_ptr->blow[i].d_side = atoi(t);
3095 /* Process 'F' for "Basic Flags" (multiple lines) */
3096 else if (buf[0] == 'F')
3098 /* Parse every entry */
3099 for (s = buf + 2; *s; )
3101 /* Find the end of this entry */
3102 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3104 /* Nuke and skip any dividers */
3108 while (*t == ' ' || *t == '|') t++;
3111 /* Parse this entry */
3112 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3114 /* Start the next entry */
3119 /* Process 'S' for "Spell Flags" (multiple lines) */
3120 else if (buf[0] == 'S')
3122 /* Parse every entry */
3123 for (s = buf + 2; *s; )
3125 /* Find the end of this entry */
3126 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3128 /* Nuke and skip any dividers */
3132 while ((*t == ' ') || (*t == '|')) t++;
3135 /* XXX XXX XXX Hack -- Read spell frequency */
3136 if (1 == sscanf(s, "1_IN_%d", &i))
3138 /* Extract a "frequency" */
3139 r_ptr->freq_spell = 100 / i;
3141 /* Start at next entry */
3148 /* Parse this entry */
3149 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3151 /* Start the next entry */
3156 /* Process 'A' for "Artifact Flags" (multiple lines) */
3157 else if (buf[0] == 'A')
3159 int id, per, rarity;
3161 /* Find the next empty blow slot (if any) */
3162 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3164 /* Oops, no more slots */
3165 if (i == 4) return (1);
3167 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3168 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3169 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3170 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3173 /* Process 'V' for "Arena power value ratio" */
3174 else if (buf[0] == 'V')
3177 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3178 r_ptr->arena_ratio = (PERCENTAGE)val;
3191 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3192 * Grab one flag for a dungeon type from a textual string
3193 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3194 * @param what 参照元の文字列ポインタ
3197 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
3199 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3203 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3210 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3211 * Grab one (basic) flag in a monster_race from a textual string
3212 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3213 * @param what 参照元の文字列ポインタ
3216 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
3218 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3221 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3224 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3227 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3230 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3233 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3236 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3240 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3247 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3248 * Grab one (spell) flag in a monster_race from a textual string
3249 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3250 * @param what 参照元の文字列ポインタ
3253 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
3255 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3258 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3261 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3265 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3272 * @brief ダンジョン情報(d_info)のパース関数 /
3273 * Initialize the "d_info" array, by parsing an ascii "template" file
3275 * @param head ヘッダ構造体
3278 errr parse_d_info(char *buf, header *head)
3285 static dungeon_info_type *d_ptr = NULL;
3288 /* Process 'N' for "New/Number/Name" */
3291 /* Find the colon before the name */
3292 s = my_strchr(buf+2, ':');
3294 /* Verify that colon */
3297 /* Nuke the colon, advance to the name */
3300 /* Paranoia -- require a name */
3301 if (!*s) return (1);
3306 /* Verify information */
3307 if (i < error_idx) return (4);
3309 /* Verify information */
3310 if (i >= head->info_num) return (2);
3312 /* Save the index */
3315 /* Point at the "info" */
3318 /* Store the name */
3319 if (!add_name(&d_ptr->name, head, s)) return (7);
3324 else if (buf[0] == 'E') return (0);
3326 else if (buf[0] == 'E')
3328 /* Acquire the Text */
3331 /* Store the name */
3332 if (!add_name(&d_ptr->name, head, s)) return (7);
3336 /* Process 'D' for "Description */
3337 else if (buf[0] == 'D')
3342 /* Acquire the text */
3347 /* Acquire the text */
3351 /* Store the text */
3352 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3355 /* Process 'W' for "More Info" (one line only) */
3356 else if (buf[0] == 'W')
3358 int min_lev, max_lev;
3360 int min_alloc, max_chance;
3361 int obj_good, obj_great;
3364 /* Scan for the values */
3365 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3366 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3368 /* Save the values */
3369 d_ptr->mindepth = (DEPTH)min_lev;
3370 d_ptr->maxdepth = (DEPTH)max_lev;
3371 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3372 d_ptr->mode = (BIT_FLAGS8)mode;
3373 d_ptr->min_m_alloc_level = min_alloc;
3374 d_ptr->max_m_alloc_chance = max_chance;
3375 d_ptr->obj_good = obj_good;
3376 d_ptr->obj_great = obj_great;
3377 d_ptr->pit = (BIT_FLAGS16)pit;
3378 d_ptr->nest = (BIT_FLAGS16)nest;
3381 /* Process 'P' for "Place Info" */
3382 else if (buf[0] == 'P')
3386 /* Scan for the values */
3387 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3389 /* Save the values */
3394 /* Process 'L' for "fLoor type" (one line only) */
3395 else if (buf[0] == 'L')
3399 /* Scan for the values */
3400 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3402 /* Save the values */
3403 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3405 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3406 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3408 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3410 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3413 /* Process 'A' for "wAll type" (one line only) */
3414 else if (buf[0] == 'A')
3418 /* Scan for the values */
3419 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3421 /* Save the values */
3422 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3424 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3425 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3427 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3430 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3431 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3433 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3434 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3436 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3437 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3439 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3440 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3443 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3444 else if (buf[0] == 'F')
3446 int artif = 0, monst = 0;
3448 /* Parse every entry */
3449 for (s = buf + 2; *s; )
3451 /* Find the end of this entry */
3452 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3454 /* Nuke and skip any dividers */
3458 while (*t == ' ' || *t == '|') t++;
3461 /* XXX XXX XXX Hack -- Read Final Artifact */
3462 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3464 /* Extract a "Final Artifact" */
3465 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3467 /* Start at next entry */
3474 /* XXX XXX XXX Hack -- Read Final Object */
3475 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3477 /* Extract a "Final Artifact" */
3478 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3480 /* Start at next entry */
3487 /* XXX XXX XXX Hack -- Read Artifact Guardian */
3488 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3490 /* Extract a "Artifact Guardian" */
3491 d_ptr->final_guardian = (MONRACE_IDX)monst;
3493 /* Start at next entry */
3500 /* XXX XXX XXX Hack -- Read Special Percentage */
3501 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3503 /* Extract a "Special %" */
3504 d_ptr->special_div = (PROB)monst;
3506 /* Start at next entry */
3513 /* Parse this entry */
3514 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3516 /* Start the next entry */
3521 /* Process 'M' for "Basic Flags" (multiple lines) */
3522 else if (buf[0] == 'M')
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 monster symbols */
3538 if (!strncmp(s, "R_CHAR_", 7))
3540 /* Skip "R_CHAR_" */
3544 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3546 /* Start at next entry */
3553 /* Parse this entry */
3554 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3556 /* Start the next entry */
3561 /* Process 'S' for "Spell Flags" (multiple lines) */
3562 else if (buf[0] == 'S')
3564 /* Parse every entry */
3565 for (s = buf + 2; *s; )
3567 /* Find the end of this entry */
3568 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3570 /* Nuke and skip any dividers */
3574 while ((*t == ' ') || (*t == '|')) t++;
3577 /* XXX XXX XXX Hack -- Read spell frequency */
3578 if (1 == sscanf(s, "1_IN_%d", &i))
3580 /* Start at next entry */
3587 /* Parse this entry */
3588 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3590 /* Start the next entry */
3603 #else /* ALLOW_TEMPLATES */
3609 #endif /* ALLOW_TEMPLATES */
3612 /* Random dungeon grid effects */
3613 #define RANDOM_NONE 0x00000000
3614 #define RANDOM_FEATURE 0x00000001
3615 #define RANDOM_MONSTER 0x00000002
3616 #define RANDOM_OBJECT 0x00000004
3617 #define RANDOM_EGO 0x00000008
3618 #define RANDOM_ARTIFACT 0x00000010
3619 #define RANDOM_TRAP 0x00000020
3622 typedef struct dungeon_grid dungeon_grid;
3626 FEAT_IDX feature; /* Terrain feature */
3627 MONSTER_IDX monster; /* Monster */
3628 OBJECT_IDX object; /* Object */
3629 EGO_IDX ego; /* Ego-Item */
3630 ARTIFACT_IDX artifact; /* Artifact */
3631 IDX trap; /* Trap */
3632 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3633 s16b special; /* Reserved for special terrain info */
3634 int random; /* Number of the random effect */
3638 static dungeon_grid letter[255];
3642 * @brief 地形情報の「F:」情報をパースする
3643 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3647 static errr parse_line_feature(char *buf)
3653 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3655 /* Tokenize the line */
3656 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3658 /* Letter to assign */
3659 int index = zz[0][0];
3661 /* Reset the info for the letter */
3662 letter[index].feature = feat_none;
3663 letter[index].monster = 0;
3664 letter[index].object = 0;
3665 letter[index].ego = 0;
3666 letter[index].artifact = 0;
3667 letter[index].trap = feat_none;
3668 letter[index].cave_info = 0;
3669 letter[index].special = 0;
3670 letter[index].random = RANDOM_NONE;
3676 letter[index].special = atoi(zz[8]);
3680 if ((zz[7][0] == '*') && !zz[7][1])
3682 letter[index].random |= RANDOM_TRAP;
3686 letter[index].trap = f_tag_to_index(zz[7]);
3687 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3692 if (zz[6][0] == '*')
3694 letter[index].random |= RANDOM_ARTIFACT;
3695 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3697 else if (zz[6][0] == '!')
3699 if (p_ptr->inside_quest)
3701 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3706 letter[index].artifact = (IDX)atoi(zz[6]);
3711 if (zz[5][0] == '*')
3713 letter[index].random |= RANDOM_EGO;
3714 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3718 letter[index].ego = (IDX)atoi(zz[5]);
3723 if (zz[4][0] == '*')
3725 letter[index].random |= RANDOM_OBJECT;
3726 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3728 else if (zz[4][0] == '!')
3730 if (p_ptr->inside_quest)
3732 int a_idx = quest[p_ptr->inside_quest].k_idx;
3735 artifact_type *a_ptr = &a_info[a_idx];
3736 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3738 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3745 letter[index].object = (IDX)atoi(zz[4]);
3750 if (zz[3][0] == '*')
3752 letter[index].random |= RANDOM_MONSTER;
3753 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3755 else if (zz[3][0] == 'c')
3757 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3758 letter[index].monster = - atoi(zz[3] + 1);
3762 letter[index].monster = (IDX)atoi(zz[3]);
3767 letter[index].cave_info = atoi(zz[2]);
3771 if ((zz[1][0] == '*') && !zz[1][1])
3773 letter[index].random |= RANDOM_FEATURE;
3777 letter[index].feature = f_tag_to_index(zz[1]);
3778 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3791 * @brief 地形情報の「B:」情報をパースする
3792 * Process "B:<Index>:<Command>:..." -- Building definition
3796 static errr parse_line_building(char *buf)
3812 /* Get the building number */
3815 /* Find the colon after the building number */
3816 s = my_strchr(s, ':');
3818 /* Verify that colon */
3821 /* Nuke the colon, advance to the sub-index */
3824 /* Paranoia -- require a sub-index */
3825 if (!*s) return (1);
3827 /* Building definition sub-index */
3830 /* Building name, owner, race */
3833 if (tokenize(s + 2, 3, zz, 0) == 3)
3835 /* Name of the building */
3836 strcpy(building[index].name, zz[0]);
3838 /* Name of the owner */
3839 strcpy(building[index].owner_name, zz[1]);
3841 /* Race of the owner */
3842 strcpy(building[index].owner_race, zz[2]);
3847 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3850 /* Building Action */
3853 if (tokenize(s + 2, 8, zz, 0) >= 7)
3855 /* Index of the action */
3856 int action_index = atoi(zz[0]);
3858 /* Name of the action */
3859 strcpy(building[index].act_names[action_index], zz[1]);
3861 /* Cost of the action for members */
3862 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3864 /* Cost of the action for non-members */
3865 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3867 /* Letter assigned to the action */
3868 building[index].letters[action_index] = zz[4][0];
3871 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3873 /* Action restriction */
3874 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3879 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3882 /* Building Classes */
3885 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3887 for (i = 0; i < MAX_CLASS; i++)
3889 building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
3895 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3898 /* Building Races */
3901 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3903 for (i = 0; i < MAX_RACES; i++)
3905 building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
3911 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3914 /* Building Realms */
3917 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3919 for (i = 0; i < MAX_MAGIC; i++)
3921 building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
3927 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3932 /* Ignore scripts */
3938 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3947 * @brief フロアの所定のマスにオブジェクトを配置する
3948 * Place the object j_ptr to a grid
3949 * @param j_ptr オブジェクト構造体の参照ポインタ
3954 static void drop_here(object_type *j_ptr, int y, int x)
3956 cave_type *c_ptr = &cave[y][x];
3959 /* Get new object */
3960 s16b o_idx = o_pop();
3962 /* Access new object */
3963 o_ptr = &o_list[o_idx];
3965 /* Structure copy */
3966 object_copy(o_ptr, j_ptr);
3974 o_ptr->held_m_idx = 0;
3977 o_ptr->next_o_idx = c_ptr->o_idx;
3979 /* Place the object */
3980 c_ptr->o_idx = o_idx;
3985 * @brief クエスト用固定ダンジョンをフロアに生成する
3986 * Parse a sub-file of the "extra info"
3996 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
4003 /* Skip "empty" lines */
4004 if (!buf[0]) return (0);
4006 /* Skip "blank" lines */
4007 if (iswspace(buf[0])) return (0);
4010 if (buf[0] == '#') return (0);
4012 /* Require "?:*" format */
4013 if (buf[1] != ':') return (1);
4016 /* Process "%:<fname>" */
4019 /* Attempt to Process the given file */
4020 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
4023 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
4026 return parse_line_feature(buf);
4029 /* Process "D:<dungeon>" -- info for the cave grids */
4030 else if (buf[0] == 'D')
4032 object_type object_type_body;
4034 /* Acquire the text */
4037 /* Length of the text */
4038 int len = strlen(s);
4040 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
4042 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
4044 /* Access the grid */
4045 cave_type *c_ptr = &cave[*y][*x];
4049 IDX object_index = letter[idx].object;
4050 IDX monster_index = letter[idx].monster;
4051 int random = letter[idx].random;
4052 IDX artifact_index = letter[idx].artifact;
4054 /* Lay down a floor */
4055 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4057 /* Only the features */
4058 if (init_flags & INIT_ONLY_FEATURES) continue;
4061 c_ptr->info = letter[idx].cave_info;
4063 /* Create a monster */
4064 if (random & RANDOM_MONSTER)
4066 monster_level = base_level + monster_index;
4068 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4070 monster_level = base_level;
4072 else if (monster_index)
4074 int old_cur_num, old_max_num;
4077 if (monster_index < 0)
4079 monster_index = -monster_index;
4082 old_cur_num = r_info[monster_index].cur_num;
4083 old_max_num = r_info[monster_index].max_num;
4085 /* Make alive again */
4086 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4088 r_info[monster_index].cur_num = 0;
4089 r_info[monster_index].max_num = 1;
4092 /* Make alive again */
4093 /* Hack -- Non-unique Nazguls are semi-unique */
4094 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4096 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4098 r_info[monster_index].max_num++;
4103 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4107 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4109 /* Make alive again for real unique monster */
4110 r_info[monster_index].cur_num = old_cur_num;
4111 r_info[monster_index].max_num = old_max_num;
4115 /* Object (and possible trap) */
4116 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4118 object_level = base_level + object_index;
4121 * Random trap and random treasure defined
4122 * 25% chance for trap and 75% chance for object
4124 if (randint0(100) < 75)
4126 place_object(*y, *x, 0L);
4133 object_level = base_level;
4135 else if (random & RANDOM_OBJECT)
4137 object_level = base_level + object_index;
4139 /* Create an out of deep object */
4140 if (randint0(100) < 75)
4141 place_object(*y, *x, 0L);
4142 else if (randint0(100) < 80)
4143 place_object(*y, *x, AM_GOOD);
4145 place_object(*y, *x, AM_GOOD | AM_GREAT);
4147 object_level = base_level;
4150 else if (random & RANDOM_TRAP)
4154 /* Hidden trap (or door) */
4155 else if (letter[idx].trap)
4157 c_ptr->mimic = c_ptr->feat;
4158 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4160 else if (object_index)
4162 /* Get local object */
4163 object_type *o_ptr = &object_type_body;
4165 /* Create the item */
4166 object_prep(o_ptr, object_index);
4168 if (o_ptr->tval == TV_GOLD)
4170 coin_type = object_index - OBJ_GOLD_LIST;
4175 /* Apply magic (no messages, no artifacts) */
4176 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4178 drop_here(o_ptr, *y, *x);
4184 if (a_info[artifact_index].cur_num)
4186 IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4188 object_type *q_ptr = &forge;
4190 object_prep(q_ptr, k_idx);
4192 /* Drop it in the dungeon */
4193 drop_here(q_ptr, *y, *x);
4197 /* Create the artifact */
4198 if (create_named_art(artifact_index, *y, *x))
4199 a_info[artifact_index].cur_num = 1;
4203 /* Terrain special */
4204 c_ptr->special = letter[idx].special;
4212 /* Process "Q:<number>:<command>:... -- quest info */
4213 else if (buf[0] == 'Q')
4220 num = tokenize(buf + 2, 33, zz, 0);
4224 num = tokenize(buf + 3, 33, zz, 0);
4227 /* Have we enough parameters? */
4228 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4231 q_ptr = &(quest[atoi(zz[0])]);
4233 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4234 if (zz[1][0] == 'Q')
4236 if (init_flags & INIT_ASSIGN)
4238 monster_race *r_ptr;
4239 artifact_type *a_ptr;
4241 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4243 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4244 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4245 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4246 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4247 q_ptr->level = (DEPTH)atoi(zz[6]);
4248 q_ptr->r_idx = (IDX)atoi(zz[7]);
4249 q_ptr->k_idx = (IDX)atoi(zz[8]);
4250 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4252 if (num > 10) q_ptr->flags = atoi(zz[10]);
4254 r_ptr = &r_info[q_ptr->r_idx];
4255 if (r_ptr->flags1 & RF1_UNIQUE)
4256 r_ptr->flags1 |= RF1_QUESTOR;
4258 a_ptr = &a_info[q_ptr->k_idx];
4259 a_ptr->gen_flags |= TRG_QUESTITEM;
4264 else if (zz[1][0] == 'R')
4266 if (init_flags & INIT_ASSIGN)
4269 IDX idx, reward_idx = 0;
4271 for (idx = 2; idx < num; idx++)
4273 IDX a_idx = (IDX)atoi(zz[idx]);
4274 if (a_idx < 1) continue;
4275 if (a_info[a_idx].cur_num > 0) continue;
4277 if (one_in_(count)) reward_idx = a_idx;
4282 /* Set quest's rewarding artifact */
4283 q_ptr->k_idx = reward_idx;
4284 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4288 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4289 q_ptr->type = QUEST_TYPE_KILL_ALL;
4296 /* Process "Q:<q_index>:N:<name>" -- quest name */
4297 else if (zz[1][0] == 'N')
4299 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4301 strcpy(q_ptr->name, zz[2]);
4307 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4308 else if (zz[1][0] == 'T')
4310 if (init_flags & INIT_SHOW_TEXT)
4312 strcpy(quest_text[quest_text_line], zz[2]);
4320 /* Process "W:<command>: ..." -- info for the wilderness */
4321 else if (buf[0] == 'W')
4323 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4326 /* Process "P:<y>:<x>" -- player position */
4327 else if (buf[0] == 'P')
4329 if (init_flags & INIT_CREATE_DUNGEON)
4331 if (tokenize(buf + 2, 2, zz, 0) == 2)
4333 int panels_x, panels_y;
4335 /* Hack - Set the dungeon size */
4336 panels_y = (*y / SCREEN_HGT);
4337 if (*y % SCREEN_HGT) panels_y++;
4338 cur_hgt = panels_y * SCREEN_HGT;
4340 panels_x = (*x / SCREEN_WID);
4341 if (*x % SCREEN_WID) panels_x++;
4342 cur_wid = panels_x * SCREEN_WID;
4344 /* Assume illegal panel */
4345 panel_row_min = cur_hgt;
4346 panel_col_min = cur_wid;
4348 /* Place player in a quest level */
4349 if (p_ptr->inside_quest)
4353 /* Delete the monster (if any) */
4354 delete_monster(p_ptr->y, p_ptr->x);
4362 /* Place player in the town */
4363 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4365 p_ptr->oldpy = atoi(zz[0]);
4366 p_ptr->oldpx = atoi(zz[1]);
4374 /* Process "B:<Index>:<Command>:..." -- Building definition */
4375 else if (buf[0] == 'B')
4377 return parse_line_building(buf);
4380 /* Process "M:<type>:<maximum>" -- set maximum values */
4381 else if (buf[0] == 'M')
4383 if (tokenize(buf+2, 2, zz, 0) == 2)
4386 if (zz[0][0] == 'T')
4388 max_towns = (IDX)atoi(zz[1]);
4391 /* Maximum quests */
4392 else if (zz[0][0] == 'Q')
4394 max_q_idx = (IDX)atoi(zz[1]);
4398 else if (zz[0][0] == 'R')
4400 max_r_idx = (IDX)atoi(zz[1]);
4404 else if (zz[0][0] == 'K')
4406 max_k_idx = (IDX)atoi(zz[1]);
4410 else if (zz[0][0] == 'V')
4412 max_v_idx = (IDX)atoi(zz[1]);
4416 else if (zz[0][0] == 'F')
4418 max_f_idx = (IDX)atoi(zz[1]);
4422 else if (zz[0][0] == 'A')
4424 max_a_idx = (IDX)atoi(zz[1]);
4428 else if (zz[0][0] == 'E')
4430 max_e_idx = (IDX)atoi(zz[1]);
4434 else if (zz[0][0] == 'D')
4436 max_d_idx = (IDX)atoi(zz[1]);
4440 else if (zz[0][0] == 'O')
4442 max_o_idx = (IDX)atoi(zz[1]);
4446 else if (zz[0][0] == 'M')
4448 max_m_idx = (IDX)atoi(zz[1]);
4451 /* Wilderness size */
4452 else if (zz[0][0] == 'W')
4454 /* Maximum wild_x_size */
4455 if (zz[0][1] == 'X')
4456 max_wild_x = atoi(zz[1]);
4457 /* Maximum wild_y_size */
4458 if (zz[0][1] == 'Y')
4459 max_wild_y = atoi(zz[1]);
4473 static cptr variant = "ZANGBAND";
4477 * @brief クエスト用固定ダンジョン生成時の分岐処理
4478 * Helper function for "process_dungeon_file()"
4483 static cptr process_dungeon_file_expr(char **sp, char *fp)
4499 while (iswspace(*s)) s++;
4517 t = process_dungeon_file_expr(&s, &f);
4526 else if (streq(t, "IOR"))
4529 while (*s && (f != b2))
4531 t = process_dungeon_file_expr(&s, &f);
4532 if (*t && !streq(t, "0")) v = "1";
4537 else if (streq(t, "AND"))
4540 while (*s && (f != b2))
4542 t = process_dungeon_file_expr(&s, &f);
4543 if (*t && streq(t, "0")) v = "0";
4548 else if (streq(t, "NOT"))
4551 while (*s && (f != b2))
4553 t = process_dungeon_file_expr(&s, &f);
4554 if (*t && streq(t, "1")) v = "0";
4559 else if (streq(t, "EQU"))
4562 if (*s && (f != b2))
4564 t = process_dungeon_file_expr(&s, &f);
4566 while (*s && (f != b2))
4568 p = process_dungeon_file_expr(&s, &f);
4569 if (streq(t, p)) v = "1";
4574 else if (streq(t, "LEQ"))
4577 if (*s && (f != b2))
4579 t = process_dungeon_file_expr(&s, &f);
4581 while (*s && (f != b2))
4584 t = process_dungeon_file_expr(&s, &f);
4585 if (*t && atoi(p) > atoi(t)) v = "0";
4590 else if (streq(t, "GEQ"))
4593 if (*s && (f != b2))
4595 t = process_dungeon_file_expr(&s, &f);
4597 while (*s && (f != b2))
4600 t = process_dungeon_file_expr(&s, &f);
4602 /* Compare two numbers instead of string */
4603 if (*t && atoi(p) < atoi(t)) v = "0";
4610 while (*s && (f != b2))
4612 t = process_dungeon_file_expr(&s, &f);
4617 if (f != b2) v = "?x?x?";
4619 /* Extract final and Terminate */
4620 if ((f = *s) != '\0') *s++ = '\0';
4626 /* Accept all printables except spaces and brackets */
4628 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4630 if (iskanji(*s)) s++;
4634 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4637 /* Extract final and Terminate */
4638 if ((f = *s) != '\0') *s++ = '\0';
4644 if (streq(b+1, "SYS"))
4650 else if (streq(b+1, "GRAF"))
4655 else if (streq(b+1, "MONOCHROME"))
4664 else if (streq(b+1, "RACE"))
4666 v = _(rp_ptr->E_title, rp_ptr->title);
4670 else if (streq(b+1, "CLASS"))
4672 v = _(cp_ptr->E_title, cp_ptr->title);
4676 else if (streq(b+1, "REALM1"))
4678 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4682 else if (streq(b+1, "REALM2"))
4684 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4688 else if (streq(b+1, "PLAYER"))
4690 static char tmp_player_name[32];
4692 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4702 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4705 v = tmp_player_name;
4709 else if (streq(b+1, "TOWN"))
4711 sprintf(tmp, "%d", p_ptr->town_num);
4716 else if (streq(b+1, "LEVEL"))
4718 sprintf(tmp, "%d", p_ptr->lev);
4722 /* Current quest number */
4723 else if (streq(b+1, "QUEST_NUMBER"))
4725 sprintf(tmp, "%d", p_ptr->inside_quest);
4729 /* Number of last quest */
4730 else if (streq(b+1, "LEAVING_QUEST"))
4732 sprintf(tmp, "%d", leaving_quest);
4737 else if (prefix(b+1, "QUEST_TYPE"))
4739 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4740 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4745 else if (prefix(b+1, "QUEST"))
4747 /* "QUEST" uses a special parameter to determine the number of the quest */
4748 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4753 else if (prefix(b+1, "RANDOM"))
4755 /* "RANDOM" uses a special parameter to determine the number of the quest */
4756 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4761 else if (streq(b+1, "VARIANT"))
4767 else if (streq(b+1, "WILDERNESS"))
4770 sprintf(tmp, "NONE");
4772 sprintf(tmp, "LITE");
4774 sprintf(tmp, "NORMAL");
4798 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4799 * Helper function for "process_dungeon_file()"
4807 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4817 bool bypass = FALSE;
4819 int x = xmin, y = ymin;
4822 /* Build the filename */
4823 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4826 fp = my_fopen(buf, "r");
4829 if (!fp) return (-1);
4832 /* Process the file */
4833 while (0 == my_fgets(fp, buf, sizeof(buf)))
4839 /* Skip "empty" lines */
4840 if (!buf[0]) continue;
4842 /* Skip "blank" lines */
4843 if (iswspace(buf[0])) continue;
4846 if (buf[0] == '#') continue;
4849 /* Process "?:<expr>" */
4850 if ((buf[0] == '?') && (buf[1] == ':'))
4859 /* Parse the expr */
4860 v = process_dungeon_file_expr(&s, &f);
4863 bypass = (streq(v, "0") ? TRUE : FALSE);
4869 /* Apply conditionals */
4870 if (bypass) continue;
4872 /* Process the line */
4873 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4885 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4888 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4889 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4895 /* Close the file */
4905 void write_r_info_txt(void)
4907 int i, j, z, fc, bc;
4910 cptr flags[32 * 10];
4915 monster_race *r_ptr;
4917 monster_blow *b_ptr;
4919 FILE *fff = fopen("output.txt", "wt");
4923 BIT_FLAGS mode = -1;
4927 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4929 fprintf(fff, "# Version stamp (required)\n\n");
4932 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4935 fprintf(fff, "##### The Player #####\n\n");
4937 for (z = -1; z < alloc_race_size; z++)
4939 /* Output the monsters in order */
4940 i = (z >= 0) ? alloc_race_table[z].index : 0;
4942 /* Acquire the monster */
4945 /* Ignore empty monsters */
4946 if (!strlen(r_name + r_ptr->name)) continue;
4948 /* Ignore useless monsters */
4949 if (i && !r_ptr->speed) continue;
4951 /* Write a note if necessary */
4952 if (i && (!r_ptr->level != !mode))
4957 fprintf(fff, "\n##### Town monsters #####\n\n");
4959 /* Note the dungeon */
4962 fprintf(fff, "\n##### Normal monsters #####\n\n");
4965 /* Record the change */
4966 mode = r_ptr->level;
4969 /* Acquire the flags */
4970 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4971 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4972 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4973 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4974 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4975 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4976 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4977 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4978 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4979 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4981 /* Write New/Number/Name */
4982 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4985 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4987 /* Write Information */
4988 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4989 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4991 /* Write more information */
4992 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4995 for(j = 0; j < 4; j++)
4997 b_ptr = &(r_ptr->blow[j]);
4999 /* Stop when done */
5000 if (!b_ptr->method) break;
5002 /* Write the blows */
5003 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
5004 r_info_blow_effect[b_ptr->effect],
5005 b_ptr->d_dice, b_ptr->d_side);
5008 /* Extract the flags */
5009 for (fc = 0, j = 0; j < 32 * 3; j++)
5011 /* Check this flag */
5012 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5015 /* Extract the extra flags */
5016 for (j = 32 * 6; j < 32 * 10; j++)
5018 /* Check this flag */
5019 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5022 /* Write the flags */
5023 for (j = 0; j < fc;)
5027 /* Start the line */
5030 for (bc = 0; (bc < 60) && (j < fc); j++)
5034 /* Format the flag */
5035 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5037 /* Add it to the buffer */
5040 /* Note the length */
5044 /* Done with this line; write it */
5045 fprintf(fff, "%s\n", buf);
5048 /* Write Spells if applicable */
5049 if (r_ptr->freq_spell)
5051 /* Write the frequency */
5052 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
5054 /* Extract the spell flags */
5055 for (fc = 0, j = 96; j < 192; j++)
5057 /* Check this flag */
5058 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5061 /* Write the flags */
5062 for (j = 0; j < fc;)
5066 /* Start the line */
5069 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5073 /* Format the flag */
5074 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5078 /* Note the length */
5085 /* Done with this line; write it */
5086 fprintf(fff, "%s\n", buf);
5090 /* Acquire the description */
5091 desc = r_text + r_ptr->text;
5092 dlen = strlen(desc);
5094 /* Write Description */
5095 for (j = 0; j < dlen;)
5099 /* Start the line */
5102 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5110 /* Done with this line; write it */
5111 fprintf(fff, "%s\n", buf);
5114 /* Space between entries */