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 #include "cmd-activate.h"
58 #ifdef ALLOW_TEMPLATES
63 /*** Helper arrays for parsing ascii template files ***/
67 * Monster Blow Methods
69 static concptr r_info_blow_method[] =
102 * モンスターの打撃属性トークンの定義 /
103 * Monster Blow Effects
105 static concptr r_info_blow_effect[] =
150 static concptr f_info_flags[] =
275 static concptr r_info_flags1[] =
315 static concptr r_info_flags2[] =
355 static concptr r_info_flags3[] =
395 static concptr r_info_flags4[] =
432 * モンスター特性トークン(発動型能力1) /
435 static concptr r_a_ability_flags1[] =
472 * モンスター特性トークン(発動型能力2) /
475 static concptr r_a_ability_flags2[] =
492 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
513 * モンスター特性トークン(発動型能力3) /
516 static concptr r_a_ability_flags3[] =
555 * モンスター特性トークン(発動型能力4) /
558 static concptr r_a_ability_flags4[] =
600 static concptr r_info_flags7[] =
640 static concptr r_info_flags8[] =
672 "WILD_SWAMP", /* ToDo: Implement Swamp */
681 static concptr r_info_flags9[] =
720 * モンスター特性トークンの定義R(耐性) /
723 static concptr r_info_flagsr[] =
761 * オブジェクト基本特性トークンの定義 /
764 static concptr k_info_flags[] =
861 "XXX3", /* Fake flag for Smith */
862 "XXX4", /* Fake flag for Smith */
912 * オブジェクト生成特性トークンの定義 /
915 static concptr k_info_gen_flags[] =
955 static concptr d_info_flags1[] =
993 * @brief データの可変文字列情報をテキストとして保管する /
994 * Add a text to the text-storage and store offset to it.
995 * @param offset 文字列保管ポインタからのオフセット
996 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
998 * @param normal_text テキストの正規化を行う
1001 * Returns FALSE when there isn't enough space available to store
1004 static bool add_text(u32b *offset, header *head, concptr buf, bool normal_text)
1006 /* Hack -- Verify space */
1007 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
1013 /* Advance and save the text index */
1014 *offset = ++head->text_size;
1017 /* Additional text */
1018 else if (normal_text)
1021 * If neither the end of the last line nor
1022 * the beginning of current line is not a space,
1023 * fill up a space as a correct separator of two words.
1025 if (head->text_size > 0 &&
1027 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1028 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
1029 (buf[0] != ' ') && !iskanji(buf[0])
1031 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1036 /* Append a space */
1037 *(head->text_ptr + head->text_size) = ' ';
1039 /* Advance the index */
1044 /* Append chars to the text */
1045 strcpy(head->text_ptr + head->text_size, buf);
1047 /* Advance the index */
1048 head->text_size += strlen(buf);
1056 * @brief データの可変文字列情報を名前として保管する /
1057 * Add a name to the name-storage and return an offset to it.
1058 * @param offset 文字列保管ポインタからのオフセット
1059 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1063 * Returns FALSE when there isn't enough space available to store
1066 static bool add_name(u32b *offset, header *head, concptr buf)
1068 /* Hack -- Verify space */
1069 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
1075 /* Advance and save the name index */
1076 *offset = ++head->name_size;
1079 /* Append chars to the names */
1080 strcpy(head->name_ptr + head->name_size, buf);
1082 /* Advance the index */
1083 head->name_size += strlen(buf);
1091 * @brief データの可変文字列情報をタグとして保管する /
1092 * Add a tag to the tag-storage and return an offset to it.
1093 * @param offset 文字列保管ポインタからのオフセット
1094 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1098 * Returns FALSE when there isn't enough space available to store
1101 static bool add_tag(STR_OFFSET *offset, header *head, concptr buf)
1105 /* Search for an existing (fake) tag */
1106 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1109 if (streq(&head->tag_ptr[i], buf)) break;
1112 /* There was no existing tag */
1113 if (i >= head->tag_size)
1115 /* Hack -- Verify space */
1116 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1119 /* Append chars to the tags */
1120 strcpy(head->tag_ptr + head->tag_size, buf);
1122 /* Point the new tag */
1125 /* Advance the index */
1126 head->tag_size += strlen(buf) + 1;
1129 /* Return offset of the tag */
1138 * @brief シンボル1文字をカラーIDに変更する /
1139 * Convert a "color letter" into an "actual" color
1140 * The colors are: dwsorgbuDWvyRGBU, as shown below
1144 TERM_COLOR color_char_to_attr(SYMBOL_CODE c)
1148 case 'd': return (TERM_DARK);
1149 case 'w': return (TERM_WHITE);
1150 case 's': return (TERM_SLATE);
1151 case 'o': return (TERM_ORANGE);
1152 case 'r': return (TERM_RED);
1153 case 'g': return (TERM_GREEN);
1154 case 'b': return (TERM_BLUE);
1155 case 'u': return (TERM_UMBER);
1157 case 'D': return (TERM_L_DARK);
1158 case 'W': return (TERM_L_WHITE);
1159 case 'v': return (TERM_VIOLET);
1160 case 'y': return (TERM_YELLOW);
1161 case 'R': return (TERM_L_RED);
1162 case 'G': return (TERM_L_GREEN);
1163 case 'B': return (TERM_L_BLUE);
1164 case 'U': return (TERM_L_UMBER);
1172 /*** Initialize from ascii template files ***/
1176 * @brief パース関数に基づいてデータファイルからデータを読み取る /
1177 * Initialize an "*_info" array, by parsing an ascii "template" file
1178 * @param fp 読み取りに使うファイルポインタ
1179 * @param buf 読み取りに使うバッファ領域
1180 * @param head ヘッダ構造体
1181 * @param parse_info_txt_line パース関数
1184 errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line)
1188 /* Just before the first record */
1191 /* Just before the first line */
1195 /* Prepare the "fake" stuff */
1196 head->name_size = 0;
1197 head->text_size = 0;
1201 while (0 == my_fgets(fp, buf, 1024))
1203 /* Advance the line number */
1206 /* Skip comments and blank lines */
1207 if (!buf[0] || (buf[0] == '#')) continue;
1209 /* Verify correct "colon" format */
1210 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1213 /* Hack -- Process 'V' for "Version" */
1220 /* Mega Hack -- Calculate Check Sum */
1221 if (buf[0] != 'N' && buf[0] != 'D')
1224 for (i = 0; buf[i]; i++)
1226 head->v_extra += (byte)buf[i];
1227 head->v_extra ^= (1 << (i % 8));
1231 /* Parse the line */
1232 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1237 /* Complete the "name" and "text" sizes */
1238 if (head->name_size) head->name_size++;
1239 if (head->text_size) head->text_size++;
1247 * @brief Vault情報(v_info)のパース関数 /
1248 * Initialize the "v_info" array, by parsing an ascii "template" file
1250 * @param head ヘッダ構造体
1253 errr parse_v_info(char *buf, header *head)
1259 static vault_type *v_ptr = NULL;
1261 /* Process 'N' for "New/Number/Name" */
1264 /* Find the colon before the name */
1265 s = my_strchr(buf+2, ':');
1267 /* Verify that colon */
1270 /* Nuke the colon, advance to the name */
1273 /* Paranoia -- require a name */
1274 if (!*s) return (1);
1279 /* Verify information */
1280 if (i <= error_idx) return (4);
1282 /* Verify information */
1283 if (i >= head->info_num) return (2);
1285 /* Save the index */
1288 /* Point at the "info" */
1291 /* Store the name */
1292 if (!add_name(&v_ptr->name, head, s)) return (7);
1295 /* There better be a current v_ptr */
1296 else if (!v_ptr) return (3);
1298 /* Process 'D' for "Description" */
1299 else if (buf[0] == 'D')
1301 /* Acquire the text */
1304 /* Store the text */
1305 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1308 /* Process 'X' for "Extra info" (one line only) */
1309 else if (buf[0] == 'X')
1311 EFFECT_ID typ, rat, hgt, wid;
1313 /* Scan for the values */
1314 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1315 &typ, &rat, &hgt, &wid)) return (1);
1317 /* Save the values */
1318 v_ptr->typ = (ROOM_IDX)typ;
1319 v_ptr->rat = (PROB)rat;
1320 v_ptr->hgt = (POSITION)hgt;
1321 v_ptr->wid = (POSITION)wid;
1332 * @brief 職業技能情報(s_info)のパース関数 /
1333 * Initialize the "s_info" array, by parsing an ascii "template" file
1335 * @param head ヘッダ構造体
1338 errr parse_s_info(char *buf, header *head)
1343 static skill_table *s_ptr = NULL;
1346 /* Process 'N' for "New/Number/Name" */
1352 /* Verify information */
1353 if (i <= error_idx) return (4);
1355 /* Verify information */
1356 if (i >= head->info_num) return (2);
1358 /* Save the index */
1361 /* Point at the "info" */
1365 /* There better be a current s_ptr */
1366 else if (!s_ptr) return (3);
1368 /* Process 'W' for "Weapon exp" */
1369 else if (buf[0] == 'W')
1371 int tval, sval, start, max;
1372 const s16b exp_conv_table[] =
1374 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1375 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1378 /* Scan for the values */
1379 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1380 &tval, &sval, &start, &max)) return (1);
1382 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1383 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1385 /* Save the values */
1386 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1387 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1390 /* Process 'S' for "Skill exp" */
1391 else if (buf[0] == 'S')
1393 int num, start, max;
1395 /* Scan for the values */
1396 if (3 != sscanf(buf+2, "%d:%d:%d",
1397 &num, &start, &max)) return (1);
1399 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1400 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1402 /* Save the values */
1403 s_ptr->s_start[num] = (SUB_EXP)start;
1404 s_ptr->s_max[num] = (SUB_EXP)max;
1416 * @brief 職業魔法情報(m_info)のパース関数 /
1417 * Initialize the "m_info" array, by parsing an ascii "template" file
1419 * @param head ヘッダ構造体
1422 errr parse_m_info(char *buf, header *head)
1429 static player_magic *m_ptr = NULL;
1432 static int realm, magic_idx = 0, readable = 0;
1435 /* Process 'N' for "New/Number/Name" */
1441 /* Verify information */
1442 if (i <= error_idx) return (4);
1444 /* Verify information */
1445 if (i >= head->info_num) return (2);
1447 /* Save the index */
1450 /* Point at the "info" */
1454 /* There better be a current m_ptr */
1455 else if (!m_ptr) return (3);
1457 /* Process 'I' for "Info" (one line only) */
1458 else if (buf[0] == 'I')
1461 int xtra, type, first, weight;
1463 /* Find the colon before the name */
1464 s = my_strchr(buf+2, ':');
1466 /* Verify that colon */
1469 /* Nuke the colon, advance to the name */
1474 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1475 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1476 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1477 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1478 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1483 /* Find the colon before the name */
1484 s = my_strchr(s, ':');
1486 /* Verify that colon */
1489 /* Nuke the colon, advance to the name */
1492 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1493 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1494 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1495 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1496 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1497 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1501 /* Scan for the values */
1502 if (4 != sscanf(s, "%x:%d:%d:%d",
1503 (uint *)&xtra, &type, &first, &weight)) return (1);
1505 m_ptr->spell_xtra = xtra;
1506 m_ptr->spell_type = type;
1507 m_ptr->spell_first = first;
1508 m_ptr->spell_weight = weight;
1512 /* Process 'R' for "Realm" (one line only) */
1513 else if (buf[0] == 'R')
1515 /* Scan for the values */
1516 if (2 != sscanf(buf+2, "%d:%d",
1517 &realm, &readable)) return (1);
1522 else if (buf[0] == 'T')
1524 int level, mana, fail, exp;
1526 if (!readable) return (1);
1527 /* Scan for the values */
1528 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1529 &level, &mana, &fail, &exp)) return (1);
1531 m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level;
1532 m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana;
1533 m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail;
1534 m_ptr->info[realm][magic_idx].sexp = (EXP)exp;
1547 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1548 * Grab one flag from a textual string
1549 * @param flags ビットフラグを追加する先の参照ポインタ
1550 * @param names トークン定義配列
1551 * @param what 参照元の文字列ポインタ
1554 static errr grab_one_flag(u32b *flags, concptr names[], concptr what)
1559 for (i = 0; i < 32; i++)
1561 if (streq(what, names[i]))
1563 *flags |= (1L << i);
1573 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1574 * Grab one flag in an feature_type from a textual string
1575 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1576 * @param what 参照元の文字列ポインタ
1579 static errr grab_one_feat_flag(feature_type *f_ptr, concptr what)
1584 for (i = 0; i < FF_FLAG_MAX; i++)
1586 if (streq(what, f_info_flags[i]))
1588 add_flag(f_ptr->flags, i);
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, concptr 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;
1622 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1625 return PARSE_ERROR_GENERIC;
1630 * @brief 地形情報(f_info)のパース関数 /
1631 * Initialize the "f_info" array, by parsing an ascii "template" file
1633 * @param head ヘッダ構造体
1636 errr parse_f_info(char *buf, header *head)
1643 static feature_type *f_ptr = NULL;
1646 /* Process 'N' for "New/Number/Name" */
1649 /* Find the colon before the name */
1650 s = my_strchr(buf+2, ':');
1654 /* Nuke the colon, advance to the name */
1661 /* Verify information */
1662 if (i <= error_idx) return (4);
1664 /* Verify information */
1665 if (i >= head->info_num) return (2);
1667 /* Save the index */
1670 /* Point at the "info" */
1673 /* Tag name is given */
1677 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1680 /* Default "mimic" */
1681 f_ptr->mimic = (FEAT_IDX)i;
1683 /* Default "destroyed state" -- if not specified */
1684 f_ptr->destroyed = (FEAT_IDX)i;
1686 /* Default "states" */
1687 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1690 /* There better be a current f_ptr */
1691 else if (!f_ptr) return (3);
1694 else if (buf[0] == 'J')
1696 /* Store the name */
1697 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1700 else if (buf[0] == 'E')
1702 /* Ignore english name */
1705 else if (buf[0] == 'J')
1707 /* Ignore Japanese name */
1710 else if (buf[0] == 'E')
1712 /* Acquire the Text */
1715 /* Store the name */
1716 if (!add_name(&f_ptr->name, head, s)) return (7);
1721 /* Process 'M' for "Mimic" (one line only) */
1722 else if (buf[0] == 'M')
1726 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1728 /* Record a fake tag index */
1729 f_ptr->mimic_tag = offset;
1733 /* Process 'G' for "Graphics" (one line only) */
1734 else if (buf[0] == 'G')
1738 char char_tmp[F_LIT_MAX];
1741 if (buf[1] != ':') return (1);
1742 if (!buf[2]) return (1);
1743 if (buf[3] != ':') return (1);
1744 if (!buf[4]) return (1);
1746 /* Extract the char */
1747 char_tmp[F_LIT_STANDARD] = buf[2];
1749 /* Extract the color */
1750 s_attr = color_char_to_attr(buf[4]);
1753 if (s_attr > 127) return (1);
1755 /* Save the standard values */
1756 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1757 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1759 /* Is this feature supports lighting? */
1762 /* G:c:a:LIT (default) */
1763 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1765 /* G:c:a:lc:la:dc:da */
1766 if (!streq(buf + 6, "LIT"))
1768 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1770 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1771 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1772 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1773 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1775 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1777 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1780 /* Use default lighting */
1783 /* No lighting support */
1784 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1787 /* Extract the color */
1788 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1789 if (f_ptr->d_attr[j] > 127) return 1;
1792 f_ptr->d_char[j] = char_tmp[j];
1798 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1800 f_ptr->d_attr[j] = s_attr;
1801 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1807 /* Hack -- Process 'F' for flags */
1808 else if (buf[0] == 'F')
1810 /* Parse every entry textually */
1811 for (s = buf + 2; *s; )
1813 /* Find the end of this entry */
1814 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1816 /* Nuke and skip any dividers */
1820 while (*t == ' ' || *t == '|') t++;
1823 /* Hack -- Read feature subtype */
1824 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1826 /* Extract a "subtype" */
1827 f_ptr->subtype = (FEAT_SUBTYPE)i;
1829 /* Start at next entry */
1835 /* Hack -- Read feature power */
1836 if (1 == sscanf(s, "POWER_%d", &i))
1838 /* Extract a "power" */
1839 f_ptr->power = (FEAT_POWER)i;
1841 /* Start at next entry */
1846 /* Parse this entry */
1847 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1849 /* Start the next entry */
1854 /* Process 'W' for "More Info" (one line only) */
1855 else if (buf[0] == 'W')
1859 /* Scan for the value */
1860 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1862 /* Save the value */
1863 f_ptr->priority = (FEAT_PRIORITY)priority;
1866 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1867 else if (buf[0] == 'K')
1871 /* Find the next empty state slot (if any) */
1872 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1874 /* Oops, no more slots */
1875 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1877 /* Analyze the first field */
1878 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1880 /* Terminate the field (if necessary) */
1881 if (*t == ':') *t++ = '\0';
1883 /* Is this default entry? */
1884 if (streq(s, "DESTROYED"))
1886 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1888 /* Record a fake tag index */
1889 f_ptr->destroyed_tag = offset;
1894 f_ptr->state[i].action = 0;
1896 /* Parse this entry */
1897 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1899 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1901 /* Record a fake tag index */
1902 f_ptr->state[i].result_tag = offset;
1914 * @brief 地形タグからIDを得る /
1915 * Convert a fake tag to a real feat index
1919 s16b f_tag_to_index(concptr str)
1923 /* Search for real index corresponding to this fake tag */
1924 for (i = 0; i < f_head.info_num; i++)
1926 if (streq(f_tag + f_info[i].tag, str))
1928 /* Return the index */
1939 * @brief 地形タグからIDを得る /
1940 * Search for real index corresponding to this fake tag
1941 * @param feat タグ文字列のオフセット
1942 * @return 地形ID。該当がないなら-1
1944 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1948 /* Don't convert non-fake tag */
1954 /* Search for real index corresponding to this fake tag */
1955 for (i = 0; i < f_head.info_num; i++)
1957 if (feat == f_info[i].tag)
1959 /* Record real index */
1965 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1971 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1972 * Retouch fake tags of f_info
1973 * @param head ヘッダ構造体
1976 void retouch_f_info(header *head)
1980 /* Convert fake tags to real feat indices */
1981 for (i = 0; i < head->info_num; i++)
1983 feature_type *f_ptr = &f_info[i];
1986 k = search_real_feat(f_ptr->mimic_tag);
1987 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1988 k = search_real_feat(f_ptr->destroyed_tag);
1989 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1990 for (j = 0; j < MAX_FEAT_STATES; j++)
1992 k = search_real_feat(f_ptr->state[j].result_tag);
1993 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
2000 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
2001 * Grab one flag in an object_kind from a textual string
2002 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
2003 * @param what 参照元の文字列ポインタ
2006 static errr grab_one_kind_flag(object_kind *k_ptr, concptr what)
2011 for (i = 0; i < TR_FLAG_MAX; i++)
2013 if (streq(what, k_info_flags[i]))
2015 add_flag(k_ptr->flags, i);
2020 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2023 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2030 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2031 * Grab one activation index flag
2032 * @param what 参照元の文字列ポインタ
2035 static byte grab_one_activation_flag(concptr what)
2041 if (activation_info[i].flag == NULL) break;
2043 if (streq(what, activation_info[i].flag))
2045 return activation_info[i].index;
2055 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2063 * @brief ベースアイテム(k_info)のパース関数 /
2064 * Initialize the "k_info" array, by parsing an ascii "template" file
2066 * @param head ヘッダ構造体
2069 errr parse_k_info(char *buf, header *head)
2076 static object_kind *k_ptr = NULL;
2079 /* Process 'N' for "New/Number/Name" */
2086 /* Find the colon before the name */
2087 s = my_strchr(buf+2, ':');
2089 /* Verify that colon */
2092 /* Nuke the colon, advance to the name */
2098 /* Verify information */
2099 if (i <= error_idx) return (4);
2101 /* Verify information */
2102 if (i >= head->info_num) return (2);
2104 /* Save the index */
2107 /* Point at the "info" */
2111 /* Paranoia -- require a name */
2112 if (!*s) return (1);
2114 /* Find the colon before the flavor */
2115 flavor = my_strchr(s, ':');
2117 /* Verify that colon */
2120 /* Nuke the colon, advance to the flavor */
2123 /* Store the flavor */
2124 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2127 /* Store the name */
2128 if (!add_name(&k_ptr->name, head, s)) return (7);
2132 /* There better be a current k_ptr */
2133 else if (!k_ptr) return (3);
2138 /* 'E' から始まる行は英語名としている */
2139 else if (buf[0] == 'E')
2144 else if (buf[0] == 'E')
2148 /* Acquire the name */
2151 /* Find the colon before the flavor */
2152 flavor = my_strchr(s, ':');
2154 /* Verify that colon */
2157 /* Nuke the colon, advance to the flavor */
2160 /* Store the flavor */
2161 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2164 /* Store the name */
2165 if (!add_name(&k_ptr->name, head, s)) return (7);
2169 /* Process 'D' for "Description" */
2170 else if (buf[0] == 'D')
2175 /* Acquire the text */
2180 /* Acquire the text */
2184 /* Store the text */
2185 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2188 /* Process 'G' for "Graphics" (one line only) */
2189 else if (buf[0] == 'G')
2195 if (buf[1] != ':') return (1);
2196 if (!buf[2]) return (1);
2197 if (buf[3] != ':') return (1);
2198 if (!buf[4]) return (1);
2200 /* Extract the char */
2203 /* Extract the attr */
2204 tmp = color_char_to_attr(buf[4]);
2207 if (tmp > 127) return (1);
2209 /* Save the values */
2210 k_ptr->d_attr = tmp;
2211 k_ptr->d_char = sym;
2214 /* Process 'I' for "Info" (one line only) */
2215 else if (buf[0] == 'I')
2217 int tval, sval, pval;
2219 /* Scan for the values */
2220 if (3 != sscanf(buf+2, "%d:%d:%d",
2221 &tval, &sval, &pval)) return (1);
2223 /* Save the values */
2224 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2225 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2226 k_ptr->pval = (PARAMETER_VALUE)pval;
2229 /* Process 'W' for "More Info" (one line only) */
2230 else if (buf[0] == 'W')
2232 int level, extra, wgt;
2235 /* Scan for the values */
2236 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2237 &level, &extra, &wgt, &cost)) return (1);
2239 /* Save the values */
2240 k_ptr->level = (DEPTH)level;
2241 k_ptr->extra = (BIT_FLAGS8)extra;
2242 k_ptr->weight = (WEIGHT)wgt;
2243 k_ptr->cost = (PRICE)cost;
2246 /* Process 'A' for "Allocation" (one line only) */
2247 else if (buf[0] == 'A')
2250 /* Simply read each number following a colon */
2251 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2253 /* Default chance */
2254 k_ptr->chance[i] = 1;
2256 /* Store the attack damage index */
2257 k_ptr->locale[i] = atoi(s+1);
2259 /* Find the slash */
2260 t = my_strchr(s+1, '/');
2262 /* Find the next colon */
2263 s = my_strchr(s+1, ':');
2265 /* If the slash is "nearby", use it */
2266 if (t && (!s || t < s))
2268 int chance = atoi(t+1);
2269 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2274 /* Hack -- Process 'P' for "power" and such */
2275 else if (buf[0] == 'P')
2277 int ac, hd1, hd2, th, td, ta;
2279 /* Scan for the values */
2280 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2281 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2283 k_ptr->ac = (ARMOUR_CLASS)ac;
2284 k_ptr->dd = (DICE_NUMBER)hd1;
2285 k_ptr->ds = (DICE_SID)hd2;
2286 k_ptr->to_h = (HIT_PROB)th;
2287 k_ptr->to_d = (HIT_POINT)td;
2288 k_ptr->to_a = (ARMOUR_CLASS)ta;
2291 /* Hack -- Process 'U' for activation index */
2292 else if (buf[0] == 'U')
2295 n = grab_one_activation_flag(buf + 2);
2306 /* Hack -- Process 'F' for flags */
2307 else if (buf[0] == 'F')
2309 /* Parse every entry textually */
2310 for (s = buf + 2; *s; )
2312 /* Find the end of this entry */
2313 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2315 /* Nuke and skip any dividers */
2319 while (*t == ' ' || *t == '|') t++;
2322 /* Parse this entry */
2323 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2325 /* Start the next entry */
2339 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2340 * Grab one activation index flag
2341 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2342 * @param what 参照元の文字列ポインタ
2343 * @return エラーがあった場合1、エラーがない場合0を返す
2345 static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
2350 for (i = 0; i < TR_FLAG_MAX; i++)
2352 if (streq(what, k_info_flags[i]))
2354 add_flag(a_ptr->flags, i);
2359 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2362 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2370 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2371 * Initialize the "a_info" array, by parsing an ascii "template" file
2373 * @param head ヘッダ構造体
2376 errr parse_a_info(char *buf, header *head)
2383 static artifact_type *a_ptr = NULL;
2386 /* Process 'N' for "New/Number/Name" */
2389 /* Find the colon before the name */
2390 s = my_strchr(buf+2, ':');
2392 /* Verify that colon */
2395 /* Nuke the colon, advance to the name */
2398 /* Paranoia -- require a name */
2399 if (!*s) return (1);
2404 /* Verify information */
2405 if (i < error_idx) return (4);
2407 /* Verify information */
2408 if (i >= head->info_num) return (2);
2410 /* Save the index */
2413 /* Point at the "info" */
2416 /* Ignore everything */
2417 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2418 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2419 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2420 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2422 /* Store the name */
2423 if (!add_name(&a_ptr->name, head, s)) return (7);
2427 /* There better be a current a_ptr */
2428 else if (!a_ptr) return (3);
2433 /* 'E' から始まる行は英語名としている */
2434 else if (buf[0] == 'E')
2439 else if (buf[0] == 'E')
2441 /* Acquire the Text */
2444 /* Store the name */
2445 if (!add_name(&a_ptr->name, head, s)) return (7);
2449 /* Process 'D' for "Description" */
2450 else if (buf[0] == 'D')
2455 /* Acquire the text */
2460 /* Acquire the text */
2464 /* Store the text */
2465 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2469 /* Process 'I' for "Info" (one line only) */
2470 else if (buf[0] == 'I')
2472 int tval, sval, pval;
2474 /* Scan for the values */
2475 if (3 != sscanf(buf+2, "%d:%d:%d",
2476 &tval, &sval, &pval)) return (1);
2478 /* Save the values */
2479 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2480 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2481 a_ptr->pval = (PARAMETER_VALUE)pval;
2484 /* Process 'W' for "More Info" (one line only) */
2485 else if (buf[0] == 'W')
2487 int level, rarity, wgt;
2490 /* Scan for the values */
2491 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2492 &level, &rarity, &wgt, &cost)) return (1);
2494 /* Save the values */
2495 a_ptr->level = (DEPTH)level;
2496 a_ptr->rarity = (RARITY)rarity;
2497 a_ptr->weight = (WEIGHT)wgt;
2498 a_ptr->cost = (PRICE)cost;
2501 /* Hack -- Process 'P' for "power" and such */
2502 else if (buf[0] == 'P')
2504 int ac, hd1, hd2, th, td, ta;
2506 /* Scan for the values */
2507 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2508 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2510 a_ptr->ac = (ARMOUR_CLASS)ac;
2511 a_ptr->dd = (DICE_NUMBER)hd1;
2512 a_ptr->ds = (DICE_SID)hd2;
2513 a_ptr->to_h = (HIT_PROB)th;
2514 a_ptr->to_d = (HIT_POINT)td;
2515 a_ptr->to_a = (ARMOUR_CLASS)ta;
2518 /* Hack -- Process 'U' for activation index */
2519 else if (buf[0] == 'U')
2522 n = grab_one_activation_flag(buf + 2);
2533 /* Hack -- Process 'F' for flags */
2534 else if (buf[0] == 'F')
2536 /* Parse every entry textually */
2537 for (s = buf + 2; *s; )
2539 /* Find the end of this entry */
2540 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2542 /* Nuke and skip any dividers */
2546 while ((*t == ' ') || (*t == '|')) t++;
2549 /* Parse this entry */
2550 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2552 /* Start the next entry */
2567 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2568 * Grab one flag in a ego-item_type from a textual string
2569 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2570 * @param what 参照元の文字列ポインタ
2571 * @return エラーがあった場合1、エラーがない場合0を返す
2573 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
2578 for (i = 0; i < TR_FLAG_MAX; i++)
2580 if (streq(what, k_info_flags[i]))
2582 add_flag(e_ptr->flags, i);
2587 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2590 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2598 * @brief アイテムエゴ情報(e_info)のパース関数 /
2599 * Initialize the "e_info" array, by parsing an ascii "template" file
2601 * @param head ヘッダ構造体
2604 errr parse_e_info(char *buf, header *head)
2610 static ego_item_type *e_ptr = NULL;
2612 /* Just before the first record */
2615 /* Just before the first line */
2618 /* Process 'N' for "New/Number/Name" */
2621 /* Find the colon before the name */
2622 s = my_strchr(buf+2, ':');
2624 /* Verify that colon */
2627 /* Nuke the colon, advance to the name */
2630 /* Paranoia -- require a name */
2631 if (!*s) return (1);
2636 /* Verify information */
2637 if (i < error_idx) return (4);
2639 /* Verify information */
2640 if (i >= head->info_num) return (2);
2642 /* Save the index */
2645 /* Point at the "info" */
2648 /* Store the name */
2649 if (!add_name(&e_ptr->name, head, s)) return (7);
2653 /* There better be a current e_ptr */
2654 else if (!e_ptr) return (3);
2659 /* 'E' から始まる行は英語名 */
2660 else if (buf[0] == 'E')
2665 else if (buf[0] == 'E')
2667 /* Acquire the Text */
2670 /* Store the name */
2671 if (!add_name(&e_ptr->name, head, s)) return (7);
2676 /* Process 'D' for "Description" */
2677 else if (buf[0] == 'D')
2679 /* Acquire the text */
2682 /* Store the text */
2683 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2688 /* Process 'X' for "Xtra" (one line only) */
2689 else if (buf[0] == 'X')
2693 /* Scan for the values */
2694 if (2 != sscanf(buf+2, "%d:%d",
2695 &slot, &rating)) return (1);
2697 /* Save the values */
2698 e_ptr->slot = (INVENTORY_IDX)slot;
2699 e_ptr->rating = (PRICE)rating;
2702 /* Process 'W' for "More Info" (one line only) */
2703 else if (buf[0] == 'W')
2705 int level, rarity, pad2;
2708 /* Scan for the values */
2709 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2710 &level, &rarity, &pad2, &cost)) return (1);
2712 /* Save the values */
2713 e_ptr->level = level;
2714 e_ptr->rarity = (RARITY)rarity;
2715 /* e_ptr->weight = wgt; */
2719 /* Hack -- Process 'C' for "creation" */
2720 else if (buf[0] == 'C')
2722 int th, td, ta, pval;
2724 /* Scan for the values */
2725 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2726 &th, &td, &ta, &pval)) return (1);
2728 e_ptr->max_to_h = (HIT_PROB)th;
2729 e_ptr->max_to_d = (HIT_POINT)td;
2730 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2731 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2734 /* Hack -- Process 'U' for activation index */
2735 else if (buf[0] == 'U')
2738 n = grab_one_activation_flag(buf + 2);
2749 /* Hack -- Process 'F' for flags */
2750 else if (buf[0] == 'F')
2752 /* Parse every entry textually */
2753 for (s = buf + 2; *s; )
2755 /* Find the end of this entry */
2756 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2758 /* Nuke and skip any dividers */
2762 while ((*t == ' ') || (*t == '|')) t++;
2765 /* Parse this entry */
2766 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2768 /* Start the next entry */
2781 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2782 * Grab one (basic) flag in a monster_race from a textual string
2783 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2784 * @param what 参照元の文字列ポインタ
2787 static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
2789 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2792 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2795 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2798 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2801 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2804 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2807 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2810 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2818 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2819 * Grab one (spell) flag in a monster_race from a textual string
2820 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2821 * @param what 参照元の文字列ポインタ
2824 static errr grab_one_spell_flag(monster_race *r_ptr, concptr what)
2826 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2829 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2832 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2835 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2843 * @brief モンスター種族情報(r_info)のパース関数 /
2844 * Initialize the "r_info" array, by parsing an ascii "template" file
2846 * @param head ヘッダ構造体
2849 errr parse_r_info(char *buf, header *head)
2855 static monster_race *r_ptr = NULL;
2858 /* Process 'N' for "New/Number/Name" */
2861 /* Find the colon before the name */
2862 s = my_strchr(buf+2, ':');
2864 /* Verify that colon */
2867 /* Nuke the colon, advance to the name */
2870 /* Paranoia -- require a name */
2871 if (!*s) return (1);
2876 /* Verify information */
2877 if (i < error_idx) return (4);
2879 /* Verify information */
2880 if (i >= head->info_num) return (2);
2882 /* Save the index */
2885 /* Point at the "info" */
2888 /* Store the name */
2889 if (!add_name(&r_ptr->name, head, s)) return (7);
2893 /* There better be a current r_ptr */
2894 else if (!r_ptr) return (3);
2899 /* 'E' から始まる行は英語名 */
2900 else if (buf[0] == 'E')
2902 /* Acquire the Text */
2905 /* Store the name */
2906 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2909 else if (buf[0] == 'E')
2911 /* Acquire the Text */
2914 /* Store the name */
2915 if (!add_name(&r_ptr->name, head, s)) return (7);
2918 /* Process 'D' for "Description" */
2919 else if (buf[0] == 'D')
2924 /* Acquire the text */
2929 /* Acquire the text */
2933 /* Store the text */
2934 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2937 /* Process 'G' for "Graphics" (one line only) */
2938 else if (buf[0] == 'G')
2944 if (buf[1] != ':') return (1);
2945 if (!buf[2]) return (1);
2946 if (buf[3] != ':') return (1);
2947 if (!buf[4]) return (1);
2949 /* Extract the char */
2952 /* Extract the attr */
2953 tmp = color_char_to_attr(buf[4]);
2956 if (tmp > 127) return (1);
2958 /* Save the values */
2959 r_ptr->d_char = sym;
2960 r_ptr->d_attr = tmp;
2963 /* Process 'I' for "Info" (one line only) */
2964 else if (buf[0] == 'I')
2966 int spd, hp1, hp2, aaf, ac, slp;
2968 /* Scan for the other values */
2969 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2970 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2972 /* Save the values */
2973 r_ptr->speed = (SPEED)spd;
2974 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2975 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2976 r_ptr->aaf = (POSITION)aaf;
2977 r_ptr->ac = (ARMOUR_CLASS)ac;
2978 r_ptr->sleep = (SLEEP_DEGREE)slp;
2981 /* Process 'W' for "More Info" (one line only) */
2982 else if (buf[0] == 'W')
2989 /* Scan for the values */
2990 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2991 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2993 /* Save the values */
2994 r_ptr->level = (DEPTH)lev;
2995 r_ptr->rarity = (RARITY)rar;
2996 r_ptr->extra = (BIT_FLAGS16)pad;
2997 r_ptr->mexp = (EXP)exp;
2998 r_ptr->next_exp = (EXP)nextexp;
2999 r_ptr->next_r_idx = (IDX)nextmon;
3002 /* Process 'R' for "Reinforcement" (up to six lines) */
3003 else if (buf[0] == 'R')
3006 /* Find the next empty blow slot (if any) */
3007 for (i = 0; i < A_MAX; i++) if (r_ptr->reinforce_id[i] == 0) break;
3009 /* Oops, no more slots */
3010 if (i == 6) return (1);
3012 /* Scan for the values */
3013 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3014 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3015 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3016 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3019 /* Process 'B' for "Blows" (up to four lines) */
3020 else if (buf[0] == 'B')
3024 /* Find the next empty blow slot (if any) */
3025 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3027 /* Oops, no more slots */
3028 if (i == 4) return (1);
3030 /* Analyze the first field */
3031 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3033 /* Terminate the field (if necessary) */
3034 if (*t == ':') *t++ = '\0';
3036 /* Analyze the method */
3037 for (n1 = 0; r_info_blow_method[n1]; n1++)
3039 if (streq(s, r_info_blow_method[n1])) break;
3042 /* Invalid method */
3043 if (!r_info_blow_method[n1]) return (1);
3045 /* Analyze the second field */
3046 for (s = t; *t && (*t != ':'); t++) /* loop */;
3048 /* Terminate the field (if necessary) */
3049 if (*t == ':') *t++ = '\0';
3051 /* Analyze effect */
3052 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3054 if (streq(s, r_info_blow_effect[n2])) break;
3057 /* Invalid effect */
3058 if (!r_info_blow_effect[n2]) return (1);
3060 /* Analyze the third field */
3061 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3063 /* Terminate the field (if necessary) */
3064 if (*t == 'd') *t++ = '\0';
3066 /* Save the method */
3067 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3069 /* Save the effect */
3070 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3072 /* Extract the damage dice and sides */
3073 r_ptr->blow[i].d_dice = atoi(s);
3074 r_ptr->blow[i].d_side = atoi(t);
3077 /* Process 'F' for "Basic Flags" (multiple lines) */
3078 else if (buf[0] == 'F')
3080 /* Parse every entry */
3081 for (s = buf + 2; *s; )
3083 /* Find the end of this entry */
3084 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3086 /* Nuke and skip any dividers */
3090 while (*t == ' ' || *t == '|') t++;
3093 /* Parse this entry */
3094 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3096 /* Start the next entry */
3101 /* Process 'S' for "Spell Flags" (multiple lines) */
3102 else if (buf[0] == 'S')
3104 /* Parse every entry */
3105 for (s = buf + 2; *s; )
3107 /* Find the end of this entry */
3108 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3110 /* Nuke and skip any dividers */
3114 while ((*t == ' ') || (*t == '|')) t++;
3117 /* Hack -- Read spell frequency */
3118 if (1 == sscanf(s, "1_IN_%d", &i))
3120 /* Extract a "frequency" */
3121 r_ptr->freq_spell = 100 / i;
3123 /* Start at next entry */
3128 /* Parse this entry */
3129 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3131 /* Start the next entry */
3136 /* Process 'A' for "Artifact Flags" (multiple lines) */
3137 else if (buf[0] == 'A')
3139 int id, per, rarity;
3141 /* Find the next empty blow slot (if any) */
3142 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3144 /* Oops, no more slots */
3145 if (i == 4) return (1);
3147 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3148 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3149 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3150 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3153 /* Process 'V' for "Arena power value ratio" */
3154 else if (buf[0] == 'V')
3157 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3158 r_ptr->arena_ratio = (PERCENTAGE)val;
3170 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3171 * Grab one flag for a dungeon type from a textual string
3172 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3173 * @param what 参照元の文字列ポインタ
3176 static errr grab_one_dungeon_flag(dungeon_type *d_ptr, concptr what)
3178 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3181 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3188 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3189 * Grab one (basic) flag in a monster_race from a textual string
3190 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3191 * @param what 参照元の文字列ポインタ
3194 static errr grab_one_basic_monster_flag(dungeon_type *d_ptr, concptr what)
3196 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3199 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3202 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3205 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3208 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3211 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3214 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3217 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3224 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3225 * Grab one (spell) flag in a monster_race from a textual string
3226 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3227 * @param what 参照元の文字列ポインタ
3230 static errr grab_one_spell_monster_flag(dungeon_type *d_ptr, concptr what)
3232 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3235 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3238 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3241 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3248 * @brief ダンジョン情報(d_info)のパース関数 /
3249 * Initialize the "d_info" array, by parsing an ascii "template" file
3251 * @param head ヘッダ構造体
3254 errr parse_d_info(char *buf, header *head)
3260 static dungeon_type *d_ptr = NULL;
3262 /* Process 'N' for "New/Number/Name" */
3265 /* Find the colon before the name */
3266 s = my_strchr(buf+2, ':');
3268 /* Verify that colon */
3271 /* Nuke the colon, advance to the name */
3274 /* Paranoia -- require a name */
3275 if (!*s) return (1);
3280 /* Verify information */
3281 if (i < error_idx) return (4);
3283 /* Verify information */
3284 if (i >= head->info_num) return (2);
3286 /* Save the index */
3289 /* Point at the "info" */
3292 /* Store the name */
3293 if (!add_name(&d_ptr->name, head, s)) return (7);
3298 else if (buf[0] == 'E') return (0);
3300 else if (buf[0] == 'E')
3302 /* Acquire the Text */
3305 /* Store the name */
3306 if (!add_name(&d_ptr->name, head, s)) return (7);
3310 /* Process 'D' for "Description */
3311 else if (buf[0] == 'D')
3316 /* Acquire the text */
3321 /* Acquire the text */
3325 /* Store the text */
3326 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3329 /* Process 'W' for "More Info" (one line only) */
3330 else if (buf[0] == 'W')
3332 int min_lev, max_lev;
3334 int min_alloc, max_chance;
3335 int obj_good, obj_great;
3338 /* Scan for the values */
3339 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3340 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3342 /* Save the values */
3343 d_ptr->mindepth = (DEPTH)min_lev;
3344 d_ptr->maxdepth = (DEPTH)max_lev;
3345 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3346 d_ptr->mode = (BIT_FLAGS8)mode;
3347 d_ptr->min_m_alloc_level = min_alloc;
3348 d_ptr->max_m_alloc_chance = max_chance;
3349 d_ptr->obj_good = obj_good;
3350 d_ptr->obj_great = obj_great;
3351 d_ptr->pit = (BIT_FLAGS16)pit;
3352 d_ptr->nest = (BIT_FLAGS16)nest;
3355 /* Process 'P' for "Place Info" */
3356 else if (buf[0] == 'P')
3360 /* Scan for the values */
3361 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3363 /* Save the values */
3368 /* Process 'L' for "fLoor type" (one line only) */
3369 else if (buf[0] == 'L')
3373 /* Scan for the values */
3374 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3376 /* Save the values */
3377 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3379 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3380 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3382 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3384 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3387 /* Process 'A' for "wAll type" (one line only) */
3388 else if (buf[0] == 'A')
3392 /* Scan for the values */
3393 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3395 /* Save the values */
3396 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3398 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3399 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3401 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3404 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3405 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3407 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3408 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3410 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3411 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3413 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3414 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3417 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3418 else if (buf[0] == 'F')
3420 int artif = 0, monst = 0;
3422 /* Parse every entry */
3423 for (s = buf + 2; *s; )
3425 /* Find the end of this entry */
3426 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3428 /* Nuke and skip any dividers */
3432 while (*t == ' ' || *t == '|') t++;
3435 /* Hack -- Read Final Artifact */
3436 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3438 /* Extract a "Final Artifact" */
3439 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3441 /* Start at next entry */
3446 /* Hack -- Read Final Object */
3447 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3449 /* Extract a "Final Artifact" */
3450 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3452 /* Start at next entry */
3457 /* Hack -- Read Artifact Guardian */
3458 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3460 /* Extract a "Artifact Guardian" */
3461 d_ptr->final_guardian = (MONRACE_IDX)monst;
3463 /* Start at next entry */
3468 /* Hack -- Read Special Percentage */
3469 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3471 /* Extract a "Special %" */
3472 d_ptr->special_div = (PROB)monst;
3474 /* Start at next entry */
3479 /* Parse this entry */
3480 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3482 /* Start the next entry */
3487 /* Process 'M' for "Basic Flags" (multiple lines) */
3488 else if (buf[0] == 'M')
3490 /* Parse every entry */
3491 for (s = buf + 2; *s; )
3493 /* Find the end of this entry */
3494 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3496 /* Nuke and skip any dividers */
3500 while (*t == ' ' || *t == '|') t++;
3503 /* Hack -- Read monster symbols */
3504 if (!strncmp(s, "R_CHAR_", 7))
3506 /* Skip "R_CHAR_" */
3510 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3512 /* Start at next entry */
3517 /* Parse this entry */
3518 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3520 /* Start the next entry */
3525 /* Process 'S' for "Spell Flags" (multiple lines) */
3526 else if (buf[0] == 'S')
3528 /* Parse every entry */
3529 for (s = buf + 2; *s; )
3531 /* Find the end of this entry */
3532 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3534 /* Nuke and skip any dividers */
3538 while ((*t == ' ') || (*t == '|')) t++;
3541 /* Hack -- Read spell frequency */
3542 if (1 == sscanf(s, "1_IN_%d", &i))
3544 /* Start at next entry */
3549 /* Parse this entry */
3550 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3552 /* Start the next entry */
3564 #else /* ALLOW_TEMPLATES */
3570 #endif /* ALLOW_TEMPLATES */
3573 /* Random dungeon grid effects */
3574 #define RANDOM_NONE 0x00000000
3575 #define RANDOM_FEATURE 0x00000001
3576 #define RANDOM_MONSTER 0x00000002
3577 #define RANDOM_OBJECT 0x00000004
3578 #define RANDOM_EGO 0x00000008
3579 #define RANDOM_ARTIFACT 0x00000010
3580 #define RANDOM_TRAP 0x00000020
3583 typedef struct dungeon_grid dungeon_grid;
3587 FEAT_IDX feature; /* Terrain feature */
3588 MONSTER_IDX monster; /* Monster */
3589 OBJECT_IDX object; /* Object */
3590 EGO_IDX ego; /* Ego-Item */
3591 ARTIFACT_IDX artifact; /* Artifact */
3592 IDX trap; /* Trap */
3593 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3594 s16b special; /* Reserved for special terrain info */
3595 int random; /* Number of the random effect */
3599 static dungeon_grid letter[255];
3603 * @brief 地形情報の「F:」情報をパースする
3604 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3608 static errr parse_line_feature(char *buf)
3613 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3615 /* Tokenize the line */
3616 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3618 /* Letter to assign */
3619 int index = zz[0][0];
3621 /* Reset the info for the letter */
3622 letter[index].feature = feat_none;
3623 letter[index].monster = 0;
3624 letter[index].object = 0;
3625 letter[index].ego = 0;
3626 letter[index].artifact = 0;
3627 letter[index].trap = feat_none;
3628 letter[index].cave_info = 0;
3629 letter[index].special = 0;
3630 letter[index].random = RANDOM_NONE;
3636 letter[index].special = (s16b)atoi(zz[8]);
3640 if ((zz[7][0] == '*') && !zz[7][1])
3642 letter[index].random |= RANDOM_TRAP;
3646 letter[index].trap = f_tag_to_index(zz[7]);
3647 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3652 if (zz[6][0] == '*')
3654 letter[index].random |= RANDOM_ARTIFACT;
3655 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3657 else if (zz[6][0] == '!')
3659 if (p_ptr->inside_quest)
3661 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3666 letter[index].artifact = (IDX)atoi(zz[6]);
3671 if (zz[5][0] == '*')
3673 letter[index].random |= RANDOM_EGO;
3674 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3678 letter[index].ego = (IDX)atoi(zz[5]);
3683 if (zz[4][0] == '*')
3685 letter[index].random |= RANDOM_OBJECT;
3686 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3688 else if (zz[4][0] == '!')
3690 if (p_ptr->inside_quest)
3692 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3695 artifact_type *a_ptr = &a_info[a_idx];
3696 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3698 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3705 letter[index].object = (IDX)atoi(zz[4]);
3710 if (zz[3][0] == '*')
3712 letter[index].random |= RANDOM_MONSTER;
3713 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3715 else if (zz[3][0] == 'c')
3717 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3718 letter[index].monster = - atoi(zz[3] + 1);
3722 letter[index].monster = (IDX)atoi(zz[3]);
3727 letter[index].cave_info = atoi(zz[2]);
3731 if ((zz[1][0] == '*') && !zz[1][1])
3733 letter[index].random |= RANDOM_FEATURE;
3737 letter[index].feature = f_tag_to_index(zz[1]);
3738 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3751 * @brief 地形情報の「B:」情報をパースする
3752 * Process "B:<Index>:<Command>:..." -- Building definition
3756 static errr parse_line_building(char *buf)
3772 /* Get the building number */
3775 /* Find the colon after the building number */
3776 s = my_strchr(s, ':');
3778 /* Verify that colon */
3781 /* Nuke the colon, advance to the sub-index */
3784 /* Paranoia -- require a sub-index */
3785 if (!*s) return (1);
3787 /* Building definition sub-index */
3790 /* Building name, owner, race */
3793 if (tokenize(s + 2, 3, zz, 0) == 3)
3795 /* Name of the building */
3796 strcpy(building[index].name, zz[0]);
3798 /* Name of the owner */
3799 strcpy(building[index].owner_name, zz[1]);
3801 /* Race of the owner */
3802 strcpy(building[index].owner_race, zz[2]);
3807 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3810 /* Building Action */
3813 if (tokenize(s + 2, 8, zz, 0) >= 7)
3815 /* Index of the action */
3816 int action_index = atoi(zz[0]);
3818 /* Name of the action */
3819 strcpy(building[index].act_names[action_index], zz[1]);
3821 /* Cost of the action for members */
3822 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3824 /* Cost of the action for non-members */
3825 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3827 /* Letter assigned to the action */
3828 building[index].letters[action_index] = zz[4][0];
3831 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3833 /* Action restriction */
3834 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3839 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3842 /* Building Classes */
3846 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);
3854 /* Building Races */
3858 n = tokenize(s + 2, MAX_RACES, zz, 0);
3859 for (i = 0; i < MAX_RACES; i++)
3861 building[index].member_race[i] = ((i < n) ? (RACE_IDX)atoi(zz[i]) : 1);
3866 /* Building Realms */
3870 n = tokenize(s + 2, MAX_MAGIC, zz, 0);
3871 for (i = 0; i < MAX_MAGIC; i++)
3873 building[index].member_realm[i+1] = ((i < n) ? (REALM_IDX)atoi(zz[i]) : 1);
3880 /* Ignore scripts */
3886 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3895 * @brief フロアの所定のマスにオブジェクトを配置する
3896 * Place the object j_ptr to a grid
3897 * @param j_ptr オブジェクト構造体の参照ポインタ
3902 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3904 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3907 OBJECT_IDX o_idx = o_pop();
3909 /* Access new object */
3910 o_ptr = &o_list[o_idx];
3912 /* Structure copy */
3913 object_copy(o_ptr, j_ptr);
3920 o_ptr->held_m_idx = 0;
3923 o_ptr->next_o_idx = g_ptr->o_idx;
3925 /* Place the object */
3926 g_ptr->o_idx = o_idx;
3931 * @brief クエスト用固定ダンジョンをフロアに生成する
3932 * Parse a sub-file of the "extra info"
3942 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3947 /* Skip "empty" lines */
3948 if (!buf[0]) return (0);
3950 /* Skip "blank" lines */
3951 if (iswspace(buf[0])) return (0);
3954 if (buf[0] == '#') return (0);
3956 /* Require "?:*" format */
3957 if (buf[1] != ':') return (1);
3960 /* Process "%:<fname>" */
3963 /* Attempt to Process the given file */
3964 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3967 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3970 return parse_line_feature(buf);
3973 /* Process "D:<dungeon>" -- info for the current_floor_ptr->grid_array grids */
3974 else if (buf[0] == 'D')
3976 object_type object_type_body;
3978 /* Acquire the text */
3981 /* Length of the text */
3982 int len = strlen(s);
3984 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3986 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3988 grid_type *g_ptr = ¤t_floor_ptr->grid_array[*y][*x];
3992 OBJECT_IDX object_index = letter[idx].object;
3993 MONSTER_IDX monster_index = letter[idx].monster;
3994 int random = letter[idx].random;
3995 ARTIFACT_IDX artifact_index = letter[idx].artifact;
3997 /* Lay down a floor */
3998 g_ptr->feat = conv_dungeon_feat(letter[idx].feature);
4000 /* Only the features */
4001 if (init_flags & INIT_ONLY_FEATURES) continue;
4004 g_ptr->info = letter[idx].cave_info;
4006 /* Create a monster */
4007 if (random & RANDOM_MONSTER)
4009 monster_level = current_floor_ptr->base_level + monster_index;
4011 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4013 monster_level = current_floor_ptr->base_level;
4015 else if (monster_index)
4017 int old_cur_num, old_max_num;
4020 if (monster_index < 0)
4022 monster_index = -monster_index;
4025 old_cur_num = r_info[monster_index].cur_num;
4026 old_max_num = r_info[monster_index].max_num;
4028 /* Make alive again */
4029 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4031 r_info[monster_index].cur_num = 0;
4032 r_info[monster_index].max_num = 1;
4035 /* Make alive again */
4036 /* Hack -- Non-unique Nazguls are semi-unique */
4037 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4039 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4041 r_info[monster_index].max_num++;
4046 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4050 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4052 /* Make alive again for real unique monster */
4053 r_info[monster_index].cur_num = old_cur_num;
4054 r_info[monster_index].max_num = old_max_num;
4058 /* Object (and possible trap) */
4059 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4061 object_level = current_floor_ptr->base_level + object_index;
4064 * Random trap and random treasure defined
4065 * 25% chance for trap and 75% chance for object
4067 if (randint0(100) < 75)
4069 place_object(*y, *x, 0L);
4076 object_level = current_floor_ptr->base_level;
4078 else if (random & RANDOM_OBJECT)
4080 object_level = current_floor_ptr->base_level + object_index;
4082 /* Create an out of deep object */
4083 if (randint0(100) < 75)
4084 place_object(*y, *x, 0L);
4085 else if (randint0(100) < 80)
4086 place_object(*y, *x, AM_GOOD);
4088 place_object(*y, *x, AM_GOOD | AM_GREAT);
4090 object_level = current_floor_ptr->base_level;
4093 else if (random & RANDOM_TRAP)
4097 /* Hidden trap (or door) */
4098 else if (letter[idx].trap)
4100 g_ptr->mimic = g_ptr->feat;
4101 g_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4103 else if (object_index)
4105 object_type *o_ptr = &object_type_body;
4106 object_prep(o_ptr, object_index);
4108 if (o_ptr->tval == TV_GOLD)
4110 coin_type = object_index - OBJ_GOLD_LIST;
4115 /* Apply magic (no messages, no artifacts) */
4116 apply_magic(o_ptr, current_floor_ptr->base_level, AM_NO_FIXED_ART | AM_GOOD);
4118 drop_here(o_ptr, *y, *x);
4124 if (a_info[artifact_index].cur_num)
4126 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4128 object_type *q_ptr = &forge;
4130 object_prep(q_ptr, k_idx);
4131 drop_here(q_ptr, *y, *x);
4135 /* Create the artifact */
4136 if (create_named_art(artifact_index, *y, *x))
4137 a_info[artifact_index].cur_num = 1;
4141 /* Terrain special */
4142 g_ptr->special = letter[idx].special;
4150 /* Process "Q:<number>:<command>:... -- quest info */
4151 else if (buf[0] == 'Q')
4158 num = tokenize(buf + 2, 33, zz, 0);
4162 num = tokenize(buf + 3, 33, zz, 0);
4165 /* Have we enough parameters? */
4166 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4169 q_ptr = &(quest[atoi(zz[0])]);
4171 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4172 if (zz[1][0] == 'Q')
4174 if (init_flags & INIT_ASSIGN)
4176 monster_race *r_ptr;
4177 artifact_type *a_ptr;
4179 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4181 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4182 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4183 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4184 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4185 q_ptr->level = (DEPTH)atoi(zz[6]);
4186 q_ptr->r_idx = (IDX)atoi(zz[7]);
4187 q_ptr->k_idx = (IDX)atoi(zz[8]);
4188 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4190 if (num > 10) q_ptr->flags = atoi(zz[10]);
4192 r_ptr = &r_info[q_ptr->r_idx];
4193 if (r_ptr->flags1 & RF1_UNIQUE)
4194 r_ptr->flags1 |= RF1_QUESTOR;
4196 a_ptr = &a_info[q_ptr->k_idx];
4197 a_ptr->gen_flags |= TRG_QUESTITEM;
4202 else if (zz[1][0] == 'R')
4204 if (init_flags & INIT_ASSIGN)
4207 IDX idx, reward_idx = 0;
4209 for (idx = 2; idx < num; idx++)
4211 IDX a_idx = (IDX)atoi(zz[idx]);
4212 if (a_idx < 1) continue;
4213 if (a_info[a_idx].cur_num > 0) continue;
4215 if (one_in_(count)) reward_idx = a_idx;
4220 /* Set quest's rewarding artifact */
4221 q_ptr->k_idx = reward_idx;
4222 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4226 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4227 q_ptr->type = QUEST_TYPE_KILL_ALL;
4234 /* Process "Q:<q_index>:N:<name>" -- quest name */
4235 else if (zz[1][0] == 'N')
4237 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4239 strcpy(q_ptr->name, zz[2]);
4245 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4246 else if (zz[1][0] == 'T')
4248 if (init_flags & INIT_SHOW_TEXT)
4250 strcpy(quest_text[quest_text_line], zz[2]);
4258 /* Process "W:<command>: ..." -- info for the wilderness */
4259 else if (buf[0] == 'W')
4261 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4264 /* Process "P:<y>:<x>" -- player position */
4265 else if (buf[0] == 'P')
4267 if (init_flags & INIT_CREATE_DUNGEON)
4269 if (tokenize(buf + 2, 2, zz, 0) == 2)
4271 int panels_x, panels_y;
4273 /* Hack - Set the dungeon size */
4274 panels_y = (*y / SCREEN_HGT);
4275 if (*y % SCREEN_HGT) panels_y++;
4276 cur_hgt = panels_y * SCREEN_HGT;
4278 panels_x = (*x / SCREEN_WID);
4279 if (*x % SCREEN_WID) panels_x++;
4280 cur_wid = panels_x * SCREEN_WID;
4282 /* Assume illegal panel */
4283 panel_row_min = cur_hgt;
4284 panel_col_min = cur_wid;
4286 /* Place player in a quest level */
4287 if (p_ptr->inside_quest)
4291 /* Delete the monster (if any) */
4292 delete_monster(p_ptr->y, p_ptr->x);
4300 /* Place player in the town */
4301 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4303 p_ptr->oldpy = atoi(zz[0]);
4304 p_ptr->oldpx = atoi(zz[1]);
4312 /* Process "B:<Index>:<Command>:..." -- Building definition */
4313 else if (buf[0] == 'B')
4315 return parse_line_building(buf);
4318 /* Process "M:<type>:<maximum>" -- set maximum values */
4319 else if (buf[0] == 'M')
4321 if (tokenize(buf+2, 2, zz, 0) == 2)
4324 if (zz[0][0] == 'T')
4326 max_towns = (TOWN_IDX)atoi(zz[1]);
4329 /* Maximum quests */
4330 else if (zz[0][0] == 'Q')
4332 max_q_idx = (QUEST_IDX)atoi(zz[1]);
4336 else if (zz[0][0] == 'R')
4338 max_r_idx = (IDX)atoi(zz[1]);
4342 else if (zz[0][0] == 'K')
4344 max_k_idx = (IDX)atoi(zz[1]);
4348 else if (zz[0][0] == 'V')
4350 max_v_idx = (IDX)atoi(zz[1]);
4354 else if (zz[0][0] == 'F')
4356 max_f_idx = (IDX)atoi(zz[1]);
4360 else if (zz[0][0] == 'A')
4362 max_a_idx = (IDX)atoi(zz[1]);
4366 else if (zz[0][0] == 'E')
4368 max_e_idx = (IDX)atoi(zz[1]);
4372 else if (zz[0][0] == 'D')
4374 max_d_idx = (IDX)atoi(zz[1]);
4378 else if (zz[0][0] == 'O')
4380 max_o_idx = (IDX)atoi(zz[1]);
4384 else if (zz[0][0] == 'M')
4386 max_m_idx = (IDX)atoi(zz[1]);
4389 /* Wilderness size */
4390 else if (zz[0][0] == 'W')
4392 /* Maximum wild_x_size */
4393 if (zz[0][1] == 'X')
4394 max_wild_x = atoi(zz[1]);
4395 /* Maximum wild_y_size */
4396 if (zz[0][1] == 'Y')
4397 max_wild_y = atoi(zz[1]);
4411 static concptr variant = "ZANGBAND";
4415 * @brief クエスト用固定ダンジョン生成時の分岐処理
4416 * Helper function for "process_dungeon_file()"
4421 static concptr process_dungeon_file_expr(char **sp, char *fp)
4437 while (iswspace(*s)) s++;
4455 t = process_dungeon_file_expr(&s, &f);
4463 else if (streq(t, "IOR"))
4466 while (*s && (f != b2))
4468 t = process_dungeon_file_expr(&s, &f);
4469 if (*t && !streq(t, "0")) v = "1";
4474 else if (streq(t, "AND"))
4477 while (*s && (f != b2))
4479 t = process_dungeon_file_expr(&s, &f);
4480 if (*t && streq(t, "0")) v = "0";
4485 else if (streq(t, "NOT"))
4488 while (*s && (f != b2))
4490 t = process_dungeon_file_expr(&s, &f);
4491 if (*t && streq(t, "1")) v = "0";
4496 else if (streq(t, "EQU"))
4499 if (*s && (f != b2))
4501 t = process_dungeon_file_expr(&s, &f);
4503 while (*s && (f != b2))
4505 p = process_dungeon_file_expr(&s, &f);
4506 if (streq(t, p)) v = "1";
4511 else if (streq(t, "LEQ"))
4514 if (*s && (f != b2))
4516 t = process_dungeon_file_expr(&s, &f);
4518 while (*s && (f != b2))
4521 t = process_dungeon_file_expr(&s, &f);
4522 if (*t && atoi(p) > atoi(t)) v = "0";
4527 else if (streq(t, "GEQ"))
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);
4539 /* Compare two numbers instead of string */
4540 if (*t && atoi(p) < atoi(t)) v = "0";
4546 while (*s && (f != b2))
4548 t = process_dungeon_file_expr(&s, &f);
4553 if (f != b2) v = "?x?x?";
4555 /* Extract final and Terminate */
4556 if ((f = *s) != '\0') *s++ = '\0';
4562 /* Accept all printables except spaces and brackets */
4564 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4566 if (iskanji(*s)) s++;
4570 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4573 /* Extract final and Terminate */
4574 if ((f = *s) != '\0') *s++ = '\0';
4580 if (streq(b+1, "SYS"))
4586 else if (streq(b+1, "GRAF"))
4591 else if (streq(b+1, "MONOCHROME"))
4600 else if (streq(b+1, "RACE"))
4602 v = _(rp_ptr->E_title, rp_ptr->title);
4606 else if (streq(b+1, "CLASS"))
4608 v = _(cp_ptr->E_title, cp_ptr->title);
4612 else if (streq(b+1, "REALM1"))
4614 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4618 else if (streq(b+1, "REALM2"))
4620 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4624 else if (streq(b+1, "PLAYER"))
4626 static char tmp_player_name[32];
4628 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4638 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4641 v = tmp_player_name;
4645 else if (streq(b+1, "TOWN"))
4647 sprintf(tmp, "%d", p_ptr->town_num);
4652 else if (streq(b+1, "LEVEL"))
4654 sprintf(tmp, "%d", p_ptr->lev);
4658 /* Current quest number */
4659 else if (streq(b+1, "QUEST_NUMBER"))
4661 sprintf(tmp, "%d", p_ptr->inside_quest);
4665 /* Number of last quest */
4666 else if (streq(b+1, "LEAVING_QUEST"))
4668 sprintf(tmp, "%d", leaving_quest);
4673 else if (prefix(b+1, "QUEST_TYPE"))
4675 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4676 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4681 else if (prefix(b+1, "QUEST"))
4683 /* "QUEST" uses a special parameter to determine the number of the quest */
4684 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4689 else if (prefix(b+1, "RANDOM"))
4691 /* "RANDOM" uses a special parameter to determine the number of the quest */
4692 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4697 else if (streq(b+1, "VARIANT"))
4703 else if (streq(b+1, "WILDERNESS"))
4706 sprintf(tmp, "NONE");
4708 sprintf(tmp, "LITE");
4710 sprintf(tmp, "NORMAL");
4730 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4731 * Helper function for "process_dungeon_file()"
4739 errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax)
4745 bool bypass = FALSE;
4746 int x = xmin, y = ymin;
4749 /* Build the filename */
4750 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4753 fp = my_fopen(buf, "r");
4756 if (!fp) return (-1);
4759 /* Process the file */
4760 while (0 == my_fgets(fp, buf, sizeof(buf)))
4766 /* Skip "empty" lines */
4767 if (!buf[0]) continue;
4769 /* Skip "blank" lines */
4770 if (iswspace(buf[0])) continue;
4773 if (buf[0] == '#') continue;
4776 /* Process "?:<expr>" */
4777 if ((buf[0] == '?') && (buf[1] == ':'))
4786 /* Parse the expr */
4787 v = process_dungeon_file_expr(&s, &f);
4790 bypass = (streq(v, "0") ? TRUE : FALSE);
4794 /* Apply conditionals */
4795 if (bypass) continue;
4797 /* Process the line */
4798 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4809 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4811 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4812 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4824 void write_r_info_txt(void)
4826 int i, j, z, fc, bc;
4829 concptr flags[32 * 10];
4834 monster_race *r_ptr;
4836 monster_blow *b_ptr;
4838 FILE *fff = fopen("output.txt", "wt");
4842 BIT_FLAGS mode = -1;
4846 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4848 fprintf(fff, "# Version stamp (required)\n\n");
4851 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4854 fprintf(fff, "##### The Player #####\n\n");
4856 for (z = -1; z < alloc_race_size; z++)
4858 /* Output the monsters in order */
4859 i = (z >= 0) ? alloc_race_table[z].index : 0;
4861 /* Acquire the monster */
4864 /* Ignore empty monsters */
4865 if (!strlen(r_name + r_ptr->name)) continue;
4867 /* Ignore useless monsters */
4868 if (i && !r_ptr->speed) continue;
4870 /* Write a note if necessary */
4871 if (i && (!r_ptr->level != !mode))
4876 fprintf(fff, "\n##### Town monsters #####\n\n");
4878 /* Note the dungeon */
4881 fprintf(fff, "\n##### Normal monsters #####\n\n");
4884 /* Record the change */
4885 mode = r_ptr->level;
4888 /* Acquire the flags */
4889 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4890 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4891 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4892 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4893 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4894 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4895 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4896 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4897 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4898 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4900 /* Write New/Number/Name */
4901 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4904 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4906 /* Write Information */
4907 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4908 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4910 /* Write more information */
4911 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4914 for(j = 0; j < 4; j++)
4916 b_ptr = &(r_ptr->blow[j]);
4918 /* Stop when done */
4919 if (!b_ptr->method) break;
4921 /* Write the blows */
4922 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4923 r_info_blow_effect[b_ptr->effect],
4924 b_ptr->d_dice, b_ptr->d_side);
4926 for (fc = 0, j = 0; j < 32 * 3; j++)
4928 /* Check this flag */
4929 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4932 /* Extract the extra flags */
4933 for (j = 32 * 6; j < 32 * 10; j++)
4935 /* Check this flag */
4936 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4939 /* Write the flags */
4940 for (j = 0; j < fc;)
4944 /* Start the line */
4947 for (bc = 0; (bc < 60) && (j < fc); j++)
4951 /* Format the flag */
4952 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4954 /* Add it to the buffer */
4957 /* Note the length */
4961 /* Done with this line; write it */
4962 fprintf(fff, "%s\n", buf);
4965 /* Write Spells if applicable */
4966 if (r_ptr->freq_spell)
4968 /* Write the frequency */
4969 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4971 /* Extract the spell flags */
4972 for (fc = 0, j = 96; j < 192; j++)
4974 /* Check this flag */
4975 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4978 /* Write the flags */
4979 for (j = 0; j < fc;)
4983 /* Start the line */
4986 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4990 /* Format the flag */
4991 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4995 /* Note the length */
5002 /* Done with this line; write it */
5003 fprintf(fff, "%s\n", buf);
5007 /* Acquire the description */
5008 desc = r_text + r_ptr->text;
5009 dlen = strlen(desc);
5011 /* Write Description */
5012 for (j = 0; j < dlen;)
5016 /* Start the line */
5019 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5027 /* Done with this line; write it */
5028 fprintf(fff, "%s\n", buf);
5031 /* Space between entries */