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.
56 #ifdef ALLOW_TEMPLATES
61 /*** Helper arrays for parsing ascii template files ***/
65 * Monster Blow Methods
67 static concptr r_info_blow_method[] =
100 * モンスターの打撃属性トークンの定義 /
101 * Monster Blow Effects
103 static concptr r_info_blow_effect[] =
148 static concptr f_info_flags[] =
273 static concptr r_info_flags1[] =
313 static concptr r_info_flags2[] =
353 static concptr r_info_flags3[] =
393 static concptr r_info_flags4[] =
430 * モンスター特性トークン(発動型能力1) /
433 static concptr r_a_ability_flags1[] =
470 * モンスター特性トークン(発動型能力2) /
473 static concptr r_a_ability_flags2[] =
490 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
511 * モンスター特性トークン(発動型能力3) /
514 static concptr r_a_ability_flags3[] =
553 * モンスター特性トークン(発動型能力4) /
556 static concptr r_a_ability_flags4[] =
598 static concptr r_info_flags7[] =
638 static concptr r_info_flags8[] =
670 "WILD_SWAMP", /* ToDo: Implement Swamp */
679 static concptr r_info_flags9[] =
718 * モンスター特性トークンの定義R(耐性) /
721 static concptr r_info_flagsr[] =
759 * オブジェクト基本特性トークンの定義 /
762 static concptr k_info_flags[] =
859 "XXX3", /* Fake flag for Smith */
860 "XXX4", /* Fake flag for Smith */
910 * オブジェクト生成特性トークンの定義 /
913 static concptr k_info_gen_flags[] =
953 static concptr d_info_flags1[] =
991 * @brief データの可変文字列情報をテキストとして保管する /
992 * Add a text to the text-storage and store offset to it.
993 * @param offset 文字列保管ポインタからのオフセット
994 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
996 * @param normal_text テキストの正規化を行う
999 * Returns FALSE when there isn't enough space available to store
1002 static bool add_text(u32b *offset, header *head, concptr buf, bool normal_text)
1004 /* Hack -- Verify space */
1005 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
1011 /* Advance and save the text index */
1012 *offset = ++head->text_size;
1015 /* Additional text */
1016 else if (normal_text)
1019 * If neither the end of the last line nor
1020 * the beginning of current line is not a space,
1021 * fill up a space as a correct separator of two words.
1023 if (head->text_size > 0 &&
1025 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1026 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
1027 (buf[0] != ' ') && !iskanji(buf[0])
1029 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1034 /* Append a space */
1035 *(head->text_ptr + head->text_size) = ' ';
1037 /* Advance the index */
1042 /* Append chars to the text */
1043 strcpy(head->text_ptr + head->text_size, buf);
1045 /* Advance the index */
1046 head->text_size += strlen(buf);
1054 * @brief データの可変文字列情報を名前として保管する /
1055 * Add a name to the name-storage and return an offset to it.
1056 * @param offset 文字列保管ポインタからのオフセット
1057 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1061 * Returns FALSE when there isn't enough space available to store
1064 static bool add_name(u32b *offset, header *head, concptr buf)
1066 /* Hack -- Verify space */
1067 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
1073 /* Advance and save the name index */
1074 *offset = ++head->name_size;
1077 /* Append chars to the names */
1078 strcpy(head->name_ptr + head->name_size, buf);
1080 /* Advance the index */
1081 head->name_size += strlen(buf);
1089 * @brief データの可変文字列情報をタグとして保管する /
1090 * Add a tag to the tag-storage and return an offset to it.
1091 * @param offset 文字列保管ポインタからのオフセット
1092 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1096 * Returns FALSE when there isn't enough space available to store
1099 static bool add_tag(STR_OFFSET *offset, header *head, concptr buf)
1103 /* Search for an existing (fake) tag */
1104 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1107 if (streq(&head->tag_ptr[i], buf)) break;
1110 /* There was no existing tag */
1111 if (i >= head->tag_size)
1113 /* Hack -- Verify space */
1114 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1117 /* Append chars to the tags */
1118 strcpy(head->tag_ptr + head->tag_size, buf);
1120 /* Point the new tag */
1123 /* Advance the index */
1124 head->tag_size += strlen(buf) + 1;
1127 /* Return offset of the tag */
1136 * @brief シンボル1文字をカラーIDに変更する /
1137 * Convert a "color letter" into an "actual" color
1138 * The colors are: dwsorgbuDWvyRGBU, as shown below
1142 byte color_char_to_attr(char c)
1146 case 'd': return (TERM_DARK);
1147 case 'w': return (TERM_WHITE);
1148 case 's': return (TERM_SLATE);
1149 case 'o': return (TERM_ORANGE);
1150 case 'r': return (TERM_RED);
1151 case 'g': return (TERM_GREEN);
1152 case 'b': return (TERM_BLUE);
1153 case 'u': return (TERM_UMBER);
1155 case 'D': return (TERM_L_DARK);
1156 case 'W': return (TERM_L_WHITE);
1157 case 'v': return (TERM_VIOLET);
1158 case 'y': return (TERM_YELLOW);
1159 case 'R': return (TERM_L_RED);
1160 case 'G': return (TERM_L_GREEN);
1161 case 'B': return (TERM_L_BLUE);
1162 case 'U': return (TERM_L_UMBER);
1170 /*** Initialize from ascii template files ***/
1174 * @brief パース関数に基づいてデータファイルからデータを読み取る /
1175 * Initialize an "*_info" array, by parsing an ascii "template" file
1176 * @param fp 読み取りに使うファイルポインタ
1177 * @param buf 読み取りに使うバッファ領域
1178 * @param head ヘッダ構造体
1179 * @param parse_info_txt_line パース関数
1182 errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line)
1186 /* Just before the first record */
1189 /* Just before the first line */
1193 /* Prepare the "fake" stuff */
1194 head->name_size = 0;
1195 head->text_size = 0;
1199 while (0 == my_fgets(fp, buf, 1024))
1201 /* Advance the line number */
1204 /* Skip comments and blank lines */
1205 if (!buf[0] || (buf[0] == '#')) continue;
1207 /* Verify correct "colon" format */
1208 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1211 /* Hack -- Process 'V' for "Version" */
1218 /* Mega Hack -- Calculate Check Sum */
1219 if (buf[0] != 'N' && buf[0] != 'D')
1222 for (i = 0; buf[i]; i++)
1224 head->v_extra += (byte)buf[i];
1225 head->v_extra ^= (1 << (i % 8));
1229 /* Parse the line */
1230 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1235 /* Complete the "name" and "text" sizes */
1236 if (head->name_size) head->name_size++;
1237 if (head->text_size) head->text_size++;
1245 * @brief Vault情報(v_info)のパース関数 /
1246 * Initialize the "v_info" array, by parsing an ascii "template" file
1248 * @param head ヘッダ構造体
1251 errr parse_v_info(char *buf, header *head)
1257 static vault_type *v_ptr = NULL;
1259 /* Process 'N' for "New/Number/Name" */
1262 /* Find the colon before the name */
1263 s = my_strchr(buf+2, ':');
1265 /* Verify that colon */
1268 /* Nuke the colon, advance to the name */
1271 /* Paranoia -- require a name */
1272 if (!*s) return (1);
1277 /* Verify information */
1278 if (i <= error_idx) return (4);
1280 /* Verify information */
1281 if (i >= head->info_num) return (2);
1283 /* Save the index */
1286 /* Point at the "info" */
1289 /* Store the name */
1290 if (!add_name(&v_ptr->name, head, s)) return (7);
1293 /* There better be a current v_ptr */
1294 else if (!v_ptr) return (3);
1296 /* Process 'D' for "Description" */
1297 else if (buf[0] == 'D')
1299 /* Acquire the text */
1302 /* Store the text */
1303 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1306 /* Process 'X' for "Extra info" (one line only) */
1307 else if (buf[0] == 'X')
1309 EFFECT_ID typ, rat, hgt, wid;
1311 /* Scan for the values */
1312 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1313 &typ, &rat, &hgt, &wid)) return (1);
1315 /* Save the values */
1316 v_ptr->typ = (ROOM_IDX)typ;
1317 v_ptr->rat = (PROB)rat;
1318 v_ptr->hgt = (POSITION)hgt;
1319 v_ptr->wid = (POSITION)wid;
1330 * @brief 職業技能情報(s_info)のパース関数 /
1331 * Initialize the "s_info" array, by parsing an ascii "template" file
1333 * @param head ヘッダ構造体
1336 errr parse_s_info(char *buf, header *head)
1341 static skill_table *s_ptr = NULL;
1344 /* Process 'N' for "New/Number/Name" */
1350 /* Verify information */
1351 if (i <= error_idx) return (4);
1353 /* Verify information */
1354 if (i >= head->info_num) return (2);
1356 /* Save the index */
1359 /* Point at the "info" */
1363 /* There better be a current s_ptr */
1364 else if (!s_ptr) return (3);
1366 /* Process 'W' for "Weapon exp" */
1367 else if (buf[0] == 'W')
1369 int tval, sval, start, max;
1370 const s16b exp_conv_table[] =
1372 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1373 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1376 /* Scan for the values */
1377 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1378 &tval, &sval, &start, &max)) return (1);
1380 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1381 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1383 /* Save the values */
1384 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1385 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1388 /* Process 'S' for "Skill exp" */
1389 else if (buf[0] == 'S')
1391 int num, start, max;
1393 /* Scan for the values */
1394 if (3 != sscanf(buf+2, "%d:%d:%d",
1395 &num, &start, &max)) return (1);
1397 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1398 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1400 /* Save the values */
1401 s_ptr->s_start[num] = (SUB_EXP)start;
1402 s_ptr->s_max[num] = (SUB_EXP)max;
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;
1545 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1546 * Grab one flag from a textual string
1547 * @param flags ビットフラグを追加する先の参照ポインタ
1548 * @param names トークン定義配列
1549 * @param what 参照元の文字列ポインタ
1552 static errr grab_one_flag(u32b *flags, concptr names[], concptr what)
1557 for (i = 0; i < 32; i++)
1559 if (streq(what, names[i]))
1561 *flags |= (1L << i);
1571 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1572 * Grab one flag in an feature_type from a textual string
1573 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1574 * @param what 参照元の文字列ポインタ
1577 static errr grab_one_feat_flag(feature_type *f_ptr, concptr what)
1582 for (i = 0; i < FF_FLAG_MAX; i++)
1584 if (streq(what, f_info_flags[i]))
1586 add_flag(f_ptr->flags, i);
1591 msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
1594 return PARSE_ERROR_GENERIC;
1599 * @brief テキストトークンを走査してフラグ(ステート)を一つ得る(地形情報向け2) /
1600 * Grab an action in an feature_type from a textual string
1601 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1602 * @param what 参照元の文字列ポインタ
1603 * @param count ステートの保存先ID
1606 static errr grab_one_feat_action(feature_type *f_ptr, concptr what, int count)
1611 for (i = 0; i < FF_FLAG_MAX; i++)
1613 if (streq(what, f_info_flags[i]))
1615 f_ptr->state[count].action = i;
1620 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1623 return PARSE_ERROR_GENERIC;
1628 * @brief 地形情報(f_info)のパース関数 /
1629 * Initialize the "f_info" array, by parsing an ascii "template" file
1631 * @param head ヘッダ構造体
1634 errr parse_f_info(char *buf, header *head)
1641 static feature_type *f_ptr = NULL;
1644 /* Process 'N' for "New/Number/Name" */
1647 /* Find the colon before the name */
1648 s = my_strchr(buf+2, ':');
1652 /* Nuke the colon, advance to the name */
1659 /* Verify information */
1660 if (i <= error_idx) return (4);
1662 /* Verify information */
1663 if (i >= head->info_num) return (2);
1665 /* Save the index */
1668 /* Point at the "info" */
1671 /* Tag name is given */
1675 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1678 /* Default "mimic" */
1679 f_ptr->mimic = (FEAT_IDX)i;
1681 /* Default "destroyed state" -- if not specified */
1682 f_ptr->destroyed = (FEAT_IDX)i;
1684 /* Default "states" */
1685 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1688 /* There better be a current f_ptr */
1689 else if (!f_ptr) return (3);
1692 else if (buf[0] == 'J')
1694 /* Store the name */
1695 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1698 else if (buf[0] == 'E')
1700 /* Ignore english name */
1703 else if (buf[0] == 'J')
1705 /* Ignore Japanese name */
1708 else if (buf[0] == 'E')
1710 /* Acquire the Text */
1713 /* Store the name */
1714 if (!add_name(&f_ptr->name, head, s)) return (7);
1719 /* Process 'M' for "Mimic" (one line only) */
1720 else if (buf[0] == 'M')
1724 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1726 /* Record a fake tag index */
1727 f_ptr->mimic_tag = offset;
1731 /* Process 'G' for "Graphics" (one line only) */
1732 else if (buf[0] == 'G')
1736 char char_tmp[F_LIT_MAX];
1739 if (buf[1] != ':') return (1);
1740 if (!buf[2]) return (1);
1741 if (buf[3] != ':') return (1);
1742 if (!buf[4]) return (1);
1744 /* Extract the char */
1745 char_tmp[F_LIT_STANDARD] = buf[2];
1747 /* Extract the color */
1748 s_attr = color_char_to_attr(buf[4]);
1751 if (s_attr > 127) return (1);
1753 /* Save the standard values */
1754 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1755 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1757 /* Is this feature supports lighting? */
1760 /* G:c:a:LIT (default) */
1761 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1763 /* G:c:a:lc:la:dc:da */
1764 if (!streq(buf + 6, "LIT"))
1766 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1768 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1769 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1770 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1771 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1773 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1775 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1778 /* Use default lighting */
1781 /* No lighting support */
1782 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1785 /* Extract the color */
1786 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1787 if (f_ptr->d_attr[j] > 127) return 1;
1790 f_ptr->d_char[j] = char_tmp[j];
1796 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1798 f_ptr->d_attr[j] = s_attr;
1799 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1805 /* Hack -- Process 'F' for flags */
1806 else if (buf[0] == 'F')
1808 /* Parse every entry textually */
1809 for (s = buf + 2; *s; )
1811 /* Find the end of this entry */
1812 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1814 /* Nuke and skip any dividers */
1818 while (*t == ' ' || *t == '|') t++;
1821 /* Hack -- Read feature subtype */
1822 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1824 /* Extract a "subtype" */
1825 f_ptr->subtype = (FEAT_SUBTYPE)i;
1827 /* Start at next entry */
1833 /* Hack -- Read feature power */
1834 if (1 == sscanf(s, "POWER_%d", &i))
1836 /* Extract a "power" */
1837 f_ptr->power = (FEAT_POWER)i;
1839 /* Start at next entry */
1844 /* Parse this entry */
1845 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1847 /* Start the next entry */
1852 /* Process 'W' for "More Info" (one line only) */
1853 else if (buf[0] == 'W')
1857 /* Scan for the value */
1858 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1860 /* Save the value */
1861 f_ptr->priority = (FEAT_PRIORITY)priority;
1864 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1865 else if (buf[0] == 'K')
1869 /* Find the next empty state slot (if any) */
1870 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1872 /* Oops, no more slots */
1873 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1875 /* Analyze the first field */
1876 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1878 /* Terminate the field (if necessary) */
1879 if (*t == ':') *t++ = '\0';
1881 /* Is this default entry? */
1882 if (streq(s, "DESTROYED"))
1884 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1886 /* Record a fake tag index */
1887 f_ptr->destroyed_tag = offset;
1892 f_ptr->state[i].action = 0;
1894 /* Parse this entry */
1895 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1897 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1899 /* Record a fake tag index */
1900 f_ptr->state[i].result_tag = offset;
1912 * @brief 地形タグからIDを得る /
1913 * Convert a fake tag to a real feat index
1917 s16b f_tag_to_index(concptr str)
1921 /* Search for real index corresponding to this fake tag */
1922 for (i = 0; i < f_head.info_num; i++)
1924 if (streq(f_tag + f_info[i].tag, str))
1926 /* Return the index */
1937 * @brief 地形タグからIDを得る /
1938 * Search for real index corresponding to this fake tag
1939 * @param feat タグ文字列のオフセット
1940 * @return 地形ID。該当がないなら-1
1942 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1946 /* Don't convert non-fake tag */
1952 /* Search for real index corresponding to this fake tag */
1953 for (i = 0; i < f_head.info_num; i++)
1955 if (feat == f_info[i].tag)
1957 /* Record real index */
1963 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1969 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1970 * Retouch fake tags of f_info
1971 * @param head ヘッダ構造体
1974 void retouch_f_info(header *head)
1978 /* Convert fake tags to real feat indices */
1979 for (i = 0; i < head->info_num; i++)
1981 feature_type *f_ptr = &f_info[i];
1984 k = search_real_feat(f_ptr->mimic_tag);
1985 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1986 k = search_real_feat(f_ptr->destroyed_tag);
1987 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1988 for (j = 0; j < MAX_FEAT_STATES; j++)
1990 k = search_real_feat(f_ptr->state[j].result_tag);
1991 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
1998 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
1999 * Grab one flag in an object_kind from a textual string
2000 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
2001 * @param what 参照元の文字列ポインタ
2004 static errr grab_one_kind_flag(object_kind *k_ptr, concptr what)
2009 for (i = 0; i < TR_FLAG_MAX; i++)
2011 if (streq(what, k_info_flags[i]))
2013 add_flag(k_ptr->flags, i);
2018 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2021 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2028 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2029 * Grab one activation index flag
2030 * @param what 参照元の文字列ポインタ
2033 static byte grab_one_activation_flag(concptr what)
2039 if (activation_info[i].flag == NULL) break;
2041 if (streq(what, activation_info[i].flag))
2043 return activation_info[i].index;
2053 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2061 * @brief ベースアイテム(k_info)のパース関数 /
2062 * Initialize the "k_info" array, by parsing an ascii "template" file
2064 * @param head ヘッダ構造体
2067 errr parse_k_info(char *buf, header *head)
2074 static object_kind *k_ptr = NULL;
2077 /* Process 'N' for "New/Number/Name" */
2084 /* Find the colon before the name */
2085 s = my_strchr(buf+2, ':');
2087 /* Verify that colon */
2090 /* Nuke the colon, advance to the name */
2096 /* Verify information */
2097 if (i <= error_idx) return (4);
2099 /* Verify information */
2100 if (i >= head->info_num) return (2);
2102 /* Save the index */
2105 /* Point at the "info" */
2109 /* Paranoia -- require a name */
2110 if (!*s) return (1);
2112 /* Find the colon before the flavor */
2113 flavor = my_strchr(s, ':');
2115 /* Verify that colon */
2118 /* Nuke the colon, advance to the flavor */
2121 /* Store the flavor */
2122 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2125 /* Store the name */
2126 if (!add_name(&k_ptr->name, head, s)) return (7);
2130 /* There better be a current k_ptr */
2131 else if (!k_ptr) return (3);
2136 /* 'E' から始まる行は英語名としている */
2137 else if (buf[0] == 'E')
2142 else if (buf[0] == 'E')
2146 /* Acquire the name */
2149 /* Find the colon before the flavor */
2150 flavor = my_strchr(s, ':');
2152 /* Verify that colon */
2155 /* Nuke the colon, advance to the flavor */
2158 /* Store the flavor */
2159 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2162 /* Store the name */
2163 if (!add_name(&k_ptr->name, head, s)) return (7);
2167 /* Process 'D' for "Description" */
2168 else if (buf[0] == 'D')
2173 /* Acquire the text */
2178 /* Acquire the text */
2182 /* Store the text */
2183 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2186 /* Process 'G' for "Graphics" (one line only) */
2187 else if (buf[0] == 'G')
2193 if (buf[1] != ':') return (1);
2194 if (!buf[2]) return (1);
2195 if (buf[3] != ':') return (1);
2196 if (!buf[4]) return (1);
2198 /* Extract the char */
2201 /* Extract the attr */
2202 tmp = color_char_to_attr(buf[4]);
2205 if (tmp > 127) return (1);
2207 /* Save the values */
2208 k_ptr->d_attr = tmp;
2209 k_ptr->d_char = sym;
2212 /* Process 'I' for "Info" (one line only) */
2213 else if (buf[0] == 'I')
2215 int tval, sval, pval;
2217 /* Scan for the values */
2218 if (3 != sscanf(buf+2, "%d:%d:%d",
2219 &tval, &sval, &pval)) return (1);
2221 /* Save the values */
2222 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2223 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2224 k_ptr->pval = (PARAMETER_VALUE)pval;
2227 /* Process 'W' for "More Info" (one line only) */
2228 else if (buf[0] == 'W')
2230 int level, extra, wgt;
2233 /* Scan for the values */
2234 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2235 &level, &extra, &wgt, &cost)) return (1);
2237 /* Save the values */
2238 k_ptr->level = (DEPTH)level;
2239 k_ptr->extra = (BIT_FLAGS8)extra;
2240 k_ptr->weight = (WEIGHT)wgt;
2241 k_ptr->cost = (PRICE)cost;
2244 /* Process 'A' for "Allocation" (one line only) */
2245 else if (buf[0] == 'A')
2248 /* Simply read each number following a colon */
2249 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2251 /* Default chance */
2252 k_ptr->chance[i] = 1;
2254 /* Store the attack damage index */
2255 k_ptr->locale[i] = atoi(s+1);
2257 /* Find the slash */
2258 t = my_strchr(s+1, '/');
2260 /* Find the next colon */
2261 s = my_strchr(s+1, ':');
2263 /* If the slash is "nearby", use it */
2264 if (t && (!s || t < s))
2266 int chance = atoi(t+1);
2267 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2272 /* Hack -- Process 'P' for "power" and such */
2273 else if (buf[0] == 'P')
2275 int ac, hd1, hd2, th, td, ta;
2277 /* Scan for the values */
2278 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2279 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2281 k_ptr->ac = (ARMOUR_CLASS)ac;
2282 k_ptr->dd = (DICE_NUMBER)hd1;
2283 k_ptr->ds = (DICE_SID)hd2;
2284 k_ptr->to_h = (HIT_PROB)th;
2285 k_ptr->to_d = (HIT_POINT)td;
2286 k_ptr->to_a = (ARMOUR_CLASS)ta;
2289 /* Hack -- Process 'U' for activation index */
2290 else if (buf[0] == 'U')
2293 n = grab_one_activation_flag(buf + 2);
2304 /* Hack -- Process 'F' for flags */
2305 else if (buf[0] == 'F')
2307 /* Parse every entry textually */
2308 for (s = buf + 2; *s; )
2310 /* Find the end of this entry */
2311 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2313 /* Nuke and skip any dividers */
2317 while (*t == ' ' || *t == '|') t++;
2320 /* Parse this entry */
2321 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2323 /* Start the next entry */
2337 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2338 * Grab one activation index flag
2339 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2340 * @param what 参照元の文字列ポインタ
2341 * @return エラーがあった場合1、エラーがない場合0を返す
2343 static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
2348 for (i = 0; i < TR_FLAG_MAX; i++)
2350 if (streq(what, k_info_flags[i]))
2352 add_flag(a_ptr->flags, i);
2357 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2360 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2368 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2369 * Initialize the "a_info" array, by parsing an ascii "template" file
2371 * @param head ヘッダ構造体
2374 errr parse_a_info(char *buf, header *head)
2381 static artifact_type *a_ptr = NULL;
2384 /* Process 'N' for "New/Number/Name" */
2387 /* Find the colon before the name */
2388 s = my_strchr(buf+2, ':');
2390 /* Verify that colon */
2393 /* Nuke the colon, advance to the name */
2396 /* Paranoia -- require a name */
2397 if (!*s) return (1);
2402 /* Verify information */
2403 if (i < error_idx) return (4);
2405 /* Verify information */
2406 if (i >= head->info_num) return (2);
2408 /* Save the index */
2411 /* Point at the "info" */
2414 /* Ignore everything */
2415 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2416 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2417 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2418 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2420 /* Store the name */
2421 if (!add_name(&a_ptr->name, head, s)) return (7);
2425 /* There better be a current a_ptr */
2426 else if (!a_ptr) return (3);
2431 /* 'E' から始まる行は英語名としている */
2432 else if (buf[0] == 'E')
2437 else if (buf[0] == 'E')
2439 /* Acquire the Text */
2442 /* Store the name */
2443 if (!add_name(&a_ptr->name, head, s)) return (7);
2447 /* Process 'D' for "Description" */
2448 else if (buf[0] == 'D')
2453 /* Acquire the text */
2458 /* Acquire the text */
2462 /* Store the text */
2463 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2467 /* Process 'I' for "Info" (one line only) */
2468 else if (buf[0] == 'I')
2470 int tval, sval, pval;
2472 /* Scan for the values */
2473 if (3 != sscanf(buf+2, "%d:%d:%d",
2474 &tval, &sval, &pval)) return (1);
2476 /* Save the values */
2477 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2478 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2479 a_ptr->pval = (PARAMETER_VALUE)pval;
2482 /* Process 'W' for "More Info" (one line only) */
2483 else if (buf[0] == 'W')
2485 int level, rarity, wgt;
2488 /* Scan for the values */
2489 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2490 &level, &rarity, &wgt, &cost)) return (1);
2492 /* Save the values */
2493 a_ptr->level = (DEPTH)level;
2494 a_ptr->rarity = (RARITY)rarity;
2495 a_ptr->weight = (WEIGHT)wgt;
2496 a_ptr->cost = (PRICE)cost;
2499 /* Hack -- Process 'P' for "power" and such */
2500 else if (buf[0] == 'P')
2502 int ac, hd1, hd2, th, td, ta;
2504 /* Scan for the values */
2505 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2506 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2508 a_ptr->ac = (ARMOUR_CLASS)ac;
2509 a_ptr->dd = (DICE_NUMBER)hd1;
2510 a_ptr->ds = (DICE_SID)hd2;
2511 a_ptr->to_h = (HIT_PROB)th;
2512 a_ptr->to_d = (HIT_POINT)td;
2513 a_ptr->to_a = (ARMOUR_CLASS)ta;
2516 /* Hack -- Process 'U' for activation index */
2517 else if (buf[0] == 'U')
2520 n = grab_one_activation_flag(buf + 2);
2531 /* Hack -- Process 'F' for flags */
2532 else if (buf[0] == 'F')
2534 /* Parse every entry textually */
2535 for (s = buf + 2; *s; )
2537 /* Find the end of this entry */
2538 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2540 /* Nuke and skip any dividers */
2544 while ((*t == ' ') || (*t == '|')) t++;
2547 /* Parse this entry */
2548 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2550 /* Start the next entry */
2565 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2566 * Grab one flag in a ego-item_type from a textual string
2567 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2568 * @param what 参照元の文字列ポインタ
2569 * @return エラーがあった場合1、エラーがない場合0を返す
2571 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
2576 for (i = 0; i < TR_FLAG_MAX; i++)
2578 if (streq(what, k_info_flags[i]))
2580 add_flag(e_ptr->flags, i);
2585 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2588 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2596 * @brief アイテムエゴ情報(e_info)のパース関数 /
2597 * Initialize the "e_info" array, by parsing an ascii "template" file
2599 * @param head ヘッダ構造体
2602 errr parse_e_info(char *buf, header *head)
2608 static ego_item_type *e_ptr = NULL;
2610 /* Just before the first record */
2613 /* Just before the first line */
2616 /* Process 'N' for "New/Number/Name" */
2619 /* Find the colon before the name */
2620 s = my_strchr(buf+2, ':');
2622 /* Verify that colon */
2625 /* Nuke the colon, advance to the name */
2628 /* Paranoia -- require a name */
2629 if (!*s) return (1);
2634 /* Verify information */
2635 if (i < error_idx) return (4);
2637 /* Verify information */
2638 if (i >= head->info_num) return (2);
2640 /* Save the index */
2643 /* Point at the "info" */
2646 /* Store the name */
2647 if (!add_name(&e_ptr->name, head, s)) return (7);
2651 /* There better be a current e_ptr */
2652 else if (!e_ptr) return (3);
2657 /* 'E' から始まる行は英語名 */
2658 else if (buf[0] == 'E')
2663 else if (buf[0] == 'E')
2665 /* Acquire the Text */
2668 /* Store the name */
2669 if (!add_name(&e_ptr->name, head, s)) return (7);
2674 /* Process 'D' for "Description" */
2675 else if (buf[0] == 'D')
2677 /* Acquire the text */
2680 /* Store the text */
2681 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2686 /* Process 'X' for "Xtra" (one line only) */
2687 else if (buf[0] == 'X')
2691 /* Scan for the values */
2692 if (2 != sscanf(buf+2, "%d:%d",
2693 &slot, &rating)) return (1);
2695 /* Save the values */
2696 e_ptr->slot = (INVENTORY_IDX)slot;
2697 e_ptr->rating = (PRICE)rating;
2700 /* Process 'W' for "More Info" (one line only) */
2701 else if (buf[0] == 'W')
2703 int level, rarity, pad2;
2706 /* Scan for the values */
2707 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2708 &level, &rarity, &pad2, &cost)) return (1);
2710 /* Save the values */
2711 e_ptr->level = level;
2712 e_ptr->rarity = (RARITY)rarity;
2713 /* e_ptr->weight = wgt; */
2717 /* Hack -- Process 'C' for "creation" */
2718 else if (buf[0] == 'C')
2720 int th, td, ta, pval;
2722 /* Scan for the values */
2723 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2724 &th, &td, &ta, &pval)) return (1);
2726 e_ptr->max_to_h = (HIT_PROB)th;
2727 e_ptr->max_to_d = (HIT_POINT)td;
2728 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2729 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2732 /* Hack -- Process 'U' for activation index */
2733 else if (buf[0] == 'U')
2736 n = grab_one_activation_flag(buf + 2);
2747 /* Hack -- Process 'F' for flags */
2748 else if (buf[0] == 'F')
2750 /* Parse every entry textually */
2751 for (s = buf + 2; *s; )
2753 /* Find the end of this entry */
2754 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2756 /* Nuke and skip any dividers */
2760 while ((*t == ' ') || (*t == '|')) t++;
2763 /* Parse this entry */
2764 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2766 /* Start the next entry */
2779 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2780 * Grab one (basic) flag in a monster_race from a textual string
2781 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2782 * @param what 参照元の文字列ポインタ
2785 static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
2787 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2790 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2793 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2796 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2799 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2802 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2805 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2808 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2816 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2817 * Grab one (spell) flag in a monster_race from a textual string
2818 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2819 * @param what 参照元の文字列ポインタ
2822 static errr grab_one_spell_flag(monster_race *r_ptr, concptr what)
2824 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2827 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2830 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2833 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2841 * @brief モンスター種族情報(r_info)のパース関数 /
2842 * Initialize the "r_info" array, by parsing an ascii "template" file
2844 * @param head ヘッダ構造体
2847 errr parse_r_info(char *buf, header *head)
2853 static monster_race *r_ptr = NULL;
2856 /* Process 'N' for "New/Number/Name" */
2859 /* Find the colon before the name */
2860 s = my_strchr(buf+2, ':');
2862 /* Verify that colon */
2865 /* Nuke the colon, advance to the name */
2868 /* Paranoia -- require a name */
2869 if (!*s) return (1);
2874 /* Verify information */
2875 if (i < error_idx) return (4);
2877 /* Verify information */
2878 if (i >= head->info_num) return (2);
2880 /* Save the index */
2883 /* Point at the "info" */
2886 /* Store the name */
2887 if (!add_name(&r_ptr->name, head, s)) return (7);
2891 /* There better be a current r_ptr */
2892 else if (!r_ptr) return (3);
2897 /* 'E' から始まる行は英語名 */
2898 else if (buf[0] == 'E')
2900 /* Acquire the Text */
2903 /* Store the name */
2904 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2907 else if (buf[0] == 'E')
2909 /* Acquire the Text */
2912 /* Store the name */
2913 if (!add_name(&r_ptr->name, head, s)) return (7);
2916 /* Process 'D' for "Description" */
2917 else if (buf[0] == 'D')
2922 /* Acquire the text */
2927 /* Acquire the text */
2931 /* Store the text */
2932 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2935 /* Process 'G' for "Graphics" (one line only) */
2936 else if (buf[0] == 'G')
2942 if (buf[1] != ':') return (1);
2943 if (!buf[2]) return (1);
2944 if (buf[3] != ':') return (1);
2945 if (!buf[4]) return (1);
2947 /* Extract the char */
2950 /* Extract the attr */
2951 tmp = color_char_to_attr(buf[4]);
2954 if (tmp > 127) return (1);
2956 /* Save the values */
2957 r_ptr->d_char = sym;
2958 r_ptr->d_attr = tmp;
2961 /* Process 'I' for "Info" (one line only) */
2962 else if (buf[0] == 'I')
2964 int spd, hp1, hp2, aaf, ac, slp;
2966 /* Scan for the other values */
2967 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2968 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2970 /* Save the values */
2971 r_ptr->speed = (SPEED)spd;
2972 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2973 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2974 r_ptr->aaf = (POSITION)aaf;
2975 r_ptr->ac = (ARMOUR_CLASS)ac;
2976 r_ptr->sleep = (SLEEP_DEGREE)slp;
2979 /* Process 'W' for "More Info" (one line only) */
2980 else if (buf[0] == 'W')
2987 /* Scan for the values */
2988 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2989 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2991 /* Save the values */
2992 r_ptr->level = (DEPTH)lev;
2993 r_ptr->rarity = (RARITY)rar;
2994 r_ptr->extra = (BIT_FLAGS16)pad;
2995 r_ptr->mexp = (EXP)exp;
2996 r_ptr->next_exp = (EXP)nextexp;
2997 r_ptr->next_r_idx = (IDX)nextmon;
3000 /* Process 'R' for "Reinforcement" (up to six lines) */
3001 else if (buf[0] == 'R')
3004 /* Find the next empty blow slot (if any) */
3005 for (i = 0; i < A_MAX; i++) if (r_ptr->reinforce_id[i] == 0) break;
3007 /* Oops, no more slots */
3008 if (i == 6) return (1);
3010 /* Scan for the values */
3011 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3012 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3013 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3014 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3017 /* Process 'B' for "Blows" (up to four lines) */
3018 else if (buf[0] == 'B')
3022 /* Find the next empty blow slot (if any) */
3023 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3025 /* Oops, no more slots */
3026 if (i == 4) return (1);
3028 /* Analyze the first field */
3029 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3031 /* Terminate the field (if necessary) */
3032 if (*t == ':') *t++ = '\0';
3034 /* Analyze the method */
3035 for (n1 = 0; r_info_blow_method[n1]; n1++)
3037 if (streq(s, r_info_blow_method[n1])) break;
3040 /* Invalid method */
3041 if (!r_info_blow_method[n1]) return (1);
3043 /* Analyze the second field */
3044 for (s = t; *t && (*t != ':'); t++) /* loop */;
3046 /* Terminate the field (if necessary) */
3047 if (*t == ':') *t++ = '\0';
3049 /* Analyze effect */
3050 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3052 if (streq(s, r_info_blow_effect[n2])) break;
3055 /* Invalid effect */
3056 if (!r_info_blow_effect[n2]) return (1);
3058 /* Analyze the third field */
3059 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3061 /* Terminate the field (if necessary) */
3062 if (*t == 'd') *t++ = '\0';
3064 /* Save the method */
3065 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3067 /* Save the effect */
3068 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3070 /* Extract the damage dice and sides */
3071 r_ptr->blow[i].d_dice = atoi(s);
3072 r_ptr->blow[i].d_side = atoi(t);
3075 /* Process 'F' for "Basic Flags" (multiple lines) */
3076 else if (buf[0] == 'F')
3078 /* Parse every entry */
3079 for (s = buf + 2; *s; )
3081 /* Find the end of this entry */
3082 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3084 /* Nuke and skip any dividers */
3088 while (*t == ' ' || *t == '|') t++;
3091 /* Parse this entry */
3092 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3094 /* Start the next entry */
3099 /* Process 'S' for "Spell Flags" (multiple lines) */
3100 else if (buf[0] == 'S')
3102 /* Parse every entry */
3103 for (s = buf + 2; *s; )
3105 /* Find the end of this entry */
3106 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3108 /* Nuke and skip any dividers */
3112 while ((*t == ' ') || (*t == '|')) t++;
3115 /* Hack -- Read spell frequency */
3116 if (1 == sscanf(s, "1_IN_%d", &i))
3118 /* Extract a "frequency" */
3119 r_ptr->freq_spell = 100 / i;
3121 /* Start at next entry */
3126 /* Parse this entry */
3127 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3129 /* Start the next entry */
3134 /* Process 'A' for "Artifact Flags" (multiple lines) */
3135 else if (buf[0] == 'A')
3137 int id, per, rarity;
3139 /* Find the next empty blow slot (if any) */
3140 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3142 /* Oops, no more slots */
3143 if (i == 4) return (1);
3145 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3146 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3147 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3148 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3151 /* Process 'V' for "Arena power value ratio" */
3152 else if (buf[0] == 'V')
3155 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3156 r_ptr->arena_ratio = (PERCENTAGE)val;
3168 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3169 * Grab one flag for a dungeon type from a textual string
3170 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3171 * @param what 参照元の文字列ポインタ
3174 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, concptr what)
3176 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3179 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3186 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3187 * Grab one (basic) flag in a monster_race from a textual string
3188 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3189 * @param what 参照元の文字列ポインタ
3192 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, concptr what)
3194 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3197 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3200 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3203 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3206 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3209 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3212 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3215 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3222 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3223 * Grab one (spell) flag in a monster_race from a textual string
3224 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3225 * @param what 参照元の文字列ポインタ
3228 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, concptr what)
3230 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3233 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3236 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3239 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3246 * @brief ダンジョン情報(d_info)のパース関数 /
3247 * Initialize the "d_info" array, by parsing an ascii "template" file
3249 * @param head ヘッダ構造体
3252 errr parse_d_info(char *buf, header *head)
3258 static dungeon_info_type *d_ptr = NULL;
3260 /* Process 'N' for "New/Number/Name" */
3263 /* Find the colon before the name */
3264 s = my_strchr(buf+2, ':');
3266 /* Verify that colon */
3269 /* Nuke the colon, advance to the name */
3272 /* Paranoia -- require a name */
3273 if (!*s) return (1);
3278 /* Verify information */
3279 if (i < error_idx) return (4);
3281 /* Verify information */
3282 if (i >= head->info_num) return (2);
3284 /* Save the index */
3287 /* Point at the "info" */
3290 /* Store the name */
3291 if (!add_name(&d_ptr->name, head, s)) return (7);
3296 else if (buf[0] == 'E') return (0);
3298 else if (buf[0] == 'E')
3300 /* Acquire the Text */
3303 /* Store the name */
3304 if (!add_name(&d_ptr->name, head, s)) return (7);
3308 /* Process 'D' for "Description */
3309 else if (buf[0] == 'D')
3314 /* Acquire the text */
3319 /* Acquire the text */
3323 /* Store the text */
3324 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3327 /* Process 'W' for "More Info" (one line only) */
3328 else if (buf[0] == 'W')
3330 int min_lev, max_lev;
3332 int min_alloc, max_chance;
3333 int obj_good, obj_great;
3336 /* Scan for the values */
3337 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3338 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3340 /* Save the values */
3341 d_ptr->mindepth = (DEPTH)min_lev;
3342 d_ptr->maxdepth = (DEPTH)max_lev;
3343 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3344 d_ptr->mode = (BIT_FLAGS8)mode;
3345 d_ptr->min_m_alloc_level = min_alloc;
3346 d_ptr->max_m_alloc_chance = max_chance;
3347 d_ptr->obj_good = obj_good;
3348 d_ptr->obj_great = obj_great;
3349 d_ptr->pit = (BIT_FLAGS16)pit;
3350 d_ptr->nest = (BIT_FLAGS16)nest;
3353 /* Process 'P' for "Place Info" */
3354 else if (buf[0] == 'P')
3358 /* Scan for the values */
3359 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3361 /* Save the values */
3366 /* Process 'L' for "fLoor type" (one line only) */
3367 else if (buf[0] == 'L')
3371 /* Scan for the values */
3372 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3374 /* Save the values */
3375 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3377 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3378 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3380 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3382 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3385 /* Process 'A' for "wAll type" (one line only) */
3386 else if (buf[0] == 'A')
3390 /* Scan for the values */
3391 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3393 /* Save the values */
3394 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3396 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3397 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3399 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3402 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3403 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3405 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3406 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3408 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3409 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3411 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3412 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3415 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3416 else if (buf[0] == 'F')
3418 int artif = 0, monst = 0;
3420 /* Parse every entry */
3421 for (s = buf + 2; *s; )
3423 /* Find the end of this entry */
3424 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3426 /* Nuke and skip any dividers */
3430 while (*t == ' ' || *t == '|') t++;
3433 /* Hack -- Read Final Artifact */
3434 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3436 /* Extract a "Final Artifact" */
3437 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3439 /* Start at next entry */
3444 /* Hack -- Read Final Object */
3445 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3447 /* Extract a "Final Artifact" */
3448 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3450 /* Start at next entry */
3455 /* Hack -- Read Artifact Guardian */
3456 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3458 /* Extract a "Artifact Guardian" */
3459 d_ptr->final_guardian = (MONRACE_IDX)monst;
3461 /* Start at next entry */
3466 /* Hack -- Read Special Percentage */
3467 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3469 /* Extract a "Special %" */
3470 d_ptr->special_div = (PROB)monst;
3472 /* Start at next entry */
3477 /* Parse this entry */
3478 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3480 /* Start the next entry */
3485 /* Process 'M' for "Basic Flags" (multiple lines) */
3486 else if (buf[0] == 'M')
3488 /* Parse every entry */
3489 for (s = buf + 2; *s; )
3491 /* Find the end of this entry */
3492 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3494 /* Nuke and skip any dividers */
3498 while (*t == ' ' || *t == '|') t++;
3501 /* Hack -- Read monster symbols */
3502 if (!strncmp(s, "R_CHAR_", 7))
3504 /* Skip "R_CHAR_" */
3508 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3510 /* Start at next entry */
3515 /* Parse this entry */
3516 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3518 /* Start the next entry */
3523 /* Process 'S' for "Spell Flags" (multiple lines) */
3524 else if (buf[0] == 'S')
3526 /* Parse every entry */
3527 for (s = buf + 2; *s; )
3529 /* Find the end of this entry */
3530 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3532 /* Nuke and skip any dividers */
3536 while ((*t == ' ') || (*t == '|')) t++;
3539 /* Hack -- Read spell frequency */
3540 if (1 == sscanf(s, "1_IN_%d", &i))
3542 /* Start at next entry */
3547 /* Parse this entry */
3548 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3550 /* Start the next entry */
3562 #else /* ALLOW_TEMPLATES */
3568 #endif /* ALLOW_TEMPLATES */
3571 /* Random dungeon grid effects */
3572 #define RANDOM_NONE 0x00000000
3573 #define RANDOM_FEATURE 0x00000001
3574 #define RANDOM_MONSTER 0x00000002
3575 #define RANDOM_OBJECT 0x00000004
3576 #define RANDOM_EGO 0x00000008
3577 #define RANDOM_ARTIFACT 0x00000010
3578 #define RANDOM_TRAP 0x00000020
3581 typedef struct dungeon_grid dungeon_grid;
3585 FEAT_IDX feature; /* Terrain feature */
3586 MONSTER_IDX monster; /* Monster */
3587 OBJECT_IDX object; /* Object */
3588 EGO_IDX ego; /* Ego-Item */
3589 ARTIFACT_IDX artifact; /* Artifact */
3590 IDX trap; /* Trap */
3591 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3592 s16b special; /* Reserved for special terrain info */
3593 int random; /* Number of the random effect */
3597 static dungeon_grid letter[255];
3601 * @brief 地形情報の「F:」情報をパースする
3602 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3606 static errr parse_line_feature(char *buf)
3611 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3613 /* Tokenize the line */
3614 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3616 /* Letter to assign */
3617 int index = zz[0][0];
3619 /* Reset the info for the letter */
3620 letter[index].feature = feat_none;
3621 letter[index].monster = 0;
3622 letter[index].object = 0;
3623 letter[index].ego = 0;
3624 letter[index].artifact = 0;
3625 letter[index].trap = feat_none;
3626 letter[index].cave_info = 0;
3627 letter[index].special = 0;
3628 letter[index].random = RANDOM_NONE;
3634 letter[index].special = (s16b)atoi(zz[8]);
3638 if ((zz[7][0] == '*') && !zz[7][1])
3640 letter[index].random |= RANDOM_TRAP;
3644 letter[index].trap = f_tag_to_index(zz[7]);
3645 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3650 if (zz[6][0] == '*')
3652 letter[index].random |= RANDOM_ARTIFACT;
3653 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3655 else if (zz[6][0] == '!')
3657 if (p_ptr->inside_quest)
3659 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3664 letter[index].artifact = (IDX)atoi(zz[6]);
3669 if (zz[5][0] == '*')
3671 letter[index].random |= RANDOM_EGO;
3672 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3676 letter[index].ego = (IDX)atoi(zz[5]);
3681 if (zz[4][0] == '*')
3683 letter[index].random |= RANDOM_OBJECT;
3684 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3686 else if (zz[4][0] == '!')
3688 if (p_ptr->inside_quest)
3690 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3693 artifact_type *a_ptr = &a_info[a_idx];
3694 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3696 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3703 letter[index].object = (IDX)atoi(zz[4]);
3708 if (zz[3][0] == '*')
3710 letter[index].random |= RANDOM_MONSTER;
3711 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3713 else if (zz[3][0] == 'c')
3715 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3716 letter[index].monster = - atoi(zz[3] + 1);
3720 letter[index].monster = (IDX)atoi(zz[3]);
3725 letter[index].cave_info = atoi(zz[2]);
3729 if ((zz[1][0] == '*') && !zz[1][1])
3731 letter[index].random |= RANDOM_FEATURE;
3735 letter[index].feature = f_tag_to_index(zz[1]);
3736 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3749 * @brief 地形情報の「B:」情報をパースする
3750 * Process "B:<Index>:<Command>:..." -- Building definition
3754 static errr parse_line_building(char *buf)
3770 /* Get the building number */
3773 /* Find the colon after the building number */
3774 s = my_strchr(s, ':');
3776 /* Verify that colon */
3779 /* Nuke the colon, advance to the sub-index */
3782 /* Paranoia -- require a sub-index */
3783 if (!*s) return (1);
3785 /* Building definition sub-index */
3788 /* Building name, owner, race */
3791 if (tokenize(s + 2, 3, zz, 0) == 3)
3793 /* Name of the building */
3794 strcpy(building[index].name, zz[0]);
3796 /* Name of the owner */
3797 strcpy(building[index].owner_name, zz[1]);
3799 /* Race of the owner */
3800 strcpy(building[index].owner_race, zz[2]);
3805 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3808 /* Building Action */
3811 if (tokenize(s + 2, 8, zz, 0) >= 7)
3813 /* Index of the action */
3814 int action_index = atoi(zz[0]);
3816 /* Name of the action */
3817 strcpy(building[index].act_names[action_index], zz[1]);
3819 /* Cost of the action for members */
3820 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3822 /* Cost of the action for non-members */
3823 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3825 /* Letter assigned to the action */
3826 building[index].letters[action_index] = zz[4][0];
3829 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3831 /* Action restriction */
3832 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3837 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3840 /* Building Classes */
3844 n = tokenize(s + 2, MAX_CLASS, zz, 0);
3847 for (i = 0; i < MAX_CLASS; i++)
3849 building[index].member_class[i] = ((i > n) ? (CLASS_IDX)atoi(zz[i]) : 1);
3855 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3858 /* Building Races */
3862 n = tokenize(s + 2, MAX_RACES, zz, 0);
3865 for (i = 0; i < MAX_RACES; i++)
3867 building[index].member_race[i] = ((i > n) ? (RACE_IDX)atoi(zz[i]) : 1);
3873 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3876 /* Building Realms */
3880 n = tokenize(s + 2, MAX_MAGIC, zz, 0);
3883 for (i = 0; i < MAX_MAGIC; i++)
3885 building[index].member_realm[i+1] = ((i > n) ? (REALM_IDX)atoi(zz[i]) : 1);
3891 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3896 /* Ignore scripts */
3902 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3911 * @brief フロアの所定のマスにオブジェクトを配置する
3912 * Place the object j_ptr to a grid
3913 * @param j_ptr オブジェクト構造体の参照ポインタ
3918 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3920 cave_type *c_ptr = &cave[y][x];
3923 OBJECT_IDX o_idx = o_pop();
3925 /* Access new object */
3926 o_ptr = &o_list[o_idx];
3928 /* Structure copy */
3929 object_copy(o_ptr, j_ptr);
3936 o_ptr->held_m_idx = 0;
3939 o_ptr->next_o_idx = c_ptr->o_idx;
3941 /* Place the object */
3942 c_ptr->o_idx = o_idx;
3947 * @brief クエスト用固定ダンジョンをフロアに生成する
3948 * Parse a sub-file of the "extra info"
3958 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3963 /* Skip "empty" lines */
3964 if (!buf[0]) return (0);
3966 /* Skip "blank" lines */
3967 if (iswspace(buf[0])) return (0);
3970 if (buf[0] == '#') return (0);
3972 /* Require "?:*" format */
3973 if (buf[1] != ':') return (1);
3976 /* Process "%:<fname>" */
3979 /* Attempt to Process the given file */
3980 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3983 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3986 return parse_line_feature(buf);
3989 /* Process "D:<dungeon>" -- info for the cave grids */
3990 else if (buf[0] == 'D')
3992 object_type object_type_body;
3994 /* Acquire the text */
3997 /* Length of the text */
3998 int len = strlen(s);
4000 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
4002 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
4004 cave_type *c_ptr = &cave[*y][*x];
4008 OBJECT_IDX object_index = letter[idx].object;
4009 MONSTER_IDX monster_index = letter[idx].monster;
4010 int random = letter[idx].random;
4011 ARTIFACT_IDX artifact_index = letter[idx].artifact;
4013 /* Lay down a floor */
4014 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4016 /* Only the features */
4017 if (init_flags & INIT_ONLY_FEATURES) continue;
4020 c_ptr->info = letter[idx].cave_info;
4022 /* Create a monster */
4023 if (random & RANDOM_MONSTER)
4025 monster_level = base_level + monster_index;
4027 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4029 monster_level = base_level;
4031 else if (monster_index)
4033 int old_cur_num, old_max_num;
4036 if (monster_index < 0)
4038 monster_index = -monster_index;
4041 old_cur_num = r_info[monster_index].cur_num;
4042 old_max_num = r_info[monster_index].max_num;
4044 /* Make alive again */
4045 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4047 r_info[monster_index].cur_num = 0;
4048 r_info[monster_index].max_num = 1;
4051 /* Make alive again */
4052 /* Hack -- Non-unique Nazguls are semi-unique */
4053 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4055 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4057 r_info[monster_index].max_num++;
4062 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4066 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4068 /* Make alive again for real unique monster */
4069 r_info[monster_index].cur_num = old_cur_num;
4070 r_info[monster_index].max_num = old_max_num;
4074 /* Object (and possible trap) */
4075 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4077 object_level = base_level + object_index;
4080 * Random trap and random treasure defined
4081 * 25% chance for trap and 75% chance for object
4083 if (randint0(100) < 75)
4085 place_object(*y, *x, 0L);
4092 object_level = base_level;
4094 else if (random & RANDOM_OBJECT)
4096 object_level = base_level + object_index;
4098 /* Create an out of deep object */
4099 if (randint0(100) < 75)
4100 place_object(*y, *x, 0L);
4101 else if (randint0(100) < 80)
4102 place_object(*y, *x, AM_GOOD);
4104 place_object(*y, *x, AM_GOOD | AM_GREAT);
4106 object_level = base_level;
4109 else if (random & RANDOM_TRAP)
4113 /* Hidden trap (or door) */
4114 else if (letter[idx].trap)
4116 c_ptr->mimic = c_ptr->feat;
4117 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4119 else if (object_index)
4121 object_type *o_ptr = &object_type_body;
4122 object_prep(o_ptr, object_index);
4124 if (o_ptr->tval == TV_GOLD)
4126 coin_type = object_index - OBJ_GOLD_LIST;
4131 /* Apply magic (no messages, no artifacts) */
4132 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4134 drop_here(o_ptr, *y, *x);
4140 if (a_info[artifact_index].cur_num)
4142 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4144 object_type *q_ptr = &forge;
4146 object_prep(q_ptr, k_idx);
4147 drop_here(q_ptr, *y, *x);
4151 /* Create the artifact */
4152 if (create_named_art(artifact_index, *y, *x))
4153 a_info[artifact_index].cur_num = 1;
4157 /* Terrain special */
4158 c_ptr->special = letter[idx].special;
4166 /* Process "Q:<number>:<command>:... -- quest info */
4167 else if (buf[0] == 'Q')
4174 num = tokenize(buf + 2, 33, zz, 0);
4178 num = tokenize(buf + 3, 33, zz, 0);
4181 /* Have we enough parameters? */
4182 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4185 q_ptr = &(quest[atoi(zz[0])]);
4187 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4188 if (zz[1][0] == 'Q')
4190 if (init_flags & INIT_ASSIGN)
4192 monster_race *r_ptr;
4193 artifact_type *a_ptr;
4195 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4197 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4198 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4199 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4200 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4201 q_ptr->level = (DEPTH)atoi(zz[6]);
4202 q_ptr->r_idx = (IDX)atoi(zz[7]);
4203 q_ptr->k_idx = (IDX)atoi(zz[8]);
4204 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4206 if (num > 10) q_ptr->flags = atoi(zz[10]);
4208 r_ptr = &r_info[q_ptr->r_idx];
4209 if (r_ptr->flags1 & RF1_UNIQUE)
4210 r_ptr->flags1 |= RF1_QUESTOR;
4212 a_ptr = &a_info[q_ptr->k_idx];
4213 a_ptr->gen_flags |= TRG_QUESTITEM;
4218 else if (zz[1][0] == 'R')
4220 if (init_flags & INIT_ASSIGN)
4223 IDX idx, reward_idx = 0;
4225 for (idx = 2; idx < num; idx++)
4227 IDX a_idx = (IDX)atoi(zz[idx]);
4228 if (a_idx < 1) continue;
4229 if (a_info[a_idx].cur_num > 0) continue;
4231 if (one_in_(count)) reward_idx = a_idx;
4236 /* Set quest's rewarding artifact */
4237 q_ptr->k_idx = reward_idx;
4238 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4242 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4243 q_ptr->type = QUEST_TYPE_KILL_ALL;
4250 /* Process "Q:<q_index>:N:<name>" -- quest name */
4251 else if (zz[1][0] == 'N')
4253 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4255 strcpy(q_ptr->name, zz[2]);
4261 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4262 else if (zz[1][0] == 'T')
4264 if (init_flags & INIT_SHOW_TEXT)
4266 strcpy(quest_text[quest_text_line], zz[2]);
4274 /* Process "W:<command>: ..." -- info for the wilderness */
4275 else if (buf[0] == 'W')
4277 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4280 /* Process "P:<y>:<x>" -- player position */
4281 else if (buf[0] == 'P')
4283 if (init_flags & INIT_CREATE_DUNGEON)
4285 if (tokenize(buf + 2, 2, zz, 0) == 2)
4287 int panels_x, panels_y;
4289 /* Hack - Set the dungeon size */
4290 panels_y = (*y / SCREEN_HGT);
4291 if (*y % SCREEN_HGT) panels_y++;
4292 cur_hgt = panels_y * SCREEN_HGT;
4294 panels_x = (*x / SCREEN_WID);
4295 if (*x % SCREEN_WID) panels_x++;
4296 cur_wid = panels_x * SCREEN_WID;
4298 /* Assume illegal panel */
4299 panel_row_min = cur_hgt;
4300 panel_col_min = cur_wid;
4302 /* Place player in a quest level */
4303 if (p_ptr->inside_quest)
4307 /* Delete the monster (if any) */
4308 delete_monster(p_ptr->y, p_ptr->x);
4316 /* Place player in the town */
4317 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4319 p_ptr->oldpy = atoi(zz[0]);
4320 p_ptr->oldpx = atoi(zz[1]);
4328 /* Process "B:<Index>:<Command>:..." -- Building definition */
4329 else if (buf[0] == 'B')
4331 return parse_line_building(buf);
4334 /* Process "M:<type>:<maximum>" -- set maximum values */
4335 else if (buf[0] == 'M')
4337 if (tokenize(buf+2, 2, zz, 0) == 2)
4340 if (zz[0][0] == 'T')
4342 max_towns = (IDX)atoi(zz[1]);
4345 /* Maximum quests */
4346 else if (zz[0][0] == 'Q')
4348 max_q_idx = (IDX)atoi(zz[1]);
4352 else if (zz[0][0] == 'R')
4354 max_r_idx = (IDX)atoi(zz[1]);
4358 else if (zz[0][0] == 'K')
4360 max_k_idx = (IDX)atoi(zz[1]);
4364 else if (zz[0][0] == 'V')
4366 max_v_idx = (IDX)atoi(zz[1]);
4370 else if (zz[0][0] == 'F')
4372 max_f_idx = (IDX)atoi(zz[1]);
4376 else if (zz[0][0] == 'A')
4378 max_a_idx = (IDX)atoi(zz[1]);
4382 else if (zz[0][0] == 'E')
4384 max_e_idx = (IDX)atoi(zz[1]);
4388 else if (zz[0][0] == 'D')
4390 max_d_idx = (IDX)atoi(zz[1]);
4394 else if (zz[0][0] == 'O')
4396 max_o_idx = (IDX)atoi(zz[1]);
4400 else if (zz[0][0] == 'M')
4402 max_m_idx = (IDX)atoi(zz[1]);
4405 /* Wilderness size */
4406 else if (zz[0][0] == 'W')
4408 /* Maximum wild_x_size */
4409 if (zz[0][1] == 'X')
4410 max_wild_x = atoi(zz[1]);
4411 /* Maximum wild_y_size */
4412 if (zz[0][1] == 'Y')
4413 max_wild_y = atoi(zz[1]);
4427 static concptr variant = "ZANGBAND";
4431 * @brief クエスト用固定ダンジョン生成時の分岐処理
4432 * Helper function for "process_dungeon_file()"
4437 static concptr process_dungeon_file_expr(char **sp, char *fp)
4453 while (iswspace(*s)) s++;
4471 t = process_dungeon_file_expr(&s, &f);
4479 else if (streq(t, "IOR"))
4482 while (*s && (f != b2))
4484 t = process_dungeon_file_expr(&s, &f);
4485 if (*t && !streq(t, "0")) v = "1";
4490 else if (streq(t, "AND"))
4493 while (*s && (f != b2))
4495 t = process_dungeon_file_expr(&s, &f);
4496 if (*t && streq(t, "0")) v = "0";
4501 else if (streq(t, "NOT"))
4504 while (*s && (f != b2))
4506 t = process_dungeon_file_expr(&s, &f);
4507 if (*t && streq(t, "1")) v = "0";
4512 else if (streq(t, "EQU"))
4515 if (*s && (f != b2))
4517 t = process_dungeon_file_expr(&s, &f);
4519 while (*s && (f != b2))
4521 p = process_dungeon_file_expr(&s, &f);
4522 if (streq(t, p)) v = "1";
4527 else if (streq(t, "LEQ"))
4530 if (*s && (f != b2))
4532 t = process_dungeon_file_expr(&s, &f);
4534 while (*s && (f != b2))
4537 t = process_dungeon_file_expr(&s, &f);
4538 if (*t && atoi(p) > atoi(t)) v = "0";
4543 else if (streq(t, "GEQ"))
4546 if (*s && (f != b2))
4548 t = process_dungeon_file_expr(&s, &f);
4550 while (*s && (f != b2))
4553 t = process_dungeon_file_expr(&s, &f);
4555 /* Compare two numbers instead of string */
4556 if (*t && atoi(p) < atoi(t)) v = "0";
4562 while (*s && (f != b2))
4564 t = process_dungeon_file_expr(&s, &f);
4569 if (f != b2) v = "?x?x?";
4571 /* Extract final and Terminate */
4572 if ((f = *s) != '\0') *s++ = '\0';
4578 /* Accept all printables except spaces and brackets */
4580 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4582 if (iskanji(*s)) s++;
4586 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4589 /* Extract final and Terminate */
4590 if ((f = *s) != '\0') *s++ = '\0';
4596 if (streq(b+1, "SYS"))
4602 else if (streq(b+1, "GRAF"))
4607 else if (streq(b+1, "MONOCHROME"))
4616 else if (streq(b+1, "RACE"))
4618 v = _(rp_ptr->E_title, rp_ptr->title);
4622 else if (streq(b+1, "CLASS"))
4624 v = _(cp_ptr->E_title, cp_ptr->title);
4628 else if (streq(b+1, "REALM1"))
4630 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4634 else if (streq(b+1, "REALM2"))
4636 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4640 else if (streq(b+1, "PLAYER"))
4642 static char tmp_player_name[32];
4644 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4654 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4657 v = tmp_player_name;
4661 else if (streq(b+1, "TOWN"))
4663 sprintf(tmp, "%d", p_ptr->town_num);
4668 else if (streq(b+1, "LEVEL"))
4670 sprintf(tmp, "%d", p_ptr->lev);
4674 /* Current quest number */
4675 else if (streq(b+1, "QUEST_NUMBER"))
4677 sprintf(tmp, "%d", p_ptr->inside_quest);
4681 /* Number of last quest */
4682 else if (streq(b+1, "LEAVING_QUEST"))
4684 sprintf(tmp, "%d", leaving_quest);
4689 else if (prefix(b+1, "QUEST_TYPE"))
4691 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4692 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4697 else if (prefix(b+1, "QUEST"))
4699 /* "QUEST" uses a special parameter to determine the number of the quest */
4700 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4705 else if (prefix(b+1, "RANDOM"))
4707 /* "RANDOM" uses a special parameter to determine the number of the quest */
4708 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4713 else if (streq(b+1, "VARIANT"))
4719 else if (streq(b+1, "WILDERNESS"))
4722 sprintf(tmp, "NONE");
4724 sprintf(tmp, "LITE");
4726 sprintf(tmp, "NORMAL");
4746 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4747 * Helper function for "process_dungeon_file()"
4755 errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax)
4761 bool bypass = FALSE;
4762 int x = xmin, y = ymin;
4765 /* Build the filename */
4766 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4769 fp = my_fopen(buf, "r");
4772 if (!fp) return (-1);
4775 /* Process the file */
4776 while (0 == my_fgets(fp, buf, sizeof(buf)))
4782 /* Skip "empty" lines */
4783 if (!buf[0]) continue;
4785 /* Skip "blank" lines */
4786 if (iswspace(buf[0])) continue;
4789 if (buf[0] == '#') continue;
4792 /* Process "?:<expr>" */
4793 if ((buf[0] == '?') && (buf[1] == ':'))
4802 /* Parse the expr */
4803 v = process_dungeon_file_expr(&s, &f);
4806 bypass = (streq(v, "0") ? TRUE : FALSE);
4810 /* Apply conditionals */
4811 if (bypass) continue;
4813 /* Process the line */
4814 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4825 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4827 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4828 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4840 void write_r_info_txt(void)
4842 int i, j, z, fc, bc;
4845 concptr flags[32 * 10];
4850 monster_race *r_ptr;
4852 monster_blow *b_ptr;
4854 FILE *fff = fopen("output.txt", "wt");
4858 BIT_FLAGS mode = -1;
4862 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4864 fprintf(fff, "# Version stamp (required)\n\n");
4867 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4870 fprintf(fff, "##### The Player #####\n\n");
4872 for (z = -1; z < alloc_race_size; z++)
4874 /* Output the monsters in order */
4875 i = (z >= 0) ? alloc_race_table[z].index : 0;
4877 /* Acquire the monster */
4880 /* Ignore empty monsters */
4881 if (!strlen(r_name + r_ptr->name)) continue;
4883 /* Ignore useless monsters */
4884 if (i && !r_ptr->speed) continue;
4886 /* Write a note if necessary */
4887 if (i && (!r_ptr->level != !mode))
4892 fprintf(fff, "\n##### Town monsters #####\n\n");
4894 /* Note the dungeon */
4897 fprintf(fff, "\n##### Normal monsters #####\n\n");
4900 /* Record the change */
4901 mode = r_ptr->level;
4904 /* Acquire the flags */
4905 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4906 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4907 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4908 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4909 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4910 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4911 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4912 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4913 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4914 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4916 /* Write New/Number/Name */
4917 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4920 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4922 /* Write Information */
4923 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4924 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4926 /* Write more information */
4927 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4930 for(j = 0; j < 4; j++)
4932 b_ptr = &(r_ptr->blow[j]);
4934 /* Stop when done */
4935 if (!b_ptr->method) break;
4937 /* Write the blows */
4938 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4939 r_info_blow_effect[b_ptr->effect],
4940 b_ptr->d_dice, b_ptr->d_side);
4942 for (fc = 0, j = 0; j < 32 * 3; j++)
4944 /* Check this flag */
4945 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4948 /* Extract the extra flags */
4949 for (j = 32 * 6; j < 32 * 10; j++)
4951 /* Check this flag */
4952 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4955 /* Write the flags */
4956 for (j = 0; j < fc;)
4960 /* Start the line */
4963 for (bc = 0; (bc < 60) && (j < fc); j++)
4967 /* Format the flag */
4968 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4970 /* Add it to the buffer */
4973 /* Note the length */
4977 /* Done with this line; write it */
4978 fprintf(fff, "%s\n", buf);
4981 /* Write Spells if applicable */
4982 if (r_ptr->freq_spell)
4984 /* Write the frequency */
4985 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4987 /* Extract the spell flags */
4988 for (fc = 0, j = 96; j < 192; j++)
4990 /* Check this flag */
4991 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4994 /* Write the flags */
4995 for (j = 0; j < fc;)
4999 /* Start the line */
5002 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5006 /* Format the flag */
5007 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5011 /* Note the length */
5018 /* Done with this line; write it */
5019 fprintf(fff, "%s\n", buf);
5023 /* Acquire the description */
5024 desc = r_text + r_ptr->text;
5025 dlen = strlen(desc);
5027 /* Write Description */
5028 for (j = 0; j < dlen;)
5032 /* Start the line */
5035 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5043 /* Done with this line; write it */
5044 fprintf(fff, "%s\n", buf);
5047 /* Space between entries */