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];
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]);
1749 if (s_attr > 127) return (1);
1751 /* Save the standard values */
1752 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1753 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1755 /* Is this feature supports lighting? */
1758 /* G:c:a:LIT (default) */
1759 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1761 /* G:c:a:lc:la:dc:da */
1762 if (!streq(buf + 6, "LIT"))
1764 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1766 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1767 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1768 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1769 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1771 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1773 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1776 /* Use default lighting */
1779 /* No lighting support */
1780 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1783 /* Extract the color */
1784 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1785 if (f_ptr->d_attr[j] > 127) return 1;
1788 f_ptr->d_char[j] = char_tmp[j];
1794 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1796 f_ptr->d_attr[j] = s_attr;
1797 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1803 /* Hack -- Process 'F' for flags */
1804 else if (buf[0] == 'F')
1806 /* Parse every entry textually */
1807 for (s = buf + 2; *s; )
1809 /* Find the end of this entry */
1810 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1812 /* Nuke and skip any dividers */
1816 while (*t == ' ' || *t == '|') t++;
1819 /* Hack -- Read feature subtype */
1820 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1822 /* Extract a "subtype" */
1823 f_ptr->subtype = (FEAT_SUBTYPE)i;
1825 /* Start at next entry */
1831 /* Hack -- Read feature power */
1832 if (1 == sscanf(s, "POWER_%d", &i))
1834 /* Extract a "power" */
1835 f_ptr->power = (FEAT_POWER)i;
1837 /* Start at next entry */
1842 /* Parse this entry */
1843 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1845 /* Start the next entry */
1850 /* Process 'W' for "More Info" (one line only) */
1851 else if (buf[0] == 'W')
1855 /* Scan for the value */
1856 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1858 /* Save the value */
1859 f_ptr->priority = (FEAT_PRIORITY)priority;
1862 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1863 else if (buf[0] == 'K')
1867 /* Find the next empty state slot (if any) */
1868 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1870 /* Oops, no more slots */
1871 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1873 /* Analyze the first field */
1874 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1876 /* Terminate the field (if necessary) */
1877 if (*t == ':') *t++ = '\0';
1879 /* Is this default entry? */
1880 if (streq(s, "DESTROYED"))
1882 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1884 /* Record a fake tag index */
1885 f_ptr->destroyed_tag = offset;
1890 f_ptr->state[i].action = 0;
1892 /* Parse this entry */
1893 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1895 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1897 /* Record a fake tag index */
1898 f_ptr->state[i].result_tag = offset;
1910 * @brief 地形タグからIDを得る /
1911 * Convert a fake tag to a real feat index
1915 s16b f_tag_to_index(concptr str)
1919 /* Search for real index corresponding to this fake tag */
1920 for (i = 0; i < f_head.info_num; i++)
1922 if (streq(f_tag + f_info[i].tag, str))
1924 /* Return the index */
1935 * @brief 地形タグからIDを得る /
1936 * Search for real index corresponding to this fake tag
1937 * @param feat タグ文字列のオフセット
1938 * @return 地形ID。該当がないなら-1
1940 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1944 /* Don't convert non-fake tag */
1950 /* Search for real index corresponding to this fake tag */
1951 for (i = 0; i < f_head.info_num; i++)
1953 if (feat == f_info[i].tag)
1955 /* Record real index */
1961 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1967 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1968 * Retouch fake tags of f_info
1969 * @param head ヘッダ構造体
1972 void retouch_f_info(header *head)
1976 /* Convert fake tags to real feat indices */
1977 for (i = 0; i < head->info_num; i++)
1979 feature_type *f_ptr = &f_info[i];
1982 k = search_real_feat(f_ptr->mimic_tag);
1983 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1984 k = search_real_feat(f_ptr->destroyed_tag);
1985 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1986 for (j = 0; j < MAX_FEAT_STATES; j++)
1988 k = search_real_feat(f_ptr->state[j].result_tag);
1989 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
1996 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
1997 * Grab one flag in an object_kind from a textual string
1998 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
1999 * @param what 参照元の文字列ポインタ
2002 static errr grab_one_kind_flag(object_kind *k_ptr, concptr what)
2007 for (i = 0; i < TR_FLAG_MAX; i++)
2009 if (streq(what, k_info_flags[i]))
2011 add_flag(k_ptr->flags, i);
2016 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2019 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2026 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2027 * Grab one activation index flag
2028 * @param what 参照元の文字列ポインタ
2031 static byte grab_one_activation_flag(concptr what)
2037 if (activation_info[i].flag == NULL) break;
2039 if (streq(what, activation_info[i].flag))
2041 return activation_info[i].index;
2051 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2059 * @brief ベースアイテム(k_info)のパース関数 /
2060 * Initialize the "k_info" array, by parsing an ascii "template" file
2062 * @param head ヘッダ構造体
2065 errr parse_k_info(char *buf, header *head)
2072 static object_kind *k_ptr = NULL;
2075 /* Process 'N' for "New/Number/Name" */
2082 /* Find the colon before the name */
2083 s = my_strchr(buf+2, ':');
2085 /* Verify that colon */
2088 /* Nuke the colon, advance to the name */
2094 /* Verify information */
2095 if (i <= error_idx) return (4);
2097 /* Verify information */
2098 if (i >= head->info_num) return (2);
2100 /* Save the index */
2103 /* Point at the "info" */
2107 /* Paranoia -- require a name */
2108 if (!*s) return (1);
2110 /* Find the colon before the flavor */
2111 flavor = my_strchr(s, ':');
2113 /* Verify that colon */
2116 /* Nuke the colon, advance to the flavor */
2119 /* Store the flavor */
2120 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2123 /* Store the name */
2124 if (!add_name(&k_ptr->name, head, s)) return (7);
2128 /* There better be a current k_ptr */
2129 else if (!k_ptr) return (3);
2134 /* 'E' から始まる行は英語名としている */
2135 else if (buf[0] == 'E')
2140 else if (buf[0] == 'E')
2144 /* Acquire the name */
2147 /* Find the colon before the flavor */
2148 flavor = my_strchr(s, ':');
2150 /* Verify that colon */
2153 /* Nuke the colon, advance to the flavor */
2156 /* Store the flavor */
2157 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2160 /* Store the name */
2161 if (!add_name(&k_ptr->name, head, s)) return (7);
2165 /* Process 'D' for "Description" */
2166 else if (buf[0] == 'D')
2171 /* Acquire the text */
2176 /* Acquire the text */
2180 /* Store the text */
2181 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2184 /* Process 'G' for "Graphics" (one line only) */
2185 else if (buf[0] == 'G')
2189 if (buf[1] != ':') return (1);
2190 if (!buf[2]) return (1);
2191 if (buf[3] != ':') return (1);
2192 if (!buf[4]) return (1);
2194 /* Extract the char */
2197 /* Extract the attr */
2198 tmp = color_char_to_attr(buf[4]);
2199 if (tmp > 127) return (1);
2201 /* Save the values */
2202 k_ptr->d_attr = tmp;
2203 k_ptr->d_char = sym;
2206 /* Process 'I' for "Info" (one line only) */
2207 else if (buf[0] == 'I')
2209 int tval, sval, pval;
2211 /* Scan for the values */
2212 if (3 != sscanf(buf+2, "%d:%d:%d",
2213 &tval, &sval, &pval)) return (1);
2215 /* Save the values */
2216 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2217 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2218 k_ptr->pval = (PARAMETER_VALUE)pval;
2221 /* Process 'W' for "More Info" (one line only) */
2222 else if (buf[0] == 'W')
2224 int level, extra, wgt;
2227 /* Scan for the values */
2228 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2229 &level, &extra, &wgt, &cost)) return (1);
2231 /* Save the values */
2232 k_ptr->level = (DEPTH)level;
2233 k_ptr->extra = (BIT_FLAGS8)extra;
2234 k_ptr->weight = (WEIGHT)wgt;
2235 k_ptr->cost = (PRICE)cost;
2238 /* Process 'A' for "Allocation" (one line only) */
2239 else if (buf[0] == 'A')
2242 /* Simply read each number following a colon */
2243 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2245 /* Default chance */
2246 k_ptr->chance[i] = 1;
2248 /* Store the attack damage index */
2249 k_ptr->locale[i] = atoi(s+1);
2251 /* Find the slash */
2252 t = my_strchr(s+1, '/');
2254 /* Find the next colon */
2255 s = my_strchr(s+1, ':');
2257 /* If the slash is "nearby", use it */
2258 if (t && (!s || t < s))
2260 int chance = atoi(t+1);
2261 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2266 /* Hack -- Process 'P' for "power" and such */
2267 else if (buf[0] == 'P')
2269 int ac, hd1, hd2, th, td, ta;
2271 /* Scan for the values */
2272 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2273 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2275 k_ptr->ac = (ARMOUR_CLASS)ac;
2276 k_ptr->dd = (DICE_NUMBER)hd1;
2277 k_ptr->ds = (DICE_SID)hd2;
2278 k_ptr->to_h = (HIT_PROB)th;
2279 k_ptr->to_d = (HIT_POINT)td;
2280 k_ptr->to_a = (ARMOUR_CLASS)ta;
2283 /* Hack -- Process 'U' for activation index */
2284 else if (buf[0] == 'U')
2287 n = grab_one_activation_flag(buf + 2);
2298 /* Hack -- Process 'F' for flags */
2299 else if (buf[0] == 'F')
2301 /* Parse every entry textually */
2302 for (s = buf + 2; *s; )
2304 /* Find the end of this entry */
2305 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2307 /* Nuke and skip any dividers */
2311 while (*t == ' ' || *t == '|') t++;
2314 /* Parse this entry */
2315 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2317 /* Start the next entry */
2331 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2332 * Grab one activation index flag
2333 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2334 * @param what 参照元の文字列ポインタ
2335 * @return エラーがあった場合1、エラーがない場合0を返す
2337 static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
2342 for (i = 0; i < TR_FLAG_MAX; i++)
2344 if (streq(what, k_info_flags[i]))
2346 add_flag(a_ptr->flags, i);
2351 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2354 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2362 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2363 * Initialize the "a_info" array, by parsing an ascii "template" file
2365 * @param head ヘッダ構造体
2368 errr parse_a_info(char *buf, header *head)
2375 static artifact_type *a_ptr = NULL;
2378 /* Process 'N' for "New/Number/Name" */
2381 /* Find the colon before the name */
2382 s = my_strchr(buf+2, ':');
2384 /* Verify that colon */
2387 /* Nuke the colon, advance to the name */
2390 /* Paranoia -- require a name */
2391 if (!*s) return (1);
2396 /* Verify information */
2397 if (i < error_idx) return (4);
2399 /* Verify information */
2400 if (i >= head->info_num) return (2);
2402 /* Save the index */
2405 /* Point at the "info" */
2408 /* Ignore everything */
2409 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2410 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2411 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2412 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2414 /* Store the name */
2415 if (!add_name(&a_ptr->name, head, s)) return (7);
2419 /* There better be a current a_ptr */
2420 else if (!a_ptr) return (3);
2425 /* 'E' から始まる行は英語名としている */
2426 else if (buf[0] == 'E')
2431 else if (buf[0] == 'E')
2433 /* Acquire the Text */
2436 /* Store the name */
2437 if (!add_name(&a_ptr->name, head, s)) return (7);
2441 /* Process 'D' for "Description" */
2442 else if (buf[0] == 'D')
2447 /* Acquire the text */
2452 /* Acquire the text */
2456 /* Store the text */
2457 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2461 /* Process 'I' for "Info" (one line only) */
2462 else if (buf[0] == 'I')
2464 int tval, sval, pval;
2466 /* Scan for the values */
2467 if (3 != sscanf(buf+2, "%d:%d:%d",
2468 &tval, &sval, &pval)) return (1);
2470 /* Save the values */
2471 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2472 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2473 a_ptr->pval = (PARAMETER_VALUE)pval;
2476 /* Process 'W' for "More Info" (one line only) */
2477 else if (buf[0] == 'W')
2479 int level, rarity, wgt;
2482 /* Scan for the values */
2483 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2484 &level, &rarity, &wgt, &cost)) return (1);
2486 /* Save the values */
2487 a_ptr->level = (DEPTH)level;
2488 a_ptr->rarity = (RARITY)rarity;
2489 a_ptr->weight = (WEIGHT)wgt;
2490 a_ptr->cost = (PRICE)cost;
2493 /* Hack -- Process 'P' for "power" and such */
2494 else if (buf[0] == 'P')
2496 int ac, hd1, hd2, th, td, ta;
2498 /* Scan for the values */
2499 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2500 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2502 a_ptr->ac = (ARMOUR_CLASS)ac;
2503 a_ptr->dd = (DICE_NUMBER)hd1;
2504 a_ptr->ds = (DICE_SID)hd2;
2505 a_ptr->to_h = (HIT_PROB)th;
2506 a_ptr->to_d = (HIT_POINT)td;
2507 a_ptr->to_a = (ARMOUR_CLASS)ta;
2510 /* Hack -- Process 'U' for activation index */
2511 else if (buf[0] == 'U')
2514 n = grab_one_activation_flag(buf + 2);
2525 /* Hack -- Process 'F' for flags */
2526 else if (buf[0] == 'F')
2528 /* Parse every entry textually */
2529 for (s = buf + 2; *s; )
2531 /* Find the end of this entry */
2532 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2534 /* Nuke and skip any dividers */
2538 while ((*t == ' ') || (*t == '|')) t++;
2541 /* Parse this entry */
2542 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2544 /* Start the next entry */
2559 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2560 * Grab one flag in a ego-item_type from a textual string
2561 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2562 * @param what 参照元の文字列ポインタ
2563 * @return エラーがあった場合1、エラーがない場合0を返す
2565 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
2570 for (i = 0; i < TR_FLAG_MAX; i++)
2572 if (streq(what, k_info_flags[i]))
2574 add_flag(e_ptr->flags, i);
2579 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2582 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2590 * @brief アイテムエゴ情報(e_info)のパース関数 /
2591 * Initialize the "e_info" array, by parsing an ascii "template" file
2593 * @param head ヘッダ構造体
2596 errr parse_e_info(char *buf, header *head)
2602 static ego_item_type *e_ptr = NULL;
2604 /* Just before the first record */
2607 /* Just before the first line */
2610 /* Process 'N' for "New/Number/Name" */
2613 /* Find the colon before the name */
2614 s = my_strchr(buf+2, ':');
2616 /* Verify that colon */
2619 /* Nuke the colon, advance to the name */
2622 /* Paranoia -- require a name */
2623 if (!*s) return (1);
2628 /* Verify information */
2629 if (i < error_idx) return (4);
2631 /* Verify information */
2632 if (i >= head->info_num) return (2);
2634 /* Save the index */
2637 /* Point at the "info" */
2640 /* Store the name */
2641 if (!add_name(&e_ptr->name, head, s)) return (7);
2645 /* There better be a current e_ptr */
2646 else if (!e_ptr) return (3);
2651 /* 'E' から始まる行は英語名 */
2652 else if (buf[0] == 'E')
2657 else if (buf[0] == 'E')
2659 /* Acquire the Text */
2662 /* Store the name */
2663 if (!add_name(&e_ptr->name, head, s)) return (7);
2668 /* Process 'D' for "Description" */
2669 else if (buf[0] == 'D')
2671 /* Acquire the text */
2674 /* Store the text */
2675 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2680 /* Process 'X' for "Xtra" (one line only) */
2681 else if (buf[0] == 'X')
2685 /* Scan for the values */
2686 if (2 != sscanf(buf+2, "%d:%d",
2687 &slot, &rating)) return (1);
2689 /* Save the values */
2690 e_ptr->slot = (INVENTORY_IDX)slot;
2691 e_ptr->rating = (PRICE)rating;
2694 /* Process 'W' for "More Info" (one line only) */
2695 else if (buf[0] == 'W')
2697 int level, rarity, pad2;
2700 /* Scan for the values */
2701 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2702 &level, &rarity, &pad2, &cost)) return (1);
2704 /* Save the values */
2705 e_ptr->level = level;
2706 e_ptr->rarity = (RARITY)rarity;
2707 /* e_ptr->weight = wgt; */
2711 /* Hack -- Process 'C' for "creation" */
2712 else if (buf[0] == 'C')
2714 int th, td, ta, pval;
2716 /* Scan for the values */
2717 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2718 &th, &td, &ta, &pval)) return (1);
2720 e_ptr->max_to_h = (HIT_PROB)th;
2721 e_ptr->max_to_d = (HIT_POINT)td;
2722 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2723 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2726 /* Hack -- Process 'U' for activation index */
2727 else if (buf[0] == 'U')
2730 n = grab_one_activation_flag(buf + 2);
2741 /* Hack -- Process 'F' for flags */
2742 else if (buf[0] == 'F')
2744 /* Parse every entry textually */
2745 for (s = buf + 2; *s; )
2747 /* Find the end of this entry */
2748 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2750 /* Nuke and skip any dividers */
2754 while ((*t == ' ') || (*t == '|')) t++;
2757 /* Parse this entry */
2758 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2760 /* Start the next entry */
2773 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2774 * Grab one (basic) flag in a monster_race from a textual string
2775 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2776 * @param what 参照元の文字列ポインタ
2779 static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
2781 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2784 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2787 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2790 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2793 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2796 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2799 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2802 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2810 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2811 * Grab one (spell) flag in a monster_race from a textual string
2812 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2813 * @param what 参照元の文字列ポインタ
2816 static errr grab_one_spell_flag(monster_race *r_ptr, concptr what)
2818 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2821 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2824 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2827 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2835 * @brief モンスター種族情報(r_info)のパース関数 /
2836 * Initialize the "r_info" array, by parsing an ascii "template" file
2838 * @param head ヘッダ構造体
2841 errr parse_r_info(char *buf, header *head)
2847 static monster_race *r_ptr = NULL;
2850 /* Process 'N' for "New/Number/Name" */
2853 /* Find the colon before the name */
2854 s = my_strchr(buf+2, ':');
2856 /* Verify that colon */
2859 /* Nuke the colon, advance to the name */
2862 /* Paranoia -- require a name */
2863 if (!*s) return (1);
2868 /* Verify information */
2869 if (i < error_idx) return (4);
2871 /* Verify information */
2872 if (i >= head->info_num) return (2);
2874 /* Save the index */
2877 /* Point at the "info" */
2880 /* Store the name */
2881 if (!add_name(&r_ptr->name, head, s)) return (7);
2885 /* There better be a current r_ptr */
2886 else if (!r_ptr) return (3);
2891 /* 'E' から始まる行は英語名 */
2892 else if (buf[0] == 'E')
2894 /* Acquire the Text */
2897 /* Store the name */
2898 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2901 else if (buf[0] == 'E')
2903 /* Acquire the Text */
2906 /* Store the name */
2907 if (!add_name(&r_ptr->name, head, s)) return (7);
2910 /* Process 'D' for "Description" */
2911 else if (buf[0] == 'D')
2916 /* Acquire the text */
2921 /* Acquire the text */
2925 /* Store the text */
2926 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2929 /* Process 'G' for "Graphics" (one line only) */
2930 else if (buf[0] == 'G')
2934 if (buf[1] != ':') return (1);
2935 if (!buf[2]) return (1);
2936 if (buf[3] != ':') return (1);
2937 if (!buf[4]) return (1);
2939 /* Extract the char */
2942 /* Extract the attr */
2943 tmp = color_char_to_attr(buf[4]);
2944 if (tmp > 127) return (1);
2946 /* Save the values */
2947 r_ptr->d_char = sym;
2948 r_ptr->d_attr = tmp;
2951 /* Process 'I' for "Info" (one line only) */
2952 else if (buf[0] == 'I')
2954 int spd, hp1, hp2, aaf, ac, slp;
2956 /* Scan for the other values */
2957 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2958 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2960 /* Save the values */
2961 r_ptr->speed = (SPEED)spd;
2962 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2963 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2964 r_ptr->aaf = (POSITION)aaf;
2965 r_ptr->ac = (ARMOUR_CLASS)ac;
2966 r_ptr->sleep = (SLEEP_DEGREE)slp;
2969 /* Process 'W' for "More Info" (one line only) */
2970 else if (buf[0] == 'W')
2977 /* Scan for the values */
2978 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2979 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2981 /* Save the values */
2982 r_ptr->level = (DEPTH)lev;
2983 r_ptr->rarity = (RARITY)rar;
2984 r_ptr->extra = (BIT_FLAGS16)pad;
2985 r_ptr->mexp = (EXP)exp;
2986 r_ptr->next_exp = (EXP)nextexp;
2987 r_ptr->next_r_idx = (IDX)nextmon;
2990 /* Process 'R' for "Reinforcement" (up to six lines) */
2991 else if (buf[0] == 'R')
2994 /* Find the next empty blow slot (if any) */
2995 for (i = 0; i < A_MAX; i++) if (r_ptr->reinforce_id[i] == 0) break;
2997 /* Oops, no more slots */
2998 if (i == 6) return (1);
3000 /* Scan for the values */
3001 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3002 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3003 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3004 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3007 /* Process 'B' for "Blows" (up to four lines) */
3008 else if (buf[0] == 'B')
3012 /* Find the next empty blow slot (if any) */
3013 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3015 /* Oops, no more slots */
3016 if (i == 4) return (1);
3018 /* Analyze the first field */
3019 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3021 /* Terminate the field (if necessary) */
3022 if (*t == ':') *t++ = '\0';
3024 /* Analyze the method */
3025 for (n1 = 0; r_info_blow_method[n1]; n1++)
3027 if (streq(s, r_info_blow_method[n1])) break;
3030 /* Invalid method */
3031 if (!r_info_blow_method[n1]) return (1);
3033 /* Analyze the second field */
3034 for (s = t; *t && (*t != ':'); t++) /* loop */;
3036 /* Terminate the field (if necessary) */
3037 if (*t == ':') *t++ = '\0';
3039 /* Analyze effect */
3040 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3042 if (streq(s, r_info_blow_effect[n2])) break;
3045 /* Invalid effect */
3046 if (!r_info_blow_effect[n2]) return (1);
3048 /* Analyze the third field */
3049 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3051 /* Terminate the field (if necessary) */
3052 if (*t == 'd') *t++ = '\0';
3054 /* Save the method */
3055 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3057 /* Save the effect */
3058 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3060 /* Extract the damage dice and sides */
3061 r_ptr->blow[i].d_dice = atoi(s);
3062 r_ptr->blow[i].d_side = atoi(t);
3065 /* Process 'F' for "Basic Flags" (multiple lines) */
3066 else if (buf[0] == 'F')
3068 /* Parse every entry */
3069 for (s = buf + 2; *s; )
3071 /* Find the end of this entry */
3072 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3074 /* Nuke and skip any dividers */
3078 while (*t == ' ' || *t == '|') t++;
3081 /* Parse this entry */
3082 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3084 /* Start the next entry */
3089 /* Process 'S' for "Spell Flags" (multiple lines) */
3090 else if (buf[0] == 'S')
3092 /* Parse every entry */
3093 for (s = buf + 2; *s; )
3095 /* Find the end of this entry */
3096 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3098 /* Nuke and skip any dividers */
3102 while ((*t == ' ') || (*t == '|')) t++;
3105 /* Hack -- Read spell frequency */
3106 if (1 == sscanf(s, "1_IN_%d", &i))
3108 /* Extract a "frequency" */
3109 r_ptr->freq_spell = 100 / i;
3111 /* Start at next entry */
3116 /* Parse this entry */
3117 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3119 /* Start the next entry */
3124 /* Process 'A' for "Artifact Flags" (multiple lines) */
3125 else if (buf[0] == 'A')
3127 int id, per, rarity;
3129 /* Find the next empty blow slot (if any) */
3130 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3132 /* Oops, no more slots */
3133 if (i == 4) return (1);
3135 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3136 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3137 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3138 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3141 /* Process 'V' for "Arena power value ratio" */
3142 else if (buf[0] == 'V')
3145 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3146 r_ptr->arena_ratio = (PERCENTAGE)val;
3158 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3159 * Grab one flag for a dungeon type from a textual string
3160 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3161 * @param what 参照元の文字列ポインタ
3164 static errr grab_one_dungeon_flag(dungeon_type *d_ptr, concptr what)
3166 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3169 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3176 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3177 * Grab one (basic) flag in a monster_race from a textual string
3178 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3179 * @param what 参照元の文字列ポインタ
3182 static errr grab_one_basic_monster_flag(dungeon_type *d_ptr, concptr what)
3184 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3187 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3190 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3193 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3196 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3199 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3202 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3205 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3212 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3213 * Grab one (spell) flag in a monster_race from a textual string
3214 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3215 * @param what 参照元の文字列ポインタ
3218 static errr grab_one_spell_monster_flag(dungeon_type *d_ptr, concptr what)
3220 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3223 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3226 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3229 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3236 * @brief ダンジョン情報(d_info)のパース関数 /
3237 * Initialize the "d_info" array, by parsing an ascii "template" file
3239 * @param head ヘッダ構造体
3242 errr parse_d_info(char *buf, header *head)
3248 static dungeon_type *d_ptr = NULL;
3250 /* Process 'N' for "New/Number/Name" */
3253 /* Find the colon before the name */
3254 s = my_strchr(buf+2, ':');
3256 /* Verify that colon */
3259 /* Nuke the colon, advance to the name */
3262 /* Paranoia -- require a name */
3263 if (!*s) return (1);
3268 /* Verify information */
3269 if (i < error_idx) return (4);
3271 /* Verify information */
3272 if (i >= head->info_num) return (2);
3274 /* Save the index */
3277 /* Point at the "info" */
3280 /* Store the name */
3281 if (!add_name(&d_ptr->name, head, s)) return (7);
3286 else if (buf[0] == 'E') return (0);
3288 else if (buf[0] == 'E')
3290 /* Acquire the Text */
3293 /* Store the name */
3294 if (!add_name(&d_ptr->name, head, s)) return (7);
3298 /* Process 'D' for "Description */
3299 else if (buf[0] == 'D')
3304 /* Acquire the text */
3309 /* Acquire the text */
3313 /* Store the text */
3314 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3317 /* Process 'W' for "More Info" (one line only) */
3318 else if (buf[0] == 'W')
3320 int min_lev, max_lev;
3322 int min_alloc, max_chance;
3323 int obj_good, obj_great;
3326 /* Scan for the values */
3327 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3328 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3330 /* Save the values */
3331 d_ptr->mindepth = (DEPTH)min_lev;
3332 d_ptr->maxdepth = (DEPTH)max_lev;
3333 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3334 d_ptr->mode = (BIT_FLAGS8)mode;
3335 d_ptr->min_m_alloc_level = min_alloc;
3336 d_ptr->max_m_alloc_chance = max_chance;
3337 d_ptr->obj_good = obj_good;
3338 d_ptr->obj_great = obj_great;
3339 d_ptr->pit = (BIT_FLAGS16)pit;
3340 d_ptr->nest = (BIT_FLAGS16)nest;
3343 /* Process 'P' for "Place Info" */
3344 else if (buf[0] == 'P')
3348 /* Scan for the values */
3349 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3351 /* Save the values */
3356 /* Process 'L' for "fLoor type" (one line only) */
3357 else if (buf[0] == 'L')
3361 /* Scan for the values */
3362 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3364 /* Save the values */
3365 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3367 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3368 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3370 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3372 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3375 /* Process 'A' for "wAll type" (one line only) */
3376 else if (buf[0] == 'A')
3380 /* Scan for the values */
3381 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3383 /* Save the values */
3384 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3386 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3387 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3389 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3392 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3393 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3395 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3396 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3398 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3399 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3401 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3402 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3405 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3406 else if (buf[0] == 'F')
3408 int artif = 0, monst = 0;
3410 /* Parse every entry */
3411 for (s = buf + 2; *s; )
3413 /* Find the end of this entry */
3414 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3416 /* Nuke and skip any dividers */
3420 while (*t == ' ' || *t == '|') t++;
3423 /* Hack -- Read Final Artifact */
3424 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3426 /* Extract a "Final Artifact" */
3427 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3429 /* Start at next entry */
3434 /* Hack -- Read Final Object */
3435 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3437 /* Extract a "Final Artifact" */
3438 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3440 /* Start at next entry */
3445 /* Hack -- Read Artifact Guardian */
3446 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3448 /* Extract a "Artifact Guardian" */
3449 d_ptr->final_guardian = (MONRACE_IDX)monst;
3451 /* Start at next entry */
3456 /* Hack -- Read Special Percentage */
3457 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3459 /* Extract a "Special %" */
3460 d_ptr->special_div = (PROB)monst;
3462 /* Start at next entry */
3467 /* Parse this entry */
3468 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3470 /* Start the next entry */
3475 /* Process 'M' for "Basic Flags" (multiple lines) */
3476 else if (buf[0] == 'M')
3478 /* Parse every entry */
3479 for (s = buf + 2; *s; )
3481 /* Find the end of this entry */
3482 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3484 /* Nuke and skip any dividers */
3488 while (*t == ' ' || *t == '|') t++;
3491 /* Hack -- Read monster symbols */
3492 if (!strncmp(s, "R_CHAR_", 7))
3494 /* Skip "R_CHAR_" */
3498 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3500 /* Start at next entry */
3505 /* Parse this entry */
3506 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3508 /* Start the next entry */
3513 /* Process 'S' for "Spell Flags" (multiple lines) */
3514 else if (buf[0] == 'S')
3516 /* Parse every entry */
3517 for (s = buf + 2; *s; )
3519 /* Find the end of this entry */
3520 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3522 /* Nuke and skip any dividers */
3526 while ((*t == ' ') || (*t == '|')) t++;
3529 /* Hack -- Read spell frequency */
3530 if (1 == sscanf(s, "1_IN_%d", &i))
3532 /* Start at next entry */
3537 /* Parse this entry */
3538 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3540 /* Start the next entry */
3552 #else /* ALLOW_TEMPLATES */
3558 #endif /* ALLOW_TEMPLATES */
3561 /* Random dungeon grid effects */
3562 #define RANDOM_NONE 0x00000000
3563 #define RANDOM_FEATURE 0x00000001
3564 #define RANDOM_MONSTER 0x00000002
3565 #define RANDOM_OBJECT 0x00000004
3566 #define RANDOM_EGO 0x00000008
3567 #define RANDOM_ARTIFACT 0x00000010
3568 #define RANDOM_TRAP 0x00000020
3571 typedef struct dungeon_grid dungeon_grid;
3575 FEAT_IDX feature; /* Terrain feature */
3576 MONSTER_IDX monster; /* Monster */
3577 OBJECT_IDX object; /* Object */
3578 EGO_IDX ego; /* Ego-Item */
3579 ARTIFACT_IDX artifact; /* Artifact */
3580 IDX trap; /* Trap */
3581 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3582 s16b special; /* Reserved for special terrain info */
3583 int random; /* Number of the random effect */
3587 static dungeon_grid letter[255];
3591 * @brief 地形情報の「F:」情報をパースする
3592 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3596 static errr parse_line_feature(char *buf)
3601 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3603 /* Tokenize the line */
3604 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3606 /* Letter to assign */
3607 int index = zz[0][0];
3609 /* Reset the info for the letter */
3610 letter[index].feature = feat_none;
3611 letter[index].monster = 0;
3612 letter[index].object = 0;
3613 letter[index].ego = 0;
3614 letter[index].artifact = 0;
3615 letter[index].trap = feat_none;
3616 letter[index].cave_info = 0;
3617 letter[index].special = 0;
3618 letter[index].random = RANDOM_NONE;
3624 letter[index].special = (s16b)atoi(zz[8]);
3628 if ((zz[7][0] == '*') && !zz[7][1])
3630 letter[index].random |= RANDOM_TRAP;
3634 letter[index].trap = f_tag_to_index(zz[7]);
3635 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3640 if (zz[6][0] == '*')
3642 letter[index].random |= RANDOM_ARTIFACT;
3643 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3645 else if (zz[6][0] == '!')
3647 if (p_ptr->inside_quest)
3649 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3654 letter[index].artifact = (IDX)atoi(zz[6]);
3659 if (zz[5][0] == '*')
3661 letter[index].random |= RANDOM_EGO;
3662 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3666 letter[index].ego = (IDX)atoi(zz[5]);
3671 if (zz[4][0] == '*')
3673 letter[index].random |= RANDOM_OBJECT;
3674 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3676 else if (zz[4][0] == '!')
3678 if (p_ptr->inside_quest)
3680 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3683 artifact_type *a_ptr = &a_info[a_idx];
3684 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3686 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3693 letter[index].object = (IDX)atoi(zz[4]);
3698 if (zz[3][0] == '*')
3700 letter[index].random |= RANDOM_MONSTER;
3701 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3703 else if (zz[3][0] == 'c')
3705 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3706 letter[index].monster = - atoi(zz[3] + 1);
3710 letter[index].monster = (IDX)atoi(zz[3]);
3715 letter[index].cave_info = atoi(zz[2]);
3719 if ((zz[1][0] == '*') && !zz[1][1])
3721 letter[index].random |= RANDOM_FEATURE;
3725 letter[index].feature = f_tag_to_index(zz[1]);
3726 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3739 * @brief 地形情報の「B:」情報をパースする
3740 * Process "B:<Index>:<Command>:..." -- Building definition
3744 static errr parse_line_building(char *buf)
3760 /* Get the building number */
3763 /* Find the colon after the building number */
3764 s = my_strchr(s, ':');
3766 /* Verify that colon */
3769 /* Nuke the colon, advance to the sub-index */
3772 /* Paranoia -- require a sub-index */
3773 if (!*s) return (1);
3775 /* Building definition sub-index */
3778 /* Building name, owner, race */
3781 if (tokenize(s + 2, 3, zz, 0) == 3)
3783 /* Name of the building */
3784 strcpy(building[index].name, zz[0]);
3786 /* Name of the owner */
3787 strcpy(building[index].owner_name, zz[1]);
3789 /* Race of the owner */
3790 strcpy(building[index].owner_race, zz[2]);
3795 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3798 /* Building Action */
3801 if (tokenize(s + 2, 8, zz, 0) >= 7)
3803 /* Index of the action */
3804 int action_index = atoi(zz[0]);
3806 /* Name of the action */
3807 strcpy(building[index].act_names[action_index], zz[1]);
3809 /* Cost of the action for members */
3810 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3812 /* Cost of the action for non-members */
3813 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3815 /* Letter assigned to the action */
3816 building[index].letters[action_index] = zz[4][0];
3819 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3821 /* Action restriction */
3822 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3827 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3830 /* Building Classes */
3834 n = tokenize(s + 2, MAX_CLASS, zz, 0);
3835 for (i = 0; i < MAX_CLASS; i++)
3837 building[index].member_class[i] = ((i < n) ? (CLASS_IDX)atoi(zz[i]) : 1);
3842 /* Building Races */
3846 n = tokenize(s + 2, MAX_RACES, zz, 0);
3847 for (i = 0; i < MAX_RACES; i++)
3849 building[index].member_race[i] = ((i < n) ? (RACE_IDX)atoi(zz[i]) : 1);
3854 /* Building Realms */
3858 n = tokenize(s + 2, MAX_MAGIC, zz, 0);
3859 for (i = 0; i < MAX_MAGIC; i++)
3861 building[index].member_realm[i+1] = ((i < n) ? (REALM_IDX)atoi(zz[i]) : 1);
3868 /* Ignore scripts */
3874 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3883 * @brief フロアの所定のマスにオブジェクトを配置する
3884 * Place the object j_ptr to a grid
3885 * @param j_ptr オブジェクト構造体の参照ポインタ
3890 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3892 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3895 OBJECT_IDX o_idx = o_pop();
3897 /* Access new object */
3898 o_ptr = ¤t_floor_ptr->o_list[o_idx];
3900 /* Structure copy */
3901 object_copy(o_ptr, j_ptr);
3908 o_ptr->held_m_idx = 0;
3911 o_ptr->next_o_idx = g_ptr->o_idx;
3913 g_ptr->o_idx = o_idx;
3918 * @brief クエスト用固定ダンジョンをフロアに生成する
3919 * Parse a sub-file of the "extra info"
3929 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3934 /* Skip "empty" lines */
3935 if (!buf[0]) return (0);
3937 /* Skip "blank" lines */
3938 if (iswspace(buf[0])) return (0);
3941 if (buf[0] == '#') return (0);
3943 /* Require "?:*" format */
3944 if (buf[1] != ':') return (1);
3947 /* Process "%:<fname>" */
3950 /* Attempt to Process the given file */
3951 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3954 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3957 return parse_line_feature(buf);
3960 /* Process "D:<dungeon>" -- info for the current_floor_ptr->grid_array grids */
3961 else if (buf[0] == 'D')
3963 object_type object_type_body;
3965 /* Acquire the text */
3968 /* Length of the text */
3969 int len = strlen(s);
3971 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3973 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3975 grid_type *g_ptr = ¤t_floor_ptr->grid_array[*y][*x];
3979 OBJECT_IDX object_index = letter[idx].object;
3980 MONSTER_IDX monster_index = letter[idx].monster;
3981 int random = letter[idx].random;
3982 ARTIFACT_IDX artifact_index = letter[idx].artifact;
3984 /* Lay down a floor */
3985 g_ptr->feat = conv_dungeon_feat(letter[idx].feature);
3987 /* Only the features */
3988 if (init_flags & INIT_ONLY_FEATURES) continue;
3991 g_ptr->info = letter[idx].cave_info;
3993 /* Create a monster */
3994 if (random & RANDOM_MONSTER)
3996 current_floor_ptr->monster_level = current_floor_ptr->base_level + monster_index;
3998 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4000 current_floor_ptr->monster_level = current_floor_ptr->base_level;
4002 else if (monster_index)
4004 int old_cur_num, old_max_num;
4007 if (monster_index < 0)
4009 monster_index = -monster_index;
4012 old_cur_num = r_info[monster_index].cur_num;
4013 old_max_num = r_info[monster_index].max_num;
4015 /* Make alive again */
4016 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4018 r_info[monster_index].cur_num = 0;
4019 r_info[monster_index].max_num = 1;
4022 /* Make alive again */
4023 /* Hack -- Non-unique Nazguls are semi-unique */
4024 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4026 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4028 r_info[monster_index].max_num++;
4033 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4037 current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
4039 /* Make alive again for real unique monster */
4040 r_info[monster_index].cur_num = old_cur_num;
4041 r_info[monster_index].max_num = old_max_num;
4045 /* Object (and possible trap) */
4046 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4048 current_floor_ptr->object_level = current_floor_ptr->base_level + object_index;
4051 * Random trap and random treasure defined
4052 * 25% chance for trap and 75% chance for object
4054 if (randint0(100) < 75)
4056 place_object(*y, *x, 0L);
4063 current_floor_ptr->object_level = current_floor_ptr->base_level;
4065 else if (random & RANDOM_OBJECT)
4067 current_floor_ptr->object_level = current_floor_ptr->base_level + object_index;
4069 /* Create an out of deep object */
4070 if (randint0(100) < 75)
4071 place_object(*y, *x, 0L);
4072 else if (randint0(100) < 80)
4073 place_object(*y, *x, AM_GOOD);
4075 place_object(*y, *x, AM_GOOD | AM_GREAT);
4077 current_floor_ptr->object_level = current_floor_ptr->base_level;
4080 else if (random & RANDOM_TRAP)
4084 /* Hidden trap (or door) */
4085 else if (letter[idx].trap)
4087 g_ptr->mimic = g_ptr->feat;
4088 g_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4090 else if (object_index)
4092 object_type *o_ptr = &object_type_body;
4093 object_prep(o_ptr, object_index);
4095 if (o_ptr->tval == TV_GOLD)
4097 coin_type = object_index - OBJ_GOLD_LIST;
4102 /* Apply magic (no messages, no artifacts) */
4103 apply_magic(o_ptr, current_floor_ptr->base_level, AM_NO_FIXED_ART | AM_GOOD);
4105 drop_here(o_ptr, *y, *x);
4111 if (a_info[artifact_index].cur_num)
4113 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4115 object_type *q_ptr = &forge;
4117 object_prep(q_ptr, k_idx);
4118 drop_here(q_ptr, *y, *x);
4122 /* Create the artifact */
4123 if (create_named_art(artifact_index, *y, *x))
4124 a_info[artifact_index].cur_num = 1;
4128 /* Terrain special */
4129 g_ptr->special = letter[idx].special;
4137 /* Process "Q:<number>:<command>:... -- quest info */
4138 else if (buf[0] == 'Q')
4145 num = tokenize(buf + 2, 33, zz, 0);
4149 num = tokenize(buf + 3, 33, zz, 0);
4152 /* Have we enough parameters? */
4153 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4156 q_ptr = &(quest[atoi(zz[0])]);
4158 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4159 if (zz[1][0] == 'Q')
4161 if (init_flags & INIT_ASSIGN)
4163 monster_race *r_ptr;
4164 artifact_type *a_ptr;
4166 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4168 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4169 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4170 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4171 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4172 q_ptr->level = (DEPTH)atoi(zz[6]);
4173 q_ptr->r_idx = (IDX)atoi(zz[7]);
4174 q_ptr->k_idx = (IDX)atoi(zz[8]);
4175 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4177 if (num > 10) q_ptr->flags = atoi(zz[10]);
4179 r_ptr = &r_info[q_ptr->r_idx];
4180 if (r_ptr->flags1 & RF1_UNIQUE)
4181 r_ptr->flags1 |= RF1_QUESTOR;
4183 a_ptr = &a_info[q_ptr->k_idx];
4184 a_ptr->gen_flags |= TRG_QUESTITEM;
4189 else if (zz[1][0] == 'R')
4191 if (init_flags & INIT_ASSIGN)
4194 IDX idx, reward_idx = 0;
4196 for (idx = 2; idx < num; idx++)
4198 IDX a_idx = (IDX)atoi(zz[idx]);
4199 if (a_idx < 1) continue;
4200 if (a_info[a_idx].cur_num > 0) continue;
4202 if (one_in_(count)) reward_idx = a_idx;
4207 /* Set quest's rewarding artifact */
4208 q_ptr->k_idx = reward_idx;
4209 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4213 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4214 q_ptr->type = QUEST_TYPE_KILL_ALL;
4221 /* Process "Q:<q_index>:N:<name>" -- quest name */
4222 else if (zz[1][0] == 'N')
4224 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4226 strcpy(q_ptr->name, zz[2]);
4232 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4233 else if (zz[1][0] == 'T')
4235 if (init_flags & INIT_SHOW_TEXT)
4237 strcpy(quest_text[quest_text_line], zz[2]);
4245 /* Process "W:<command>: ..." -- info for the wilderness */
4246 else if (buf[0] == 'W')
4248 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4251 /* Process "P:<y>:<x>" -- player position */
4252 else if (buf[0] == 'P')
4254 if (init_flags & INIT_CREATE_DUNGEON)
4256 if (tokenize(buf + 2, 2, zz, 0) == 2)
4258 int panels_x, panels_y;
4260 /* Hack - Set the dungeon size */
4261 panels_y = (*y / SCREEN_HGT);
4262 if (*y % SCREEN_HGT) panels_y++;
4263 current_floor_ptr->height = panels_y * SCREEN_HGT;
4265 panels_x = (*x / SCREEN_WID);
4266 if (*x % SCREEN_WID) panels_x++;
4267 current_floor_ptr->width = panels_x * SCREEN_WID;
4269 /* Assume illegal panel */
4270 panel_row_min = current_floor_ptr->height;
4271 panel_col_min = current_floor_ptr->width;
4273 /* Place player in a quest level */
4274 if (p_ptr->inside_quest)
4278 /* Delete the monster (if any) */
4279 delete_monster(p_ptr->y, p_ptr->x);
4287 /* Place player in the town */
4288 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4290 p_ptr->oldpy = atoi(zz[0]);
4291 p_ptr->oldpx = atoi(zz[1]);
4299 /* Process "B:<Index>:<Command>:..." -- Building definition */
4300 else if (buf[0] == 'B')
4302 return parse_line_building(buf);
4305 /* Process "M:<type>:<maximum>" -- set maximum values */
4306 else if (buf[0] == 'M')
4308 if (tokenize(buf+2, 2, zz, 0) == 2)
4311 if (zz[0][0] == 'T')
4313 max_towns = (TOWN_IDX)atoi(zz[1]);
4316 /* Maximum quests */
4317 else if (zz[0][0] == 'Q')
4319 max_q_idx = (QUEST_IDX)atoi(zz[1]);
4323 else if (zz[0][0] == 'R')
4325 max_r_idx = (IDX)atoi(zz[1]);
4329 else if (zz[0][0] == 'K')
4331 max_k_idx = (IDX)atoi(zz[1]);
4335 else if (zz[0][0] == 'V')
4337 max_v_idx = (IDX)atoi(zz[1]);
4341 else if (zz[0][0] == 'F')
4343 max_f_idx = (IDX)atoi(zz[1]);
4347 else if (zz[0][0] == 'A')
4349 max_a_idx = (IDX)atoi(zz[1]);
4353 else if (zz[0][0] == 'E')
4355 max_e_idx = (IDX)atoi(zz[1]);
4359 else if (zz[0][0] == 'D')
4361 max_d_idx = (IDX)atoi(zz[1]);
4365 else if (zz[0][0] == 'O')
4367 current_floor_ptr->max_o_idx = (IDX)atoi(zz[1]);
4371 else if (zz[0][0] == 'M')
4373 current_floor_ptr->max_m_idx = (IDX)atoi(zz[1]);
4376 /* Wilderness size */
4377 else if (zz[0][0] == 'W')
4379 /* Maximum wild_x_size */
4380 if (zz[0][1] == 'X')
4381 current_world_ptr->max_wild_x = atoi(zz[1]);
4382 /* Maximum wild_y_size */
4383 if (zz[0][1] == 'Y')
4384 current_world_ptr->max_wild_y = atoi(zz[1]);
4398 static concptr variant = "ZANGBAND";
4402 * @brief クエスト用固定ダンジョン生成時の分岐処理
4403 * Helper function for "process_dungeon_file()"
4408 static concptr process_dungeon_file_expr(char **sp, char *fp)
4424 while (iswspace(*s)) s++;
4442 t = process_dungeon_file_expr(&s, &f);
4450 else if (streq(t, "IOR"))
4453 while (*s && (f != b2))
4455 t = process_dungeon_file_expr(&s, &f);
4456 if (*t && !streq(t, "0")) v = "1";
4461 else if (streq(t, "AND"))
4464 while (*s && (f != b2))
4466 t = process_dungeon_file_expr(&s, &f);
4467 if (*t && streq(t, "0")) v = "0";
4472 else if (streq(t, "NOT"))
4475 while (*s && (f != b2))
4477 t = process_dungeon_file_expr(&s, &f);
4478 if (*t && streq(t, "1")) v = "0";
4483 else if (streq(t, "EQU"))
4486 if (*s && (f != b2))
4488 t = process_dungeon_file_expr(&s, &f);
4490 while (*s && (f != b2))
4492 p = process_dungeon_file_expr(&s, &f);
4493 if (streq(t, p)) v = "1";
4498 else if (streq(t, "LEQ"))
4501 if (*s && (f != b2))
4503 t = process_dungeon_file_expr(&s, &f);
4505 while (*s && (f != b2))
4508 t = process_dungeon_file_expr(&s, &f);
4509 if (*t && atoi(p) > atoi(t)) v = "0";
4514 else if (streq(t, "GEQ"))
4517 if (*s && (f != b2))
4519 t = process_dungeon_file_expr(&s, &f);
4521 while (*s && (f != b2))
4524 t = process_dungeon_file_expr(&s, &f);
4526 /* Compare two numbers instead of string */
4527 if (*t && atoi(p) < atoi(t)) v = "0";
4533 while (*s && (f != b2))
4535 t = process_dungeon_file_expr(&s, &f);
4540 if (f != b2) v = "?x?x?";
4542 /* Extract final and Terminate */
4543 if ((f = *s) != '\0') *s++ = '\0';
4549 /* Accept all printables except spaces and brackets */
4551 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4553 if (iskanji(*s)) s++;
4557 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4560 /* Extract final and Terminate */
4561 if ((f = *s) != '\0') *s++ = '\0';
4567 if (streq(b+1, "SYS"))
4573 else if (streq(b+1, "GRAF"))
4578 else if (streq(b+1, "MONOCHROME"))
4587 else if (streq(b+1, "RACE"))
4589 v = _(rp_ptr->E_title, rp_ptr->title);
4593 else if (streq(b+1, "CLASS"))
4595 v = _(cp_ptr->E_title, cp_ptr->title);
4599 else if (streq(b+1, "REALM1"))
4601 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4605 else if (streq(b+1, "REALM2"))
4607 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4611 else if (streq(b+1, "PLAYER"))
4613 static char tmp_player_name[32];
4615 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4625 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4628 v = tmp_player_name;
4632 else if (streq(b+1, "TOWN"))
4634 sprintf(tmp, "%d", p_ptr->town_num);
4639 else if (streq(b+1, "LEVEL"))
4641 sprintf(tmp, "%d", p_ptr->lev);
4645 /* Current quest number */
4646 else if (streq(b+1, "QUEST_NUMBER"))
4648 sprintf(tmp, "%d", p_ptr->inside_quest);
4652 /* Number of last quest */
4653 else if (streq(b+1, "LEAVING_QUEST"))
4655 sprintf(tmp, "%d", leaving_quest);
4660 else if (prefix(b+1, "QUEST_TYPE"))
4662 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4663 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4668 else if (prefix(b+1, "QUEST"))
4670 /* "QUEST" uses a special parameter to determine the number of the quest */
4671 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4676 else if (prefix(b+1, "RANDOM"))
4678 /* "RANDOM" uses a special parameter to determine the number of the quest */
4679 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4684 else if (streq(b+1, "VARIANT"))
4690 else if (streq(b+1, "WILDERNESS"))
4693 sprintf(tmp, "NONE");
4695 sprintf(tmp, "LITE");
4697 sprintf(tmp, "NORMAL");
4717 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4718 * Helper function for "process_dungeon_file()"
4726 errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax)
4732 bool bypass = FALSE;
4733 int x = xmin, y = ymin;
4736 /* Build the filename */
4737 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4740 fp = my_fopen(buf, "r");
4743 if (!fp) return (-1);
4746 /* Process the file */
4747 while (0 == my_fgets(fp, buf, sizeof(buf)))
4753 /* Skip "empty" lines */
4754 if (!buf[0]) continue;
4756 /* Skip "blank" lines */
4757 if (iswspace(buf[0])) continue;
4760 if (buf[0] == '#') continue;
4763 /* Process "?:<expr>" */
4764 if ((buf[0] == '?') && (buf[1] == ':'))
4773 /* Parse the expr */
4774 v = process_dungeon_file_expr(&s, &f);
4777 bypass = (streq(v, "0") ? TRUE : FALSE);
4781 /* Apply conditionals */
4782 if (bypass) continue;
4784 /* Process the line */
4785 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4796 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4798 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4799 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4811 void write_r_info_txt(void)
4813 int i, j, z, fc, bc;
4816 concptr flags[32 * 10];
4821 monster_race *r_ptr;
4823 monster_blow *b_ptr;
4825 FILE *fff = fopen("output.txt", "wt");
4829 BIT_FLAGS mode = -1;
4833 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4835 fprintf(fff, "# Version stamp (required)\n\n");
4838 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4841 fprintf(fff, "##### The Player #####\n\n");
4843 for (z = -1; z < alloc_race_size; z++)
4845 /* Output the monsters in order */
4846 i = (z >= 0) ? alloc_race_table[z].index : 0;
4848 /* Acquire the monster */
4851 /* Ignore empty monsters */
4852 if (!strlen(r_name + r_ptr->name)) continue;
4854 /* Ignore useless monsters */
4855 if (i && !r_ptr->speed) continue;
4857 /* Write a note if necessary */
4858 if (i && (!r_ptr->level != !mode))
4863 fprintf(fff, "\n##### Town monsters #####\n\n");
4865 /* Note the dungeon */
4868 fprintf(fff, "\n##### Normal monsters #####\n\n");
4871 /* Record the change */
4872 mode = r_ptr->level;
4875 /* Acquire the flags */
4876 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4877 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4878 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4879 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4880 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4881 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4882 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4883 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4884 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4885 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4887 /* Write New/Number/Name */
4888 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4891 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4893 /* Write Information */
4894 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4895 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4897 /* Write more information */
4898 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4901 for(j = 0; j < 4; j++)
4903 b_ptr = &(r_ptr->blow[j]);
4905 /* Stop when done */
4906 if (!b_ptr->method) break;
4908 /* Write the blows */
4909 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4910 r_info_blow_effect[b_ptr->effect],
4911 b_ptr->d_dice, b_ptr->d_side);
4913 for (fc = 0, j = 0; j < 32 * 3; j++)
4915 /* Check this flag */
4916 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4919 /* Extract the extra flags */
4920 for (j = 32 * 6; j < 32 * 10; j++)
4922 /* Check this flag */
4923 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4926 /* Write the flags */
4927 for (j = 0; j < fc;)
4931 /* Start the line */
4934 for (bc = 0; (bc < 60) && (j < fc); j++)
4938 /* Format the flag */
4939 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4941 /* Add it to the buffer */
4944 /* Note the length */
4948 /* Done with this line; write it */
4949 fprintf(fff, "%s\n", buf);
4952 /* Write Spells if applicable */
4953 if (r_ptr->freq_spell)
4955 /* Write the frequency */
4956 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4958 /* Extract the spell flags */
4959 for (fc = 0, j = 96; j < 192; j++)
4961 /* Check this flag */
4962 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4965 /* Write the flags */
4966 for (j = 0; j < fc;)
4970 /* Start the line */
4973 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4977 /* Format the flag */
4978 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4982 /* Note the length */
4989 /* Done with this line; write it */
4990 fprintf(fff, "%s\n", buf);
4994 /* Acquire the description */
4995 desc = r_text + r_ptr->text;
4996 dlen = strlen(desc);
4998 /* Write Description */
4999 for (j = 0; j < dlen;)
5003 /* Start the line */
5006 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5014 /* Done with this line; write it */
5015 fprintf(fff, "%s\n", buf);
5018 /* Space between entries */