3 /* Purpose: Initialization (part 1) -BEN- */
10 static char *_strchr(char *ptr, char ch)
12 for ( ; *ptr != '\0'; ++ptr)
14 if (*ptr == ch) return ptr;
15 if (iskanji(*ptr)) ++ptr;
20 #define strchr _strchr
23 * This file is used to initialize various variables and arrays for the
24 * Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
25 * the common limitation of "read()" and "write()" to only 32767 bytes
28 * Several of the arrays for Angband are built from "template" files in
29 * the "lib/file" directory, from which quick-load binary "image" files
30 * are constructed whenever they are not present in the "lib/data"
31 * directory, or if those files become obsolete, if we are allowed.
33 * Warning -- the "ascii" file parsers use a minor hack to collect the
34 * name and text information in a single pass. Thus, the game will not
35 * be able to load any template file with more than 20K of names or 60K
36 * of text, even though technically, up to 64K should be legal.
38 * Note that if "ALLOW_TEMPLATES" is not defined, then a lot of the code
39 * in this file is compiled out, and the game will not run unless valid
40 * "binary template files" already exist in "lib/data". Thus, one can
41 * compile Angband with ALLOW_TEMPLATES defined, run once to create the
42 * "*.raw" files in "lib/data", and then quit, and recompile without
43 * defining ALLOW_TEMPLATES, which will both save 20K and prevent people
44 * from changing the ascii template files in potentially dangerous ways.
46 * The code could actually be removed and placed into a "stand-alone"
47 * program, but that feels a little silly, especially considering some
48 * of the platforms that we currently support.
51 #ifdef ALLOW_TEMPLATES
56 /*** Helper arrays for parsing ascii template files ***/
59 * Monster Blow Methods
61 static cptr r_info_blow_method[] =
94 * Monster Blow Effects
96 static cptr r_info_blow_effect[] =
139 static cptr r_info_flags1[] =
178 static cptr r_info_flags2[] =
217 static cptr r_info_flags3[] =
256 static cptr r_info_flags4[] =
295 static cptr r_info_flags5[] =
334 static cptr r_info_flags6[] =
351 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
374 static cptr r_info_flags7[] =
413 static cptr r_info_flags8[] =
445 "WILD_SWAMP", /* ToDo: Implement Swamp */
451 * Monster race flags - Drops
453 static cptr r_info_flags9[] =
494 static cptr k_info_flags1[] =
533 static cptr k_info_flags2[] =
572 static cptr k_info_flags3[] =
609 static cptr k_info_gen_flags[] =
649 static cptr d_info_flags1[] =
687 * Add a text to the text-storage and store offset to it.
689 * Returns FALSE when there isn't enough space available to store
692 static bool add_text(u32b *offset, header *head, cptr buf)
694 /* Hack -- Verify space */
695 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
701 /* Advance and save the text index */
702 *offset = ++head->text_size;
705 /* Append chars to the text */
706 strcpy(head->text_ptr + head->text_size, buf);
708 /* Advance the index */
709 head->text_size += strlen(buf);
717 * Add a name to the name-storage and return an offset to it.
719 * Returns FALSE when there isn't enough space available to store
722 static bool add_name(u32b *offset, header *head, cptr buf)
724 /* Hack -- Verify space */
725 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
731 /* Advance and save the name index */
732 *offset = ++head->name_size;
735 /* Append chars to the names */
736 strcpy(head->name_ptr + head->name_size, buf);
738 /* Advance the index */
739 head->name_size += strlen(buf);
747 * Convert a "color letter" into an "actual" color
748 * The colors are: dwsorgbuDWvyRGBU, as shown below
750 byte color_char_to_attr(char c)
754 case 'd': return (TERM_DARK);
755 case 'w': return (TERM_WHITE);
756 case 's': return (TERM_SLATE);
757 case 'o': return (TERM_ORANGE);
758 case 'r': return (TERM_RED);
759 case 'g': return (TERM_GREEN);
760 case 'b': return (TERM_BLUE);
761 case 'u': return (TERM_UMBER);
763 case 'D': return (TERM_L_DARK);
764 case 'W': return (TERM_L_WHITE);
765 case 'v': return (TERM_VIOLET);
766 case 'y': return (TERM_YELLOW);
767 case 'R': return (TERM_L_RED);
768 case 'G': return (TERM_L_GREEN);
769 case 'B': return (TERM_L_BLUE);
770 case 'U': return (TERM_L_UMBER);
778 /*** Initialize from ascii template files ***/
782 * Initialize an "*_info" array, by parsing an ascii "template" file
784 errr init_info_txt(FILE *fp, char *buf, header *head,
785 parse_info_txt_func parse_info_txt_line)
789 /* Just before the first record */
792 /* Just before the first line */
796 /* Prepare the "fake" stuff */
801 while (0 == my_fgets(fp, buf, 1024))
803 /* Advance the line number */
806 /* Skip comments and blank lines */
807 if (!buf[0] || (buf[0] == '#')) continue;
809 /* Verify correct "colon" format */
810 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
813 /* Hack -- Process 'V' for "Version" */
821 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
826 /* Complete the "name" and "text" sizes */
827 if (head->name_size) head->name_size++;
828 if (head->text_size) head->text_size++;
836 * Initialize the "v_info" array, by parsing an ascii "template" file
838 errr parse_v_info(char *buf, header *head)
844 static vault_type *v_ptr = NULL;
846 /* Process 'N' for "New/Number/Name" */
849 /* Find the colon before the name */
850 s = strchr(buf+2, ':');
852 /* Verify that colon */
855 /* Nuke the colon, advance to the name */
858 /* Paranoia -- require a name */
864 /* Verify information */
865 if (i <= error_idx) return (4);
867 /* Verify information */
868 if (i >= head->info_num) return (2);
873 /* Point at the "info" */
877 if (!add_name(&v_ptr->name, head, s)) return (7);
880 /* There better be a current v_ptr */
881 else if (!v_ptr) return (3);
883 /* Process 'D' for "Description" */
884 else if (buf[0] == 'D')
886 /* Acquire the text */
890 if (!add_text(&v_ptr->text, head, s)) return (7);
893 /* Process 'X' for "Extra info" (one line only) */
894 else if (buf[0] == 'X')
896 int typ, rat, hgt, wid;
898 /* Scan for the values */
899 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
900 &typ, &rat, &hgt, &wid)) return (1);
902 /* Save the values */
919 * Initialize the "s_info" array, by parsing an ascii "template" file
921 errr parse_s_info(char *buf, header *head)
926 static skill_table *s_ptr = NULL;
929 /* Process 'N' for "New/Number/Name" */
935 /* Verify information */
936 if (i <= error_idx) return (4);
938 /* Verify information */
939 if (i >= head->info_num) return (2);
944 /* Point at the "info" */
948 /* There better be a current s_ptr */
949 else if (!s_ptr) return (3);
951 /* Process 'W' for "Weapon exp" */
952 else if (buf[0] == 'W')
954 int tval, sval, start, max;
955 const s16b exp_conv_table[] = { 0, 4000, 6000, 7000, 8000 };
957 /* Scan for the values */
958 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
959 &tval, &sval, &start, &max)) return (1);
961 if (start < 0 || start > 4 || max < 0 || max > 4) return (8);
963 /* Save the values */
964 s_ptr->w_start[tval][sval] = exp_conv_table[start];
965 s_ptr->w_max[tval][sval] = exp_conv_table[max];
968 /* Process 'S' for "Skill exp" */
969 else if (buf[0] == 'S')
973 /* Scan for the values */
974 if (3 != sscanf(buf+2, "%d:%d:%d",
975 &num, &start, &max)) return (1);
977 if (start < 0 || start > 8000 || max < 0 || max > 8000) return (8);
979 /* Save the values */
980 s_ptr->s_start[num] = start;
981 s_ptr->s_max[num] = max;
994 * Initialize the "m_info" array, by parsing an ascii "template" file
996 errr parse_m_info(char *buf, header *head)
1003 static player_magic *m_ptr = NULL;
1006 static int realm, magic_idx = 0, readable = 0;
1009 /* Process 'N' for "New/Number/Name" */
1015 /* Verify information */
1016 if (i <= error_idx) return (4);
1018 /* Verify information */
1019 if (i >= head->info_num) return (2);
1021 /* Save the index */
1024 /* Point at the "info" */
1028 /* There better be a current m_ptr */
1029 else if (!m_ptr) return (3);
1031 /* Process 'I' for "Info" (one line only) */
1032 else if (buf[0] == 'I')
1035 int xtra, type, first, weight;
1037 /* Find the colon before the name */
1038 s = strchr(buf+2, ':');
1040 /* Verify that colon */
1043 /* Nuke the colon, advance to the name */
1048 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1049 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1050 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1051 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1052 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1057 /* Find the colon before the name */
1060 /* Verify that colon */
1063 /* Nuke the colon, advance to the name */
1066 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1067 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1068 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1069 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1070 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1071 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1075 /* Scan for the values */
1076 if (4 != sscanf(s, "%d:%d:%d:%d",
1077 &xtra, &type, &first, &weight)) return (1);
1079 m_ptr->spell_xtra = xtra;
1080 m_ptr->spell_type = type;
1081 m_ptr->spell_first = first;
1082 m_ptr->spell_weight = weight;
1086 /* Process 'R' for "Realm" (one line only) */
1087 else if (buf[0] == 'R')
1089 /* Scan for the values */
1090 if (2 != sscanf(buf+2, "%d:%d",
1091 &realm, &readable)) return (1);
1096 else if (buf[0] == 'T')
1098 int level, mana, fail, exp;
1100 if (!readable) return (1);
1101 /* Scan for the values */
1102 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1103 &level, &mana, &fail, &exp)) return (1);
1105 m_ptr->info[realm][magic_idx].slevel = level;
1106 m_ptr->info[realm][magic_idx].smana = mana;
1107 m_ptr->info[realm][magic_idx].sfail = fail;
1108 m_ptr->info[realm][magic_idx].sexp = exp;
1122 * Initialize the "f_info" array, by parsing an ascii "template" file
1124 errr parse_f_info(char *buf, header *head)
1131 static feature_type *f_ptr = NULL;
1134 /* Process 'N' for "New/Number/Name" */
1137 /* Find the colon before the name */
1138 s = strchr(buf+2, ':');
1140 /* Verify that colon */
1143 /* Nuke the colon, advance to the name */
1147 /* Paranoia -- require a name */
1148 if (!*s) return (1);
1154 /* Verify information */
1155 if (i <= error_idx) return (4);
1157 /* Verify information */
1158 if (i >= head->info_num) return (2);
1160 /* Save the index */
1163 /* Point at the "info" */
1167 /* Store the name */
1168 if (!add_name(&f_ptr->name, head, s)) return (7);
1170 /* Default "mimic" */
1174 /* There better be a current f_ptr */
1175 else if (!f_ptr) return (3);
1178 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1179 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1180 else if (buf[0] == 'E')
1185 else if (buf[0] == 'E')
1187 /* Acquire the Text */
1190 /* Store the name */
1191 if (!add_name(&f_ptr->name, head, s)) return (7);
1197 /* Process 'D' for "Description" */
1198 else if (buf[0] == 'D')
1200 /* Acquire the text */
1203 /* Store the text */
1204 if (!add_text(&f_ptr->text, head, s)) return (7);
1210 /* Process 'M' for "Mimic" (one line only) */
1211 else if (buf[0] == 'M')
1215 /* Scan for the values */
1216 if (1 != sscanf(buf+2, "%d",
1217 &mimic)) return (1);
1219 /* Save the values */
1220 f_ptr->mimic = mimic;
1225 /* Process 'G' for "Graphics" (one line only) */
1226 else if (buf[0] == 'G')
1231 if (!buf[2]) return (1);
1232 if (!buf[3]) return (1);
1233 if (!buf[4]) return (1);
1235 /* Extract the color */
1236 tmp = color_char_to_attr(buf[4]);
1239 if (tmp > 127) return (1);
1241 /* Save the values */
1242 f_ptr->d_attr = tmp;
1243 f_ptr->d_char = buf[2];
1256 * Grab one flag in an object_kind from a textual string
1258 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
1263 for (i = 0; i < 32; i++)
1265 if (streq(what, k_info_flags1[i]))
1267 k_ptr->flags1 |= (1L << i);
1273 for (i = 0; i < 32; i++)
1275 if (streq(what, k_info_flags2[i]))
1277 k_ptr->flags2 |= (1L << i);
1283 for (i = 0; i < 32; i++)
1285 if (streq(what, k_info_flags3[i]))
1287 k_ptr->flags3 |= (1L << i);
1292 /* Check gen_flags */
1293 for (i = 0; i < 32; i++)
1295 if (streq(what, k_info_gen_flags[i]))
1297 k_ptr->gen_flags |= (1L << i);
1304 msg_format("̤ÃΤΥ¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1306 msg_format("Unknown object flag '%s'.", what);
1316 * Initialize the "k_info" array, by parsing an ascii "template" file
1318 errr parse_k_info(char *buf, header *head)
1325 static object_kind *k_ptr = NULL;
1328 /* Process 'N' for "New/Number/Name" */
1331 /* Find the colon before the name */
1332 s = strchr(buf+2, ':');
1334 /* Verify that colon */
1337 /* Nuke the colon, advance to the name */
1341 /* Paranoia -- require a name */
1342 if (!*s) return (1);
1347 /* Verify information */
1348 if (i <= error_idx) return (4);
1350 /* Verify information */
1351 if (i >= head->info_num) return (2);
1353 /* Save the index */
1356 /* Point at the "info" */
1360 /* Store the name */
1361 if (!add_name(&k_ptr->name, head, s)) return (7);
1365 /* There better be a current k_ptr */
1366 else if (!k_ptr) return (3);
1370 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1371 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1372 else if (buf[0] == 'E')
1377 else if (buf[0] == 'E')
1379 /* Acquire the Text */
1382 /* Store the name */
1383 if (!add_name(&k_ptr->name, head, s)) return (7);
1387 /* Process 'D' for "Description" */
1388 else if (buf[0] == 'D')
1393 /* Acquire the text */
1398 /* Acquire the text */
1402 /* Store the text */
1403 if (!add_text(&k_ptr->text, head, s)) return (7);
1406 /* Process 'G' for "Graphics" (one line only) */
1407 else if (buf[0] == 'G')
1413 if (!buf[2]) return (1);
1414 if (!buf[3]) return (1);
1415 if (!buf[4]) return (1);
1417 /* Extract the char */
1420 /* Extract the attr */
1421 tmp = color_char_to_attr(buf[4]);
1424 if (tmp > 127) return (1);
1426 /* Save the values */
1427 k_ptr->d_attr = tmp;
1428 k_ptr->d_char = sym;
1431 /* Process 'I' for "Info" (one line only) */
1432 else if (buf[0] == 'I')
1434 int tval, sval, pval;
1436 /* Scan for the values */
1437 if (3 != sscanf(buf+2, "%d:%d:%d",
1438 &tval, &sval, &pval)) return (1);
1440 /* Save the values */
1446 /* Process 'W' for "More Info" (one line only) */
1447 else if (buf[0] == 'W')
1449 int level, extra, wgt;
1452 /* Scan for the values */
1453 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1454 &level, &extra, &wgt, &cost)) return (1);
1456 /* Save the values */
1457 k_ptr->level = level;
1458 k_ptr->extra = extra;
1459 k_ptr->weight = wgt;
1463 /* Process 'A' for "Allocation" (one line only) */
1464 else if (buf[0] == 'A')
1468 /* XXX XXX XXX Simply read each number following a colon */
1469 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
1471 /* Default chance */
1472 k_ptr->chance[i] = 1;
1474 /* Store the attack damage index */
1475 k_ptr->locale[i] = atoi(s+1);
1477 /* Find the slash */
1478 t = strchr(s+1, '/');
1480 /* Find the next colon */
1481 s = strchr(s+1, ':');
1483 /* If the slash is "nearby", use it */
1484 if (t && (!s || t < s))
1486 int chance = atoi(t+1);
1487 if (chance > 0) k_ptr->chance[i] = chance;
1492 /* Hack -- Process 'P' for "power" and such */
1493 else if (buf[0] == 'P')
1495 int ac, hd1, hd2, th, td, ta;
1497 /* Scan for the values */
1498 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1499 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1509 /* Hack -- Process 'F' for flags */
1510 else if (buf[0] == 'F')
1512 /* Parse every entry textually */
1513 for (s = buf + 2; *s; )
1515 /* Find the end of this entry */
1516 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1518 /* Nuke and skip any dividers */
1522 while (*t == ' ' || *t == '|') t++;
1525 /* Parse this entry */
1526 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
1528 /* Start the next entry */
1544 * Grab one flag in an artifact_type from a textual string
1546 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
1551 for (i = 0; i < 32; i++)
1553 if (streq(what, k_info_flags1[i]))
1555 a_ptr->flags1 |= (1L << i);
1561 for (i = 0; i < 32; i++)
1563 if (streq(what, k_info_flags2[i]))
1565 a_ptr->flags2 |= (1L << i);
1571 for (i = 0; i < 32; i++)
1573 if (streq(what, k_info_flags3[i]))
1575 a_ptr->flags3 |= (1L << i);
1580 /* Check gen_flags */
1581 for (i = 0; i < 32; i++)
1583 if (streq(what, k_info_gen_flags[i]))
1585 a_ptr->gen_flags |= (1L << i);
1592 msg_format("̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1594 msg_format("Unknown artifact flag '%s'.", what);
1606 * Initialize the "a_info" array, by parsing an ascii "template" file
1608 errr parse_a_info(char *buf, header *head)
1615 static artifact_type *a_ptr = NULL;
1618 /* Process 'N' for "New/Number/Name" */
1621 /* Find the colon before the name */
1622 s = strchr(buf+2, ':');
1624 /* Verify that colon */
1627 /* Nuke the colon, advance to the name */
1630 /* Paranoia -- require a name */
1631 if (!*s) return (1);
1636 /* Verify information */
1637 if (i < error_idx) return (4);
1639 /* Verify information */
1640 if (i >= head->info_num) return (2);
1642 /* Save the index */
1645 /* Point at the "info" */
1648 /* Ignore everything */
1649 a_ptr->flags3 |= (TR3_IGNORE_ACID);
1650 a_ptr->flags3 |= (TR3_IGNORE_ELEC);
1651 a_ptr->flags3 |= (TR3_IGNORE_FIRE);
1652 a_ptr->flags3 |= (TR3_IGNORE_COLD);
1654 /* Store the name */
1655 if (!add_name(&a_ptr->name, head, s)) return (7);
1659 /* There better be a current a_ptr */
1660 else if (!a_ptr) return (3);
1664 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1665 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1666 else if (buf[0] == 'E')
1671 else if (buf[0] == 'E')
1673 /* Acquire the Text */
1676 /* Store the name */
1677 if (!add_name(&a_ptr->name, head, s)) return (7);
1681 /* Process 'D' for "Description" */
1682 else if (buf[0] == 'D')
1687 /* Acquire the text */
1692 /* Acquire the text */
1696 /* Store the text */
1697 if (!add_text(&a_ptr->text, head, s)) return (7);
1701 /* Process 'I' for "Info" (one line only) */
1702 else if (buf[0] == 'I')
1704 int tval, sval, pval;
1706 /* Scan for the values */
1707 if (3 != sscanf(buf+2, "%d:%d:%d",
1708 &tval, &sval, &pval)) return (1);
1710 /* Save the values */
1716 /* Process 'W' for "More Info" (one line only) */
1717 else if (buf[0] == 'W')
1719 int level, rarity, wgt;
1722 /* Scan for the values */
1723 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1724 &level, &rarity, &wgt, &cost)) return (1);
1726 /* Save the values */
1727 a_ptr->level = level;
1728 a_ptr->rarity = rarity;
1729 a_ptr->weight = wgt;
1733 /* Hack -- Process 'P' for "power" and such */
1734 else if (buf[0] == 'P')
1736 int ac, hd1, hd2, th, td, ta;
1738 /* Scan for the values */
1739 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1740 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1750 /* Hack -- Process 'F' for flags */
1751 else if (buf[0] == 'F')
1753 /* Parse every entry textually */
1754 for (s = buf + 2; *s; )
1756 /* Find the end of this entry */
1757 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1759 /* Nuke and skip any dividers */
1763 while ((*t == ' ') || (*t == '|')) t++;
1766 /* Parse this entry */
1767 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
1769 /* Start the next entry */
1785 * Grab one flag in a ego-item_type from a textual string
1787 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
1792 for (i = 0; i < 32; i++)
1794 if (streq(what, k_info_flags1[i]))
1796 e_ptr->flags1 |= (1L << i);
1802 for (i = 0; i < 32; i++)
1804 if (streq(what, k_info_flags2[i]))
1806 e_ptr->flags2 |= (1L << i);
1812 for (i = 0; i < 32; i++)
1814 if (streq(what, k_info_flags3[i]))
1816 e_ptr->flags3 |= (1L << i);
1821 /* Check gen_flags */
1822 for (i = 0; i < 32; i++)
1824 if (streq(what, k_info_gen_flags[i]))
1826 e_ptr->gen_flags |= (1L << i);
1833 msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1835 msg_format("Unknown ego-item flag '%s'.", what);
1847 * Initialize the "e_info" array, by parsing an ascii "template" file
1849 errr parse_e_info(char *buf, header *head)
1856 static ego_item_type *e_ptr = NULL;
1859 /* Just before the first record */
1862 /* Just before the first line */
1866 /* Process 'N' for "New/Number/Name" */
1869 /* Find the colon before the name */
1870 s = strchr(buf+2, ':');
1872 /* Verify that colon */
1875 /* Nuke the colon, advance to the name */
1878 /* Paranoia -- require a name */
1879 if (!*s) return (1);
1884 /* Verify information */
1885 if (i < error_idx) return (4);
1887 /* Verify information */
1888 if (i >= head->info_num) return (2);
1890 /* Save the index */
1893 /* Point at the "info" */
1896 /* Store the name */
1897 if (!add_name(&e_ptr->name, head, s)) return (7);
1901 /* There better be a current e_ptr */
1902 else if (!e_ptr) return (3);
1906 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1907 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
1908 else if (buf[0] == 'E')
1913 else if (buf[0] == 'E')
1915 /* Acquire the Text */
1918 /* Store the name */
1919 if (!add_name(&e_ptr->name, head, s)) return (7);
1924 /* Process 'D' for "Description" */
1925 else if (buf[0] == 'D')
1927 /* Acquire the text */
1930 /* Store the text */
1931 if (!add_text(&e_ptr->text, head, s)) return (7);
1936 /* Process 'X' for "Xtra" (one line only) */
1937 else if (buf[0] == 'X')
1941 /* Scan for the values */
1942 if (2 != sscanf(buf+2, "%d:%d",
1943 &slot, &rating)) return (1);
1945 /* Save the values */
1947 e_ptr->rating = rating;
1950 /* Process 'W' for "More Info" (one line only) */
1951 else if (buf[0] == 'W')
1953 int level, rarity, pad2;
1956 /* Scan for the values */
1957 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1958 &level, &rarity, &pad2, &cost)) return (1);
1960 /* Save the values */
1961 e_ptr->level = level;
1962 e_ptr->rarity = rarity;
1963 /* e_ptr->weight = wgt; */
1967 /* Hack -- Process 'C' for "creation" */
1968 else if (buf[0] == 'C')
1972 /* Scan for the values */
1973 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1974 &th, &td, &ta, &pv)) return (1);
1976 e_ptr->max_to_h = th;
1977 e_ptr->max_to_d = td;
1978 e_ptr->max_to_a = ta;
1979 e_ptr->max_pval = pv;
1982 /* Hack -- Process 'F' for flags */
1983 else if (buf[0] == 'F')
1985 /* Parse every entry textually */
1986 for (s = buf + 2; *s; )
1988 /* Find the end of this entry */
1989 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1991 /* Nuke and skip any dividers */
1995 while ((*t == ' ') || (*t == '|')) t++;
1998 /* Parse this entry */
1999 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2001 /* Start the next entry */
2015 * Grab one (basic) flag in a monster_race from a textual string
2017 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2022 for (i = 0; i < 32; i++)
2024 if (streq(what, r_info_flags1[i]))
2026 r_ptr->flags1 |= (1L << i);
2032 for (i = 0; i < 32; i++)
2034 if (streq(what, r_info_flags2[i]))
2036 r_ptr->flags2 |= (1L << i);
2042 for (i = 0; i < 32; i++)
2044 if (streq(what, r_info_flags3[i]))
2046 r_ptr->flags3 |= (1L << i);
2052 for (i = 0; i < 32; i++)
2054 if (streq(what, r_info_flags7[i]))
2056 r_ptr->flags7 |= (1L << i);
2062 for (i = 0; i < 32; i++)
2064 if (streq(what, r_info_flags8[i]))
2066 r_ptr->flags8 |= (1L << i);
2072 for (i = 0; i < 32; i++)
2074 if (streq(what, r_info_flags9[i]))
2076 r_ptr->flags9 |= (1L << i);
2083 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2085 msg_format("Unknown monster flag '%s'.", what);
2095 * Grab one (spell) flag in a monster_race from a textual string
2097 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2102 for (i = 0; i < 32; i++)
2104 if (streq(what, r_info_flags4[i]))
2106 r_ptr->flags4 |= (1L << i);
2112 for (i = 0; i < 32; i++)
2114 if (streq(what, r_info_flags5[i]))
2116 r_ptr->flags5 |= (1L << i);
2122 for (i = 0; i < 32; i++)
2124 if (streq(what, r_info_flags6[i]))
2126 r_ptr->flags6 |= (1L << i);
2133 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2135 msg_format("Unknown monster flag '%s'.", what);
2147 * Initialize the "r_info" array, by parsing an ascii "template" file
2149 errr parse_r_info(char *buf, header *head)
2156 static monster_race *r_ptr = NULL;
2159 /* Process 'N' for "New/Number/Name" */
2162 /* Find the colon before the name */
2163 s = strchr(buf+2, ':');
2165 /* Verify that colon */
2168 /* Nuke the colon, advance to the name */
2171 /* Paranoia -- require a name */
2172 if (!*s) return (1);
2177 /* Verify information */
2178 if (i < error_idx) return (4);
2180 /* Verify information */
2181 if (i >= head->info_num) return (2);
2183 /* Save the index */
2186 /* Point at the "info" */
2189 /* Store the name */
2190 if (!add_name(&r_ptr->name, head, s)) return (7);
2194 /* There better be a current r_ptr */
2195 else if (!r_ptr) return (3);
2199 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2200 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
2201 else if (buf[0] == 'E')
2203 /* Acquire the Text */
2206 /* Store the name */
2207 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2210 else if (buf[0] == 'E')
2212 /* Acquire the Text */
2215 /* Store the name */
2216 if (!add_name(&r_ptr->name, head, s)) return (7);
2219 /* Process 'D' for "Description" */
2220 else if (buf[0] == 'D')
2225 /* Acquire the text */
2230 /* Acquire the text */
2234 /* Store the text */
2235 if (!add_text(&r_ptr->text, head, s)) return (7);
2238 /* Process 'G' for "Graphics" (one line only) */
2239 else if (buf[0] == 'G')
2245 if (!buf[2]) return (1);
2246 if (!buf[3]) return (1);
2247 if (!buf[4]) return (1);
2249 /* Extract the char */
2252 /* Extract the attr */
2253 tmp = color_char_to_attr(buf[4]);
2256 if (tmp > 127) return (1);
2258 /* Save the values */
2259 r_ptr->d_char = sym;
2260 r_ptr->d_attr = tmp;
2263 /* Process 'I' for "Info" (one line only) */
2264 else if (buf[0] == 'I')
2266 int spd, hp1, hp2, aaf, ac, slp;
2268 /* Scan for the other values */
2269 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2270 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2272 /* Save the values */
2281 /* Process 'W' for "More Info" (one line only) */
2282 else if (buf[0] == 'W')
2289 /* Scan for the values */
2290 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2291 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2293 /* Save the values */
2295 r_ptr->rarity = rar;
2298 r_ptr->next_exp = nextexp;
2299 r_ptr->next_r_idx = nextmon;
2302 /* Process 'B' for "Blows" (up to four lines) */
2303 else if (buf[0] == 'B')
2307 /* Find the next empty blow slot (if any) */
2308 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
2310 /* Oops, no more slots */
2311 if (i == 4) return (1);
2313 /* Analyze the first field */
2314 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
2316 /* Terminate the field (if necessary) */
2317 if (*t == ':') *t++ = '\0';
2319 /* Analyze the method */
2320 for (n1 = 0; r_info_blow_method[n1]; n1++)
2322 if (streq(s, r_info_blow_method[n1])) break;
2325 /* Invalid method */
2326 if (!r_info_blow_method[n1]) return (1);
2328 /* Analyze the second field */
2329 for (s = t; *t && (*t != ':'); t++) /* loop */;
2331 /* Terminate the field (if necessary) */
2332 if (*t == ':') *t++ = '\0';
2334 /* Analyze effect */
2335 for (n2 = 0; r_info_blow_effect[n2]; n2++)
2337 if (streq(s, r_info_blow_effect[n2])) break;
2340 /* Invalid effect */
2341 if (!r_info_blow_effect[n2]) return (1);
2343 /* Analyze the third field */
2344 for (s = t; *t && (*t != 'd'); t++) /* loop */;
2346 /* Terminate the field (if necessary) */
2347 if (*t == 'd') *t++ = '\0';
2349 /* Save the method */
2350 r_ptr->blow[i].method = n1;
2352 /* Save the effect */
2353 r_ptr->blow[i].effect = n2;
2355 /* Extract the damage dice and sides */
2356 r_ptr->blow[i].d_dice = atoi(s);
2357 r_ptr->blow[i].d_side = atoi(t);
2360 /* Process 'F' for "Basic Flags" (multiple lines) */
2361 else if (buf[0] == 'F')
2363 /* Parse every entry */
2364 for (s = buf + 2; *s; )
2366 /* Find the end of this entry */
2367 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2369 /* Nuke and skip any dividers */
2373 while (*t == ' ' || *t == '|') t++;
2376 /* Parse this entry */
2377 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
2379 /* Start the next entry */
2384 /* Process 'S' for "Spell Flags" (multiple lines) */
2385 else if (buf[0] == 'S')
2387 /* Parse every entry */
2388 for (s = buf + 2; *s; )
2390 /* Find the end of this entry */
2391 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2393 /* Nuke and skip any dividers */
2397 while ((*t == ' ') || (*t == '|')) t++;
2400 /* XXX XXX XXX Hack -- Read spell frequency */
2401 if (1 == sscanf(s, "1_IN_%d", &i))
2403 /* Extract a "frequency" */
2404 r_ptr->freq_spell = r_ptr->freq_inate = 100 / i;
2406 /* Start at next entry */
2413 /* Parse this entry */
2414 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
2416 /* Start the next entry */
2431 * Grab one flag for a dungeon type from a textual string
2433 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
2438 for (i = 0; i < 32; i++)
2440 if (streq(what, d_info_flags1[i]))
2442 d_ptr->flags1 |= (1L << i);
2449 msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
2451 msg_format("Unknown dungeon type flag '%s'.", what);
2459 * Grab one (basic) flag in a monster_race from a textual string
2461 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
2466 for (i = 0; i < 32; i++)
2468 if (streq(what, r_info_flags1[i]))
2470 d_ptr->mflags1 |= (1L << i);
2476 for (i = 0; i < 32; i++)
2478 if (streq(what, r_info_flags2[i]))
2480 d_ptr->mflags2 |= (1L << i);
2486 for (i = 0; i < 32; i++)
2488 if (streq(what, r_info_flags3[i]))
2490 d_ptr->mflags3 |= (1L << i);
2496 for (i = 0; i < 32; i++)
2498 if (streq(what, r_info_flags7[i]))
2500 d_ptr->mflags7 |= (1L << i);
2506 for (i = 0; i < 32; i++)
2508 if (streq(what, r_info_flags8[i]))
2510 d_ptr->mflags8 |= (1L << i);
2516 for (i = 0; i < 32; i++)
2518 if (streq(what, r_info_flags9[i]))
2520 d_ptr->mflags9 |= (1L << i);
2527 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2529 msg_format("Unknown monster flag '%s'.", what);
2537 * Grab one (spell) flag in a monster_race from a textual string
2539 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
2544 for (i = 0; i < 32; i++)
2546 if (streq(what, r_info_flags4[i]))
2548 d_ptr->mflags4 |= (1L << i);
2554 for (i = 0; i < 32; i++)
2556 if (streq(what, r_info_flags5[i]))
2558 d_ptr->mflags5 |= (1L << i);
2564 for (i = 0; i < 32; i++)
2566 if (streq(what, r_info_flags6[i]))
2568 d_ptr->mflags6 |= (1L << i);
2575 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2577 msg_format("Unknown monster flag '%s'.", what);
2585 * Initialize the "d_info" array, by parsing an ascii "template" file
2587 errr parse_d_info(char *buf, header *head)
2594 static dungeon_info_type *d_ptr = NULL;
2597 /* Process 'N' for "New/Number/Name" */
2600 /* Find the colon before the name */
2601 s = strchr(buf+2, ':');
2603 /* Verify that colon */
2606 /* Nuke the colon, advance to the name */
2609 /* Paranoia -- require a name */
2610 if (!*s) return (1);
2615 /* Verify information */
2616 if (i < error_idx) return (4);
2618 /* Verify information */
2619 if (i >= head->info_num) return (2);
2621 /* Save the index */
2624 /* Point at the "info" */
2627 /* Store the name */
2628 if (!add_name(&d_ptr->name, head, s)) return (7);
2633 else if (buf[0] == 'E') return (0);
2635 else if (buf[0] == 'E')
2637 /* Acquire the Text */
2640 /* Store the name */
2641 if (!add_name(&d_ptr->name, head, s)) return (7);
2645 /* Process 'D' for "Description */
2646 else if (buf[0] == 'D')
2651 /* Acquire the text */
2656 /* Acquire the text */
2660 /* Store the text */
2661 if (!add_text(&d_ptr->text, head, s)) return (7);
2664 /* Process 'W' for "More Info" (one line only) */
2665 else if (buf[0] == 'W')
2667 int min_lev, max_lev;
2669 int min_alloc, max_chance;
2670 int obj_good, obj_great;
2673 /* Scan for the values */
2674 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
2675 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
2677 /* Save the values */
2678 d_ptr->mindepth = min_lev;
2679 d_ptr->maxdepth = max_lev;
2680 d_ptr->min_plev = min_plev;
2682 d_ptr->min_m_alloc_level = min_alloc;
2683 d_ptr->max_m_alloc_chance = max_chance;
2684 d_ptr->obj_good = obj_good;
2685 d_ptr->obj_great = obj_great;
2690 /* Process 'P' for "Place Info" */
2691 else if (buf[0] == 'P')
2695 /* Scan for the values */
2696 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
2698 /* Save the values */
2703 /* Process 'L' for "fLoor type" (one line only) */
2704 else if (buf[0] == 'L')
2710 /* Scan for the values */
2711 if (7 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d",
2712 &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) return (1);
2714 /* Save the values */
2716 d_ptr->floor_percent1 = p1;
2718 d_ptr->floor_percent2 = p2;
2720 d_ptr->floor_percent3 = p3;
2721 d_ptr->tunnel_percent = tunnel;
2724 /* Process 'A' for "wAll type" (one line only) */
2725 else if (buf[0] == 'A')
2727 int w1, w2, w3, outer, inner, stream1, stream2;
2730 /* Scan for the values */
2731 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
2732 &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) return (1);
2734 /* Save the values */
2735 d_ptr->fill_type1 = w1;
2736 d_ptr->fill_percent1 = p1;
2737 d_ptr->fill_type2 = w2;
2738 d_ptr->fill_percent2 = p2;
2739 d_ptr->fill_type3 = w3;
2740 d_ptr->fill_percent3 = p3;
2741 d_ptr->outer_wall = outer;
2742 d_ptr->inner_wall = inner;
2743 d_ptr->stream1 = stream1;
2744 d_ptr->stream2 = stream2;
2747 /* Process 'F' for "Dungeon Flags" (multiple lines) */
2748 else if (buf[0] == 'F')
2750 int artif = 0, monst = 0;
2752 /* Parse every entry */
2753 for (s = buf + 2; *s; )
2755 /* Find the end of this entry */
2756 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2758 /* Nuke and skip any dividers */
2762 while (*t == ' ' || *t == '|') t++;
2765 /* XXX XXX XXX Hack -- Read Final Artifact */
2766 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
2768 /* Extract a "Final Artifact" */
2769 d_ptr->final_artifact = artif;
2771 /* Start at next entry */
2778 /* XXX XXX XXX Hack -- Read Final Object */
2779 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
2781 /* Extract a "Final Artifact" */
2782 d_ptr->final_object = artif;
2784 /* Start at next entry */
2791 /* XXX XXX XXX Hack -- Read Artifact Guardian */
2792 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
2794 /* Extract a "Artifact Guardian" */
2795 d_ptr->final_guardian = monst;
2797 /* Start at next entry */
2804 /* XXX XXX XXX Hack -- Read Special Percentage */
2805 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
2807 /* Extract a "Special %" */
2808 d_ptr->special_div = monst;
2810 /* Start at next entry */
2817 /* Parse this entry */
2818 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
2820 /* Start the next entry */
2825 /* Process 'M' for "Basic Flags" (multiple lines) */
2826 else if (buf[0] == 'M')
2828 byte r_char_number = 0, r_char;
2830 /* Parse every entry */
2831 for (s = buf + 2; *s; )
2833 /* Find the end of this entry */
2834 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2836 /* Nuke and skip any dividers */
2840 while (*t == ' ' || *t == '|') t++;
2843 /* XXX XXX XXX Hack -- Read monster symbols */
2844 if (1 == sscanf(s, "R_CHAR_%c", &r_char))
2846 /* Limited to 5 races */
2847 if(r_char_number >= 5) continue;
2849 /* Extract a "frequency" */
2850 d_ptr->r_char[r_char_number++] = r_char;
2852 /* Start at next entry */
2859 /* Parse this entry */
2860 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
2862 /* Start the next entry */
2867 /* Process 'S' for "Spell Flags" (multiple lines) */
2868 else if (buf[0] == 'S')
2870 /* Parse every entry */
2871 for (s = buf + 2; *s; )
2873 /* Find the end of this entry */
2874 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2876 /* Nuke and skip any dividers */
2880 while ((*t == ' ') || (*t == '|')) t++;
2883 /* XXX XXX XXX Hack -- Read spell frequency */
2884 if (1 == sscanf(s, "1_IN_%d", &i))
2886 /* Start at next entry */
2893 /* Parse this entry */
2894 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
2896 /* Start the next entry */
2909 #else /* ALLOW_TEMPLATES */
2915 #endif /* ALLOW_TEMPLATES */
2918 /* Random dungeon grid effects */
2919 #define RANDOM_NONE 0x00
2920 #define RANDOM_FEATURE 0x01
2921 #define RANDOM_MONSTER 0x02
2922 #define RANDOM_OBJECT 0x04
2923 #define RANDOM_EGO 0x08
2924 #define RANDOM_ARTIFACT 0x10
2925 #define RANDOM_TRAP 0x20
2928 typedef struct dungeon_grid dungeon_grid;
2932 int feature; /* Terrain feature */
2933 int monster; /* Monster */
2934 int object; /* Object */
2935 int ego; /* Ego-Item */
2936 int artifact; /* Artifact */
2937 int trap; /* Trap */
2938 int cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
2939 int special; /* Reserved for special terrain info */
2940 int random; /* Number of the random effect */
2944 static dungeon_grid letter[255];
2948 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
2950 static errr parse_line_feature(char *buf)
2956 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
2958 /* Tokenize the line */
2959 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
2961 /* Letter to assign */
2962 int index = zz[0][0];
2964 /* Reset the info for the letter */
2965 letter[index].feature = 0;
2966 letter[index].monster = 0;
2967 letter[index].object = 0;
2968 letter[index].ego = 0;
2969 letter[index].artifact = 0;
2970 letter[index].trap = 0;
2971 letter[index].cave_info = 0;
2972 letter[index].special = 0;
2973 letter[index].random = 0;
2979 letter[index].special = atoi(zz[8]);
2983 if (zz[7][0] == '*')
2985 letter[index].random |= RANDOM_TRAP;
2990 letter[index].trap = atoi(zz[7]);
2995 letter[index].trap = atoi(zz[7]);
3000 if (zz[6][0] == '*')
3002 letter[index].random |= RANDOM_ARTIFACT;
3007 letter[index].artifact = atoi(zz[6]);
3012 letter[index].artifact = atoi(zz[6]);
3017 if (zz[5][0] == '*')
3019 letter[index].random |= RANDOM_EGO;
3024 letter[index].ego = atoi(zz[5]);
3029 letter[index].ego = atoi(zz[5]);
3034 if (zz[4][0] == '*')
3036 letter[index].random |= RANDOM_OBJECT;
3041 letter[index].object = atoi(zz[4]);
3046 letter[index].object = atoi(zz[4]);
3051 if (zz[3][0] == '*')
3053 letter[index].random |= RANDOM_MONSTER;
3057 letter[index].monster = atoi(zz[3]);
3060 else if (zz[3][0] == 'c')
3062 letter[index].monster = - atoi(zz[3]+1);
3066 letter[index].monster = atoi(zz[3]);
3071 letter[index].cave_info = atoi(zz[2]);
3075 if (zz[1][0] == '*')
3077 letter[index].random |= RANDOM_FEATURE;
3081 letter[index].feature = atoi(zz[1]);
3086 letter[index].feature = atoi(zz[1]);
3099 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3101 static errr parse_line_building(char *buf)
3117 /* Get the building number */
3120 /* Find the colon after the building number */
3123 /* Verify that colon */
3126 /* Nuke the colon, advance to the sub-index */
3129 /* Paranoia -- require a sub-index */
3130 if (!*s) return (1);
3132 /* Building definition sub-index */
3135 /* Building name, owner, race */
3138 if (tokenize(s + 2, 3, zz, 0) == 3)
3140 /* Name of the building */
3141 strcpy(building[index].name, zz[0]);
3143 /* Name of the owner */
3144 strcpy(building[index].owner_name, zz[1]);
3146 /* Race of the owner */
3147 strcpy(building[index].owner_race, zz[2]);
3152 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3155 /* Building Action */
3158 if (tokenize(s + 2, 8, zz, 0) >= 7)
3160 /* Index of the action */
3161 int action_index = atoi(zz[0]);
3163 /* Name of the action */
3164 strcpy(building[index].act_names[action_index], zz[1]);
3166 /* Cost of the action for members */
3167 building[index].member_costs[action_index] = atoi(zz[2]);
3169 /* Cost of the action for non-members */
3170 building[index].other_costs[action_index] = atoi(zz[3]);
3172 /* Letter assigned to the action */
3173 building[index].letters[action_index] = zz[4][0];
3176 building[index].actions[action_index] = atoi(zz[5]);
3178 /* Action restriction */
3179 building[index].action_restr[action_index] = atoi(zz[6]);
3184 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3187 /* Building Classes */
3190 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3192 for (i = 0; i < MAX_CLASS; i++)
3194 building[index].member_class[i] = atoi(zz[i]);
3200 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3203 /* Building Races */
3206 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3208 for (i = 0; i < MAX_RACES; i++)
3210 building[index].member_race[i] = atoi(zz[i]);
3216 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3219 /* Building Realms */
3222 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3224 for (i = 0; i < MAX_MAGIC; i++)
3226 building[index].member_realm[i+1] = atoi(zz[i]);
3232 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3237 /* Ignore scripts */
3243 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3252 * Parse a sub-file of the "extra info"
3254 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3261 /* Skip "empty" lines */
3262 if (!buf[0]) return (0);
3264 /* Skip "blank" lines */
3265 if (isspace(buf[0])) return (0);
3268 if (buf[0] == '#') return (0);
3270 /* Require "?:*" format */
3271 if (buf[1] != ':') return (1);
3274 /* Process "%:<fname>" */
3277 /* Attempt to Process the given file */
3278 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3281 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3284 return parse_line_feature(buf);
3287 /* Process "D:<dungeon>" -- info for the cave grids */
3288 else if (buf[0] == 'D')
3290 object_type object_type_body;
3292 /* Acquire the text */
3295 /* Length of the text */
3296 int len = strlen(s);
3298 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3300 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3302 /* Access the grid */
3303 cave_type *c_ptr = &cave[*y][*x];
3307 int object_index = letter[idx].object;
3308 int monster_index = letter[idx].monster;
3309 int random = letter[idx].random;
3310 int artifact_index = letter[idx].artifact;
3312 /* Lay down a floor */
3313 c_ptr->feat = letter[idx].feature;
3315 /* Only the features */
3316 if (init_flags & INIT_ONLY_FEATURES) continue;
3319 c_ptr->info = letter[idx].cave_info;
3321 /* Create a monster */
3322 if (random & RANDOM_MONSTER)
3324 monster_level = base_level + monster_index;
3326 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
3328 monster_level = base_level;
3330 else if (monster_index)
3332 int old_cur_num, old_max_num;
3335 if (monster_index < 0)
3337 monster_index = -monster_index;
3340 old_cur_num = r_info[monster_index].cur_num;
3341 old_max_num = r_info[monster_index].max_num;
3343 /* Make alive again */
3344 if (r_info[monster_index].flags1 & RF1_UNIQUE)
3346 r_info[monster_index].cur_num = 0;
3347 r_info[monster_index].max_num = 1;
3350 /* Make alive again */
3351 if (r_info[monster_index].flags7 & RF7_UNIQUE_7)
3353 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
3355 r_info[monster_index].max_num++;
3360 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
3364 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3366 /* Make alive again for real unique monster */
3367 r_info[monster_index].cur_num = old_cur_num;
3368 r_info[monster_index].max_num = old_max_num;
3372 /* Object (and possible trap) */
3373 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
3375 object_level = base_level + object_index;
3378 * Random trap and random treasure defined
3379 * 25% chance for trap and 75% chance for object
3381 if (randint0(100) < 75)
3383 place_object(*y, *x, FALSE, FALSE);
3390 object_level = base_level;
3392 else if (random & RANDOM_OBJECT)
3394 object_level = base_level + object_index;
3396 /* Create an out of deep object */
3397 if (randint0(100) < 75)
3398 place_object(*y, *x, FALSE, FALSE);
3399 else if (randint0(100) < 80)
3400 place_object(*y, *x, TRUE, FALSE);
3402 place_object(*y, *x, TRUE, TRUE);
3404 object_level = base_level;
3407 else if (random & RANDOM_TRAP)
3411 else if (object_index)
3413 /* Get local object */
3414 object_type *o_ptr = &object_type_body;
3416 /* Create the item */
3417 object_prep(o_ptr, object_index);
3419 if (o_ptr->tval == TV_GOLD)
3421 coin_type = object_index - OBJ_GOLD_LIST;
3426 /* Apply magic (no messages, no artifacts) */
3427 apply_magic(o_ptr, base_level, FALSE, TRUE, FALSE, FALSE);
3429 (void)drop_near(o_ptr, -1, *y, *x);
3435 if (a_info[artifact_index].cur_num)
3439 object_type *q_ptr = &forge;
3441 object_prep(q_ptr, k_idx);
3443 /* Drop it in the dungeon */
3444 (void)drop_near(q_ptr, -1, *y, *x);
3448 /* Create the artifact */
3449 create_named_art(artifact_index, *y, *x);
3451 a_info[artifact_index].cur_num = 1;
3455 /* Terrain special */
3456 c_ptr->special = letter[idx].special;
3464 /* Process "Q:<number>:<command>:... -- quest info */
3465 else if (buf[0] == 'Q')
3472 num = tokenize(buf + 2, 33, zz, 0);
3476 num = tokenize(buf + 3, 33, zz, 0);
3479 /* Have we enough parameters? */
3480 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3483 q_ptr = &(quest[atoi(zz[0])]);
3485 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
3486 if (zz[1][0] == 'Q')
3488 if (init_flags & INIT_ASSIGN)
3490 monster_race *r_ptr;
3491 artifact_type *a_ptr;
3493 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3495 q_ptr->type = atoi(zz[2]);
3496 q_ptr->num_mon = atoi(zz[3]);
3497 q_ptr->cur_num = atoi(zz[4]);
3498 q_ptr->max_num = atoi(zz[5]);
3499 q_ptr->level = atoi(zz[6]);
3500 q_ptr->r_idx = atoi(zz[7]);
3501 q_ptr->k_idx = atoi(zz[8]);
3502 q_ptr->dungeon = atoi(zz[9]);
3505 q_ptr->flags = atoi(zz[10]);
3507 r_ptr = &r_info[q_ptr->r_idx];
3508 if (r_ptr->flags1 & RF1_UNIQUE)
3509 r_ptr->flags1 |= RF1_QUESTOR;
3511 a_ptr = &a_info[q_ptr->k_idx];
3512 a_ptr->gen_flags |= TRG_QUESTITEM;
3517 /* Process "Q:<q_index>:N:<name>" -- quest name */
3518 else if (zz[1][0] == 'N')
3520 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT))
3522 strcpy(q_ptr->name, zz[2]);
3528 /* Process "Q:<q_index>:T:<text>" -- quest description line */
3529 else if (zz[1][0] == 'T')
3531 if (init_flags & INIT_SHOW_TEXT)
3533 strcpy(quest_text[quest_text_line], zz[2]);
3541 /* Process "W:<command>: ..." -- info for the wilderness */
3542 else if (buf[0] == 'W')
3544 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
3547 /* Process "P:<y>:<x>" -- player position */
3548 else if (buf[0] == 'P')
3550 if (init_flags & INIT_CREATE_DUNGEON)
3552 if (tokenize(buf + 2, 2, zz, 0) == 2)
3554 int panels_x, panels_y;
3556 /* Hack - Set the dungeon size */
3557 panels_y = (*y / SCREEN_HGT);
3558 if (*y % SCREEN_HGT) panels_y++;
3559 cur_hgt = panels_y * SCREEN_HGT;
3561 panels_x = (*x / SCREEN_WID);
3562 if (*x % SCREEN_WID) panels_x++;
3563 cur_wid = panels_x * SCREEN_WID;
3565 /* Assume illegal panel */
3566 panel_row_min = cur_hgt;
3567 panel_col_min = cur_wid;
3569 /* Place player in a quest level */
3570 if (p_ptr->inside_quest)
3574 /* Delete the monster (if any) */
3575 delete_monster(py, px);
3583 /* Place player in the town */
3584 else if (!p_ptr->oldpx && !p_ptr->oldpy)
3586 p_ptr->oldpy = atoi(zz[0]);
3587 p_ptr->oldpx = atoi(zz[1]);
3595 /* Process "B:<Index>:<Command>:..." -- Building definition */
3596 else if (buf[0] == 'B')
3598 return parse_line_building(buf);
3601 /* Process "M:<type>:<maximum>" -- set maximum values */
3602 else if (buf[0] == 'M')
3604 if (tokenize(buf+2, 2, zz, 0) == 2)
3607 if (zz[0][0] == 'T')
3609 max_towns = atoi(zz[1]);
3612 /* Maximum quests */
3613 else if (zz[0][0] == 'Q')
3615 max_quests = atoi(zz[1]);
3619 else if (zz[0][0] == 'R')
3621 max_r_idx = atoi(zz[1]);
3625 else if (zz[0][0] == 'K')
3627 max_k_idx = atoi(zz[1]);
3631 else if (zz[0][0] == 'V')
3633 max_v_idx = atoi(zz[1]);
3637 else if (zz[0][0] == 'F')
3639 max_f_idx = atoi(zz[1]);
3643 else if (zz[0][0] == 'A')
3645 max_a_idx = atoi(zz[1]);
3649 else if (zz[0][0] == 'E')
3651 max_e_idx = atoi(zz[1]);
3655 else if (zz[0][0] == 'D')
3657 max_d_idx = atoi(zz[1]);
3661 else if (zz[0][0] == 'O')
3663 max_o_idx = atoi(zz[1]);
3667 else if (zz[0][0] == 'M')
3669 max_m_idx = atoi(zz[1]);
3672 /* Wilderness size */
3673 else if (zz[0][0] == 'W')
3675 /* Maximum wild_x_size */
3676 if (zz[0][1] == 'X')
3677 max_wild_x = atoi(zz[1]);
3678 /* Maximum wild_y_size */
3679 if (zz[0][1] == 'Y')
3680 max_wild_y = atoi(zz[1]);
3694 static cptr variant = "ZANGBAND";
3698 * Helper function for "process_dungeon_file()"
3700 static cptr process_dungeon_file_expr(char **sp, char *fp)
3716 while (isspace(*s)) s++;
3734 t = process_dungeon_file_expr(&s, &f);
3743 else if (streq(t, "IOR"))
3746 while (*s && (f != b2))
3748 t = process_dungeon_file_expr(&s, &f);
3749 if (*t && !streq(t, "0")) v = "1";
3754 else if (streq(t, "AND"))
3757 while (*s && (f != b2))
3759 t = process_dungeon_file_expr(&s, &f);
3760 if (*t && streq(t, "0")) v = "0";
3765 else if (streq(t, "NOT"))
3768 while (*s && (f != b2))
3770 t = process_dungeon_file_expr(&s, &f);
3771 if (*t && streq(t, "1")) v = "0";
3776 else if (streq(t, "EQU"))
3779 if (*s && (f != b2))
3781 t = process_dungeon_file_expr(&s, &f);
3783 while (*s && (f != b2))
3786 t = process_dungeon_file_expr(&s, &f);
3787 if (*t && !streq(p, t)) v = "0";
3792 else if (streq(t, "LEQ"))
3795 if (*s && (f != b2))
3797 t = process_dungeon_file_expr(&s, &f);
3799 while (*s && (f != b2))
3802 t = process_dungeon_file_expr(&s, &f);
3803 if (*t && (strcmp(p, t) > 0)) v = "0";
3808 else if (streq(t, "GEQ"))
3811 if (*s && (f != b2))
3813 t = process_dungeon_file_expr(&s, &f);
3815 while (*s && (f != b2))
3818 t = process_dungeon_file_expr(&s, &f);
3819 if (*t && (strcmp(p, t) < 0)) v = "0";
3826 while (*s && (f != b2))
3828 t = process_dungeon_file_expr(&s, &f);
3833 if (f != b2) v = "?x?x?";
3835 /* Extract final and Terminate */
3836 if ((f = *s) != '\0') *s++ = '\0';
3842 /* Accept all printables except spaces and brackets */
3843 while (isprint(*s) && !strchr((char *)" []", *s)) ++s;
3845 /* Extract final and Terminate */
3846 if ((f = *s) != '\0') *s++ = '\0';
3852 if (streq(b+1, "SYS"))
3858 else if (streq(b+1, "GRAF"))
3863 else if (streq(b+1, "MONOCHROME"))
3872 else if (streq(b+1, "RACE"))
3875 v = rp_ptr->E_title;
3882 else if (streq(b+1, "CLASS"))
3885 v = cp_ptr->E_title;
3892 else if (streq(b+1, "REALM1"))
3895 v = E_realm_names[p_ptr->realm1];
3897 v = realm_names[p_ptr->realm1];
3902 else if (streq(b+1, "REALM2"))
3905 v = E_realm_names[p_ptr->realm2];
3907 v = realm_names[p_ptr->realm2];
3912 else if (streq(b+1, "PLAYER"))
3918 else if (streq(b+1, "TOWN"))
3920 sprintf(tmp, "%d", p_ptr->town_num);
3925 else if (streq(b+1, "LEVEL"))
3927 sprintf(tmp, "%d", p_ptr->lev);
3931 /* Current quest number */
3932 else if (streq(b+1, "QUEST_NUMBER"))
3934 sprintf(tmp, "%d", p_ptr->inside_quest);
3938 /* Number of last quest */
3939 else if (streq(b+1, "LEAVING_QUEST"))
3941 sprintf(tmp, "%d", leaving_quest);
3946 else if (prefix(b+1, "QUEST"))
3948 /* "QUEST" uses a special parameter to determine the number of the quest */
3949 sprintf(tmp, "%d", quest[atoi(b+6)].status);
3954 else if (prefix(b+1, "RANDOM"))
3956 /* "RANDOM" uses a special parameter to determine the number of the quest */
3957 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
3962 else if (streq(b+1, "VARIANT"))
3968 else if (streq(b+1, "WILDERNESS"))
3971 sprintf(tmp, "NONE");
3973 sprintf(tmp, "LITE");
3975 sprintf(tmp, "NORMAL");
3998 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4008 bool bypass = FALSE;
4010 int x = xmin, y = ymin;
4013 /* Build the filename */
4014 path_build(buf, 1024, ANGBAND_DIR_EDIT, name);
4017 fp = my_fopen(buf, "r");
4020 if (!fp) return (-1);
4023 /* Process the file */
4024 while (0 == my_fgets(fp, buf, 1024))
4030 /* Skip "empty" lines */
4031 if (!buf[0]) continue;
4033 /* Skip "blank" lines */
4034 if (isspace(buf[0])) continue;
4037 if (buf[0] == '#') continue;
4040 /* Process "?:<expr>" */
4041 if ((buf[0] == '?') && (buf[1] == ':'))
4050 /* Parse the expr */
4051 v = process_dungeon_file_expr(&s, &f);
4054 bypass = (streq(v, "0") ? TRUE : FALSE);
4060 /* Apply conditionals */
4061 if (bypass) continue;
4064 /* Process "%:<file>" */
4067 /* Process that file if allowed */
4068 (void)process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax);
4075 /* Process the line */
4076 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4088 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4091 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4093 msg_format("'%s'¤ò²òÀÏÃæ¡£", buf);
4095 msg_format("Parsing '%s'.", buf);
4102 /* Close the file */
4112 void write_r_info_txt(void)
4114 int i, j, z, fc, bc;
4122 monster_race *r_ptr;
4124 monster_blow *b_ptr;
4126 FILE *fff = fopen("output.txt", "wt");
4134 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4136 fprintf(fff, "# Version stamp (required)\n\n");
4139 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4142 fprintf(fff, "##### The Player #####\n\n");
4144 for (z = -1; z < alloc_race_size; z++)
4146 /* Output the monsters in order */
4147 i = (z >= 0) ? alloc_race_table[z].index : 0;
4149 /* Acquire the monster */
4152 /* Ignore empty monsters */
4153 if (!strlen(r_name + r_ptr->name)) continue;
4155 /* Ignore useless monsters */
4156 if (i && !r_ptr->speed) continue;
4158 /* Write a note if necessary */
4159 if (i && (!r_ptr->level != !mode))
4164 fprintf(fff, "\n##### Town monsters #####\n\n");
4166 /* Note the dungeon */
4169 fprintf(fff, "\n##### Normal monsters #####\n\n");
4172 /* Record the change */
4173 mode = r_ptr->level;
4176 /* Acquire the flags */
4177 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4178 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4179 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4180 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4181 f_ptr[4] = r_ptr->flags5; n_ptr[4] = r_info_flags5;
4182 f_ptr[5] = r_ptr->flags6; n_ptr[5] = r_info_flags6;
4183 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4184 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4185 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4187 /* Write New/Number/Name */
4188 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4191 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4193 /* Write Information */
4194 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4195 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4197 /* Write more information */
4198 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4201 for(j = 0; j < 4; j++)
4203 b_ptr = &(r_ptr->blow[j]);
4205 /* Stop when done */
4206 if (!b_ptr->method) break;
4208 /* Write the blows */
4209 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4210 r_info_blow_effect[b_ptr->effect],
4211 b_ptr->d_dice, b_ptr->d_side);
4214 /* Extract the flags */
4215 for (fc = 0, j = 0; j < 96; j++)
4217 /* Check this flag */
4218 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4221 /* Extract the extra flags */
4222 for (j = 192; j < 288; j++)
4224 /* Check this flag */
4225 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4228 /* Write the flags */
4229 for (j = 0; j < fc;)
4233 /* Start the line */
4236 for (bc = 0; (bc < 60) && (j < fc); j++)
4240 /* Format the flag */
4241 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4243 /* Add it to the buffer */
4246 /* Note the length */
4250 /* Done with this line; write it */
4251 fprintf(fff, "%s\n", buf);
4254 /* Write Spells if applicable */
4255 if (r_ptr->freq_spell)
4257 /* Write the frequency */
4258 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4260 /* Extract the spell flags */
4261 for (fc = 0, j = 96; j < 192; j++)
4263 /* Check this flag */
4264 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4267 /* Write the flags */
4268 for (j = 0; j < fc;)
4272 /* Start the line */
4275 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4279 /* Format the flag */
4280 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4284 /* Note the length */
4291 /* Done with this line; write it */
4292 fprintf(fff, "%s\n", buf);
4296 /* Acquire the description */
4297 desc = r_text + r_ptr->text;
4298 dlen = strlen(desc);
4300 /* Write Description */
4301 for (j = 0; j < dlen;)
4305 /* Start the line */
4308 for (bc = 0, t = buf + 2; ((bc < 60) || !isspace(desc[j])) && (j < dlen); j++, bc++, t++)
4316 /* Done with this line; write it */
4317 fprintf(fff, "%s\n", buf);
4320 /* Space between entries */