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"
57 #ifdef ALLOW_TEMPLATES
62 /*** Helper arrays for parsing ascii template files ***/
66 * Monster Blow Methods
68 static concptr r_info_blow_method[] =
101 * モンスターの打撃属性トークンの定義 /
102 * Monster Blow Effects
104 static concptr r_info_blow_effect[] =
149 static concptr f_info_flags[] =
274 static concptr r_info_flags1[] =
314 static concptr r_info_flags2[] =
354 static concptr r_info_flags3[] =
394 static concptr r_info_flags4[] =
431 * モンスター特性トークン(発動型能力1) /
434 static concptr r_a_ability_flags1[] =
471 * モンスター特性トークン(発動型能力2) /
474 static concptr r_a_ability_flags2[] =
491 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
512 * モンスター特性トークン(発動型能力3) /
515 static concptr r_a_ability_flags3[] =
554 * モンスター特性トークン(発動型能力4) /
557 static concptr r_a_ability_flags4[] =
599 static concptr r_info_flags7[] =
639 static concptr r_info_flags8[] =
671 "WILD_SWAMP", /* ToDo: Implement Swamp */
680 static concptr r_info_flags9[] =
719 * モンスター特性トークンの定義R(耐性) /
722 static concptr r_info_flagsr[] =
760 * オブジェクト基本特性トークンの定義 /
763 static concptr k_info_flags[] =
860 "XXX3", /* Fake flag for Smith */
861 "XXX4", /* Fake flag for Smith */
911 * オブジェクト生成特性トークンの定義 /
914 static concptr k_info_gen_flags[] =
954 static concptr d_info_flags1[] =
992 * @brief データの可変文字列情報をテキストとして保管する /
993 * Add a text to the text-storage and store offset to it.
994 * @param offset 文字列保管ポインタからのオフセット
995 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
997 * @param normal_text テキストの正規化を行う
1000 * Returns FALSE when there isn't enough space available to store
1003 static bool add_text(u32b *offset, header *head, concptr buf, bool normal_text)
1005 /* Hack -- Verify space */
1006 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
1012 /* Advance and save the text index */
1013 *offset = ++head->text_size;
1016 /* Additional text */
1017 else if (normal_text)
1020 * If neither the end of the last line nor
1021 * the beginning of current line is not a space,
1022 * fill up a space as a correct separator of two words.
1024 if (head->text_size > 0 &&
1026 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1027 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
1028 (buf[0] != ' ') && !iskanji(buf[0])
1030 (*(head->text_ptr + head->text_size - 1) != ' ') &&
1035 /* Append a space */
1036 *(head->text_ptr + head->text_size) = ' ';
1038 /* Advance the index */
1043 /* Append chars to the text */
1044 strcpy(head->text_ptr + head->text_size, buf);
1046 /* Advance the index */
1047 head->text_size += strlen(buf);
1055 * @brief データの可変文字列情報を名前として保管する /
1056 * Add a name to the name-storage and return an offset to it.
1057 * @param offset 文字列保管ポインタからのオフセット
1058 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1062 * Returns FALSE when there isn't enough space available to store
1065 static bool add_name(u32b *offset, header *head, concptr buf)
1067 /* Hack -- Verify space */
1068 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
1074 /* Advance and save the name index */
1075 *offset = ++head->name_size;
1078 /* Append chars to the names */
1079 strcpy(head->name_ptr + head->name_size, buf);
1081 /* Advance the index */
1082 head->name_size += strlen(buf);
1090 * @brief データの可変文字列情報をタグとして保管する /
1091 * Add a tag to the tag-storage and return an offset to it.
1092 * @param offset 文字列保管ポインタからのオフセット
1093 * @param head テキスト保管ヘッダ情報の構造体参照ポインタ
1097 * Returns FALSE when there isn't enough space available to store
1100 static bool add_tag(STR_OFFSET *offset, header *head, concptr buf)
1104 /* Search for an existing (fake) tag */
1105 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1108 if (streq(&head->tag_ptr[i], buf)) break;
1111 /* There was no existing tag */
1112 if (i >= head->tag_size)
1114 /* Hack -- Verify space */
1115 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1118 /* Append chars to the tags */
1119 strcpy(head->tag_ptr + head->tag_size, buf);
1121 /* Point the new tag */
1124 /* Advance the index */
1125 head->tag_size += strlen(buf) + 1;
1128 /* Return offset of the tag */
1137 * @brief シンボル1文字をカラーIDに変更する /
1138 * Convert a "color letter" into an "actual" color
1139 * The colors are: dwsorgbuDWvyRGBU, as shown below
1143 byte color_char_to_attr(char c)
1147 case 'd': return (TERM_DARK);
1148 case 'w': return (TERM_WHITE);
1149 case 's': return (TERM_SLATE);
1150 case 'o': return (TERM_ORANGE);
1151 case 'r': return (TERM_RED);
1152 case 'g': return (TERM_GREEN);
1153 case 'b': return (TERM_BLUE);
1154 case 'u': return (TERM_UMBER);
1156 case 'D': return (TERM_L_DARK);
1157 case 'W': return (TERM_L_WHITE);
1158 case 'v': return (TERM_VIOLET);
1159 case 'y': return (TERM_YELLOW);
1160 case 'R': return (TERM_L_RED);
1161 case 'G': return (TERM_L_GREEN);
1162 case 'B': return (TERM_L_BLUE);
1163 case 'U': return (TERM_L_UMBER);
1171 /*** Initialize from ascii template files ***/
1175 * @brief パース関数に基づいてデータファイルからデータを読み取る /
1176 * Initialize an "*_info" array, by parsing an ascii "template" file
1177 * @param fp 読み取りに使うファイルポインタ
1178 * @param buf 読み取りに使うバッファ領域
1179 * @param head ヘッダ構造体
1180 * @param parse_info_txt_line パース関数
1183 errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line)
1187 /* Just before the first record */
1190 /* Just before the first line */
1194 /* Prepare the "fake" stuff */
1195 head->name_size = 0;
1196 head->text_size = 0;
1200 while (0 == my_fgets(fp, buf, 1024))
1202 /* Advance the line number */
1205 /* Skip comments and blank lines */
1206 if (!buf[0] || (buf[0] == '#')) continue;
1208 /* Verify correct "colon" format */
1209 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1212 /* Hack -- Process 'V' for "Version" */
1219 /* Mega Hack -- Calculate Check Sum */
1220 if (buf[0] != 'N' && buf[0] != 'D')
1223 for (i = 0; buf[i]; i++)
1225 head->v_extra += (byte)buf[i];
1226 head->v_extra ^= (1 << (i % 8));
1230 /* Parse the line */
1231 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1236 /* Complete the "name" and "text" sizes */
1237 if (head->name_size) head->name_size++;
1238 if (head->text_size) head->text_size++;
1246 * @brief Vault情報(v_info)のパース関数 /
1247 * Initialize the "v_info" array, by parsing an ascii "template" file
1249 * @param head ヘッダ構造体
1252 errr parse_v_info(char *buf, header *head)
1258 static vault_type *v_ptr = NULL;
1260 /* Process 'N' for "New/Number/Name" */
1263 /* Find the colon before the name */
1264 s = my_strchr(buf+2, ':');
1266 /* Verify that colon */
1269 /* Nuke the colon, advance to the name */
1272 /* Paranoia -- require a name */
1273 if (!*s) return (1);
1278 /* Verify information */
1279 if (i <= error_idx) return (4);
1281 /* Verify information */
1282 if (i >= head->info_num) return (2);
1284 /* Save the index */
1287 /* Point at the "info" */
1290 /* Store the name */
1291 if (!add_name(&v_ptr->name, head, s)) return (7);
1294 /* There better be a current v_ptr */
1295 else if (!v_ptr) return (3);
1297 /* Process 'D' for "Description" */
1298 else if (buf[0] == 'D')
1300 /* Acquire the text */
1303 /* Store the text */
1304 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1307 /* Process 'X' for "Extra info" (one line only) */
1308 else if (buf[0] == 'X')
1310 EFFECT_ID typ, rat, hgt, wid;
1312 /* Scan for the values */
1313 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1314 &typ, &rat, &hgt, &wid)) return (1);
1316 /* Save the values */
1317 v_ptr->typ = (ROOM_IDX)typ;
1318 v_ptr->rat = (PROB)rat;
1319 v_ptr->hgt = (POSITION)hgt;
1320 v_ptr->wid = (POSITION)wid;
1331 * @brief 職業技能情報(s_info)のパース関数 /
1332 * Initialize the "s_info" array, by parsing an ascii "template" file
1334 * @param head ヘッダ構造体
1337 errr parse_s_info(char *buf, header *head)
1342 static skill_table *s_ptr = NULL;
1345 /* Process 'N' for "New/Number/Name" */
1351 /* Verify information */
1352 if (i <= error_idx) return (4);
1354 /* Verify information */
1355 if (i >= head->info_num) return (2);
1357 /* Save the index */
1360 /* Point at the "info" */
1364 /* There better be a current s_ptr */
1365 else if (!s_ptr) return (3);
1367 /* Process 'W' for "Weapon exp" */
1368 else if (buf[0] == 'W')
1370 int tval, sval, start, max;
1371 const s16b exp_conv_table[] =
1373 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1374 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1377 /* Scan for the values */
1378 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1379 &tval, &sval, &start, &max)) return (1);
1381 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1382 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1384 /* Save the values */
1385 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1386 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1389 /* Process 'S' for "Skill exp" */
1390 else if (buf[0] == 'S')
1392 int num, start, max;
1394 /* Scan for the values */
1395 if (3 != sscanf(buf+2, "%d:%d:%d",
1396 &num, &start, &max)) return (1);
1398 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1399 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1401 /* Save the values */
1402 s_ptr->s_start[num] = (SUB_EXP)start;
1403 s_ptr->s_max[num] = (SUB_EXP)max;
1415 * @brief 職業魔法情報(m_info)のパース関数 /
1416 * Initialize the "m_info" array, by parsing an ascii "template" file
1418 * @param head ヘッダ構造体
1421 errr parse_m_info(char *buf, header *head)
1428 static player_magic *m_ptr = NULL;
1431 static int realm, magic_idx = 0, readable = 0;
1434 /* Process 'N' for "New/Number/Name" */
1440 /* Verify information */
1441 if (i <= error_idx) return (4);
1443 /* Verify information */
1444 if (i >= head->info_num) return (2);
1446 /* Save the index */
1449 /* Point at the "info" */
1453 /* There better be a current m_ptr */
1454 else if (!m_ptr) return (3);
1456 /* Process 'I' for "Info" (one line only) */
1457 else if (buf[0] == 'I')
1460 int xtra, type, first, weight;
1462 /* Find the colon before the name */
1463 s = my_strchr(buf+2, ':');
1465 /* Verify that colon */
1468 /* Nuke the colon, advance to the name */
1473 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1474 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1475 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1476 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1477 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1482 /* Find the colon before the name */
1483 s = my_strchr(s, ':');
1485 /* Verify that colon */
1488 /* Nuke the colon, advance to the name */
1491 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1492 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1493 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1494 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1495 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1496 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1500 /* Scan for the values */
1501 if (4 != sscanf(s, "%x:%d:%d:%d",
1502 (uint *)&xtra, &type, &first, &weight)) return (1);
1504 m_ptr->spell_xtra = xtra;
1505 m_ptr->spell_type = type;
1506 m_ptr->spell_first = first;
1507 m_ptr->spell_weight = weight;
1511 /* Process 'R' for "Realm" (one line only) */
1512 else if (buf[0] == 'R')
1514 /* Scan for the values */
1515 if (2 != sscanf(buf+2, "%d:%d",
1516 &realm, &readable)) return (1);
1521 else if (buf[0] == 'T')
1523 int level, mana, fail, exp;
1525 if (!readable) return (1);
1526 /* Scan for the values */
1527 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1528 &level, &mana, &fail, &exp)) return (1);
1530 m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level;
1531 m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana;
1532 m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail;
1533 m_ptr->info[realm][magic_idx].sexp = (EXP)exp;
1546 * @brief テキストトークンを走査してフラグを一つ得る(汎用) /
1547 * Grab one flag from a textual string
1548 * @param flags ビットフラグを追加する先の参照ポインタ
1549 * @param names トークン定義配列
1550 * @param what 参照元の文字列ポインタ
1553 static errr grab_one_flag(u32b *flags, concptr names[], concptr what)
1558 for (i = 0; i < 32; i++)
1560 if (streq(what, names[i]))
1562 *flags |= (1L << i);
1572 * @brief テキストトークンを走査してフラグを一つ得る(地形情報向け) /
1573 * Grab one flag in an feature_type from a textual string
1574 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1575 * @param what 参照元の文字列ポインタ
1578 static errr grab_one_feat_flag(feature_type *f_ptr, concptr what)
1583 for (i = 0; i < FF_FLAG_MAX; i++)
1585 if (streq(what, f_info_flags[i]))
1587 add_flag(f_ptr->flags, i);
1592 msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
1595 return PARSE_ERROR_GENERIC;
1600 * @brief テキストトークンを走査してフラグ(ステート)を一つ得る(地形情報向け2) /
1601 * Grab an action in an feature_type from a textual string
1602 * @param f_ptr 地形情報を保管する先の構造体参照ポインタ
1603 * @param what 参照元の文字列ポインタ
1604 * @param count ステートの保存先ID
1607 static errr grab_one_feat_action(feature_type *f_ptr, concptr what, int count)
1612 for (i = 0; i < FF_FLAG_MAX; i++)
1614 if (streq(what, f_info_flags[i]))
1616 f_ptr->state[count].action = i;
1621 msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
1624 return PARSE_ERROR_GENERIC;
1629 * @brief 地形情報(f_info)のパース関数 /
1630 * Initialize the "f_info" array, by parsing an ascii "template" file
1632 * @param head ヘッダ構造体
1635 errr parse_f_info(char *buf, header *head)
1642 static feature_type *f_ptr = NULL;
1645 /* Process 'N' for "New/Number/Name" */
1648 /* Find the colon before the name */
1649 s = my_strchr(buf+2, ':');
1653 /* Nuke the colon, advance to the name */
1660 /* Verify information */
1661 if (i <= error_idx) return (4);
1663 /* Verify information */
1664 if (i >= head->info_num) return (2);
1666 /* Save the index */
1669 /* Point at the "info" */
1672 /* Tag name is given */
1676 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1679 /* Default "mimic" */
1680 f_ptr->mimic = (FEAT_IDX)i;
1682 /* Default "destroyed state" -- if not specified */
1683 f_ptr->destroyed = (FEAT_IDX)i;
1685 /* Default "states" */
1686 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1689 /* There better be a current f_ptr */
1690 else if (!f_ptr) return (3);
1693 else if (buf[0] == 'J')
1695 /* Store the name */
1696 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1699 else if (buf[0] == 'E')
1701 /* Ignore english name */
1704 else if (buf[0] == 'J')
1706 /* Ignore Japanese name */
1709 else if (buf[0] == 'E')
1711 /* Acquire the Text */
1714 /* Store the name */
1715 if (!add_name(&f_ptr->name, head, s)) return (7);
1720 /* Process 'M' for "Mimic" (one line only) */
1721 else if (buf[0] == 'M')
1725 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1727 /* Record a fake tag index */
1728 f_ptr->mimic_tag = offset;
1732 /* Process 'G' for "Graphics" (one line only) */
1733 else if (buf[0] == 'G')
1737 char char_tmp[F_LIT_MAX];
1740 if (buf[1] != ':') return (1);
1741 if (!buf[2]) return (1);
1742 if (buf[3] != ':') return (1);
1743 if (!buf[4]) return (1);
1745 /* Extract the char */
1746 char_tmp[F_LIT_STANDARD] = buf[2];
1748 /* Extract the color */
1749 s_attr = color_char_to_attr(buf[4]);
1752 if (s_attr > 127) return (1);
1754 /* Save the standard values */
1755 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1756 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1758 /* Is this feature supports lighting? */
1761 /* G:c:a:LIT (default) */
1762 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1764 /* G:c:a:lc:la:dc:da */
1765 if (!streq(buf + 6, "LIT"))
1767 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1769 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1770 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1771 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1772 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1774 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1776 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1779 /* Use default lighting */
1782 /* No lighting support */
1783 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1786 /* Extract the color */
1787 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1788 if (f_ptr->d_attr[j] > 127) return 1;
1791 f_ptr->d_char[j] = char_tmp[j];
1797 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1799 f_ptr->d_attr[j] = s_attr;
1800 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1806 /* Hack -- Process 'F' for flags */
1807 else if (buf[0] == 'F')
1809 /* Parse every entry textually */
1810 for (s = buf + 2; *s; )
1812 /* Find the end of this entry */
1813 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1815 /* Nuke and skip any dividers */
1819 while (*t == ' ' || *t == '|') t++;
1822 /* Hack -- Read feature subtype */
1823 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1825 /* Extract a "subtype" */
1826 f_ptr->subtype = (FEAT_SUBTYPE)i;
1828 /* Start at next entry */
1834 /* Hack -- Read feature power */
1835 if (1 == sscanf(s, "POWER_%d", &i))
1837 /* Extract a "power" */
1838 f_ptr->power = (FEAT_POWER)i;
1840 /* Start at next entry */
1845 /* Parse this entry */
1846 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1848 /* Start the next entry */
1853 /* Process 'W' for "More Info" (one line only) */
1854 else if (buf[0] == 'W')
1858 /* Scan for the value */
1859 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1861 /* Save the value */
1862 f_ptr->priority = (FEAT_PRIORITY)priority;
1865 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1866 else if (buf[0] == 'K')
1870 /* Find the next empty state slot (if any) */
1871 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1873 /* Oops, no more slots */
1874 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1876 /* Analyze the first field */
1877 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1879 /* Terminate the field (if necessary) */
1880 if (*t == ':') *t++ = '\0';
1882 /* Is this default entry? */
1883 if (streq(s, "DESTROYED"))
1885 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1887 /* Record a fake tag index */
1888 f_ptr->destroyed_tag = offset;
1893 f_ptr->state[i].action = 0;
1895 /* Parse this entry */
1896 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1898 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1900 /* Record a fake tag index */
1901 f_ptr->state[i].result_tag = offset;
1913 * @brief 地形タグからIDを得る /
1914 * Convert a fake tag to a real feat index
1918 s16b f_tag_to_index(concptr str)
1922 /* Search for real index corresponding to this fake tag */
1923 for (i = 0; i < f_head.info_num; i++)
1925 if (streq(f_tag + f_info[i].tag, str))
1927 /* Return the index */
1938 * @brief 地形タグからIDを得る /
1939 * Search for real index corresponding to this fake tag
1940 * @param feat タグ文字列のオフセット
1941 * @return 地形ID。該当がないなら-1
1943 static FEAT_IDX search_real_feat(STR_OFFSET feat)
1947 /* Don't convert non-fake tag */
1953 /* Search for real index corresponding to this fake tag */
1954 for (i = 0; i < f_head.info_num; i++)
1956 if (feat == f_info[i].tag)
1958 /* Record real index */
1964 msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
1970 * @brief 地形情報の各種タグからIDへ変換して結果を収める /
1971 * Retouch fake tags of f_info
1972 * @param head ヘッダ構造体
1975 void retouch_f_info(header *head)
1979 /* Convert fake tags to real feat indices */
1980 for (i = 0; i < head->info_num; i++)
1982 feature_type *f_ptr = &f_info[i];
1985 k = search_real_feat(f_ptr->mimic_tag);
1986 f_ptr->mimic = k < 0 ? f_ptr->mimic : k;
1987 k = search_real_feat(f_ptr->destroyed_tag);
1988 f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k;
1989 for (j = 0; j < MAX_FEAT_STATES; j++)
1991 k = search_real_feat(f_ptr->state[j].result_tag);
1992 f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k;
1999 * @brief テキストトークンを走査してフラグを一つ得る(ベースアイテム用) /
2000 * Grab one flag in an object_kind from a textual string
2001 * @param k_ptr 保管先のベースアイテム構造体参照ポインタ
2002 * @param what 参照元の文字列ポインタ
2005 static errr grab_one_kind_flag(object_kind *k_ptr, concptr what)
2010 for (i = 0; i < TR_FLAG_MAX; i++)
2012 if (streq(what, k_info_flags[i]))
2014 add_flag(k_ptr->flags, i);
2019 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
2022 msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
2029 * @brief テキストトークンを走査してフラグを一つ得る(発動能力用) /
2030 * Grab one activation index flag
2031 * @param what 参照元の文字列ポインタ
2034 static byte grab_one_activation_flag(concptr what)
2040 if (activation_info[i].flag == NULL) break;
2042 if (streq(what, activation_info[i].flag))
2044 return activation_info[i].index;
2054 msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
2062 * @brief ベースアイテム(k_info)のパース関数 /
2063 * Initialize the "k_info" array, by parsing an ascii "template" file
2065 * @param head ヘッダ構造体
2068 errr parse_k_info(char *buf, header *head)
2075 static object_kind *k_ptr = NULL;
2078 /* Process 'N' for "New/Number/Name" */
2085 /* Find the colon before the name */
2086 s = my_strchr(buf+2, ':');
2088 /* Verify that colon */
2091 /* Nuke the colon, advance to the name */
2097 /* Verify information */
2098 if (i <= error_idx) return (4);
2100 /* Verify information */
2101 if (i >= head->info_num) return (2);
2103 /* Save the index */
2106 /* Point at the "info" */
2110 /* Paranoia -- require a name */
2111 if (!*s) return (1);
2113 /* Find the colon before the flavor */
2114 flavor = my_strchr(s, ':');
2116 /* Verify that colon */
2119 /* Nuke the colon, advance to the flavor */
2122 /* Store the flavor */
2123 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2126 /* Store the name */
2127 if (!add_name(&k_ptr->name, head, s)) return (7);
2131 /* There better be a current k_ptr */
2132 else if (!k_ptr) return (3);
2137 /* 'E' から始まる行は英語名としている */
2138 else if (buf[0] == 'E')
2143 else if (buf[0] == 'E')
2147 /* Acquire the name */
2150 /* Find the colon before the flavor */
2151 flavor = my_strchr(s, ':');
2153 /* Verify that colon */
2156 /* Nuke the colon, advance to the flavor */
2159 /* Store the flavor */
2160 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2163 /* Store the name */
2164 if (!add_name(&k_ptr->name, head, s)) return (7);
2168 /* Process 'D' for "Description" */
2169 else if (buf[0] == 'D')
2174 /* Acquire the text */
2179 /* Acquire the text */
2183 /* Store the text */
2184 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2187 /* Process 'G' for "Graphics" (one line only) */
2188 else if (buf[0] == 'G')
2194 if (buf[1] != ':') return (1);
2195 if (!buf[2]) return (1);
2196 if (buf[3] != ':') return (1);
2197 if (!buf[4]) return (1);
2199 /* Extract the char */
2202 /* Extract the attr */
2203 tmp = color_char_to_attr(buf[4]);
2206 if (tmp > 127) return (1);
2208 /* Save the values */
2209 k_ptr->d_attr = tmp;
2210 k_ptr->d_char = sym;
2213 /* Process 'I' for "Info" (one line only) */
2214 else if (buf[0] == 'I')
2216 int tval, sval, pval;
2218 /* Scan for the values */
2219 if (3 != sscanf(buf+2, "%d:%d:%d",
2220 &tval, &sval, &pval)) return (1);
2222 /* Save the values */
2223 k_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2224 k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2225 k_ptr->pval = (PARAMETER_VALUE)pval;
2228 /* Process 'W' for "More Info" (one line only) */
2229 else if (buf[0] == 'W')
2231 int level, extra, wgt;
2234 /* Scan for the values */
2235 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2236 &level, &extra, &wgt, &cost)) return (1);
2238 /* Save the values */
2239 k_ptr->level = (DEPTH)level;
2240 k_ptr->extra = (BIT_FLAGS8)extra;
2241 k_ptr->weight = (WEIGHT)wgt;
2242 k_ptr->cost = (PRICE)cost;
2245 /* Process 'A' for "Allocation" (one line only) */
2246 else if (buf[0] == 'A')
2249 /* Simply read each number following a colon */
2250 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2252 /* Default chance */
2253 k_ptr->chance[i] = 1;
2255 /* Store the attack damage index */
2256 k_ptr->locale[i] = atoi(s+1);
2258 /* Find the slash */
2259 t = my_strchr(s+1, '/');
2261 /* Find the next colon */
2262 s = my_strchr(s+1, ':');
2264 /* If the slash is "nearby", use it */
2265 if (t && (!s || t < s))
2267 int chance = atoi(t+1);
2268 if (chance > 0) k_ptr->chance[i] = (PROB)chance;
2273 /* Hack -- Process 'P' for "power" and such */
2274 else if (buf[0] == 'P')
2276 int ac, hd1, hd2, th, td, ta;
2278 /* Scan for the values */
2279 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2280 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2282 k_ptr->ac = (ARMOUR_CLASS)ac;
2283 k_ptr->dd = (DICE_NUMBER)hd1;
2284 k_ptr->ds = (DICE_SID)hd2;
2285 k_ptr->to_h = (HIT_PROB)th;
2286 k_ptr->to_d = (HIT_POINT)td;
2287 k_ptr->to_a = (ARMOUR_CLASS)ta;
2290 /* Hack -- Process 'U' for activation index */
2291 else if (buf[0] == 'U')
2294 n = grab_one_activation_flag(buf + 2);
2305 /* Hack -- Process 'F' for flags */
2306 else if (buf[0] == 'F')
2308 /* Parse every entry textually */
2309 for (s = buf + 2; *s; )
2311 /* Find the end of this entry */
2312 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2314 /* Nuke and skip any dividers */
2318 while (*t == ' ' || *t == '|') t++;
2321 /* Parse this entry */
2322 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2324 /* Start the next entry */
2338 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2339 * Grab one activation index flag
2340 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
2341 * @param what 参照元の文字列ポインタ
2342 * @return エラーがあった場合1、エラーがない場合0を返す
2344 static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
2349 for (i = 0; i < TR_FLAG_MAX; i++)
2351 if (streq(what, k_info_flags[i]))
2353 add_flag(a_ptr->flags, i);
2358 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2361 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
2369 * @brief 固定アーティファクト情報(a_info)のパース関数 /
2370 * Initialize the "a_info" array, by parsing an ascii "template" file
2372 * @param head ヘッダ構造体
2375 errr parse_a_info(char *buf, header *head)
2382 static artifact_type *a_ptr = NULL;
2385 /* Process 'N' for "New/Number/Name" */
2388 /* Find the colon before the name */
2389 s = my_strchr(buf+2, ':');
2391 /* Verify that colon */
2394 /* Nuke the colon, advance to the name */
2397 /* Paranoia -- require a name */
2398 if (!*s) return (1);
2403 /* Verify information */
2404 if (i < error_idx) return (4);
2406 /* Verify information */
2407 if (i >= head->info_num) return (2);
2409 /* Save the index */
2412 /* Point at the "info" */
2415 /* Ignore everything */
2416 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2417 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2418 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2419 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2421 /* Store the name */
2422 if (!add_name(&a_ptr->name, head, s)) return (7);
2426 /* There better be a current a_ptr */
2427 else if (!a_ptr) return (3);
2432 /* 'E' から始まる行は英語名としている */
2433 else if (buf[0] == 'E')
2438 else if (buf[0] == 'E')
2440 /* Acquire the Text */
2443 /* Store the name */
2444 if (!add_name(&a_ptr->name, head, s)) return (7);
2448 /* Process 'D' for "Description" */
2449 else if (buf[0] == 'D')
2454 /* Acquire the text */
2459 /* Acquire the text */
2463 /* Store the text */
2464 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2468 /* Process 'I' for "Info" (one line only) */
2469 else if (buf[0] == 'I')
2471 int tval, sval, pval;
2473 /* Scan for the values */
2474 if (3 != sscanf(buf+2, "%d:%d:%d",
2475 &tval, &sval, &pval)) return (1);
2477 /* Save the values */
2478 a_ptr->tval = (OBJECT_TYPE_VALUE)tval;
2479 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
2480 a_ptr->pval = (PARAMETER_VALUE)pval;
2483 /* Process 'W' for "More Info" (one line only) */
2484 else if (buf[0] == 'W')
2486 int level, rarity, wgt;
2489 /* Scan for the values */
2490 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2491 &level, &rarity, &wgt, &cost)) return (1);
2493 /* Save the values */
2494 a_ptr->level = (DEPTH)level;
2495 a_ptr->rarity = (RARITY)rarity;
2496 a_ptr->weight = (WEIGHT)wgt;
2497 a_ptr->cost = (PRICE)cost;
2500 /* Hack -- Process 'P' for "power" and such */
2501 else if (buf[0] == 'P')
2503 int ac, hd1, hd2, th, td, ta;
2505 /* Scan for the values */
2506 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2507 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2509 a_ptr->ac = (ARMOUR_CLASS)ac;
2510 a_ptr->dd = (DICE_NUMBER)hd1;
2511 a_ptr->ds = (DICE_SID)hd2;
2512 a_ptr->to_h = (HIT_PROB)th;
2513 a_ptr->to_d = (HIT_POINT)td;
2514 a_ptr->to_a = (ARMOUR_CLASS)ta;
2517 /* Hack -- Process 'U' for activation index */
2518 else if (buf[0] == 'U')
2521 n = grab_one_activation_flag(buf + 2);
2532 /* Hack -- Process 'F' for flags */
2533 else if (buf[0] == 'F')
2535 /* Parse every entry textually */
2536 for (s = buf + 2; *s; )
2538 /* Find the end of this entry */
2539 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2541 /* Nuke and skip any dividers */
2545 while ((*t == ' ') || (*t == '|')) t++;
2548 /* Parse this entry */
2549 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2551 /* Start the next entry */
2566 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
2567 * Grab one flag in a ego-item_type from a textual string
2568 * @param e_ptr 保管先のエゴ構造体参照ポインタ
2569 * @param what 参照元の文字列ポインタ
2570 * @return エラーがあった場合1、エラーがない場合0を返す
2572 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
2577 for (i = 0; i < TR_FLAG_MAX; i++)
2579 if (streq(what, k_info_flags[i]))
2581 add_flag(e_ptr->flags, i);
2586 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2589 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
2597 * @brief アイテムエゴ情報(e_info)のパース関数 /
2598 * Initialize the "e_info" array, by parsing an ascii "template" file
2600 * @param head ヘッダ構造体
2603 errr parse_e_info(char *buf, header *head)
2609 static ego_item_type *e_ptr = NULL;
2611 /* Just before the first record */
2614 /* Just before the first line */
2617 /* Process 'N' for "New/Number/Name" */
2620 /* Find the colon before the name */
2621 s = my_strchr(buf+2, ':');
2623 /* Verify that colon */
2626 /* Nuke the colon, advance to the name */
2629 /* Paranoia -- require a name */
2630 if (!*s) return (1);
2635 /* Verify information */
2636 if (i < error_idx) return (4);
2638 /* Verify information */
2639 if (i >= head->info_num) return (2);
2641 /* Save the index */
2644 /* Point at the "info" */
2647 /* Store the name */
2648 if (!add_name(&e_ptr->name, head, s)) return (7);
2652 /* There better be a current e_ptr */
2653 else if (!e_ptr) return (3);
2658 /* 'E' から始まる行は英語名 */
2659 else if (buf[0] == 'E')
2664 else if (buf[0] == 'E')
2666 /* Acquire the Text */
2669 /* Store the name */
2670 if (!add_name(&e_ptr->name, head, s)) return (7);
2675 /* Process 'D' for "Description" */
2676 else if (buf[0] == 'D')
2678 /* Acquire the text */
2681 /* Store the text */
2682 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2687 /* Process 'X' for "Xtra" (one line only) */
2688 else if (buf[0] == 'X')
2692 /* Scan for the values */
2693 if (2 != sscanf(buf+2, "%d:%d",
2694 &slot, &rating)) return (1);
2696 /* Save the values */
2697 e_ptr->slot = (INVENTORY_IDX)slot;
2698 e_ptr->rating = (PRICE)rating;
2701 /* Process 'W' for "More Info" (one line only) */
2702 else if (buf[0] == 'W')
2704 int level, rarity, pad2;
2707 /* Scan for the values */
2708 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2709 &level, &rarity, &pad2, &cost)) return (1);
2711 /* Save the values */
2712 e_ptr->level = level;
2713 e_ptr->rarity = (RARITY)rarity;
2714 /* e_ptr->weight = wgt; */
2718 /* Hack -- Process 'C' for "creation" */
2719 else if (buf[0] == 'C')
2721 int th, td, ta, pval;
2723 /* Scan for the values */
2724 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2725 &th, &td, &ta, &pval)) return (1);
2727 e_ptr->max_to_h = (HIT_PROB)th;
2728 e_ptr->max_to_d = (HIT_POINT)td;
2729 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
2730 e_ptr->max_pval = (PARAMETER_VALUE)pval;
2733 /* Hack -- Process 'U' for activation index */
2734 else if (buf[0] == 'U')
2737 n = grab_one_activation_flag(buf + 2);
2748 /* Hack -- Process 'F' for flags */
2749 else if (buf[0] == 'F')
2751 /* Parse every entry textually */
2752 for (s = buf + 2; *s; )
2754 /* Find the end of this entry */
2755 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2757 /* Nuke and skip any dividers */
2761 while ((*t == ' ') || (*t == '|')) t++;
2764 /* Parse this entry */
2765 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2767 /* Start the next entry */
2780 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
2781 * Grab one (basic) flag in a monster_race from a textual string
2782 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2783 * @param what 参照元の文字列ポインタ
2786 static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
2788 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2791 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2794 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2797 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2800 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2803 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2806 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2809 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2817 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
2818 * Grab one (spell) flag in a monster_race from a textual string
2819 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
2820 * @param what 参照元の文字列ポインタ
2823 static errr grab_one_spell_flag(monster_race *r_ptr, concptr what)
2825 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2828 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
2831 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
2834 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
2842 * @brief モンスター種族情報(r_info)のパース関数 /
2843 * Initialize the "r_info" array, by parsing an ascii "template" file
2845 * @param head ヘッダ構造体
2848 errr parse_r_info(char *buf, header *head)
2854 static monster_race *r_ptr = NULL;
2857 /* Process 'N' for "New/Number/Name" */
2860 /* Find the colon before the name */
2861 s = my_strchr(buf+2, ':');
2863 /* Verify that colon */
2866 /* Nuke the colon, advance to the name */
2869 /* Paranoia -- require a name */
2870 if (!*s) return (1);
2875 /* Verify information */
2876 if (i < error_idx) return (4);
2878 /* Verify information */
2879 if (i >= head->info_num) return (2);
2881 /* Save the index */
2884 /* Point at the "info" */
2887 /* Store the name */
2888 if (!add_name(&r_ptr->name, head, s)) return (7);
2892 /* There better be a current r_ptr */
2893 else if (!r_ptr) return (3);
2898 /* 'E' から始まる行は英語名 */
2899 else if (buf[0] == 'E')
2901 /* Acquire the Text */
2904 /* Store the name */
2905 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2908 else if (buf[0] == 'E')
2910 /* Acquire the Text */
2913 /* Store the name */
2914 if (!add_name(&r_ptr->name, head, s)) return (7);
2917 /* Process 'D' for "Description" */
2918 else if (buf[0] == 'D')
2923 /* Acquire the text */
2928 /* Acquire the text */
2932 /* Store the text */
2933 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2936 /* Process 'G' for "Graphics" (one line only) */
2937 else if (buf[0] == 'G')
2943 if (buf[1] != ':') return (1);
2944 if (!buf[2]) return (1);
2945 if (buf[3] != ':') return (1);
2946 if (!buf[4]) return (1);
2948 /* Extract the char */
2951 /* Extract the attr */
2952 tmp = color_char_to_attr(buf[4]);
2955 if (tmp > 127) return (1);
2957 /* Save the values */
2958 r_ptr->d_char = sym;
2959 r_ptr->d_attr = tmp;
2962 /* Process 'I' for "Info" (one line only) */
2963 else if (buf[0] == 'I')
2965 int spd, hp1, hp2, aaf, ac, slp;
2967 /* Scan for the other values */
2968 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2969 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2971 /* Save the values */
2972 r_ptr->speed = (SPEED)spd;
2973 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
2974 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
2975 r_ptr->aaf = (POSITION)aaf;
2976 r_ptr->ac = (ARMOUR_CLASS)ac;
2977 r_ptr->sleep = (SLEEP_DEGREE)slp;
2980 /* Process 'W' for "More Info" (one line only) */
2981 else if (buf[0] == 'W')
2988 /* Scan for the values */
2989 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2990 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2992 /* Save the values */
2993 r_ptr->level = (DEPTH)lev;
2994 r_ptr->rarity = (RARITY)rar;
2995 r_ptr->extra = (BIT_FLAGS16)pad;
2996 r_ptr->mexp = (EXP)exp;
2997 r_ptr->next_exp = (EXP)nextexp;
2998 r_ptr->next_r_idx = (IDX)nextmon;
3001 /* Process 'R' for "Reinforcement" (up to six lines) */
3002 else if (buf[0] == 'R')
3005 /* Find the next empty blow slot (if any) */
3006 for (i = 0; i < A_MAX; i++) if (r_ptr->reinforce_id[i] == 0) break;
3008 /* Oops, no more slots */
3009 if (i == 6) return (1);
3011 /* Scan for the values */
3012 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
3013 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
3014 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
3015 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
3018 /* Process 'B' for "Blows" (up to four lines) */
3019 else if (buf[0] == 'B')
3023 /* Find the next empty blow slot (if any) */
3024 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
3026 /* Oops, no more slots */
3027 if (i == 4) return (1);
3029 /* Analyze the first field */
3030 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
3032 /* Terminate the field (if necessary) */
3033 if (*t == ':') *t++ = '\0';
3035 /* Analyze the method */
3036 for (n1 = 0; r_info_blow_method[n1]; n1++)
3038 if (streq(s, r_info_blow_method[n1])) break;
3041 /* Invalid method */
3042 if (!r_info_blow_method[n1]) return (1);
3044 /* Analyze the second field */
3045 for (s = t; *t && (*t != ':'); t++) /* loop */;
3047 /* Terminate the field (if necessary) */
3048 if (*t == ':') *t++ = '\0';
3050 /* Analyze effect */
3051 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3053 if (streq(s, r_info_blow_effect[n2])) break;
3056 /* Invalid effect */
3057 if (!r_info_blow_effect[n2]) return (1);
3059 /* Analyze the third field */
3060 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3062 /* Terminate the field (if necessary) */
3063 if (*t == 'd') *t++ = '\0';
3065 /* Save the method */
3066 r_ptr->blow[i].method = (BLOW_METHOD)n1;
3068 /* Save the effect */
3069 r_ptr->blow[i].effect = (BLOW_EFFECT)n2;
3071 /* Extract the damage dice and sides */
3072 r_ptr->blow[i].d_dice = atoi(s);
3073 r_ptr->blow[i].d_side = atoi(t);
3076 /* Process 'F' for "Basic Flags" (multiple lines) */
3077 else if (buf[0] == 'F')
3079 /* Parse every entry */
3080 for (s = buf + 2; *s; )
3082 /* Find the end of this entry */
3083 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3085 /* Nuke and skip any dividers */
3089 while (*t == ' ' || *t == '|') t++;
3092 /* Parse this entry */
3093 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3095 /* Start the next entry */
3100 /* Process 'S' for "Spell Flags" (multiple lines) */
3101 else if (buf[0] == 'S')
3103 /* Parse every entry */
3104 for (s = buf + 2; *s; )
3106 /* Find the end of this entry */
3107 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3109 /* Nuke and skip any dividers */
3113 while ((*t == ' ') || (*t == '|')) t++;
3116 /* Hack -- Read spell frequency */
3117 if (1 == sscanf(s, "1_IN_%d", &i))
3119 /* Extract a "frequency" */
3120 r_ptr->freq_spell = 100 / i;
3122 /* Start at next entry */
3127 /* Parse this entry */
3128 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3130 /* Start the next entry */
3135 /* Process 'A' for "Artifact Flags" (multiple lines) */
3136 else if (buf[0] == 'A')
3138 int id, per, rarity;
3140 /* Find the next empty blow slot (if any) */
3141 for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
3143 /* Oops, no more slots */
3144 if (i == 4) return (1);
3146 if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
3147 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
3148 r_ptr->artifact_rarity[i] = (RARITY)rarity;
3149 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
3152 /* Process 'V' for "Arena power value ratio" */
3153 else if (buf[0] == 'V')
3156 if (3 != sscanf(buf+2, "%d", &val)) return (1);
3157 r_ptr->arena_ratio = (PERCENTAGE)val;
3169 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
3170 * Grab one flag for a dungeon type from a textual string
3171 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3172 * @param what 参照元の文字列ポインタ
3175 static errr grab_one_dungeon_flag(dungeon_type *d_ptr, concptr what)
3177 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3180 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
3187 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
3188 * Grab one (basic) flag in a monster_race from a textual string
3189 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3190 * @param what 参照元の文字列ポインタ
3193 static errr grab_one_basic_monster_flag(dungeon_type *d_ptr, concptr what)
3195 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3198 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3201 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3204 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3207 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3210 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3213 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3216 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3223 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
3224 * Grab one (spell) flag in a monster_race from a textual string
3225 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
3226 * @param what 参照元の文字列ポインタ
3229 static errr grab_one_spell_monster_flag(dungeon_type *d_ptr, concptr what)
3231 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3234 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
3237 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
3240 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
3247 * @brief ダンジョン情報(d_info)のパース関数 /
3248 * Initialize the "d_info" array, by parsing an ascii "template" file
3250 * @param head ヘッダ構造体
3253 errr parse_d_info(char *buf, header *head)
3259 static dungeon_type *d_ptr = NULL;
3261 /* Process 'N' for "New/Number/Name" */
3264 /* Find the colon before the name */
3265 s = my_strchr(buf+2, ':');
3267 /* Verify that colon */
3270 /* Nuke the colon, advance to the name */
3273 /* Paranoia -- require a name */
3274 if (!*s) return (1);
3279 /* Verify information */
3280 if (i < error_idx) return (4);
3282 /* Verify information */
3283 if (i >= head->info_num) return (2);
3285 /* Save the index */
3288 /* Point at the "info" */
3291 /* Store the name */
3292 if (!add_name(&d_ptr->name, head, s)) return (7);
3297 else if (buf[0] == 'E') return (0);
3299 else if (buf[0] == 'E')
3301 /* Acquire the Text */
3304 /* Store the name */
3305 if (!add_name(&d_ptr->name, head, s)) return (7);
3309 /* Process 'D' for "Description */
3310 else if (buf[0] == 'D')
3315 /* Acquire the text */
3320 /* Acquire the text */
3324 /* Store the text */
3325 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3328 /* Process 'W' for "More Info" (one line only) */
3329 else if (buf[0] == 'W')
3331 int min_lev, max_lev;
3333 int min_alloc, max_chance;
3334 int obj_good, obj_great;
3337 /* Scan for the values */
3338 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3339 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3341 /* Save the values */
3342 d_ptr->mindepth = (DEPTH)min_lev;
3343 d_ptr->maxdepth = (DEPTH)max_lev;
3344 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
3345 d_ptr->mode = (BIT_FLAGS8)mode;
3346 d_ptr->min_m_alloc_level = min_alloc;
3347 d_ptr->max_m_alloc_chance = max_chance;
3348 d_ptr->obj_good = obj_good;
3349 d_ptr->obj_great = obj_great;
3350 d_ptr->pit = (BIT_FLAGS16)pit;
3351 d_ptr->nest = (BIT_FLAGS16)nest;
3354 /* Process 'P' for "Place Info" */
3355 else if (buf[0] == 'P')
3359 /* Scan for the values */
3360 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3362 /* Save the values */
3367 /* Process 'L' for "fLoor type" (one line only) */
3368 else if (buf[0] == 'L')
3372 /* Scan for the values */
3373 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3375 /* Save the values */
3376 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3378 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3379 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3381 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3383 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3386 /* Process 'A' for "wAll type" (one line only) */
3387 else if (buf[0] == 'A')
3391 /* Scan for the values */
3392 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3394 /* Save the values */
3395 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3397 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3398 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3400 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
3403 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3404 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3406 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3407 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3409 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3410 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3412 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3413 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3416 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3417 else if (buf[0] == 'F')
3419 int artif = 0, monst = 0;
3421 /* Parse every entry */
3422 for (s = buf + 2; *s; )
3424 /* Find the end of this entry */
3425 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3427 /* Nuke and skip any dividers */
3431 while (*t == ' ' || *t == '|') t++;
3434 /* Hack -- Read Final Artifact */
3435 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3437 /* Extract a "Final Artifact" */
3438 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
3440 /* Start at next entry */
3445 /* Hack -- Read Final Object */
3446 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3448 /* Extract a "Final Artifact" */
3449 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
3451 /* Start at next entry */
3456 /* Hack -- Read Artifact Guardian */
3457 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3459 /* Extract a "Artifact Guardian" */
3460 d_ptr->final_guardian = (MONRACE_IDX)monst;
3462 /* Start at next entry */
3467 /* Hack -- Read Special Percentage */
3468 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3470 /* Extract a "Special %" */
3471 d_ptr->special_div = (PROB)monst;
3473 /* Start at next entry */
3478 /* Parse this entry */
3479 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3481 /* Start the next entry */
3486 /* Process 'M' for "Basic Flags" (multiple lines) */
3487 else if (buf[0] == 'M')
3489 /* Parse every entry */
3490 for (s = buf + 2; *s; )
3492 /* Find the end of this entry */
3493 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3495 /* Nuke and skip any dividers */
3499 while (*t == ' ' || *t == '|') t++;
3502 /* Hack -- Read monster symbols */
3503 if (!strncmp(s, "R_CHAR_", 7))
3505 /* Skip "R_CHAR_" */
3509 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3511 /* Start at next entry */
3516 /* Parse this entry */
3517 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3519 /* Start the next entry */
3524 /* Process 'S' for "Spell Flags" (multiple lines) */
3525 else if (buf[0] == 'S')
3527 /* Parse every entry */
3528 for (s = buf + 2; *s; )
3530 /* Find the end of this entry */
3531 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3533 /* Nuke and skip any dividers */
3537 while ((*t == ' ') || (*t == '|')) t++;
3540 /* Hack -- Read spell frequency */
3541 if (1 == sscanf(s, "1_IN_%d", &i))
3543 /* Start at next entry */
3548 /* Parse this entry */
3549 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3551 /* Start the next entry */
3563 #else /* ALLOW_TEMPLATES */
3569 #endif /* ALLOW_TEMPLATES */
3572 /* Random dungeon grid effects */
3573 #define RANDOM_NONE 0x00000000
3574 #define RANDOM_FEATURE 0x00000001
3575 #define RANDOM_MONSTER 0x00000002
3576 #define RANDOM_OBJECT 0x00000004
3577 #define RANDOM_EGO 0x00000008
3578 #define RANDOM_ARTIFACT 0x00000010
3579 #define RANDOM_TRAP 0x00000020
3582 typedef struct dungeon_grid dungeon_grid;
3586 FEAT_IDX feature; /* Terrain feature */
3587 MONSTER_IDX monster; /* Monster */
3588 OBJECT_IDX object; /* Object */
3589 EGO_IDX ego; /* Ego-Item */
3590 ARTIFACT_IDX artifact; /* Artifact */
3591 IDX trap; /* Trap */
3592 BIT_FLAGS cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3593 s16b special; /* Reserved for special terrain info */
3594 int random; /* Number of the random effect */
3598 static dungeon_grid letter[255];
3602 * @brief 地形情報の「F:」情報をパースする
3603 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3607 static errr parse_line_feature(char *buf)
3612 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3614 /* Tokenize the line */
3615 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3617 /* Letter to assign */
3618 int index = zz[0][0];
3620 /* Reset the info for the letter */
3621 letter[index].feature = feat_none;
3622 letter[index].monster = 0;
3623 letter[index].object = 0;
3624 letter[index].ego = 0;
3625 letter[index].artifact = 0;
3626 letter[index].trap = feat_none;
3627 letter[index].cave_info = 0;
3628 letter[index].special = 0;
3629 letter[index].random = RANDOM_NONE;
3635 letter[index].special = (s16b)atoi(zz[8]);
3639 if ((zz[7][0] == '*') && !zz[7][1])
3641 letter[index].random |= RANDOM_TRAP;
3645 letter[index].trap = f_tag_to_index(zz[7]);
3646 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3651 if (zz[6][0] == '*')
3653 letter[index].random |= RANDOM_ARTIFACT;
3654 if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1);
3656 else if (zz[6][0] == '!')
3658 if (p_ptr->inside_quest)
3660 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3665 letter[index].artifact = (IDX)atoi(zz[6]);
3670 if (zz[5][0] == '*')
3672 letter[index].random |= RANDOM_EGO;
3673 if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1);
3677 letter[index].ego = (IDX)atoi(zz[5]);
3682 if (zz[4][0] == '*')
3684 letter[index].random |= RANDOM_OBJECT;
3685 if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1);
3687 else if (zz[4][0] == '!')
3689 if (p_ptr->inside_quest)
3691 ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
3694 artifact_type *a_ptr = &a_info[a_idx];
3695 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3697 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3704 letter[index].object = (IDX)atoi(zz[4]);
3709 if (zz[3][0] == '*')
3711 letter[index].random |= RANDOM_MONSTER;
3712 if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1);
3714 else if (zz[3][0] == 'c')
3716 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3717 letter[index].monster = - atoi(zz[3] + 1);
3721 letter[index].monster = (IDX)atoi(zz[3]);
3726 letter[index].cave_info = atoi(zz[2]);
3730 if ((zz[1][0] == '*') && !zz[1][1])
3732 letter[index].random |= RANDOM_FEATURE;
3736 letter[index].feature = f_tag_to_index(zz[1]);
3737 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3750 * @brief 地形情報の「B:」情報をパースする
3751 * Process "B:<Index>:<Command>:..." -- Building definition
3755 static errr parse_line_building(char *buf)
3771 /* Get the building number */
3774 /* Find the colon after the building number */
3775 s = my_strchr(s, ':');
3777 /* Verify that colon */
3780 /* Nuke the colon, advance to the sub-index */
3783 /* Paranoia -- require a sub-index */
3784 if (!*s) return (1);
3786 /* Building definition sub-index */
3789 /* Building name, owner, race */
3792 if (tokenize(s + 2, 3, zz, 0) == 3)
3794 /* Name of the building */
3795 strcpy(building[index].name, zz[0]);
3797 /* Name of the owner */
3798 strcpy(building[index].owner_name, zz[1]);
3800 /* Race of the owner */
3801 strcpy(building[index].owner_race, zz[2]);
3806 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3809 /* Building Action */
3812 if (tokenize(s + 2, 8, zz, 0) >= 7)
3814 /* Index of the action */
3815 int action_index = atoi(zz[0]);
3817 /* Name of the action */
3818 strcpy(building[index].act_names[action_index], zz[1]);
3820 /* Cost of the action for members */
3821 building[index].member_costs[action_index] = (PRICE)atoi(zz[2]);
3823 /* Cost of the action for non-members */
3824 building[index].other_costs[action_index] = (PRICE)atoi(zz[3]);
3826 /* Letter assigned to the action */
3827 building[index].letters[action_index] = zz[4][0];
3830 building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]);
3832 /* Action restriction */
3833 building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]);
3838 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3841 /* Building Classes */
3845 n = tokenize(s + 2, MAX_CLASS, zz, 0);
3846 for (i = 0; i < MAX_CLASS; i++)
3848 building[index].member_class[i] = ((i < n) ? (CLASS_IDX)atoi(zz[i]) : 1);
3853 /* Building Races */
3857 n = tokenize(s + 2, MAX_RACES, zz, 0);
3858 for (i = 0; i < MAX_RACES; i++)
3860 building[index].member_race[i] = ((i < n) ? (RACE_IDX)atoi(zz[i]) : 1);
3865 /* Building Realms */
3869 n = tokenize(s + 2, MAX_MAGIC, zz, 0);
3870 for (i = 0; i < MAX_MAGIC; i++)
3872 building[index].member_realm[i+1] = ((i < n) ? (REALM_IDX)atoi(zz[i]) : 1);
3879 /* Ignore scripts */
3885 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3894 * @brief フロアの所定のマスにオブジェクトを配置する
3895 * Place the object j_ptr to a grid
3896 * @param j_ptr オブジェクト構造体の参照ポインタ
3901 static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
3903 cave_type *c_ptr = &cave[y][x];
3906 OBJECT_IDX o_idx = o_pop();
3908 /* Access new object */
3909 o_ptr = &o_list[o_idx];
3911 /* Structure copy */
3912 object_copy(o_ptr, j_ptr);
3919 o_ptr->held_m_idx = 0;
3922 o_ptr->next_o_idx = c_ptr->o_idx;
3924 /* Place the object */
3925 c_ptr->o_idx = o_idx;
3930 * @brief クエスト用固定ダンジョンをフロアに生成する
3931 * Parse a sub-file of the "extra info"
3941 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3946 /* Skip "empty" lines */
3947 if (!buf[0]) return (0);
3949 /* Skip "blank" lines */
3950 if (iswspace(buf[0])) return (0);
3953 if (buf[0] == '#') return (0);
3955 /* Require "?:*" format */
3956 if (buf[1] != ':') return (1);
3959 /* Process "%:<fname>" */
3962 /* Attempt to Process the given file */
3963 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3966 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3969 return parse_line_feature(buf);
3972 /* Process "D:<dungeon>" -- info for the cave grids */
3973 else if (buf[0] == 'D')
3975 object_type object_type_body;
3977 /* Acquire the text */
3980 /* Length of the text */
3981 int len = strlen(s);
3983 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3985 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3987 cave_type *c_ptr = &cave[*y][*x];
3991 OBJECT_IDX object_index = letter[idx].object;
3992 MONSTER_IDX monster_index = letter[idx].monster;
3993 int random = letter[idx].random;
3994 ARTIFACT_IDX artifact_index = letter[idx].artifact;
3996 /* Lay down a floor */
3997 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
3999 /* Only the features */
4000 if (init_flags & INIT_ONLY_FEATURES) continue;
4003 c_ptr->info = letter[idx].cave_info;
4005 /* Create a monster */
4006 if (random & RANDOM_MONSTER)
4008 monster_level = base_level + monster_index;
4010 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4012 monster_level = base_level;
4014 else if (monster_index)
4016 int old_cur_num, old_max_num;
4019 if (monster_index < 0)
4021 monster_index = -monster_index;
4024 old_cur_num = r_info[monster_index].cur_num;
4025 old_max_num = r_info[monster_index].max_num;
4027 /* Make alive again */
4028 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4030 r_info[monster_index].cur_num = 0;
4031 r_info[monster_index].max_num = 1;
4034 /* Make alive again */
4035 /* Hack -- Non-unique Nazguls are semi-unique */
4036 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4038 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4040 r_info[monster_index].max_num++;
4045 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4049 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4051 /* Make alive again for real unique monster */
4052 r_info[monster_index].cur_num = old_cur_num;
4053 r_info[monster_index].max_num = old_max_num;
4057 /* Object (and possible trap) */
4058 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4060 object_level = base_level + object_index;
4063 * Random trap and random treasure defined
4064 * 25% chance for trap and 75% chance for object
4066 if (randint0(100) < 75)
4068 place_object(*y, *x, 0L);
4075 object_level = base_level;
4077 else if (random & RANDOM_OBJECT)
4079 object_level = base_level + object_index;
4081 /* Create an out of deep object */
4082 if (randint0(100) < 75)
4083 place_object(*y, *x, 0L);
4084 else if (randint0(100) < 80)
4085 place_object(*y, *x, AM_GOOD);
4087 place_object(*y, *x, AM_GOOD | AM_GREAT);
4089 object_level = base_level;
4092 else if (random & RANDOM_TRAP)
4096 /* Hidden trap (or door) */
4097 else if (letter[idx].trap)
4099 c_ptr->mimic = c_ptr->feat;
4100 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4102 else if (object_index)
4104 object_type *o_ptr = &object_type_body;
4105 object_prep(o_ptr, object_index);
4107 if (o_ptr->tval == TV_GOLD)
4109 coin_type = object_index - OBJ_GOLD_LIST;
4114 /* Apply magic (no messages, no artifacts) */
4115 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4117 drop_here(o_ptr, *y, *x);
4123 if (a_info[artifact_index].cur_num)
4125 KIND_OBJECT_IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4127 object_type *q_ptr = &forge;
4129 object_prep(q_ptr, k_idx);
4130 drop_here(q_ptr, *y, *x);
4134 /* Create the artifact */
4135 if (create_named_art(artifact_index, *y, *x))
4136 a_info[artifact_index].cur_num = 1;
4140 /* Terrain special */
4141 c_ptr->special = letter[idx].special;
4149 /* Process "Q:<number>:<command>:... -- quest info */
4150 else if (buf[0] == 'Q')
4157 num = tokenize(buf + 2, 33, zz, 0);
4161 num = tokenize(buf + 3, 33, zz, 0);
4164 /* Have we enough parameters? */
4165 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4168 q_ptr = &(quest[atoi(zz[0])]);
4170 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4171 if (zz[1][0] == 'Q')
4173 if (init_flags & INIT_ASSIGN)
4175 monster_race *r_ptr;
4176 artifact_type *a_ptr;
4178 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4180 q_ptr->type = (QUEST_TYPE)atoi(zz[2]);
4181 q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]);
4182 q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]);
4183 q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]);
4184 q_ptr->level = (DEPTH)atoi(zz[6]);
4185 q_ptr->r_idx = (IDX)atoi(zz[7]);
4186 q_ptr->k_idx = (IDX)atoi(zz[8]);
4187 q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]);
4189 if (num > 10) q_ptr->flags = atoi(zz[10]);
4191 r_ptr = &r_info[q_ptr->r_idx];
4192 if (r_ptr->flags1 & RF1_UNIQUE)
4193 r_ptr->flags1 |= RF1_QUESTOR;
4195 a_ptr = &a_info[q_ptr->k_idx];
4196 a_ptr->gen_flags |= TRG_QUESTITEM;
4201 else if (zz[1][0] == 'R')
4203 if (init_flags & INIT_ASSIGN)
4206 IDX idx, reward_idx = 0;
4208 for (idx = 2; idx < num; idx++)
4210 IDX a_idx = (IDX)atoi(zz[idx]);
4211 if (a_idx < 1) continue;
4212 if (a_info[a_idx].cur_num > 0) continue;
4214 if (one_in_(count)) reward_idx = a_idx;
4219 /* Set quest's rewarding artifact */
4220 q_ptr->k_idx = reward_idx;
4221 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4225 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4226 q_ptr->type = QUEST_TYPE_KILL_ALL;
4233 /* Process "Q:<q_index>:N:<name>" -- quest name */
4234 else if (zz[1][0] == 'N')
4236 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4238 strcpy(q_ptr->name, zz[2]);
4244 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4245 else if (zz[1][0] == 'T')
4247 if (init_flags & INIT_SHOW_TEXT)
4249 strcpy(quest_text[quest_text_line], zz[2]);
4257 /* Process "W:<command>: ..." -- info for the wilderness */
4258 else if (buf[0] == 'W')
4260 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4263 /* Process "P:<y>:<x>" -- player position */
4264 else if (buf[0] == 'P')
4266 if (init_flags & INIT_CREATE_DUNGEON)
4268 if (tokenize(buf + 2, 2, zz, 0) == 2)
4270 int panels_x, panels_y;
4272 /* Hack - Set the dungeon size */
4273 panels_y = (*y / SCREEN_HGT);
4274 if (*y % SCREEN_HGT) panels_y++;
4275 cur_hgt = panels_y * SCREEN_HGT;
4277 panels_x = (*x / SCREEN_WID);
4278 if (*x % SCREEN_WID) panels_x++;
4279 cur_wid = panels_x * SCREEN_WID;
4281 /* Assume illegal panel */
4282 panel_row_min = cur_hgt;
4283 panel_col_min = cur_wid;
4285 /* Place player in a quest level */
4286 if (p_ptr->inside_quest)
4290 /* Delete the monster (if any) */
4291 delete_monster(p_ptr->y, p_ptr->x);
4299 /* Place player in the town */
4300 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4302 p_ptr->oldpy = atoi(zz[0]);
4303 p_ptr->oldpx = atoi(zz[1]);
4311 /* Process "B:<Index>:<Command>:..." -- Building definition */
4312 else if (buf[0] == 'B')
4314 return parse_line_building(buf);
4317 /* Process "M:<type>:<maximum>" -- set maximum values */
4318 else if (buf[0] == 'M')
4320 if (tokenize(buf+2, 2, zz, 0) == 2)
4323 if (zz[0][0] == 'T')
4325 max_towns = (TOWN_IDX)atoi(zz[1]);
4328 /* Maximum quests */
4329 else if (zz[0][0] == 'Q')
4331 max_q_idx = (QUEST_IDX)atoi(zz[1]);
4335 else if (zz[0][0] == 'R')
4337 max_r_idx = (IDX)atoi(zz[1]);
4341 else if (zz[0][0] == 'K')
4343 max_k_idx = (IDX)atoi(zz[1]);
4347 else if (zz[0][0] == 'V')
4349 max_v_idx = (IDX)atoi(zz[1]);
4353 else if (zz[0][0] == 'F')
4355 max_f_idx = (IDX)atoi(zz[1]);
4359 else if (zz[0][0] == 'A')
4361 max_a_idx = (IDX)atoi(zz[1]);
4365 else if (zz[0][0] == 'E')
4367 max_e_idx = (IDX)atoi(zz[1]);
4371 else if (zz[0][0] == 'D')
4373 max_d_idx = (IDX)atoi(zz[1]);
4377 else if (zz[0][0] == 'O')
4379 max_o_idx = (IDX)atoi(zz[1]);
4383 else if (zz[0][0] == 'M')
4385 max_m_idx = (IDX)atoi(zz[1]);
4388 /* Wilderness size */
4389 else if (zz[0][0] == 'W')
4391 /* Maximum wild_x_size */
4392 if (zz[0][1] == 'X')
4393 max_wild_x = atoi(zz[1]);
4394 /* Maximum wild_y_size */
4395 if (zz[0][1] == 'Y')
4396 max_wild_y = atoi(zz[1]);
4410 static concptr variant = "ZANGBAND";
4414 * @brief クエスト用固定ダンジョン生成時の分岐処理
4415 * Helper function for "process_dungeon_file()"
4420 static concptr process_dungeon_file_expr(char **sp, char *fp)
4436 while (iswspace(*s)) s++;
4454 t = process_dungeon_file_expr(&s, &f);
4462 else if (streq(t, "IOR"))
4465 while (*s && (f != b2))
4467 t = process_dungeon_file_expr(&s, &f);
4468 if (*t && !streq(t, "0")) v = "1";
4473 else if (streq(t, "AND"))
4476 while (*s && (f != b2))
4478 t = process_dungeon_file_expr(&s, &f);
4479 if (*t && streq(t, "0")) v = "0";
4484 else if (streq(t, "NOT"))
4487 while (*s && (f != b2))
4489 t = process_dungeon_file_expr(&s, &f);
4490 if (*t && streq(t, "1")) v = "0";
4495 else if (streq(t, "EQU"))
4498 if (*s && (f != b2))
4500 t = process_dungeon_file_expr(&s, &f);
4502 while (*s && (f != b2))
4504 p = process_dungeon_file_expr(&s, &f);
4505 if (streq(t, p)) v = "1";
4510 else if (streq(t, "LEQ"))
4513 if (*s && (f != b2))
4515 t = process_dungeon_file_expr(&s, &f);
4517 while (*s && (f != b2))
4520 t = process_dungeon_file_expr(&s, &f);
4521 if (*t && atoi(p) > atoi(t)) v = "0";
4526 else if (streq(t, "GEQ"))
4529 if (*s && (f != b2))
4531 t = process_dungeon_file_expr(&s, &f);
4533 while (*s && (f != b2))
4536 t = process_dungeon_file_expr(&s, &f);
4538 /* Compare two numbers instead of string */
4539 if (*t && atoi(p) < atoi(t)) v = "0";
4545 while (*s && (f != b2))
4547 t = process_dungeon_file_expr(&s, &f);
4552 if (f != b2) v = "?x?x?";
4554 /* Extract final and Terminate */
4555 if ((f = *s) != '\0') *s++ = '\0';
4561 /* Accept all printables except spaces and brackets */
4563 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4565 if (iskanji(*s)) s++;
4569 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4572 /* Extract final and Terminate */
4573 if ((f = *s) != '\0') *s++ = '\0';
4579 if (streq(b+1, "SYS"))
4585 else if (streq(b+1, "GRAF"))
4590 else if (streq(b+1, "MONOCHROME"))
4599 else if (streq(b+1, "RACE"))
4601 v = _(rp_ptr->E_title, rp_ptr->title);
4605 else if (streq(b+1, "CLASS"))
4607 v = _(cp_ptr->E_title, cp_ptr->title);
4611 else if (streq(b+1, "REALM1"))
4613 v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
4617 else if (streq(b+1, "REALM2"))
4619 v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
4623 else if (streq(b+1, "PLAYER"))
4625 static char tmp_player_name[32];
4627 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
4637 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4640 v = tmp_player_name;
4644 else if (streq(b+1, "TOWN"))
4646 sprintf(tmp, "%d", p_ptr->town_num);
4651 else if (streq(b+1, "LEVEL"))
4653 sprintf(tmp, "%d", p_ptr->lev);
4657 /* Current quest number */
4658 else if (streq(b+1, "QUEST_NUMBER"))
4660 sprintf(tmp, "%d", p_ptr->inside_quest);
4664 /* Number of last quest */
4665 else if (streq(b+1, "LEAVING_QUEST"))
4667 sprintf(tmp, "%d", leaving_quest);
4672 else if (prefix(b+1, "QUEST_TYPE"))
4674 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4675 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4680 else if (prefix(b+1, "QUEST"))
4682 /* "QUEST" uses a special parameter to determine the number of the quest */
4683 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4688 else if (prefix(b+1, "RANDOM"))
4690 /* "RANDOM" uses a special parameter to determine the number of the quest */
4691 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4696 else if (streq(b+1, "VARIANT"))
4702 else if (streq(b+1, "WILDERNESS"))
4705 sprintf(tmp, "NONE");
4707 sprintf(tmp, "LITE");
4709 sprintf(tmp, "NORMAL");
4729 * @brief クエスト用固定ダンジョン生成時のメインルーチン
4730 * Helper function for "process_dungeon_file()"
4738 errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax)
4744 bool bypass = FALSE;
4745 int x = xmin, y = ymin;
4748 /* Build the filename */
4749 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4752 fp = my_fopen(buf, "r");
4755 if (!fp) return (-1);
4758 /* Process the file */
4759 while (0 == my_fgets(fp, buf, sizeof(buf)))
4765 /* Skip "empty" lines */
4766 if (!buf[0]) continue;
4768 /* Skip "blank" lines */
4769 if (iswspace(buf[0])) continue;
4772 if (buf[0] == '#') continue;
4775 /* Process "?:<expr>" */
4776 if ((buf[0] == '?') && (buf[1] == ':'))
4785 /* Parse the expr */
4786 v = process_dungeon_file_expr(&s, &f);
4789 bypass = (streq(v, "0") ? TRUE : FALSE);
4793 /* Apply conditionals */
4794 if (bypass) continue;
4796 /* Process the line */
4797 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4808 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4810 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4811 msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
4823 void write_r_info_txt(void)
4825 int i, j, z, fc, bc;
4828 concptr flags[32 * 10];
4833 monster_race *r_ptr;
4835 monster_blow *b_ptr;
4837 FILE *fff = fopen("output.txt", "wt");
4841 BIT_FLAGS mode = -1;
4845 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4847 fprintf(fff, "# Version stamp (required)\n\n");
4850 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4853 fprintf(fff, "##### The Player #####\n\n");
4855 for (z = -1; z < alloc_race_size; z++)
4857 /* Output the monsters in order */
4858 i = (z >= 0) ? alloc_race_table[z].index : 0;
4860 /* Acquire the monster */
4863 /* Ignore empty monsters */
4864 if (!strlen(r_name + r_ptr->name)) continue;
4866 /* Ignore useless monsters */
4867 if (i && !r_ptr->speed) continue;
4869 /* Write a note if necessary */
4870 if (i && (!r_ptr->level != !mode))
4875 fprintf(fff, "\n##### Town monsters #####\n\n");
4877 /* Note the dungeon */
4880 fprintf(fff, "\n##### Normal monsters #####\n\n");
4883 /* Record the change */
4884 mode = r_ptr->level;
4887 /* Acquire the flags */
4888 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4889 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4890 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4891 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4892 f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
4893 f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
4894 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4895 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4896 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4897 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4899 /* Write New/Number/Name */
4900 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4903 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4905 /* Write Information */
4906 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4907 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4909 /* Write more information */
4910 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4913 for(j = 0; j < 4; j++)
4915 b_ptr = &(r_ptr->blow[j]);
4917 /* Stop when done */
4918 if (!b_ptr->method) break;
4920 /* Write the blows */
4921 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4922 r_info_blow_effect[b_ptr->effect],
4923 b_ptr->d_dice, b_ptr->d_side);
4925 for (fc = 0, j = 0; j < 32 * 3; j++)
4927 /* Check this flag */
4928 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4931 /* Extract the extra flags */
4932 for (j = 32 * 6; j < 32 * 10; j++)
4934 /* Check this flag */
4935 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4938 /* Write the flags */
4939 for (j = 0; j < fc;)
4943 /* Start the line */
4946 for (bc = 0; (bc < 60) && (j < fc); j++)
4950 /* Format the flag */
4951 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4953 /* Add it to the buffer */
4956 /* Note the length */
4960 /* Done with this line; write it */
4961 fprintf(fff, "%s\n", buf);
4964 /* Write Spells if applicable */
4965 if (r_ptr->freq_spell)
4967 /* Write the frequency */
4968 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4970 /* Extract the spell flags */
4971 for (fc = 0, j = 96; j < 192; j++)
4973 /* Check this flag */
4974 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4977 /* Write the flags */
4978 for (j = 0; j < fc;)
4982 /* Start the line */
4985 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4989 /* Format the flag */
4990 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4994 /* Note the length */
5001 /* Done with this line; write it */
5002 fprintf(fff, "%s\n", buf);
5006 /* Acquire the description */
5007 desc = r_text + r_ptr->text;
5008 dlen = strlen(desc);
5010 /* Write Description */
5011 for (j = 0; j < dlen;)
5015 /* Start the line */
5018 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5026 /* Done with this line; write it */
5027 fprintf(fff, "%s\n", buf);
5030 /* Space between entries */