3 /* Purpose: Initialization (part 1) -BEN- */
10 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 static int 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, "%x:%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 < 0) 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);
1388 /* Process 'D' for "Description" */
1389 else if (buf[0] == 'D')
1391 /* Acquire the text */
1394 /* Store the text */
1395 if (!add_text(&k_ptr->text, head, s)) return (7);
1401 /* Process 'G' for "Graphics" (one line only) */
1402 else if (buf[0] == 'G')
1408 if (!buf[2]) return (1);
1409 if (!buf[3]) return (1);
1410 if (!buf[4]) return (1);
1412 /* Extract the char */
1415 /* Extract the attr */
1416 tmp = color_char_to_attr(buf[4]);
1419 if (tmp < 0) return (1);
1421 /* Save the values */
1422 k_ptr->d_attr = tmp;
1423 k_ptr->d_char = sym;
1426 /* Process 'I' for "Info" (one line only) */
1427 else if (buf[0] == 'I')
1429 int tval, sval, pval;
1431 /* Scan for the values */
1432 if (3 != sscanf(buf+2, "%d:%d:%d",
1433 &tval, &sval, &pval)) return (1);
1435 /* Save the values */
1441 /* Process 'W' for "More Info" (one line only) */
1442 else if (buf[0] == 'W')
1444 int level, extra, wgt;
1447 /* Scan for the values */
1448 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1449 &level, &extra, &wgt, &cost)) return (1);
1451 /* Save the values */
1452 k_ptr->level = level;
1453 k_ptr->extra = extra;
1454 k_ptr->weight = wgt;
1458 /* Process 'A' for "Allocation" (one line only) */
1459 else if (buf[0] == 'A')
1463 /* XXX XXX XXX Simply read each number following a colon */
1464 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
1466 /* Default chance */
1467 k_ptr->chance[i] = 1;
1469 /* Store the attack damage index */
1470 k_ptr->locale[i] = atoi(s+1);
1472 /* Find the slash */
1473 t = strchr(s+1, '/');
1475 /* Find the next colon */
1476 s = strchr(s+1, ':');
1478 /* If the slash is "nearby", use it */
1479 if (t && (!s || t < s))
1481 int chance = atoi(t+1);
1482 if (chance > 0) k_ptr->chance[i] = chance;
1487 /* Hack -- Process 'P' for "power" and such */
1488 else if (buf[0] == 'P')
1490 int ac, hd1, hd2, th, td, ta;
1492 /* Scan for the values */
1493 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1494 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1504 /* Hack -- Process 'F' for flags */
1505 else if (buf[0] == 'F')
1507 /* Parse every entry textually */
1508 for (s = buf + 2; *s; )
1510 /* Find the end of this entry */
1511 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1513 /* Nuke and skip any dividers */
1517 while (*t == ' ' || *t == '|') t++;
1520 /* Parse this entry */
1521 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
1523 /* Start the next entry */
1539 * Grab one flag in an artifact_type from a textual string
1541 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
1546 for (i = 0; i < 32; i++)
1548 if (streq(what, k_info_flags1[i]))
1550 a_ptr->flags1 |= (1L << i);
1556 for (i = 0; i < 32; i++)
1558 if (streq(what, k_info_flags2[i]))
1560 a_ptr->flags2 |= (1L << i);
1566 for (i = 0; i < 32; i++)
1568 if (streq(what, k_info_flags3[i]))
1570 a_ptr->flags3 |= (1L << i);
1575 /* Check gen_flags */
1576 for (i = 0; i < 32; i++)
1578 if (streq(what, k_info_gen_flags[i]))
1580 a_ptr->gen_flags |= (1L << i);
1587 msg_format("̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1589 msg_format("Unknown artifact flag '%s'.", what);
1601 * Initialize the "a_info" array, by parsing an ascii "template" file
1603 errr parse_a_info(char *buf, header *head)
1610 static artifact_type *a_ptr = NULL;
1613 /* Process 'N' for "New/Number/Name" */
1616 /* Find the colon before the name */
1617 s = strchr(buf+2, ':');
1619 /* Verify that colon */
1622 /* Nuke the colon, advance to the name */
1625 /* Paranoia -- require a name */
1626 if (!*s) return (1);
1631 /* Verify information */
1632 if (i < error_idx) return (4);
1634 /* Verify information */
1635 if (i >= head->info_num) return (2);
1637 /* Save the index */
1640 /* Point at the "info" */
1643 /* Ignore everything */
1644 a_ptr->flags3 |= (TR3_IGNORE_ACID);
1645 a_ptr->flags3 |= (TR3_IGNORE_ELEC);
1646 a_ptr->flags3 |= (TR3_IGNORE_FIRE);
1647 a_ptr->flags3 |= (TR3_IGNORE_COLD);
1649 /* Store the name */
1650 if (!add_name(&a_ptr->name, head, s)) return (7);
1654 /* There better be a current a_ptr */
1655 else if (!a_ptr) return (3);
1659 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1660 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1661 else if (buf[0] == 'E')
1666 else if (buf[0] == 'E')
1668 /* Acquire the Text */
1671 /* Store the name */
1672 if (!add_name(&a_ptr->name, head, s)) return (7);
1676 /* Process 'D' for "Description" */
1677 else if (buf[0] == 'D')
1682 /* Acquire the text */
1687 /* Acquire the text */
1691 /* Store the text */
1692 if (!add_text(&a_ptr->text, head, s)) return (7);
1696 /* Process 'I' for "Info" (one line only) */
1697 else if (buf[0] == 'I')
1699 int tval, sval, pval;
1701 /* Scan for the values */
1702 if (3 != sscanf(buf+2, "%d:%d:%d",
1703 &tval, &sval, &pval)) return (1);
1705 /* Save the values */
1711 /* Process 'W' for "More Info" (one line only) */
1712 else if (buf[0] == 'W')
1714 int level, rarity, wgt;
1717 /* Scan for the values */
1718 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1719 &level, &rarity, &wgt, &cost)) return (1);
1721 /* Save the values */
1722 a_ptr->level = level;
1723 a_ptr->rarity = rarity;
1724 a_ptr->weight = wgt;
1728 /* Hack -- Process 'P' for "power" and such */
1729 else if (buf[0] == 'P')
1731 int ac, hd1, hd2, th, td, ta;
1733 /* Scan for the values */
1734 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1735 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1745 /* Hack -- Process 'F' for flags */
1746 else if (buf[0] == 'F')
1748 /* Parse every entry textually */
1749 for (s = buf + 2; *s; )
1751 /* Find the end of this entry */
1752 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1754 /* Nuke and skip any dividers */
1758 while ((*t == ' ') || (*t == '|')) t++;
1761 /* Parse this entry */
1762 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
1764 /* Start the next entry */
1780 * Grab one flag in a ego-item_type from a textual string
1782 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
1787 for (i = 0; i < 32; i++)
1789 if (streq(what, k_info_flags1[i]))
1791 e_ptr->flags1 |= (1L << i);
1797 for (i = 0; i < 32; i++)
1799 if (streq(what, k_info_flags2[i]))
1801 e_ptr->flags2 |= (1L << i);
1807 for (i = 0; i < 32; i++)
1809 if (streq(what, k_info_flags3[i]))
1811 e_ptr->flags3 |= (1L << i);
1816 /* Check gen_flags */
1817 for (i = 0; i < 32; i++)
1819 if (streq(what, k_info_gen_flags[i]))
1821 e_ptr->gen_flags |= (1L << i);
1828 msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1830 msg_format("Unknown ego-item flag '%s'.", what);
1842 * Initialize the "e_info" array, by parsing an ascii "template" file
1844 errr parse_e_info(char *buf, header *head)
1851 static ego_item_type *e_ptr = NULL;
1854 /* Just before the first record */
1857 /* Just before the first line */
1861 /* Process 'N' for "New/Number/Name" */
1864 /* Find the colon before the name */
1865 s = strchr(buf+2, ':');
1867 /* Verify that colon */
1870 /* Nuke the colon, advance to the name */
1873 /* Paranoia -- require a name */
1874 if (!*s) return (1);
1879 /* Verify information */
1880 if (i < error_idx) return (4);
1882 /* Verify information */
1883 if (i >= head->info_num) return (2);
1885 /* Save the index */
1888 /* Point at the "info" */
1891 /* Store the name */
1892 if (!add_name(&e_ptr->name, head, s)) return (7);
1896 /* There better be a current e_ptr */
1897 else if (!e_ptr) return (3);
1901 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1902 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
1903 else if (buf[0] == 'E')
1908 else if (buf[0] == 'E')
1910 /* Acquire the Text */
1913 /* Store the name */
1914 if (!add_name(&e_ptr->name, head, s)) return (7);
1919 /* Process 'D' for "Description" */
1920 else if (buf[0] == 'D')
1922 /* Acquire the text */
1925 /* Store the text */
1926 if (!add_text(&e_ptr->text, head, s)) return (7);
1931 /* Process 'X' for "Xtra" (one line only) */
1932 else if (buf[0] == 'X')
1936 /* Scan for the values */
1937 if (2 != sscanf(buf+2, "%d:%d",
1938 &slot, &rating)) return (1);
1940 /* Save the values */
1942 e_ptr->rating = rating;
1945 /* Process 'W' for "More Info" (one line only) */
1946 else if (buf[0] == 'W')
1948 int level, rarity, pad2;
1951 /* Scan for the values */
1952 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1953 &level, &rarity, &pad2, &cost)) return (1);
1955 /* Save the values */
1956 e_ptr->level = level;
1957 e_ptr->rarity = rarity;
1958 /* e_ptr->weight = wgt; */
1962 /* Hack -- Process 'C' for "creation" */
1963 else if (buf[0] == 'C')
1967 /* Scan for the values */
1968 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1969 &th, &td, &ta, &pv)) return (1);
1971 e_ptr->max_to_h = th;
1972 e_ptr->max_to_d = td;
1973 e_ptr->max_to_a = ta;
1974 e_ptr->max_pval = pv;
1977 /* Hack -- Process 'F' for flags */
1978 else if (buf[0] == 'F')
1980 /* Parse every entry textually */
1981 for (s = buf + 2; *s; )
1983 /* Find the end of this entry */
1984 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1986 /* Nuke and skip any dividers */
1990 while ((*t == ' ') || (*t == '|')) t++;
1993 /* Parse this entry */
1994 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
1996 /* Start the next entry */
2010 * Grab one (basic) flag in a monster_race from a textual string
2012 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2017 for (i = 0; i < 32; i++)
2019 if (streq(what, r_info_flags1[i]))
2021 r_ptr->flags1 |= (1L << i);
2027 for (i = 0; i < 32; i++)
2029 if (streq(what, r_info_flags2[i]))
2031 r_ptr->flags2 |= (1L << i);
2037 for (i = 0; i < 32; i++)
2039 if (streq(what, r_info_flags3[i]))
2041 r_ptr->flags3 |= (1L << i);
2047 for (i = 0; i < 32; i++)
2049 if (streq(what, r_info_flags7[i]))
2051 r_ptr->flags7 |= (1L << i);
2057 for (i = 0; i < 32; i++)
2059 if (streq(what, r_info_flags8[i]))
2061 r_ptr->flags8 |= (1L << i);
2067 for (i = 0; i < 32; i++)
2069 if (streq(what, r_info_flags9[i]))
2071 r_ptr->flags9 |= (1L << i);
2078 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2080 msg_format("Unknown monster flag '%s'.", what);
2090 * Grab one (spell) flag in a monster_race from a textual string
2092 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2097 for (i = 0; i < 32; i++)
2099 if (streq(what, r_info_flags4[i]))
2101 r_ptr->flags4 |= (1L << i);
2107 for (i = 0; i < 32; i++)
2109 if (streq(what, r_info_flags5[i]))
2111 r_ptr->flags5 |= (1L << i);
2117 for (i = 0; i < 32; i++)
2119 if (streq(what, r_info_flags6[i]))
2121 r_ptr->flags6 |= (1L << i);
2128 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2130 msg_format("Unknown monster flag '%s'.", what);
2142 * Initialize the "r_info" array, by parsing an ascii "template" file
2144 errr parse_r_info(char *buf, header *head)
2151 static monster_race *r_ptr = NULL;
2154 /* Process 'N' for "New/Number/Name" */
2157 /* Find the colon before the name */
2158 s = strchr(buf+2, ':');
2160 /* Verify that colon */
2163 /* Nuke the colon, advance to the name */
2166 /* Paranoia -- require a name */
2167 if (!*s) return (1);
2172 /* Verify information */
2173 if (i < error_idx) return (4);
2175 /* Verify information */
2176 if (i >= head->info_num) return (2);
2178 /* Save the index */
2181 /* Point at the "info" */
2184 /* Store the name */
2185 if (!add_name(&r_ptr->name, head, s)) return (7);
2189 /* There better be a current r_ptr */
2190 else if (!r_ptr) return (3);
2194 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2195 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
2196 else if (buf[0] == 'E')
2198 /* Acquire the Text */
2201 /* Store the name */
2202 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2205 else if (buf[0] == 'E')
2207 /* Acquire the Text */
2210 /* Store the name */
2211 if (!add_name(&r_ptr->name, head, s)) return (7);
2214 /* Process 'D' for "Description" */
2215 else if (buf[0] == 'D')
2220 /* Acquire the text */
2225 /* Acquire the text */
2229 /* Store the text */
2230 if (!add_text(&r_ptr->text, head, s)) return (7);
2233 /* Process 'G' for "Graphics" (one line only) */
2234 else if (buf[0] == 'G')
2240 if (!buf[2]) return (1);
2241 if (!buf[3]) return (1);
2242 if (!buf[4]) return (1);
2244 /* Extract the char */
2247 /* Extract the attr */
2248 tmp = color_char_to_attr(buf[4]);
2251 if (tmp < 0) return (1);
2253 /* Save the values */
2254 r_ptr->d_char = sym;
2255 r_ptr->d_attr = tmp;
2258 /* Process 'I' for "Info" (one line only) */
2259 else if (buf[0] == 'I')
2261 int spd, hp1, hp2, aaf, ac, slp;
2263 /* Scan for the other values */
2264 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2265 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2267 /* Save the values */
2276 /* Process 'W' for "More Info" (one line only) */
2277 else if (buf[0] == 'W')
2284 /* Scan for the values */
2285 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2286 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2288 /* Save the values */
2290 r_ptr->rarity = rar;
2293 r_ptr->next_exp = nextexp;
2294 r_ptr->next_r_idx = nextmon;
2297 /* Process 'B' for "Blows" (up to four lines) */
2298 else if (buf[0] == 'B')
2302 /* Find the next empty blow slot (if any) */
2303 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
2305 /* Oops, no more slots */
2306 if (i == 4) return (1);
2308 /* Analyze the first field */
2309 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
2311 /* Terminate the field (if necessary) */
2312 if (*t == ':') *t++ = '\0';
2314 /* Analyze the method */
2315 for (n1 = 0; r_info_blow_method[n1]; n1++)
2317 if (streq(s, r_info_blow_method[n1])) break;
2320 /* Invalid method */
2321 if (!r_info_blow_method[n1]) return (1);
2323 /* Analyze the second field */
2324 for (s = t; *t && (*t != ':'); t++) /* loop */;
2326 /* Terminate the field (if necessary) */
2327 if (*t == ':') *t++ = '\0';
2329 /* Analyze effect */
2330 for (n2 = 0; r_info_blow_effect[n2]; n2++)
2332 if (streq(s, r_info_blow_effect[n2])) break;
2335 /* Invalid effect */
2336 if (!r_info_blow_effect[n2]) return (1);
2338 /* Analyze the third field */
2339 for (s = t; *t && (*t != 'd'); t++) /* loop */;
2341 /* Terminate the field (if necessary) */
2342 if (*t == 'd') *t++ = '\0';
2344 /* Save the method */
2345 r_ptr->blow[i].method = n1;
2347 /* Save the effect */
2348 r_ptr->blow[i].effect = n2;
2350 /* Extract the damage dice and sides */
2351 r_ptr->blow[i].d_dice = atoi(s);
2352 r_ptr->blow[i].d_side = atoi(t);
2355 /* Process 'F' for "Basic Flags" (multiple lines) */
2356 else if (buf[0] == 'F')
2358 /* Parse every entry */
2359 for (s = buf + 2; *s; )
2361 /* Find the end of this entry */
2362 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2364 /* Nuke and skip any dividers */
2368 while (*t == ' ' || *t == '|') t++;
2371 /* Parse this entry */
2372 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
2374 /* Start the next entry */
2379 /* Process 'S' for "Spell Flags" (multiple lines) */
2380 else if (buf[0] == 'S')
2382 /* Parse every entry */
2383 for (s = buf + 2; *s; )
2385 /* Find the end of this entry */
2386 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2388 /* Nuke and skip any dividers */
2392 while ((*t == ' ') || (*t == '|')) t++;
2395 /* XXX XXX XXX Hack -- Read spell frequency */
2396 if (1 == sscanf(s, "1_IN_%d", &i))
2398 /* Extract a "frequency" */
2399 r_ptr->freq_spell = r_ptr->freq_inate = 100 / i;
2401 /* Start at next entry */
2408 /* Parse this entry */
2409 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
2411 /* Start the next entry */
2426 * Grab one flag for a dungeon type from a textual string
2428 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
2433 for (i = 0; i < 32; i++)
2435 if (streq(what, d_info_flags1[i]))
2437 d_ptr->flags1 |= (1L << i);
2444 msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
2446 msg_format("Unknown dungeon type flag '%s'.", what);
2454 * Grab one (basic) flag in a monster_race from a textual string
2456 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
2461 for (i = 0; i < 32; i++)
2463 if (streq(what, r_info_flags1[i]))
2465 d_ptr->mflags1 |= (1L << i);
2471 for (i = 0; i < 32; i++)
2473 if (streq(what, r_info_flags2[i]))
2475 d_ptr->mflags2 |= (1L << i);
2481 for (i = 0; i < 32; i++)
2483 if (streq(what, r_info_flags3[i]))
2485 d_ptr->mflags3 |= (1L << i);
2491 for (i = 0; i < 32; i++)
2493 if (streq(what, r_info_flags7[i]))
2495 d_ptr->mflags7 |= (1L << i);
2501 for (i = 0; i < 32; i++)
2503 if (streq(what, r_info_flags8[i]))
2505 d_ptr->mflags8 |= (1L << i);
2511 for (i = 0; i < 32; i++)
2513 if (streq(what, r_info_flags9[i]))
2515 d_ptr->mflags9 |= (1L << i);
2522 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2524 msg_format("Unknown monster flag '%s'.", what);
2532 * Grab one (spell) flag in a monster_race from a textual string
2534 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
2539 for (i = 0; i < 32; i++)
2541 if (streq(what, r_info_flags4[i]))
2543 d_ptr->mflags4 |= (1L << i);
2549 for (i = 0; i < 32; i++)
2551 if (streq(what, r_info_flags5[i]))
2553 d_ptr->mflags5 |= (1L << i);
2559 for (i = 0; i < 32; i++)
2561 if (streq(what, r_info_flags6[i]))
2563 d_ptr->mflags6 |= (1L << i);
2570 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2572 msg_format("Unknown monster flag '%s'.", what);
2580 * Initialize the "d_info" array, by parsing an ascii "template" file
2582 errr parse_d_info(char *buf, header *head)
2589 static dungeon_info_type *d_ptr = NULL;
2592 /* Process 'N' for "New/Number/Name" */
2595 /* Find the colon before the name */
2596 s = strchr(buf+2, ':');
2598 /* Verify that colon */
2601 /* Nuke the colon, advance to the name */
2604 /* Paranoia -- require a name */
2605 if (!*s) return (1);
2610 /* Verify information */
2611 if (i < error_idx) return (4);
2613 /* Verify information */
2614 if (i >= head->info_num) return (2);
2616 /* Save the index */
2619 /* Point at the "info" */
2622 /* Store the name */
2623 if (!add_name(&d_ptr->name, head, s)) return (7);
2628 else if (buf[0] == 'E') return (0);
2630 else if (buf[0] == 'E')
2632 /* Acquire the Text */
2635 /* Store the name */
2636 if (!add_name(&d_ptr->name, head, s)) return (7);
2640 /* Process 'D' for "Description */
2641 else if (buf[0] == 'D')
2646 /* Acquire the text */
2651 /* Acquire the text */
2655 /* Store the text */
2656 if (!add_text(&d_ptr->text, head, s)) return (7);
2659 /* Process 'W' for "More Info" (one line only) */
2660 else if (buf[0] == 'W')
2662 int min_lev, max_lev;
2664 int min_alloc, max_chance;
2665 int obj_good, obj_great;
2668 /* Scan for the values */
2669 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
2670 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
2672 /* Save the values */
2673 d_ptr->mindepth = min_lev;
2674 d_ptr->maxdepth = max_lev;
2675 d_ptr->min_plev = min_plev;
2677 d_ptr->min_m_alloc_level = min_alloc;
2678 d_ptr->max_m_alloc_chance = max_chance;
2679 d_ptr->obj_good = obj_good;
2680 d_ptr->obj_great = obj_great;
2685 /* Process 'P' for "Place Info" */
2686 else if (buf[0] == 'P')
2690 /* Scan for the values */
2691 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
2693 /* Save the values */
2698 /* Process 'L' for "fLoor type" (one line only) */
2699 else if (buf[0] == 'L')
2705 /* Scan for the values */
2706 if (7 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d",
2707 &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) return (1);
2709 /* Save the values */
2711 d_ptr->floor_percent1 = p1;
2713 d_ptr->floor_percent2 = p2;
2715 d_ptr->floor_percent3 = p3;
2716 d_ptr->tunnel_percent = tunnel;
2719 /* Process 'A' for "wAll type" (one line only) */
2720 else if (buf[0] == 'A')
2722 int w1, w2, w3, outer, inner, stream1, stream2;
2725 /* Scan for the values */
2726 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
2727 &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) return (1);
2729 /* Save the values */
2730 d_ptr->fill_type1 = w1;
2731 d_ptr->fill_percent1 = p1;
2732 d_ptr->fill_type2 = w2;
2733 d_ptr->fill_percent2 = p2;
2734 d_ptr->fill_type3 = w3;
2735 d_ptr->fill_percent3 = p3;
2736 d_ptr->outer_wall = outer;
2737 d_ptr->inner_wall = inner;
2738 d_ptr->stream1 = stream1;
2739 d_ptr->stream2 = stream2;
2742 /* Process 'F' for "Dungeon Flags" (multiple lines) */
2743 else if (buf[0] == 'F')
2745 int artif = 0, monst = 0;
2747 /* Parse every entry */
2748 for (s = buf + 2; *s; )
2750 /* Find the end of this entry */
2751 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2753 /* Nuke and skip any dividers */
2757 while (*t == ' ' || *t == '|') t++;
2760 /* XXX XXX XXX Hack -- Read Final Artifact */
2761 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
2763 /* Extract a "Final Artifact" */
2764 d_ptr->final_artifact = artif;
2766 /* Start at next entry */
2773 /* XXX XXX XXX Hack -- Read Final Object */
2774 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
2776 /* Extract a "Final Artifact" */
2777 d_ptr->final_object = artif;
2779 /* Start at next entry */
2786 /* XXX XXX XXX Hack -- Read Artifact Guardian */
2787 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
2789 /* Extract a "Artifact Guardian" */
2790 d_ptr->final_guardian = monst;
2792 /* Start at next entry */
2799 /* XXX XXX XXX Hack -- Read Special Percentage */
2800 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
2802 /* Extract a "Special %" */
2803 d_ptr->special_div = monst;
2805 /* Start at next entry */
2812 /* Parse this entry */
2813 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
2815 /* Start the next entry */
2820 /* Process 'M' for "Basic Flags" (multiple lines) */
2821 else if (buf[0] == 'M')
2823 byte r_char_number = 0, r_char;
2825 /* Parse every entry */
2826 for (s = buf + 2; *s; )
2828 /* Find the end of this entry */
2829 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2831 /* Nuke and skip any dividers */
2835 while (*t == ' ' || *t == '|') t++;
2838 /* XXX XXX XXX Hack -- Read monster symbols */
2839 if (1 == sscanf(s, "R_CHAR_%c", &r_char))
2841 /* Limited to 5 races */
2842 if(r_char_number >= 5) continue;
2844 /* Extract a "frequency" */
2845 d_ptr->r_char[r_char_number++] = r_char;
2847 /* Start at next entry */
2854 /* Parse this entry */
2855 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
2857 /* Start the next entry */
2862 /* Process 'S' for "Spell Flags" (multiple lines) */
2863 else if (buf[0] == 'S')
2865 /* Parse every entry */
2866 for (s = buf + 2; *s; )
2868 /* Find the end of this entry */
2869 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2871 /* Nuke and skip any dividers */
2875 while ((*t == ' ') || (*t == '|')) t++;
2878 /* XXX XXX XXX Hack -- Read spell frequency */
2879 if (1 == sscanf(s, "1_IN_%d", &i))
2881 /* Start at next entry */
2888 /* Parse this entry */
2889 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
2891 /* Start the next entry */
2904 #else /* ALLOW_TEMPLATES */
2910 #endif /* ALLOW_TEMPLATES */
2913 /* Random dungeon grid effects */
2914 #define RANDOM_NONE 0x00
2915 #define RANDOM_FEATURE 0x01
2916 #define RANDOM_MONSTER 0x02
2917 #define RANDOM_OBJECT 0x04
2918 #define RANDOM_EGO 0x08
2919 #define RANDOM_ARTIFACT 0x10
2920 #define RANDOM_TRAP 0x20
2923 typedef struct dungeon_grid dungeon_grid;
2927 int feature; /* Terrain feature */
2928 int monster; /* Monster */
2929 int object; /* Object */
2930 int ego; /* Ego-Item */
2931 int artifact; /* Artifact */
2932 int trap; /* Trap */
2933 int cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
2934 int special; /* Reserved for special terrain info */
2935 int random; /* Number of the random effect */
2939 static dungeon_grid letter[255];
2943 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
2945 static errr parse_line_feature(char *buf)
2951 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
2953 /* Tokenize the line */
2954 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
2956 /* Letter to assign */
2957 int index = zz[0][0];
2959 /* Reset the info for the letter */
2960 letter[index].feature = 0;
2961 letter[index].monster = 0;
2962 letter[index].object = 0;
2963 letter[index].ego = 0;
2964 letter[index].artifact = 0;
2965 letter[index].trap = 0;
2966 letter[index].cave_info = 0;
2967 letter[index].special = 0;
2968 letter[index].random = 0;
2974 letter[index].special = atoi(zz[8]);
2978 if (zz[7][0] == '*')
2980 letter[index].random |= RANDOM_TRAP;
2985 letter[index].trap = atoi(zz[7]);
2990 letter[index].trap = atoi(zz[7]);
2995 if (zz[6][0] == '*')
2997 letter[index].random |= RANDOM_ARTIFACT;
3002 letter[index].artifact = atoi(zz[6]);
3007 letter[index].artifact = atoi(zz[6]);
3012 if (zz[5][0] == '*')
3014 letter[index].random |= RANDOM_EGO;
3019 letter[index].ego = atoi(zz[5]);
3024 letter[index].ego = atoi(zz[5]);
3029 if (zz[4][0] == '*')
3031 letter[index].random |= RANDOM_OBJECT;
3036 letter[index].object = atoi(zz[4]);
3041 letter[index].object = atoi(zz[4]);
3046 if (zz[3][0] == '*')
3048 letter[index].random |= RANDOM_MONSTER;
3052 letter[index].monster = atoi(zz[3]);
3055 else if (zz[3][0] == 'c')
3057 letter[index].monster = - atoi(zz[3]+1);
3061 letter[index].monster = atoi(zz[3]);
3066 letter[index].cave_info = atoi(zz[2]);
3070 if (zz[1][0] == '*')
3072 letter[index].random |= RANDOM_FEATURE;
3076 letter[index].feature = atoi(zz[1]);
3081 letter[index].feature = atoi(zz[1]);
3094 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3096 static errr parse_line_building(char *buf)
3112 /* Get the building number */
3115 /* Find the colon after the building number */
3118 /* Verify that colon */
3121 /* Nuke the colon, advance to the sub-index */
3124 /* Paranoia -- require a sub-index */
3125 if (!*s) return (1);
3127 /* Building definition sub-index */
3130 /* Building name, owner, race */
3133 if (tokenize(s + 2, 3, zz, 0) == 3)
3135 /* Name of the building */
3136 strcpy(building[index].name, zz[0]);
3138 /* Name of the owner */
3139 strcpy(building[index].owner_name, zz[1]);
3141 /* Race of the owner */
3142 strcpy(building[index].owner_race, zz[2]);
3147 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3150 /* Building Action */
3153 if (tokenize(s + 2, 8, zz, 0) >= 7)
3155 /* Index of the action */
3156 int action_index = atoi(zz[0]);
3158 /* Name of the action */
3159 strcpy(building[index].act_names[action_index], zz[1]);
3161 /* Cost of the action for members */
3162 building[index].member_costs[action_index] = atoi(zz[2]);
3164 /* Cost of the action for non-members */
3165 building[index].other_costs[action_index] = atoi(zz[3]);
3167 /* Letter assigned to the action */
3168 building[index].letters[action_index] = zz[4][0];
3171 building[index].actions[action_index] = atoi(zz[5]);
3173 /* Action restriction */
3174 building[index].action_restr[action_index] = atoi(zz[6]);
3179 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3182 /* Building Classes */
3185 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3187 for (i = 0; i < MAX_CLASS; i++)
3189 building[index].member_class[i] = atoi(zz[i]);
3195 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3198 /* Building Races */
3201 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3203 for (i = 0; i < MAX_RACES; i++)
3205 building[index].member_race[i] = atoi(zz[i]);
3211 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3214 /* Building Realms */
3217 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3219 for (i = 0; i < MAX_MAGIC; i++)
3221 building[index].member_realm[i+1] = atoi(zz[i]);
3227 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3232 /* Ignore scripts */
3238 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3247 * Parse a sub-file of the "extra info"
3249 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3256 /* Skip "empty" lines */
3257 if (!buf[0]) return (0);
3259 /* Skip "blank" lines */
3260 if (isspace(buf[0])) return (0);
3263 if (buf[0] == '#') return (0);
3265 /* Require "?:*" format */
3266 if (buf[1] != ':') return (1);
3269 /* Process "%:<fname>" */
3272 /* Attempt to Process the given file */
3273 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3276 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3279 return parse_line_feature(buf);
3282 /* Process "D:<dungeon>" -- info for the cave grids */
3283 else if (buf[0] == 'D')
3285 object_type object_type_body;
3287 /* Acquire the text */
3290 /* Length of the text */
3291 int len = strlen(s);
3293 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3295 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3297 /* Access the grid */
3298 cave_type *c_ptr = &cave[*y][*x];
3302 int object_index = letter[idx].object;
3303 int monster_index = letter[idx].monster;
3304 int random = letter[idx].random;
3305 int artifact_index = letter[idx].artifact;
3307 /* Lay down a floor */
3308 c_ptr->feat = letter[idx].feature;
3310 /* Only the features */
3311 if (init_flags & INIT_ONLY_FEATURES) continue;
3314 c_ptr->info = letter[idx].cave_info;
3316 /* Create a monster */
3317 if (random & RANDOM_MONSTER)
3319 monster_level = base_level + monster_index;
3321 place_monster(*y, *x, TRUE, TRUE);
3323 monster_level = base_level;
3325 else if (monster_index)
3327 int old_cur_num, old_max_num;
3330 if (monster_index < 0)
3332 monster_index = -monster_index;
3335 old_cur_num = r_info[monster_index].cur_num;
3336 old_max_num = r_info[monster_index].max_num;
3338 /* Make alive again */
3339 if (r_info[monster_index].flags1 & RF1_UNIQUE)
3341 r_info[monster_index].cur_num = 0;
3342 r_info[monster_index].max_num = 1;
3345 /* Make alive again */
3346 if (r_info[monster_index].flags7 & RF7_UNIQUE_7)
3348 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
3350 r_info[monster_index].max_num++;
3355 place_monster_aux(*y, *x, monster_index, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE);
3359 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3361 /* Make alive again for real unique monster */
3362 r_info[monster_index].cur_num = old_cur_num;
3363 r_info[monster_index].max_num = old_max_num;
3367 /* Object (and possible trap) */
3368 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
3370 object_level = base_level + object_index;
3373 * Random trap and random treasure defined
3374 * 25% chance for trap and 75% chance for object
3376 if (randint0(100) < 75)
3378 place_object(*y, *x, FALSE, FALSE);
3385 object_level = base_level;
3387 else if (random & RANDOM_OBJECT)
3389 object_level = base_level + object_index;
3391 /* Create an out of deep object */
3392 if (randint0(100) < 75)
3393 place_object(*y, *x, FALSE, FALSE);
3394 else if (randint0(100) < 80)
3395 place_object(*y, *x, TRUE, FALSE);
3397 place_object(*y, *x, TRUE, TRUE);
3399 object_level = base_level;
3402 else if (random & RANDOM_TRAP)
3406 else if (object_index)
3408 /* Get local object */
3409 object_type *o_ptr = &object_type_body;
3411 /* Create the item */
3412 object_prep(o_ptr, object_index);
3414 if (o_ptr->tval == TV_GOLD)
3416 coin_type = object_index - OBJ_GOLD_LIST;
3421 /* Apply magic (no messages, no artifacts) */
3422 apply_magic(o_ptr, base_level, FALSE, TRUE, FALSE, FALSE);
3424 (void)drop_near(o_ptr, -1, *y, *x);
3430 if (a_info[artifact_index].cur_num)
3434 object_type *q_ptr = &forge;
3436 object_prep(q_ptr, k_idx);
3438 /* Drop it in the dungeon */
3439 (void)drop_near(q_ptr, -1, *y, *x);
3443 /* Create the artifact */
3444 create_named_art(artifact_index, *y, *x);
3446 a_info[artifact_index].cur_num = 1;
3450 /* Terrain special */
3451 c_ptr->special = letter[idx].special;
3459 /* Process "Q:<number>:<command>:... -- quest info */
3460 else if (buf[0] == 'Q')
3467 num = tokenize(buf + 2, 33, zz, 0);
3471 num = tokenize(buf + 3, 33, zz, 0);
3474 /* Have we enough parameters? */
3475 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3478 q_ptr = &(quest[atoi(zz[0])]);
3480 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
3481 if (zz[1][0] == 'Q')
3483 if (init_flags & INIT_ASSIGN)
3485 monster_race *r_ptr;
3486 artifact_type *a_ptr;
3488 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3490 q_ptr->type = atoi(zz[2]);
3491 q_ptr->num_mon = atoi(zz[3]);
3492 q_ptr->cur_num = atoi(zz[4]);
3493 q_ptr->max_num = atoi(zz[5]);
3494 q_ptr->level = atoi(zz[6]);
3495 q_ptr->r_idx = atoi(zz[7]);
3496 q_ptr->k_idx = atoi(zz[8]);
3497 q_ptr->dungeon = atoi(zz[9]);
3500 q_ptr->flags = atoi(zz[10]);
3502 r_ptr = &r_info[q_ptr->r_idx];
3503 if (r_ptr->flags1 & RF1_UNIQUE)
3504 r_ptr->flags1 |= RF1_QUESTOR;
3506 a_ptr = &a_info[q_ptr->k_idx];
3507 a_ptr->gen_flags |= TRG_QUESTITEM;
3512 /* Process "Q:<q_index>:N:<name>" -- quest name */
3513 else if (zz[1][0] == 'N')
3515 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT))
3517 strcpy(q_ptr->name, zz[2]);
3523 /* Process "Q:<q_index>:T:<text>" -- quest description line */
3524 else if (zz[1][0] == 'T')
3526 if (init_flags & INIT_SHOW_TEXT)
3528 strcpy(quest_text[quest_text_line], zz[2]);
3536 /* Process "W:<command>: ..." -- info for the wilderness */
3537 else if (buf[0] == 'W')
3539 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
3542 /* Process "P:<y>:<x>" -- player position */
3543 else if (buf[0] == 'P')
3545 if (init_flags & INIT_CREATE_DUNGEON)
3547 if (tokenize(buf + 2, 2, zz, 0) == 2)
3549 int panels_x, panels_y;
3551 /* Hack - Set the dungeon size */
3552 panels_y = (*y / SCREEN_HGT);
3553 if (*y % SCREEN_HGT) panels_y++;
3554 cur_hgt = panels_y * SCREEN_HGT;
3556 panels_x = (*x / SCREEN_WID);
3557 if (*x % SCREEN_WID) panels_x++;
3558 cur_wid = panels_x * SCREEN_WID;
3560 /* Choose a panel row */
3561 max_panel_rows = (cur_hgt / SCREEN_HGT) * 2 - 2;
3562 if (max_panel_rows < 0) max_panel_rows = 0;
3564 /* Choose a panel col */
3565 max_panel_cols = (cur_wid / SCREEN_WID) * 2 - 2;
3566 if (max_panel_cols < 0) max_panel_cols = 0;
3568 /* Assume illegal panel */
3569 panel_row = max_panel_rows;
3570 panel_col = max_panel_cols;
3572 /* Place player in a quest level */
3573 if (p_ptr->inside_quest)
3577 /* Delete the monster (if any) */
3578 delete_monster(py, px);
3586 /* Place player in the town */
3587 else if (!p_ptr->oldpx && !p_ptr->oldpy)
3589 p_ptr->oldpy = atoi(zz[0]);
3590 p_ptr->oldpx = atoi(zz[1]);
3598 /* Process "B:<Index>:<Command>:..." -- Building definition */
3599 else if (buf[0] == 'B')
3601 return parse_line_building(buf);
3604 /* Process "M:<type>:<maximum>" -- set maximum values */
3605 else if (buf[0] == 'M')
3607 if (tokenize(buf+2, 2, zz, 0) == 2)
3610 if (zz[0][0] == 'T')
3612 max_towns = atoi(zz[1]);
3615 /* Maximum quests */
3616 else if (zz[0][0] == 'Q')
3618 max_quests = atoi(zz[1]);
3622 else if (zz[0][0] == 'R')
3624 max_r_idx = atoi(zz[1]);
3628 else if (zz[0][0] == 'K')
3630 max_k_idx = atoi(zz[1]);
3634 else if (zz[0][0] == 'V')
3636 max_v_idx = atoi(zz[1]);
3640 else if (zz[0][0] == 'F')
3642 max_f_idx = atoi(zz[1]);
3646 else if (zz[0][0] == 'A')
3648 max_a_idx = atoi(zz[1]);
3652 else if (zz[0][0] == 'E')
3654 max_e_idx = atoi(zz[1]);
3658 else if (zz[0][0] == 'D')
3660 max_d_idx = atoi(zz[1]);
3664 else if (zz[0][0] == 'O')
3666 max_o_idx = atoi(zz[1]);
3670 else if (zz[0][0] == 'M')
3672 max_m_idx = atoi(zz[1]);
3675 /* Wilderness size */
3676 else if (zz[0][0] == 'W')
3678 /* Maximum wild_x_size */
3679 if (zz[0][1] == 'X')
3680 max_wild_x = atoi(zz[1]);
3681 /* Maximum wild_y_size */
3682 if (zz[0][1] == 'Y')
3683 max_wild_y = atoi(zz[1]);
3697 static cptr variant = "ZANGBAND";
3701 * Helper function for "process_dungeon_file()"
3703 static cptr process_dungeon_file_expr(char **sp, char *fp)
3719 while (isspace(*s)) s++;
3737 t = process_dungeon_file_expr(&s, &f);
3746 else if (streq(t, "IOR"))
3749 while (*s && (f != b2))
3751 t = process_dungeon_file_expr(&s, &f);
3752 if (*t && !streq(t, "0")) v = "1";
3757 else if (streq(t, "AND"))
3760 while (*s && (f != b2))
3762 t = process_dungeon_file_expr(&s, &f);
3763 if (*t && streq(t, "0")) v = "0";
3768 else if (streq(t, "NOT"))
3771 while (*s && (f != b2))
3773 t = process_dungeon_file_expr(&s, &f);
3774 if (*t && streq(t, "1")) v = "0";
3779 else if (streq(t, "EQU"))
3782 if (*s && (f != b2))
3784 t = process_dungeon_file_expr(&s, &f);
3786 while (*s && (f != b2))
3789 t = process_dungeon_file_expr(&s, &f);
3790 if (*t && !streq(p, t)) v = "0";
3795 else if (streq(t, "LEQ"))
3798 if (*s && (f != b2))
3800 t = process_dungeon_file_expr(&s, &f);
3802 while (*s && (f != b2))
3805 t = process_dungeon_file_expr(&s, &f);
3806 if (*t && (strcmp(p, t) > 0)) v = "0";
3811 else if (streq(t, "GEQ"))
3814 if (*s && (f != b2))
3816 t = process_dungeon_file_expr(&s, &f);
3818 while (*s && (f != b2))
3821 t = process_dungeon_file_expr(&s, &f);
3822 if (*t && (strcmp(p, t) < 0)) v = "0";
3829 while (*s && (f != b2))
3831 t = process_dungeon_file_expr(&s, &f);
3836 if (f != b2) v = "?x?x?";
3838 /* Extract final and Terminate */
3839 if ((f = *s) != '\0') *s++ = '\0';
3845 /* Accept all printables except spaces and brackets */
3846 while (isprint(*s) && !strchr(" []", *s)) ++s;
3848 /* Extract final and Terminate */
3849 if ((f = *s) != '\0') *s++ = '\0';
3855 if (streq(b+1, "SYS"))
3861 else if (streq(b+1, "GRAF"))
3866 else if (streq(b+1, "MONOCHROME"))
3875 else if (streq(b+1, "RACE"))
3878 v = rp_ptr->E_title;
3885 else if (streq(b+1, "CLASS"))
3888 v = cp_ptr->E_title;
3895 else if (streq(b+1, "REALM1"))
3898 v = E_realm_names[p_ptr->realm1];
3900 v = realm_names[p_ptr->realm1];
3905 else if (streq(b+1, "REALM2"))
3908 v = E_realm_names[p_ptr->realm2];
3910 v = realm_names[p_ptr->realm2];
3915 else if (streq(b+1, "PLAYER"))
3921 else if (streq(b+1, "TOWN"))
3923 sprintf(tmp, "%d", p_ptr->town_num);
3928 else if (streq(b+1, "LEVEL"))
3930 sprintf(tmp, "%d", p_ptr->lev);
3934 /* Current quest number */
3935 else if (streq(b+1, "QUEST_NUMBER"))
3937 sprintf(tmp, "%d", p_ptr->inside_quest);
3941 /* Number of last quest */
3942 else if (streq(b+1, "LEAVING_QUEST"))
3944 sprintf(tmp, "%d", leaving_quest);
3949 else if (prefix(b+1, "QUEST"))
3951 /* "QUEST" uses a special parameter to determine the number of the quest */
3952 sprintf(tmp, "%d", quest[atoi(b+6)].status);
3957 else if (prefix(b+1, "RANDOM"))
3959 /* "RANDOM" uses a special parameter to determine the number of the quest */
3960 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
3965 else if (streq(b+1, "VARIANT"))
3971 else if (streq(b+1, "WILDERNESS"))
3974 sprintf(tmp, "NONE");
3976 sprintf(tmp, "LITE");
3978 sprintf(tmp, "NORMAL");
4001 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4011 bool bypass = FALSE;
4013 int x = xmin, y = ymin;
4016 /* Build the filename */
4017 path_build(buf, 1024, ANGBAND_DIR_EDIT, name);
4020 fp = my_fopen(buf, "r");
4023 if (!fp) return (-1);
4026 /* Process the file */
4027 while (0 == my_fgets(fp, buf, 1024))
4033 /* Skip "empty" lines */
4034 if (!buf[0]) continue;
4036 /* Skip "blank" lines */
4037 if (isspace(buf[0])) continue;
4040 if (buf[0] == '#') continue;
4043 /* Process "?:<expr>" */
4044 if ((buf[0] == '?') && (buf[1] == ':'))
4053 /* Parse the expr */
4054 v = process_dungeon_file_expr(&s, &f);
4057 bypass = (streq(v, "0") ? TRUE : FALSE);
4063 /* Apply conditionals */
4064 if (bypass) continue;
4067 /* Process "%:<file>" */
4070 /* Process that file if allowed */
4071 (void)process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax);
4078 /* Process the line */
4079 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4091 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4094 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4096 msg_format("'%s'¤ò²òÀÏÃæ¡£", buf);
4098 msg_format("Parsing '%s'.", buf);
4105 /* Close the file */
4115 void write_r_info_txt(void)
4117 int i, j, z, fc, bc;
4125 monster_race *r_ptr;
4127 monster_blow *b_ptr;
4129 FILE *fff = fopen("output.txt", "wt");
4137 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4139 fprintf(fff, "# Version stamp (required)\n\n");
4142 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4145 fprintf(fff, "##### The Player #####\n\n");
4147 for (z = -1; z < alloc_race_size; z++)
4149 /* Output the monsters in order */
4150 i = (z >= 0) ? alloc_race_table[z].index : 0;
4152 /* Acquire the monster */
4155 /* Ignore empty monsters */
4156 if (!strlen(r_name + r_ptr->name)) continue;
4158 /* Ignore useless monsters */
4159 if (i && !r_ptr->speed) continue;
4161 /* Write a note if necessary */
4162 if (i && (!r_ptr->level != !mode))
4167 fprintf(fff, "\n##### Town monsters #####\n\n");
4169 /* Note the dungeon */
4172 fprintf(fff, "\n##### Normal monsters #####\n\n");
4175 /* Record the change */
4176 mode = r_ptr->level;
4179 /* Acquire the flags */
4180 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4181 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4182 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4183 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4184 f_ptr[4] = r_ptr->flags5; n_ptr[4] = r_info_flags5;
4185 f_ptr[5] = r_ptr->flags6; n_ptr[5] = r_info_flags6;
4186 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4187 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4188 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4190 /* Write New/Number/Name */
4191 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4194 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4196 /* Write Information */
4197 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4198 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4200 /* Write more information */
4201 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4204 for(j = 0; j < 4; j++)
4206 b_ptr = &(r_ptr->blow[j]);
4208 /* Stop when done */
4209 if (!b_ptr->method) break;
4211 /* Write the blows */
4212 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4213 r_info_blow_effect[b_ptr->effect],
4214 b_ptr->d_dice, b_ptr->d_side);
4217 /* Extract the flags */
4218 for (fc = 0, j = 0; j < 96; j++)
4220 /* Check this flag */
4221 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4224 /* Extract the extra flags */
4225 for (j = 192; j < 288; j++)
4227 /* Check this flag */
4228 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4231 /* Write the flags */
4232 for (j = 0; j < fc;)
4236 /* Start the line */
4239 for (bc = 0; (bc < 60) && (j < fc); j++)
4243 /* Format the flag */
4244 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4246 /* Add it to the buffer */
4249 /* Note the length */
4253 /* Done with this line; write it */
4254 fprintf(fff, "%s\n", buf);
4257 /* Write Spells if applicable */
4258 if (r_ptr->freq_spell)
4260 /* Write the frequency */
4261 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4263 /* Extract the spell flags */
4264 for (fc = 0, j = 96; j < 192; j++)
4266 /* Check this flag */
4267 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4270 /* Write the flags */
4271 for (j = 0; j < fc;)
4275 /* Start the line */
4278 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4282 /* Format the flag */
4283 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4287 /* Note the length */
4294 /* Done with this line; write it */
4295 fprintf(fff, "%s\n", buf);
4299 /* Acquire the description */
4300 desc = r_text + r_ptr->text;
4301 dlen = strlen(desc);
4303 /* Write Description */
4304 for (j = 0; j < dlen;)
4308 /* Start the line */
4311 for (bc = 0, t = buf + 2; ((bc < 60) || !isspace(desc[j])) && (j < dlen); j++, bc++, t++)
4319 /* Done with this line; write it */
4320 fprintf(fff, "%s\n", buf);
4323 /* Space between entries */