4 * Copyright (c) 1997 Ben Harrison
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Initialization (part 1) -BEN- */
17 * This file is used to initialize various variables and arrays for the
18 * Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
19 * the common limitation of "read()" and "write()" to only 32767 bytes
22 * Several of the arrays for Angband are built from "template" files in
23 * the "lib/file" directory, from which quick-load binary "image" files
24 * are constructed whenever they are not present in the "lib/data"
25 * directory, or if those files become obsolete, if we are allowed.
27 * Warning -- the "ascii" file parsers use a minor hack to collect the
28 * name and text information in a single pass. Thus, the game will not
29 * be able to load any template file with more than 20K of names or 60K
30 * of text, even though technically, up to 64K should be legal.
32 * Note that if "ALLOW_TEMPLATES" is not defined, then a lot of the code
33 * in this file is compiled out, and the game will not run unless valid
34 * "binary template files" already exist in "lib/data". Thus, one can
35 * compile Angband with ALLOW_TEMPLATES defined, run once to create the
36 * "*.raw" files in "lib/data", and then quit, and recompile without
37 * defining ALLOW_TEMPLATES, which will both save 20K and prevent people
38 * from changing the ascii template files in potentially dangerous ways.
40 * The code could actually be removed and placed into a "stand-alone"
41 * program, but that feels a little silly, especially considering some
42 * of the platforms that we currently support.
45 #ifdef ALLOW_TEMPLATES
50 /*** Helper arrays for parsing ascii template files ***/
53 * Monster Blow Methods
55 static cptr r_info_blow_method[] =
88 * Monster Blow Effects
90 static cptr r_info_blow_effect[] =
133 static cptr r_info_flags1[] =
172 static cptr r_info_flags2[] =
211 static cptr r_info_flags3[] =
250 static cptr r_info_flags4[] =
289 static cptr r_info_flags5[] =
328 static cptr r_info_flags6[] =
345 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
368 static cptr r_info_flags7[] =
407 static cptr r_info_flags8[] =
439 "WILD_SWAMP", /* ToDo: Implement Swamp */
445 * Monster race flags - Drops
447 static cptr r_info_flags9[] =
486 * Monster race flags - Resistances
488 static cptr r_info_flagsr[] =
528 static cptr k_info_flags[] =
653 static cptr k_info_gen_flags[] =
693 static cptr d_info_flags1[] =
731 * Add a text to the text-storage and store offset to it.
733 * Returns FALSE when there isn't enough space available to store
736 static bool add_text(u32b *offset, header *head, cptr buf)
738 /* Hack -- Verify space */
739 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
745 /* Advance and save the text index */
746 *offset = ++head->text_size;
749 /* Append chars to the text */
750 strcpy(head->text_ptr + head->text_size, buf);
752 /* Advance the index */
753 head->text_size += strlen(buf);
761 * Add a name to the name-storage and return an offset to it.
763 * Returns FALSE when there isn't enough space available to store
766 static bool add_name(u32b *offset, header *head, cptr buf)
768 /* Hack -- Verify space */
769 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
775 /* Advance and save the name index */
776 *offset = ++head->name_size;
779 /* Append chars to the names */
780 strcpy(head->name_ptr + head->name_size, buf);
782 /* Advance the index */
783 head->name_size += strlen(buf);
791 * Convert a "color letter" into an "actual" color
792 * The colors are: dwsorgbuDWvyRGBU, as shown below
794 byte color_char_to_attr(char c)
798 case 'd': return (TERM_DARK);
799 case 'w': return (TERM_WHITE);
800 case 's': return (TERM_SLATE);
801 case 'o': return (TERM_ORANGE);
802 case 'r': return (TERM_RED);
803 case 'g': return (TERM_GREEN);
804 case 'b': return (TERM_BLUE);
805 case 'u': return (TERM_UMBER);
807 case 'D': return (TERM_L_DARK);
808 case 'W': return (TERM_L_WHITE);
809 case 'v': return (TERM_VIOLET);
810 case 'y': return (TERM_YELLOW);
811 case 'R': return (TERM_L_RED);
812 case 'G': return (TERM_L_GREEN);
813 case 'B': return (TERM_L_BLUE);
814 case 'U': return (TERM_L_UMBER);
822 /*** Initialize from ascii template files ***/
826 * Initialize an "*_info" array, by parsing an ascii "template" file
828 errr init_info_txt(FILE *fp, char *buf, header *head,
829 parse_info_txt_func parse_info_txt_line)
833 /* Just before the first record */
836 /* Just before the first line */
840 /* Prepare the "fake" stuff */
845 while (0 == my_fgets(fp, buf, 1024))
847 /* Advance the line number */
850 /* Skip comments and blank lines */
851 if (!buf[0] || (buf[0] == '#')) continue;
853 /* Verify correct "colon" format */
854 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
857 /* Hack -- Process 'V' for "Version" */
864 /* Mega Hack -- Calculate Check Sum */
865 if (buf[0] != 'N' && buf[0] != 'D')
868 for (i = 0; buf[i]; i++)
870 head->v_extra += (byte)buf[i];
871 head->v_extra ^= (1 << (i % 8));
876 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
881 /* Complete the "name" and "text" sizes */
882 if (head->name_size) head->name_size++;
883 if (head->text_size) head->text_size++;
891 * Initialize the "v_info" array, by parsing an ascii "template" file
893 errr parse_v_info(char *buf, header *head)
899 static vault_type *v_ptr = NULL;
901 /* Process 'N' for "New/Number/Name" */
904 /* Find the colon before the name */
905 s = my_strchr(buf+2, ':');
907 /* Verify that colon */
910 /* Nuke the colon, advance to the name */
913 /* Paranoia -- require a name */
919 /* Verify information */
920 if (i <= error_idx) return (4);
922 /* Verify information */
923 if (i >= head->info_num) return (2);
928 /* Point at the "info" */
932 if (!add_name(&v_ptr->name, head, s)) return (7);
935 /* There better be a current v_ptr */
936 else if (!v_ptr) return (3);
938 /* Process 'D' for "Description" */
939 else if (buf[0] == 'D')
941 /* Acquire the text */
945 if (!add_text(&v_ptr->text, head, s)) return (7);
948 /* Process 'X' for "Extra info" (one line only) */
949 else if (buf[0] == 'X')
951 int typ, rat, hgt, wid;
953 /* Scan for the values */
954 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
955 &typ, &rat, &hgt, &wid)) return (1);
957 /* Save the values */
974 * Initialize the "s_info" array, by parsing an ascii "template" file
976 errr parse_s_info(char *buf, header *head)
981 static skill_table *s_ptr = NULL;
984 /* Process 'N' for "New/Number/Name" */
990 /* Verify information */
991 if (i <= error_idx) return (4);
993 /* Verify information */
994 if (i >= head->info_num) return (2);
999 /* Point at the "info" */
1003 /* There better be a current s_ptr */
1004 else if (!s_ptr) return (3);
1006 /* Process 'W' for "Weapon exp" */
1007 else if (buf[0] == 'W')
1009 int tval, sval, start, max;
1010 const s16b exp_conv_table[] =
1012 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1013 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1016 /* Scan for the values */
1017 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1018 &tval, &sval, &start, &max)) return (1);
1020 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1021 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1023 /* Save the values */
1024 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1025 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1028 /* Process 'S' for "Skill exp" */
1029 else if (buf[0] == 'S')
1031 int num, start, max;
1033 /* Scan for the values */
1034 if (3 != sscanf(buf+2, "%d:%d:%d",
1035 &num, &start, &max)) return (1);
1037 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1038 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1040 /* Save the values */
1041 s_ptr->s_start[num] = start;
1042 s_ptr->s_max[num] = max;
1055 * Initialize the "m_info" array, by parsing an ascii "template" file
1057 errr parse_m_info(char *buf, header *head)
1064 static player_magic *m_ptr = NULL;
1067 static int realm, magic_idx = 0, readable = 0;
1070 /* Process 'N' for "New/Number/Name" */
1076 /* Verify information */
1077 if (i <= error_idx) return (4);
1079 /* Verify information */
1080 if (i >= head->info_num) return (2);
1082 /* Save the index */
1085 /* Point at the "info" */
1089 /* There better be a current m_ptr */
1090 else if (!m_ptr) return (3);
1092 /* Process 'I' for "Info" (one line only) */
1093 else if (buf[0] == 'I')
1096 int xtra, type, first, weight;
1098 /* Find the colon before the name */
1099 s = my_strchr(buf+2, ':');
1101 /* Verify that colon */
1104 /* Nuke the colon, advance to the name */
1109 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1110 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1111 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1112 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1113 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1118 /* Find the colon before the name */
1119 s = my_strchr(s, ':');
1121 /* Verify that colon */
1124 /* Nuke the colon, advance to the name */
1127 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1128 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1129 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1130 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1131 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1132 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1136 /* Scan for the values */
1137 if (4 != sscanf(s, "%x:%d:%d:%d",
1138 (uint *)&xtra, &type, &first, &weight)) return (1);
1140 m_ptr->spell_xtra = xtra;
1141 m_ptr->spell_type = type;
1142 m_ptr->spell_first = first;
1143 m_ptr->spell_weight = weight;
1147 /* Process 'R' for "Realm" (one line only) */
1148 else if (buf[0] == 'R')
1150 /* Scan for the values */
1151 if (2 != sscanf(buf+2, "%d:%d",
1152 &realm, &readable)) return (1);
1157 else if (buf[0] == 'T')
1159 int level, mana, fail, exp;
1161 if (!readable) return (1);
1162 /* Scan for the values */
1163 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1164 &level, &mana, &fail, &exp)) return (1);
1166 m_ptr->info[realm][magic_idx].slevel = level;
1167 m_ptr->info[realm][magic_idx].smana = mana;
1168 m_ptr->info[realm][magic_idx].sfail = fail;
1169 m_ptr->info[realm][magic_idx].sexp = exp;
1183 * Initialize the "f_info" array, by parsing an ascii "template" file
1185 errr parse_f_info(char *buf, header *head)
1192 static feature_type *f_ptr = NULL;
1195 /* Process 'N' for "New/Number/Name" */
1198 /* Find the colon before the name */
1199 s = my_strchr(buf+2, ':');
1201 /* Verify that colon */
1204 /* Nuke the colon, advance to the name */
1208 /* Paranoia -- require a name */
1209 if (!*s) return (1);
1215 /* Verify information */
1216 if (i <= error_idx) return (4);
1218 /* Verify information */
1219 if (i >= head->info_num) return (2);
1221 /* Save the index */
1224 /* Point at the "info" */
1228 /* Store the name */
1229 if (!add_name(&f_ptr->name, head, s)) return (7);
1231 /* Default "mimic" */
1235 /* There better be a current f_ptr */
1236 else if (!f_ptr) return (3);
1239 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1240 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1241 else if (buf[0] == 'E')
1246 else if (buf[0] == 'E')
1248 /* Acquire the Text */
1251 /* Store the name */
1252 if (!add_name(&f_ptr->name, head, s)) return (7);
1257 /* Process 'M' for "Mimic" (one line only) */
1258 else if (buf[0] == 'M')
1262 /* Scan for the values */
1263 if (1 != sscanf(buf+2, "%d",
1264 &mimic)) return (1);
1266 /* Save the values */
1267 f_ptr->mimic = mimic;
1272 /* Process 'G' for "Graphics" (one line only) */
1273 else if (buf[0] == 'G')
1278 if (!buf[2]) return (1);
1279 if (!buf[3]) return (1);
1280 if (!buf[4]) return (1);
1282 /* Extract the color */
1283 tmp = color_char_to_attr(buf[4]);
1286 if (tmp > 127) return (1);
1288 /* Save the values */
1289 f_ptr->d_attr = tmp;
1290 f_ptr->d_char = buf[2];
1303 * Grab one flag in an object_kind from a textual string
1305 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
1310 for (i = 0; i < TR_FLAG_MAX; i++)
1312 if (streq(what, k_info_flags[i]))
1314 add_flag(k_ptr->flags, i);
1319 /* Check gen_flags */
1320 for (i = 0; i < 32; i++)
1322 if (streq(what, k_info_gen_flags[i]))
1324 k_ptr->gen_flags |= (1L << i);
1331 msg_format("̤ÃΤΥ¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1333 msg_format("Unknown object flag '%s'.", what);
1343 * Initialize the "k_info" array, by parsing an ascii "template" file
1345 errr parse_k_info(char *buf, header *head)
1352 static object_kind *k_ptr = NULL;
1355 /* Process 'N' for "New/Number/Name" */
1358 /* Find the colon before the name */
1359 s = my_strchr(buf+2, ':');
1361 /* Verify that colon */
1364 /* Nuke the colon, advance to the name */
1368 /* Paranoia -- require a name */
1369 if (!*s) return (1);
1374 /* Verify information */
1375 if (i <= error_idx) return (4);
1377 /* Verify information */
1378 if (i >= head->info_num) return (2);
1380 /* Save the index */
1383 /* Point at the "info" */
1387 /* Store the name */
1388 if (!add_name(&k_ptr->name, head, s)) return (7);
1392 /* There better be a current k_ptr */
1393 else if (!k_ptr) return (3);
1397 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1398 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1399 else if (buf[0] == 'E')
1404 else if (buf[0] == 'E')
1406 /* Acquire the Text */
1409 /* Store the name */
1410 if (!add_name(&k_ptr->name, head, s)) return (7);
1414 /* Process 'D' for "Description" */
1415 else if (buf[0] == 'D')
1420 /* Acquire the text */
1425 /* Acquire the text */
1429 /* Store the text */
1430 if (!add_text(&k_ptr->text, head, s)) return (7);
1433 /* Process 'G' for "Graphics" (one line only) */
1434 else if (buf[0] == 'G')
1440 if (!buf[2]) return (1);
1441 if (!buf[3]) return (1);
1442 if (!buf[4]) return (1);
1444 /* Extract the char */
1447 /* Extract the attr */
1448 tmp = color_char_to_attr(buf[4]);
1451 if (tmp > 127) return (1);
1453 /* Save the values */
1454 k_ptr->d_attr = tmp;
1455 k_ptr->d_char = sym;
1458 /* Process 'I' for "Info" (one line only) */
1459 else if (buf[0] == 'I')
1461 int tval, sval, pval;
1463 /* Scan for the values */
1464 if (3 != sscanf(buf+2, "%d:%d:%d",
1465 &tval, &sval, &pval)) return (1);
1467 /* Save the values */
1473 /* Process 'W' for "More Info" (one line only) */
1474 else if (buf[0] == 'W')
1476 int level, extra, wgt;
1479 /* Scan for the values */
1480 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1481 &level, &extra, &wgt, &cost)) return (1);
1483 /* Save the values */
1484 k_ptr->level = level;
1485 k_ptr->extra = extra;
1486 k_ptr->weight = wgt;
1490 /* Process 'A' for "Allocation" (one line only) */
1491 else if (buf[0] == 'A')
1495 /* XXX XXX XXX Simply read each number following a colon */
1496 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
1498 /* Default chance */
1499 k_ptr->chance[i] = 1;
1501 /* Store the attack damage index */
1502 k_ptr->locale[i] = atoi(s+1);
1504 /* Find the slash */
1505 t = my_strchr(s+1, '/');
1507 /* Find the next colon */
1508 s = my_strchr(s+1, ':');
1510 /* If the slash is "nearby", use it */
1511 if (t && (!s || t < s))
1513 int chance = atoi(t+1);
1514 if (chance > 0) k_ptr->chance[i] = chance;
1519 /* Hack -- Process 'P' for "power" and such */
1520 else if (buf[0] == 'P')
1522 int ac, hd1, hd2, th, td, ta;
1524 /* Scan for the values */
1525 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1526 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1536 /* Hack -- Process 'F' for flags */
1537 else if (buf[0] == 'F')
1539 /* Parse every entry textually */
1540 for (s = buf + 2; *s; )
1542 /* Find the end of this entry */
1543 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1545 /* Nuke and skip any dividers */
1549 while (*t == ' ' || *t == '|') t++;
1552 /* Parse this entry */
1553 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
1555 /* Start the next entry */
1571 * Grab one flag in an artifact_type from a textual string
1573 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
1578 for (i = 0; i < TR_FLAG_MAX; i++)
1580 if (streq(what, k_info_flags[i]))
1582 add_flag(a_ptr->flags, i);
1587 /* Check gen_flags */
1588 for (i = 0; i < 32; i++)
1590 if (streq(what, k_info_gen_flags[i]))
1592 a_ptr->gen_flags |= (1L << i);
1599 msg_format("̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1601 msg_format("Unknown artifact flag '%s'.", what);
1613 * Initialize the "a_info" array, by parsing an ascii "template" file
1615 errr parse_a_info(char *buf, header *head)
1622 static artifact_type *a_ptr = NULL;
1625 /* Process 'N' for "New/Number/Name" */
1628 /* Find the colon before the name */
1629 s = my_strchr(buf+2, ':');
1631 /* Verify that colon */
1634 /* Nuke the colon, advance to the name */
1637 /* Paranoia -- require a name */
1638 if (!*s) return (1);
1643 /* Verify information */
1644 if (i < error_idx) return (4);
1646 /* Verify information */
1647 if (i >= head->info_num) return (2);
1649 /* Save the index */
1652 /* Point at the "info" */
1655 /* Ignore everything */
1656 add_flag(a_ptr->flags, TR_IGNORE_ACID);
1657 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
1658 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
1659 add_flag(a_ptr->flags, TR_IGNORE_COLD);
1661 /* Store the name */
1662 if (!add_name(&a_ptr->name, head, s)) return (7);
1666 /* There better be a current a_ptr */
1667 else if (!a_ptr) return (3);
1671 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1672 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
1673 else if (buf[0] == 'E')
1678 else if (buf[0] == 'E')
1680 /* Acquire the Text */
1683 /* Store the name */
1684 if (!add_name(&a_ptr->name, head, s)) return (7);
1688 /* Process 'D' for "Description" */
1689 else if (buf[0] == 'D')
1694 /* Acquire the text */
1699 /* Acquire the text */
1703 /* Store the text */
1704 if (!add_text(&a_ptr->text, head, s)) return (7);
1708 /* Process 'I' for "Info" (one line only) */
1709 else if (buf[0] == 'I')
1711 int tval, sval, pval;
1713 /* Scan for the values */
1714 if (3 != sscanf(buf+2, "%d:%d:%d",
1715 &tval, &sval, &pval)) return (1);
1717 /* Save the values */
1723 /* Process 'W' for "More Info" (one line only) */
1724 else if (buf[0] == 'W')
1726 int level, rarity, wgt;
1729 /* Scan for the values */
1730 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1731 &level, &rarity, &wgt, &cost)) return (1);
1733 /* Save the values */
1734 a_ptr->level = level;
1735 a_ptr->rarity = rarity;
1736 a_ptr->weight = wgt;
1740 /* Hack -- Process 'P' for "power" and such */
1741 else if (buf[0] == 'P')
1743 int ac, hd1, hd2, th, td, ta;
1745 /* Scan for the values */
1746 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
1747 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
1757 /* Hack -- Process 'F' for flags */
1758 else if (buf[0] == 'F')
1760 /* Parse every entry textually */
1761 for (s = buf + 2; *s; )
1763 /* Find the end of this entry */
1764 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1766 /* Nuke and skip any dividers */
1770 while ((*t == ' ') || (*t == '|')) t++;
1773 /* Parse this entry */
1774 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
1776 /* Start the next entry */
1792 * Grab one flag in a ego-item_type from a textual string
1794 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
1799 for (i = 0; i < TR_FLAG_MAX; i++)
1801 if (streq(what, k_info_flags[i]))
1803 add_flag(e_ptr->flags, i);
1808 /* Check gen_flags */
1809 for (i = 0; i < 32; i++)
1811 if (streq(what, k_info_gen_flags[i]))
1813 e_ptr->gen_flags |= (1L << i);
1820 msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1822 msg_format("Unknown ego-item flag '%s'.", what);
1834 * Initialize the "e_info" array, by parsing an ascii "template" file
1836 errr parse_e_info(char *buf, header *head)
1843 static ego_item_type *e_ptr = NULL;
1846 /* Just before the first record */
1849 /* Just before the first line */
1853 /* Process 'N' for "New/Number/Name" */
1856 /* Find the colon before the name */
1857 s = my_strchr(buf+2, ':');
1859 /* Verify that colon */
1862 /* Nuke the colon, advance to the name */
1865 /* Paranoia -- require a name */
1866 if (!*s) return (1);
1871 /* Verify information */
1872 if (i < error_idx) return (4);
1874 /* Verify information */
1875 if (i >= head->info_num) return (2);
1877 /* Save the index */
1880 /* Point at the "info" */
1883 /* Store the name */
1884 if (!add_name(&e_ptr->name, head, s)) return (7);
1888 /* There better be a current e_ptr */
1889 else if (!e_ptr) return (3);
1893 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
1894 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
1895 else if (buf[0] == 'E')
1900 else if (buf[0] == 'E')
1902 /* Acquire the Text */
1905 /* Store the name */
1906 if (!add_name(&e_ptr->name, head, s)) return (7);
1911 /* Process 'D' for "Description" */
1912 else if (buf[0] == 'D')
1914 /* Acquire the text */
1917 /* Store the text */
1918 if (!add_text(&e_ptr->text, head, s)) return (7);
1923 /* Process 'X' for "Xtra" (one line only) */
1924 else if (buf[0] == 'X')
1928 /* Scan for the values */
1929 if (2 != sscanf(buf+2, "%d:%d",
1930 &slot, &rating)) return (1);
1932 /* Save the values */
1934 e_ptr->rating = rating;
1937 /* Process 'W' for "More Info" (one line only) */
1938 else if (buf[0] == 'W')
1940 int level, rarity, pad2;
1943 /* Scan for the values */
1944 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
1945 &level, &rarity, &pad2, &cost)) return (1);
1947 /* Save the values */
1948 e_ptr->level = level;
1949 e_ptr->rarity = rarity;
1950 /* e_ptr->weight = wgt; */
1954 /* Hack -- Process 'C' for "creation" */
1955 else if (buf[0] == 'C')
1959 /* Scan for the values */
1960 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1961 &th, &td, &ta, &pv)) return (1);
1963 e_ptr->max_to_h = th;
1964 e_ptr->max_to_d = td;
1965 e_ptr->max_to_a = ta;
1966 e_ptr->max_pval = pv;
1969 /* Hack -- Process 'F' for flags */
1970 else if (buf[0] == 'F')
1972 /* Parse every entry textually */
1973 for (s = buf + 2; *s; )
1975 /* Find the end of this entry */
1976 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1978 /* Nuke and skip any dividers */
1982 while ((*t == ' ') || (*t == '|')) t++;
1985 /* Parse this entry */
1986 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
1988 /* Start the next entry */
2002 * Grab one (basic) flag in a monster_race from a textual string
2004 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2009 for (i = 0; i < 32; i++)
2011 if (streq(what, r_info_flags1[i]))
2013 r_ptr->flags1 |= (1L << i);
2019 for (i = 0; i < 32; i++)
2021 if (streq(what, r_info_flags2[i]))
2023 r_ptr->flags2 |= (1L << i);
2029 for (i = 0; i < 32; i++)
2031 if (streq(what, r_info_flags3[i]))
2033 r_ptr->flags3 |= (1L << i);
2039 for (i = 0; i < 32; i++)
2041 if (streq(what, r_info_flags7[i]))
2043 r_ptr->flags7 |= (1L << i);
2049 for (i = 0; i < 32; i++)
2051 if (streq(what, r_info_flags8[i]))
2053 r_ptr->flags8 |= (1L << i);
2059 for (i = 0; i < 32; i++)
2061 if (streq(what, r_info_flags9[i]))
2063 r_ptr->flags9 |= (1L << i);
2068 /* Scan flagsr (resistance) */
2069 for (i = 0; i < 32; i++)
2071 if (streq(what, r_info_flagsr[i]))
2073 r_ptr->flagsr |= (1L << i);
2080 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2082 msg_format("Unknown monster flag '%s'.", what);
2092 * Grab one (spell) flag in a monster_race from a textual string
2094 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2099 for (i = 0; i < 32; i++)
2101 if (streq(what, r_info_flags4[i]))
2103 r_ptr->flags4 |= (1L << i);
2109 for (i = 0; i < 32; i++)
2111 if (streq(what, r_info_flags5[i]))
2113 r_ptr->flags5 |= (1L << i);
2119 for (i = 0; i < 32; i++)
2121 if (streq(what, r_info_flags6[i]))
2123 r_ptr->flags6 |= (1L << i);
2130 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2132 msg_format("Unknown monster flag '%s'.", what);
2144 * Initialize the "r_info" array, by parsing an ascii "template" file
2146 errr parse_r_info(char *buf, header *head)
2153 static monster_race *r_ptr = NULL;
2156 /* Process 'N' for "New/Number/Name" */
2159 /* Find the colon before the name */
2160 s = my_strchr(buf+2, ':');
2162 /* Verify that colon */
2165 /* Nuke the colon, advance to the name */
2168 /* Paranoia -- require a name */
2169 if (!*s) return (1);
2174 /* Verify information */
2175 if (i < error_idx) return (4);
2177 /* Verify information */
2178 if (i >= head->info_num) return (2);
2180 /* Save the index */
2183 /* Point at the "info" */
2186 /* Store the name */
2187 if (!add_name(&r_ptr->name, head, s)) return (7);
2191 /* There better be a current r_ptr */
2192 else if (!r_ptr) return (3);
2196 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2197 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
2198 else if (buf[0] == 'E')
2200 /* Acquire the Text */
2203 /* Store the name */
2204 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2207 else if (buf[0] == 'E')
2209 /* Acquire the Text */
2212 /* Store the name */
2213 if (!add_name(&r_ptr->name, head, s)) return (7);
2216 /* Process 'D' for "Description" */
2217 else if (buf[0] == 'D')
2222 /* Acquire the text */
2227 /* Acquire the text */
2231 /* Store the text */
2232 if (!add_text(&r_ptr->text, head, s)) return (7);
2235 /* Process 'G' for "Graphics" (one line only) */
2236 else if (buf[0] == 'G')
2242 if (!buf[2]) return (1);
2243 if (!buf[3]) return (1);
2244 if (!buf[4]) return (1);
2246 /* Extract the char */
2249 /* Extract the attr */
2250 tmp = color_char_to_attr(buf[4]);
2253 if (tmp > 127) return (1);
2255 /* Save the values */
2256 r_ptr->d_char = sym;
2257 r_ptr->d_attr = tmp;
2260 /* Process 'I' for "Info" (one line only) */
2261 else if (buf[0] == 'I')
2263 int spd, hp1, hp2, aaf, ac, slp;
2265 /* Scan for the other values */
2266 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2267 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2269 /* Save the values */
2278 /* Process 'W' for "More Info" (one line only) */
2279 else if (buf[0] == 'W')
2286 /* Scan for the values */
2287 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2288 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2290 /* Save the values */
2292 r_ptr->rarity = rar;
2295 r_ptr->next_exp = nextexp;
2296 r_ptr->next_r_idx = nextmon;
2299 /* Process 'B' for "Blows" (up to four lines) */
2300 else if (buf[0] == 'B')
2304 /* Find the next empty blow slot (if any) */
2305 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
2307 /* Oops, no more slots */
2308 if (i == 4) return (1);
2310 /* Analyze the first field */
2311 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
2313 /* Terminate the field (if necessary) */
2314 if (*t == ':') *t++ = '\0';
2316 /* Analyze the method */
2317 for (n1 = 0; r_info_blow_method[n1]; n1++)
2319 if (streq(s, r_info_blow_method[n1])) break;
2322 /* Invalid method */
2323 if (!r_info_blow_method[n1]) return (1);
2325 /* Analyze the second field */
2326 for (s = t; *t && (*t != ':'); t++) /* loop */;
2328 /* Terminate the field (if necessary) */
2329 if (*t == ':') *t++ = '\0';
2331 /* Analyze effect */
2332 for (n2 = 0; r_info_blow_effect[n2]; n2++)
2334 if (streq(s, r_info_blow_effect[n2])) break;
2337 /* Invalid effect */
2338 if (!r_info_blow_effect[n2]) return (1);
2340 /* Analyze the third field */
2341 for (s = t; *t && (*t != 'd'); t++) /* loop */;
2343 /* Terminate the field (if necessary) */
2344 if (*t == 'd') *t++ = '\0';
2346 /* Save the method */
2347 r_ptr->blow[i].method = n1;
2349 /* Save the effect */
2350 r_ptr->blow[i].effect = n2;
2352 /* Extract the damage dice and sides */
2353 r_ptr->blow[i].d_dice = atoi(s);
2354 r_ptr->blow[i].d_side = atoi(t);
2357 /* Process 'F' for "Basic Flags" (multiple lines) */
2358 else if (buf[0] == 'F')
2360 /* Parse every entry */
2361 for (s = buf + 2; *s; )
2363 /* Find the end of this entry */
2364 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2366 /* Nuke and skip any dividers */
2370 while (*t == ' ' || *t == '|') t++;
2373 /* Parse this entry */
2374 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
2376 /* Start the next entry */
2381 /* Process 'S' for "Spell Flags" (multiple lines) */
2382 else if (buf[0] == 'S')
2384 /* Parse every entry */
2385 for (s = buf + 2; *s; )
2387 /* Find the end of this entry */
2388 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2390 /* Nuke and skip any dividers */
2394 while ((*t == ' ') || (*t == '|')) t++;
2397 /* XXX XXX XXX Hack -- Read spell frequency */
2398 if (1 == sscanf(s, "1_IN_%d", &i))
2400 /* Extract a "frequency" */
2401 r_ptr->freq_spell = 100 / i;
2403 /* Start at next entry */
2410 /* Parse this entry */
2411 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
2413 /* Start the next entry */
2428 * Grab one flag for a dungeon type from a textual string
2430 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
2435 for (i = 0; i < 32; i++)
2437 if (streq(what, d_info_flags1[i]))
2439 d_ptr->flags1 |= (1L << i);
2446 msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
2448 msg_format("Unknown dungeon type flag '%s'.", what);
2456 * Grab one (basic) flag in a monster_race from a textual string
2458 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
2463 for (i = 0; i < 32; i++)
2465 if (streq(what, r_info_flags1[i]))
2467 d_ptr->mflags1 |= (1L << i);
2473 for (i = 0; i < 32; i++)
2475 if (streq(what, r_info_flags2[i]))
2477 d_ptr->mflags2 |= (1L << i);
2483 for (i = 0; i < 32; i++)
2485 if (streq(what, r_info_flags3[i]))
2487 d_ptr->mflags3 |= (1L << i);
2493 for (i = 0; i < 32; i++)
2495 if (streq(what, r_info_flags7[i]))
2497 d_ptr->mflags7 |= (1L << i);
2503 for (i = 0; i < 32; i++)
2505 if (streq(what, r_info_flags8[i]))
2507 d_ptr->mflags8 |= (1L << i);
2513 for (i = 0; i < 32; i++)
2515 if (streq(what, r_info_flags9[i]))
2517 d_ptr->mflags9 |= (1L << i);
2522 /* Scan flagsr (resistance) */
2523 for (i = 0; i < 32; i++)
2525 if (streq(what, r_info_flagsr[i]))
2527 d_ptr->mflagsr |= (1L << i);
2534 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2536 msg_format("Unknown monster flag '%s'.", what);
2544 * Grab one (spell) flag in a monster_race from a textual string
2546 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
2551 for (i = 0; i < 32; i++)
2553 if (streq(what, r_info_flags4[i]))
2555 d_ptr->mflags4 |= (1L << i);
2561 for (i = 0; i < 32; i++)
2563 if (streq(what, r_info_flags5[i]))
2565 d_ptr->mflags5 |= (1L << i);
2571 for (i = 0; i < 32; i++)
2573 if (streq(what, r_info_flags6[i]))
2575 d_ptr->mflags6 |= (1L << i);
2582 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2584 msg_format("Unknown monster flag '%s'.", what);
2592 * Initialize the "d_info" array, by parsing an ascii "template" file
2594 errr parse_d_info(char *buf, header *head)
2601 static dungeon_info_type *d_ptr = NULL;
2604 /* Process 'N' for "New/Number/Name" */
2607 /* Find the colon before the name */
2608 s = my_strchr(buf+2, ':');
2610 /* Verify that colon */
2613 /* Nuke the colon, advance to the name */
2616 /* Paranoia -- require a name */
2617 if (!*s) return (1);
2622 /* Verify information */
2623 if (i < error_idx) return (4);
2625 /* Verify information */
2626 if (i >= head->info_num) return (2);
2628 /* Save the index */
2631 /* Point at the "info" */
2634 /* Store the name */
2635 if (!add_name(&d_ptr->name, head, s)) return (7);
2640 else if (buf[0] == 'E') return (0);
2642 else if (buf[0] == 'E')
2644 /* Acquire the Text */
2647 /* Store the name */
2648 if (!add_name(&d_ptr->name, head, s)) return (7);
2652 /* Process 'D' for "Description */
2653 else if (buf[0] == 'D')
2658 /* Acquire the text */
2663 /* Acquire the text */
2667 /* Store the text */
2668 if (!add_text(&d_ptr->text, head, s)) return (7);
2671 /* Process 'W' for "More Info" (one line only) */
2672 else if (buf[0] == 'W')
2674 int min_lev, max_lev;
2676 int min_alloc, max_chance;
2677 int obj_good, obj_great;
2680 /* Scan for the values */
2681 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
2682 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
2684 /* Save the values */
2685 d_ptr->mindepth = min_lev;
2686 d_ptr->maxdepth = max_lev;
2687 d_ptr->min_plev = min_plev;
2689 d_ptr->min_m_alloc_level = min_alloc;
2690 d_ptr->max_m_alloc_chance = max_chance;
2691 d_ptr->obj_good = obj_good;
2692 d_ptr->obj_great = obj_great;
2697 /* Process 'P' for "Place Info" */
2698 else if (buf[0] == 'P')
2702 /* Scan for the values */
2703 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
2705 /* Save the values */
2710 /* Process 'L' for "fLoor type" (one line only) */
2711 else if (buf[0] == 'L')
2717 /* Scan for the values */
2718 if (7 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d",
2719 &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) return (1);
2721 /* Save the values */
2723 d_ptr->floor_percent1 = p1;
2725 d_ptr->floor_percent2 = p2;
2727 d_ptr->floor_percent3 = p3;
2728 d_ptr->tunnel_percent = tunnel;
2731 /* Process 'A' for "wAll type" (one line only) */
2732 else if (buf[0] == 'A')
2734 int w1, w2, w3, outer, inner, stream1, stream2;
2737 /* Scan for the values */
2738 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
2739 &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) return (1);
2741 /* Save the values */
2742 d_ptr->fill_type1 = w1;
2743 d_ptr->fill_percent1 = p1;
2744 d_ptr->fill_type2 = w2;
2745 d_ptr->fill_percent2 = p2;
2746 d_ptr->fill_type3 = w3;
2747 d_ptr->fill_percent3 = p3;
2748 d_ptr->outer_wall = outer;
2749 d_ptr->inner_wall = inner;
2750 d_ptr->stream1 = stream1;
2751 d_ptr->stream2 = stream2;
2754 /* Process 'F' for "Dungeon Flags" (multiple lines) */
2755 else if (buf[0] == 'F')
2757 int artif = 0, monst = 0;
2759 /* Parse every entry */
2760 for (s = buf + 2; *s; )
2762 /* Find the end of this entry */
2763 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2765 /* Nuke and skip any dividers */
2769 while (*t == ' ' || *t == '|') t++;
2772 /* XXX XXX XXX Hack -- Read Final Artifact */
2773 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
2775 /* Extract a "Final Artifact" */
2776 d_ptr->final_artifact = artif;
2778 /* Start at next entry */
2785 /* XXX XXX XXX Hack -- Read Final Object */
2786 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
2788 /* Extract a "Final Artifact" */
2789 d_ptr->final_object = artif;
2791 /* Start at next entry */
2798 /* XXX XXX XXX Hack -- Read Artifact Guardian */
2799 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
2801 /* Extract a "Artifact Guardian" */
2802 d_ptr->final_guardian = monst;
2804 /* Start at next entry */
2811 /* XXX XXX XXX Hack -- Read Special Percentage */
2812 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
2814 /* Extract a "Special %" */
2815 d_ptr->special_div = monst;
2817 /* Start at next entry */
2824 /* Parse this entry */
2825 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
2827 /* Start the next entry */
2832 /* Process 'M' for "Basic Flags" (multiple lines) */
2833 else if (buf[0] == 'M')
2835 /* Parse every entry */
2836 for (s = buf + 2; *s; )
2838 /* Find the end of this entry */
2839 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2841 /* Nuke and skip any dividers */
2845 while (*t == ' ' || *t == '|') t++;
2848 /* Hack -- Read monster symbols */
2849 if (!strncmp(s, "R_CHAR_", 7))
2851 /* Skip "R_CHAR_" */
2855 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
2857 /* Start at next entry */
2864 /* Parse this entry */
2865 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
2867 /* Start the next entry */
2872 /* Process 'S' for "Spell Flags" (multiple lines) */
2873 else if (buf[0] == 'S')
2875 /* Parse every entry */
2876 for (s = buf + 2; *s; )
2878 /* Find the end of this entry */
2879 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2881 /* Nuke and skip any dividers */
2885 while ((*t == ' ') || (*t == '|')) t++;
2888 /* XXX XXX XXX Hack -- Read spell frequency */
2889 if (1 == sscanf(s, "1_IN_%d", &i))
2891 /* Start at next entry */
2898 /* Parse this entry */
2899 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
2901 /* Start the next entry */
2914 #else /* ALLOW_TEMPLATES */
2920 #endif /* ALLOW_TEMPLATES */
2923 /* Random dungeon grid effects */
2924 #define RANDOM_NONE 0x00
2925 #define RANDOM_FEATURE 0x01
2926 #define RANDOM_MONSTER 0x02
2927 #define RANDOM_OBJECT 0x04
2928 #define RANDOM_EGO 0x08
2929 #define RANDOM_ARTIFACT 0x10
2930 #define RANDOM_TRAP 0x20
2933 typedef struct dungeon_grid dungeon_grid;
2937 int feature; /* Terrain feature */
2938 int monster; /* Monster */
2939 int object; /* Object */
2940 int ego; /* Ego-Item */
2941 int artifact; /* Artifact */
2942 int trap; /* Trap */
2943 int cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
2944 int special; /* Reserved for special terrain info */
2945 int random; /* Number of the random effect */
2949 static dungeon_grid letter[255];
2953 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
2955 static errr parse_line_feature(char *buf)
2961 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
2963 /* Tokenize the line */
2964 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
2966 /* Letter to assign */
2967 int index = zz[0][0];
2969 /* Reset the info for the letter */
2970 letter[index].feature = 0;
2971 letter[index].monster = 0;
2972 letter[index].object = 0;
2973 letter[index].ego = 0;
2974 letter[index].artifact = 0;
2975 letter[index].trap = 0;
2976 letter[index].cave_info = 0;
2977 letter[index].special = 0;
2978 letter[index].random = 0;
2984 letter[index].special = atoi(zz[8]);
2988 if (zz[7][0] == '*')
2990 letter[index].random |= RANDOM_TRAP;
2995 letter[index].trap = atoi(zz[7]);
3000 letter[index].trap = atoi(zz[7]);
3005 if (zz[6][0] == '*')
3007 letter[index].random |= RANDOM_ARTIFACT;
3012 letter[index].artifact = atoi(zz[6]);
3017 letter[index].artifact = atoi(zz[6]);
3022 if (zz[5][0] == '*')
3024 letter[index].random |= RANDOM_EGO;
3029 letter[index].ego = atoi(zz[5]);
3034 letter[index].ego = atoi(zz[5]);
3039 if (zz[4][0] == '*')
3041 letter[index].random |= RANDOM_OBJECT;
3046 letter[index].object = atoi(zz[4]);
3051 letter[index].object = atoi(zz[4]);
3056 if (zz[3][0] == '*')
3058 letter[index].random |= RANDOM_MONSTER;
3062 letter[index].monster = atoi(zz[3]);
3065 else if (zz[3][0] == 'c')
3067 letter[index].monster = - atoi(zz[3]+1);
3071 letter[index].monster = atoi(zz[3]);
3076 letter[index].cave_info = atoi(zz[2]);
3080 if (zz[1][0] == '*')
3082 letter[index].random |= RANDOM_FEATURE;
3086 letter[index].feature = atoi(zz[1]);
3091 letter[index].feature = atoi(zz[1]);
3104 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3106 static errr parse_line_building(char *buf)
3122 /* Get the building number */
3125 /* Find the colon after the building number */
3126 s = my_strchr(s, ':');
3128 /* Verify that colon */
3131 /* Nuke the colon, advance to the sub-index */
3134 /* Paranoia -- require a sub-index */
3135 if (!*s) return (1);
3137 /* Building definition sub-index */
3140 /* Building name, owner, race */
3143 if (tokenize(s + 2, 3, zz, 0) == 3)
3145 /* Name of the building */
3146 strcpy(building[index].name, zz[0]);
3148 /* Name of the owner */
3149 strcpy(building[index].owner_name, zz[1]);
3151 /* Race of the owner */
3152 strcpy(building[index].owner_race, zz[2]);
3157 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3160 /* Building Action */
3163 if (tokenize(s + 2, 8, zz, 0) >= 7)
3165 /* Index of the action */
3166 int action_index = atoi(zz[0]);
3168 /* Name of the action */
3169 strcpy(building[index].act_names[action_index], zz[1]);
3171 /* Cost of the action for members */
3172 building[index].member_costs[action_index] = atoi(zz[2]);
3174 /* Cost of the action for non-members */
3175 building[index].other_costs[action_index] = atoi(zz[3]);
3177 /* Letter assigned to the action */
3178 building[index].letters[action_index] = zz[4][0];
3181 building[index].actions[action_index] = atoi(zz[5]);
3183 /* Action restriction */
3184 building[index].action_restr[action_index] = atoi(zz[6]);
3189 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3192 /* Building Classes */
3195 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3197 for (i = 0; i < MAX_CLASS; i++)
3199 building[index].member_class[i] = atoi(zz[i]);
3205 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3208 /* Building Races */
3211 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3213 for (i = 0; i < MAX_RACES; i++)
3215 building[index].member_race[i] = atoi(zz[i]);
3221 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3224 /* Building Realms */
3227 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3229 for (i = 0; i < MAX_MAGIC; i++)
3231 building[index].member_realm[i+1] = atoi(zz[i]);
3237 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3242 /* Ignore scripts */
3248 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3257 * Parse a sub-file of the "extra info"
3259 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3266 /* Skip "empty" lines */
3267 if (!buf[0]) return (0);
3269 /* Skip "blank" lines */
3270 if (isspace(buf[0])) return (0);
3273 if (buf[0] == '#') return (0);
3275 /* Require "?:*" format */
3276 if (buf[1] != ':') return (1);
3279 /* Process "%:<fname>" */
3282 /* Attempt to Process the given file */
3283 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3286 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3289 return parse_line_feature(buf);
3292 /* Process "D:<dungeon>" -- info for the cave grids */
3293 else if (buf[0] == 'D')
3295 object_type object_type_body;
3297 /* Acquire the text */
3300 /* Length of the text */
3301 int len = strlen(s);
3303 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3305 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3307 /* Access the grid */
3308 cave_type *c_ptr = &cave[*y][*x];
3312 int object_index = letter[idx].object;
3313 int monster_index = letter[idx].monster;
3314 int random = letter[idx].random;
3315 int artifact_index = letter[idx].artifact;
3317 /* Lay down a floor */
3318 c_ptr->feat = letter[idx].feature;
3320 /* Only the features */
3321 if (init_flags & INIT_ONLY_FEATURES) continue;
3324 c_ptr->info = letter[idx].cave_info;
3326 /* Create a monster */
3327 if (random & RANDOM_MONSTER)
3329 monster_level = base_level + monster_index;
3331 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
3333 monster_level = base_level;
3335 else if (monster_index)
3337 int old_cur_num, old_max_num;
3340 if (monster_index < 0)
3342 monster_index = -monster_index;
3345 old_cur_num = r_info[monster_index].cur_num;
3346 old_max_num = r_info[monster_index].max_num;
3348 /* Make alive again */
3349 if (r_info[monster_index].flags1 & RF1_UNIQUE)
3351 r_info[monster_index].cur_num = 0;
3352 r_info[monster_index].max_num = 1;
3355 /* Make alive again */
3356 /* Hack -- Non-unique Nazguls are semi-unique */
3357 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
3359 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
3361 r_info[monster_index].max_num++;
3366 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
3370 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3372 /* Make alive again for real unique monster */
3373 r_info[monster_index].cur_num = old_cur_num;
3374 r_info[monster_index].max_num = old_max_num;
3378 /* Object (and possible trap) */
3379 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
3381 object_level = base_level + object_index;
3384 * Random trap and random treasure defined
3385 * 25% chance for trap and 75% chance for object
3387 if (randint0(100) < 75)
3389 place_object(*y, *x, 0L);
3396 object_level = base_level;
3398 else if (random & RANDOM_OBJECT)
3400 object_level = base_level + object_index;
3402 /* Create an out of deep object */
3403 if (randint0(100) < 75)
3404 place_object(*y, *x, 0L);
3405 else if (randint0(100) < 80)
3406 place_object(*y, *x, AM_GOOD);
3408 place_object(*y, *x, AM_GOOD | AM_GREAT);
3410 object_level = base_level;
3413 else if (random & RANDOM_TRAP)
3417 /* Hidden trap (or door) */
3418 else if (letter[idx].trap)
3420 c_ptr->mimic = c_ptr->feat;
3421 c_ptr->feat = letter[idx].trap;
3423 else if (object_index)
3425 /* Get local object */
3426 object_type *o_ptr = &object_type_body;
3428 /* Create the item */
3429 object_prep(o_ptr, object_index);
3431 if (o_ptr->tval == TV_GOLD)
3433 coin_type = object_index - OBJ_GOLD_LIST;
3438 /* Apply magic (no messages, no artifacts) */
3439 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
3441 (void)drop_near(o_ptr, -1, *y, *x);
3447 if (a_info[artifact_index].cur_num)
3449 int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
3451 object_type *q_ptr = &forge;
3453 object_prep(q_ptr, k_idx);
3455 /* Drop it in the dungeon */
3456 (void)drop_near(q_ptr, -1, *y, *x);
3460 /* Create the artifact */
3461 create_named_art(artifact_index, *y, *x);
3463 a_info[artifact_index].cur_num = 1;
3467 /* Terrain special */
3468 c_ptr->special = letter[idx].special;
3476 /* Process "Q:<number>:<command>:... -- quest info */
3477 else if (buf[0] == 'Q')
3484 num = tokenize(buf + 2, 33, zz, 0);
3488 num = tokenize(buf + 3, 33, zz, 0);
3491 /* Have we enough parameters? */
3492 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3495 q_ptr = &(quest[atoi(zz[0])]);
3497 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
3498 if (zz[1][0] == 'Q')
3500 if (init_flags & INIT_ASSIGN)
3502 monster_race *r_ptr;
3503 artifact_type *a_ptr;
3505 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3507 q_ptr->type = atoi(zz[2]);
3508 q_ptr->num_mon = atoi(zz[3]);
3509 q_ptr->cur_num = atoi(zz[4]);
3510 q_ptr->max_num = atoi(zz[5]);
3511 q_ptr->level = atoi(zz[6]);
3512 q_ptr->r_idx = atoi(zz[7]);
3513 q_ptr->k_idx = atoi(zz[8]);
3514 q_ptr->dungeon = atoi(zz[9]);
3517 q_ptr->flags = atoi(zz[10]);
3519 r_ptr = &r_info[q_ptr->r_idx];
3520 if (r_ptr->flags1 & RF1_UNIQUE)
3521 r_ptr->flags1 |= RF1_QUESTOR;
3523 a_ptr = &a_info[q_ptr->k_idx];
3524 a_ptr->gen_flags |= TRG_QUESTITEM;
3529 /* Process "Q:<q_index>:N:<name>" -- quest name */
3530 else if (zz[1][0] == 'N')
3532 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT))
3534 strcpy(q_ptr->name, zz[2]);
3540 /* Process "Q:<q_index>:T:<text>" -- quest description line */
3541 else if (zz[1][0] == 'T')
3543 if (init_flags & INIT_SHOW_TEXT)
3545 strcpy(quest_text[quest_text_line], zz[2]);
3553 /* Process "W:<command>: ..." -- info for the wilderness */
3554 else if (buf[0] == 'W')
3556 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
3559 /* Process "P:<y>:<x>" -- player position */
3560 else if (buf[0] == 'P')
3562 if (init_flags & INIT_CREATE_DUNGEON)
3564 if (tokenize(buf + 2, 2, zz, 0) == 2)
3566 int panels_x, panels_y;
3568 /* Hack - Set the dungeon size */
3569 panels_y = (*y / SCREEN_HGT);
3570 if (*y % SCREEN_HGT) panels_y++;
3571 cur_hgt = panels_y * SCREEN_HGT;
3573 panels_x = (*x / SCREEN_WID);
3574 if (*x % SCREEN_WID) panels_x++;
3575 cur_wid = panels_x * SCREEN_WID;
3577 /* Assume illegal panel */
3578 panel_row_min = cur_hgt;
3579 panel_col_min = cur_wid;
3581 /* Place player in a quest level */
3582 if (p_ptr->inside_quest)
3586 /* Delete the monster (if any) */
3587 delete_monster(py, px);
3595 /* Place player in the town */
3596 else if (!p_ptr->oldpx && !p_ptr->oldpy)
3598 p_ptr->oldpy = atoi(zz[0]);
3599 p_ptr->oldpx = atoi(zz[1]);
3607 /* Process "B:<Index>:<Command>:..." -- Building definition */
3608 else if (buf[0] == 'B')
3610 return parse_line_building(buf);
3613 /* Process "M:<type>:<maximum>" -- set maximum values */
3614 else if (buf[0] == 'M')
3616 if (tokenize(buf+2, 2, zz, 0) == 2)
3619 if (zz[0][0] == 'T')
3621 max_towns = atoi(zz[1]);
3624 /* Maximum quests */
3625 else if (zz[0][0] == 'Q')
3627 max_quests = atoi(zz[1]);
3631 else if (zz[0][0] == 'R')
3633 max_r_idx = atoi(zz[1]);
3637 else if (zz[0][0] == 'K')
3639 max_k_idx = atoi(zz[1]);
3643 else if (zz[0][0] == 'V')
3645 max_v_idx = atoi(zz[1]);
3649 else if (zz[0][0] == 'F')
3651 max_f_idx = atoi(zz[1]);
3655 else if (zz[0][0] == 'A')
3657 max_a_idx = atoi(zz[1]);
3661 else if (zz[0][0] == 'E')
3663 max_e_idx = atoi(zz[1]);
3667 else if (zz[0][0] == 'D')
3669 max_d_idx = atoi(zz[1]);
3673 else if (zz[0][0] == 'O')
3675 max_o_idx = atoi(zz[1]);
3679 else if (zz[0][0] == 'M')
3681 max_m_idx = atoi(zz[1]);
3684 /* Wilderness size */
3685 else if (zz[0][0] == 'W')
3687 /* Maximum wild_x_size */
3688 if (zz[0][1] == 'X')
3689 max_wild_x = atoi(zz[1]);
3690 /* Maximum wild_y_size */
3691 if (zz[0][1] == 'Y')
3692 max_wild_y = atoi(zz[1]);
3706 static cptr variant = "ZANGBAND";
3710 * Helper function for "process_dungeon_file()"
3712 static cptr process_dungeon_file_expr(char **sp, char *fp)
3728 while (isspace(*s)) s++;
3746 t = process_dungeon_file_expr(&s, &f);
3755 else if (streq(t, "IOR"))
3758 while (*s && (f != b2))
3760 t = process_dungeon_file_expr(&s, &f);
3761 if (*t && !streq(t, "0")) v = "1";
3766 else if (streq(t, "AND"))
3769 while (*s && (f != b2))
3771 t = process_dungeon_file_expr(&s, &f);
3772 if (*t && streq(t, "0")) v = "0";
3777 else if (streq(t, "NOT"))
3780 while (*s && (f != b2))
3782 t = process_dungeon_file_expr(&s, &f);
3783 if (*t && streq(t, "1")) v = "0";
3788 else if (streq(t, "EQU"))
3791 if (*s && (f != b2))
3793 t = process_dungeon_file_expr(&s, &f);
3795 while (*s && (f != b2))
3797 p = process_dungeon_file_expr(&s, &f);
3798 if (streq(t, p)) v = "1";
3803 else if (streq(t, "LEQ"))
3806 if (*s && (f != b2))
3808 t = process_dungeon_file_expr(&s, &f);
3810 while (*s && (f != b2))
3813 t = process_dungeon_file_expr(&s, &f);
3814 if (*t && atoi(p) > atoi(t)) v = "0";
3819 else if (streq(t, "GEQ"))
3822 if (*s && (f != b2))
3824 t = process_dungeon_file_expr(&s, &f);
3826 while (*s && (f != b2))
3829 t = process_dungeon_file_expr(&s, &f);
3831 /* Compare two numbers instead of string */
3832 if (*t && atoi(p) < atoi(t)) v = "0";
3839 while (*s && (f != b2))
3841 t = process_dungeon_file_expr(&s, &f);
3846 if (f != b2) v = "?x?x?";
3848 /* Extract final and Terminate */
3849 if ((f = *s) != '\0') *s++ = '\0';
3855 /* Accept all printables except spaces and brackets */
3856 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
3858 /* Extract final and Terminate */
3859 if ((f = *s) != '\0') *s++ = '\0';
3865 if (streq(b+1, "SYS"))
3871 else if (streq(b+1, "GRAF"))
3876 else if (streq(b+1, "MONOCHROME"))
3885 else if (streq(b+1, "RACE"))
3888 v = rp_ptr->E_title;
3895 else if (streq(b+1, "CLASS"))
3898 v = cp_ptr->E_title;
3905 else if (streq(b+1, "REALM1"))
3908 v = E_realm_names[p_ptr->realm1];
3910 v = realm_names[p_ptr->realm1];
3915 else if (streq(b+1, "REALM2"))
3918 v = E_realm_names[p_ptr->realm2];
3920 v = realm_names[p_ptr->realm2];
3925 else if (streq(b+1, "PLAYER"))
3931 else if (streq(b+1, "TOWN"))
3933 sprintf(tmp, "%d", p_ptr->town_num);
3938 else if (streq(b+1, "LEVEL"))
3940 sprintf(tmp, "%d", p_ptr->lev);
3944 /* Current quest number */
3945 else if (streq(b+1, "QUEST_NUMBER"))
3947 sprintf(tmp, "%d", p_ptr->inside_quest);
3951 /* Number of last quest */
3952 else if (streq(b+1, "LEAVING_QUEST"))
3954 sprintf(tmp, "%d", leaving_quest);
3959 else if (prefix(b+1, "QUEST"))
3961 /* "QUEST" uses a special parameter to determine the number of the quest */
3962 sprintf(tmp, "%d", quest[atoi(b+6)].status);
3967 else if (prefix(b+1, "RANDOM"))
3969 /* "RANDOM" uses a special parameter to determine the number of the quest */
3970 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
3975 else if (streq(b+1, "VARIANT"))
3981 else if (streq(b+1, "WILDERNESS"))
3984 sprintf(tmp, "NONE");
3986 sprintf(tmp, "LITE");
3988 sprintf(tmp, "NORMAL");
4011 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4021 bool bypass = FALSE;
4023 int x = xmin, y = ymin;
4026 /* Build the filename */
4027 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4030 fp = my_fopen(buf, "r");
4033 if (!fp) return (-1);
4036 /* Process the file */
4037 while (0 == my_fgets(fp, buf, sizeof(buf)))
4043 /* Skip "empty" lines */
4044 if (!buf[0]) continue;
4046 /* Skip "blank" lines */
4047 if (isspace(buf[0])) continue;
4050 if (buf[0] == '#') continue;
4053 /* Process "?:<expr>" */
4054 if ((buf[0] == '?') && (buf[1] == ':'))
4063 /* Parse the expr */
4064 v = process_dungeon_file_expr(&s, &f);
4067 bypass = (streq(v, "0") ? TRUE : FALSE);
4073 /* Apply conditionals */
4074 if (bypass) continue;
4076 /* Process the line */
4077 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4089 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4092 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4094 msg_format("'%s'¤ò²òÀÏÃæ¡£", buf);
4096 msg_format("Parsing '%s'.", buf);
4103 /* Close the file */
4113 void write_r_info_txt(void)
4115 int i, j, z, fc, bc;
4118 cptr flags[32 * 10];
4123 monster_race *r_ptr;
4125 monster_blow *b_ptr;
4127 FILE *fff = fopen("output.txt", "wt");
4135 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4137 fprintf(fff, "# Version stamp (required)\n\n");
4140 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4143 fprintf(fff, "##### The Player #####\n\n");
4145 for (z = -1; z < alloc_race_size; z++)
4147 /* Output the monsters in order */
4148 i = (z >= 0) ? alloc_race_table[z].index : 0;
4150 /* Acquire the monster */
4153 /* Ignore empty monsters */
4154 if (!strlen(r_name + r_ptr->name)) continue;
4156 /* Ignore useless monsters */
4157 if (i && !r_ptr->speed) continue;
4159 /* Write a note if necessary */
4160 if (i && (!r_ptr->level != !mode))
4165 fprintf(fff, "\n##### Town monsters #####\n\n");
4167 /* Note the dungeon */
4170 fprintf(fff, "\n##### Normal monsters #####\n\n");
4173 /* Record the change */
4174 mode = r_ptr->level;
4177 /* Acquire the flags */
4178 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4179 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4180 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4181 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4182 f_ptr[4] = r_ptr->flags5; n_ptr[4] = r_info_flags5;
4183 f_ptr[5] = r_ptr->flags6; n_ptr[5] = r_info_flags6;
4184 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4185 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4186 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4187 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4189 /* Write New/Number/Name */
4190 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4193 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4195 /* Write Information */
4196 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4197 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4199 /* Write more information */
4200 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4203 for(j = 0; j < 4; j++)
4205 b_ptr = &(r_ptr->blow[j]);
4207 /* Stop when done */
4208 if (!b_ptr->method) break;
4210 /* Write the blows */
4211 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4212 r_info_blow_effect[b_ptr->effect],
4213 b_ptr->d_dice, b_ptr->d_side);
4216 /* Extract the flags */
4217 for (fc = 0, j = 0; j < 32 * 3; j++)
4219 /* Check this flag */
4220 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4223 /* Extract the extra flags */
4224 for (j = 32 * 6; j < 32 * 10; j++)
4226 /* Check this flag */
4227 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4230 /* Write the flags */
4231 for (j = 0; j < fc;)
4235 /* Start the line */
4238 for (bc = 0; (bc < 60) && (j < fc); j++)
4242 /* Format the flag */
4243 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4245 /* Add it to the buffer */
4248 /* Note the length */
4252 /* Done with this line; write it */
4253 fprintf(fff, "%s\n", buf);
4256 /* Write Spells if applicable */
4257 if (r_ptr->freq_spell)
4259 /* Write the frequency */
4260 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
4262 /* Extract the spell flags */
4263 for (fc = 0, j = 96; j < 192; j++)
4265 /* Check this flag */
4266 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4269 /* Write the flags */
4270 for (j = 0; j < fc;)
4274 /* Start the line */
4277 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
4281 /* Format the flag */
4282 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4286 /* Note the length */
4293 /* Done with this line; write it */
4294 fprintf(fff, "%s\n", buf);
4298 /* Acquire the description */
4299 desc = r_text + r_ptr->text;
4300 dlen = strlen(desc);
4302 /* Write Description */
4303 for (j = 0; j < dlen;)
4307 /* Start the line */
4310 for (bc = 0, t = buf + 2; ((bc < 60) || !isspace(desc[j])) && (j < dlen); j++, bc++, t++)
4318 /* Done with this line; write it */
4319 fprintf(fff, "%s\n", buf);
4322 /* Space between entries */