3 * @brief ¥²¡¼¥à¥Ç¡¼¥¿½é´ü²½1 / Initialization (part 1) -BEN-
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 * This file is used to initialize various variables and arrays for the
16 * Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
17 * the common limitation of "read()" and "write()" to only 32767 bytes
19 * Several of the arrays for Angband are built from "template" files in
20 * the "lib/file" directory, from which quick-load binary "image" files
21 * are constructed whenever they are not present in the "lib/data"
22 * directory, or if those files become obsolete, if we are allowed.
23 * Warning -- the "ascii" file parsers use a minor hack to collect the
24 * name and text information in a single pass. Thus, the game will not
25 * be able to load any template file with more than 20K of names or 60K
26 * of text, even though technically, up to 64K should be legal.
27 * Note that if "ALLOW_TEMPLATES" is not defined, then a lot of the code
28 * in this file is compiled out, and the game will not run unless valid
29 * "binary template files" already exist in "lib/data". Thus, one can
30 * compile Angband with ALLOW_TEMPLATES defined, run once to create the
31 * "*.raw" files in "lib/data", and then quit, and recompile without
32 * defining ALLOW_TEMPLATES, which will both save 20K and prevent people
33 * from changing the ascii template files in potentially dangerous ways.
34 * The code could actually be removed and placed into a "stand-alone"
35 * program, but that feels a little silly, especially considering some
36 * of the platforms that we currently support.
44 #ifdef ALLOW_TEMPLATES
49 /*** Helper arrays for parsing ascii template files ***/
52 * ¥â¥ó¥¹¥¿¡¼¤ÎÂÇ·â¼êÃʥȡ¼¥¯¥ó¤ÎÄêµÁ /
53 * Monster Blow Methods
55 static cptr r_info_blow_method[] =
88 * ¥â¥ó¥¹¥¿¡¼¤ÎÂÇ·â°À¥È¡¼¥¯¥ó¤ÎÄêµÁ /
89 * Monster Blow Effects
91 static cptr r_info_blow_effect[] =
133 * ÃÏ·Á°À¥È¡¼¥¯¥ó¤ÎÄêµÁ /
136 static cptr f_info_flags[] =
258 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ1 /
261 static cptr r_info_flags1[] =
298 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ2 /
301 static cptr r_info_flags2[] =
338 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ3 /
341 static cptr r_info_flags3[] =
378 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ4 /
381 static cptr r_info_flags4[] =
418 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ5 /
421 static cptr r_info_flags5[] =
458 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ6 /
461 static cptr r_info_flags6[] =
478 "ANIM_DEAD", /* ToDo: Implement ANIM_DEAD */
499 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ7 /
502 static cptr r_info_flags7[] =
539 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ8 /
542 static cptr r_info_flags8[] =
574 "WILD_SWAMP", /* ToDo: Implement Swamp */
580 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ9 /
583 static cptr r_info_flags9[] =
622 * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁR(ÂÑÀ) /
625 static cptr r_info_flagsr[] =
663 * ¥ª¥Ö¥¸¥§¥¯¥È´ðËÜÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
666 static cptr k_info_flags[] =
763 "XXX3", /* Fake flag for Smith */
764 "XXX4", /* Fake flag for Smith */
814 * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
817 static cptr k_info_gen_flags[] =
854 * ¥À¥ó¥¸¥ç¥óÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
857 static cptr d_info_flags1[] =
895 * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò¥Æ¥¥¹¥È¤È¤·¤ÆÊݴɤ¹¤ë /
896 * Add a text to the text-storage and store offset to it.
897 * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
898 * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
899 * @param buf ÊÝ´Éʸ»úÎó
900 * @param normal_text ¥Æ¥¥¹¥È¤ÎÀµµ¬²½¤ò¹Ô¤¦
902 * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
903 * Returns FALSE when there isn't enough space available to store
906 static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
908 /* Hack -- Verify space */
909 if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
915 /* Advance and save the text index */
916 *offset = ++head->text_size;
919 /* Additional text */
920 else if (normal_text)
923 * If neither the end of the last line nor
924 * the beginning of current line is not a space,
925 * fill up a space as a correct separator of two words.
927 if (head->text_size > 0 &&
929 (*(head->text_ptr + head->text_size - 1) != ' ') &&
930 ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
931 (buf[0] != ' ') && !iskanji(buf[0])
933 (*(head->text_ptr + head->text_size - 1) != ' ') &&
939 *(head->text_ptr + head->text_size) = ' ';
941 /* Advance the index */
946 /* Append chars to the text */
947 strcpy(head->text_ptr + head->text_size, buf);
949 /* Advance the index */
950 head->text_size += strlen(buf);
958 * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò̾Á°¤È¤·¤ÆÊݴɤ¹¤ë /
959 * Add a name to the name-storage and return an offset to it.
960 * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
961 * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
962 * @param buf ÊÝ´Éʸ»úÎó
964 * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
965 * Returns FALSE when there isn't enough space available to store
968 static bool add_name(u32b *offset, header *head, cptr buf)
970 /* Hack -- Verify space */
971 if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
977 /* Advance and save the name index */
978 *offset = ++head->name_size;
981 /* Append chars to the names */
982 strcpy(head->name_ptr + head->name_size, buf);
984 /* Advance the index */
985 head->name_size += strlen(buf);
993 * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò¥¿¥°¤È¤·¤ÆÊݴɤ¹¤ë /
994 * Add a tag to the tag-storage and return an offset to it.
995 * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
996 * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
997 * @param buf ÊÝ´Éʸ»úÎó
999 * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
1000 * Returns FALSE when there isn't enough space available to store
1003 static bool add_tag(s16b *offset, header *head, cptr buf)
1007 /* Search for an existing (fake) tag */
1008 for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
1011 if (streq(&head->tag_ptr[i], buf)) break;
1014 /* There was no existing tag */
1015 if (i >= head->tag_size)
1017 /* Hack -- Verify space */
1018 if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
1021 /* Append chars to the tags */
1022 strcpy(head->tag_ptr + head->tag_size, buf);
1024 /* Point the new tag */
1027 /* Advance the index */
1028 head->tag_size += strlen(buf) + 1;
1031 /* Return offset of the tag */
1040 * @brief ¥·¥ó¥Ü¥ë1ʸ»ú¤ò¥«¥é¡¼ID¤ËÊѹ¹¤¹¤ë /
1041 * Convert a "color letter" into an "actual" color
1042 * The colors are: dwsorgbuDWvyRGBU, as shown below
1043 * @param c ¥·¥ó¥Ü¥ëʸ»ú
1046 byte color_char_to_attr(char c)
1050 case 'd': return (TERM_DARK);
1051 case 'w': return (TERM_WHITE);
1052 case 's': return (TERM_SLATE);
1053 case 'o': return (TERM_ORANGE);
1054 case 'r': return (TERM_RED);
1055 case 'g': return (TERM_GREEN);
1056 case 'b': return (TERM_BLUE);
1057 case 'u': return (TERM_UMBER);
1059 case 'D': return (TERM_L_DARK);
1060 case 'W': return (TERM_L_WHITE);
1061 case 'v': return (TERM_VIOLET);
1062 case 'y': return (TERM_YELLOW);
1063 case 'R': return (TERM_L_RED);
1064 case 'G': return (TERM_L_GREEN);
1065 case 'B': return (TERM_L_BLUE);
1066 case 'U': return (TERM_L_UMBER);
1074 /*** Initialize from ascii template files ***/
1078 * @brief ¥Ñ¡¼¥¹´Ø¿ô¤Ë´ð¤Å¤¤¤Æ¥Ç¡¼¥¿¥Õ¥¡¥¤¥ë¤«¤é¥Ç¡¼¥¿¤òÆɤ߼è¤ë /
1079 * Initialize an "*_info" array, by parsing an ascii "template" file
1080 * @param fp Æɤ߼è¤ê¤Ë»È¤¦¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿
1081 * @param buf Æɤ߼è¤ê¤Ë»È¤¦¥Ð¥Ã¥Õ¥¡Îΰè
1082 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1083 * @param parse_info_txt_line ¥Ñ¡¼¥¹´Ø¿ô
1084 * @return ¥¨¥é¡¼¥³¡¼¥É
1086 errr init_info_txt(FILE *fp, char *buf, header *head,
1087 parse_info_txt_func parse_info_txt_line)
1091 /* Just before the first record */
1094 /* Just before the first line */
1098 /* Prepare the "fake" stuff */
1099 head->name_size = 0;
1100 head->text_size = 0;
1104 while (0 == my_fgets(fp, buf, 1024))
1106 /* Advance the line number */
1109 /* Skip comments and blank lines */
1110 if (!buf[0] || (buf[0] == '#')) continue;
1112 /* Verify correct "colon" format */
1113 if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
1116 /* Hack -- Process 'V' for "Version" */
1123 /* Mega Hack -- Calculate Check Sum */
1124 if (buf[0] != 'N' && buf[0] != 'D')
1127 for (i = 0; buf[i]; i++)
1129 head->v_extra += (byte)buf[i];
1130 head->v_extra ^= (1 << (i % 8));
1134 /* Parse the line */
1135 if ((err = (*parse_info_txt_line)(buf, head)) != 0)
1140 /* Complete the "name" and "text" sizes */
1141 if (head->name_size) head->name_size++;
1142 if (head->text_size) head->text_size++;
1150 * @brief Vault¾ðÊó(v_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
1151 * Initialize the "v_info" array, by parsing an ascii "template" file
1152 * @param buf ¥Æ¥¥¹¥ÈÎó
1153 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1154 * @return ¥¨¥é¡¼¥³¡¼¥É
1156 errr parse_v_info(char *buf, header *head)
1162 static vault_type *v_ptr = NULL;
1164 /* Process 'N' for "New/Number/Name" */
1167 /* Find the colon before the name */
1168 s = my_strchr(buf+2, ':');
1170 /* Verify that colon */
1173 /* Nuke the colon, advance to the name */
1176 /* Paranoia -- require a name */
1177 if (!*s) return (1);
1182 /* Verify information */
1183 if (i <= error_idx) return (4);
1185 /* Verify information */
1186 if (i >= head->info_num) return (2);
1188 /* Save the index */
1191 /* Point at the "info" */
1194 /* Store the name */
1195 if (!add_name(&v_ptr->name, head, s)) return (7);
1198 /* There better be a current v_ptr */
1199 else if (!v_ptr) return (3);
1201 /* Process 'D' for "Description" */
1202 else if (buf[0] == 'D')
1204 /* Acquire the text */
1207 /* Store the text */
1208 if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
1211 /* Process 'X' for "Extra info" (one line only) */
1212 else if (buf[0] == 'X')
1214 int typ, rat, hgt, wid;
1216 /* Scan for the values */
1217 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1218 &typ, &rat, &hgt, &wid)) return (1);
1220 /* Save the values */
1236 * @brief ¿¦¶Èµ»Ç½¾ðÊó(s_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
1237 * Initialize the "s_info" array, by parsing an ascii "template" file
1238 * @param buf ¥Æ¥¥¹¥ÈÎó
1239 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1240 * @return ¥¨¥é¡¼¥³¡¼¥É
1242 errr parse_s_info(char *buf, header *head)
1247 static skill_table *s_ptr = NULL;
1250 /* Process 'N' for "New/Number/Name" */
1256 /* Verify information */
1257 if (i <= error_idx) return (4);
1259 /* Verify information */
1260 if (i >= head->info_num) return (2);
1262 /* Save the index */
1265 /* Point at the "info" */
1269 /* There better be a current s_ptr */
1270 else if (!s_ptr) return (3);
1272 /* Process 'W' for "Weapon exp" */
1273 else if (buf[0] == 'W')
1275 int tval, sval, start, max;
1276 const s16b exp_conv_table[] =
1278 WEAPON_EXP_UNSKILLED, WEAPON_EXP_BEGINNER, WEAPON_EXP_SKILLED,
1279 WEAPON_EXP_EXPERT, WEAPON_EXP_MASTER
1282 /* Scan for the values */
1283 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1284 &tval, &sval, &start, &max)) return (1);
1286 if (start < EXP_LEVEL_UNSKILLED || start > EXP_LEVEL_MASTER
1287 || max < EXP_LEVEL_UNSKILLED || max > EXP_LEVEL_MASTER) return (8);
1289 /* Save the values */
1290 s_ptr->w_start[tval][sval] = exp_conv_table[start];
1291 s_ptr->w_max[tval][sval] = exp_conv_table[max];
1294 /* Process 'S' for "Skill exp" */
1295 else if (buf[0] == 'S')
1297 int num, start, max;
1299 /* Scan for the values */
1300 if (3 != sscanf(buf+2, "%d:%d:%d",
1301 &num, &start, &max)) return (1);
1303 if (start < WEAPON_EXP_UNSKILLED || start > WEAPON_EXP_MASTER
1304 || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8);
1306 /* Save the values */
1307 s_ptr->s_start[num] = start;
1308 s_ptr->s_max[num] = max;
1321 * @brief ¿¦¶ÈËâË¡¾ðÊó(m_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
1322 * Initialize the "m_info" array, by parsing an ascii "template" file
1323 * @param buf ¥Æ¥¥¹¥ÈÎó
1324 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1325 * @return ¥¨¥é¡¼¥³¡¼¥É
1327 errr parse_m_info(char *buf, header *head)
1334 static player_magic *m_ptr = NULL;
1337 static int realm, magic_idx = 0, readable = 0;
1340 /* Process 'N' for "New/Number/Name" */
1346 /* Verify information */
1347 if (i <= error_idx) return (4);
1349 /* Verify information */
1350 if (i >= head->info_num) return (2);
1352 /* Save the index */
1355 /* Point at the "info" */
1359 /* There better be a current m_ptr */
1360 else if (!m_ptr) return (3);
1362 /* Process 'I' for "Info" (one line only) */
1363 else if (buf[0] == 'I')
1366 int xtra, type, first, weight;
1368 /* Find the colon before the name */
1369 s = my_strchr(buf+2, ':');
1371 /* Verify that colon */
1374 /* Nuke the colon, advance to the name */
1379 if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
1380 else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
1381 else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
1382 else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
1383 else if (streq(book, "NONE")) m_ptr->spell_book = 0;
1388 /* Find the colon before the name */
1389 s = my_strchr(s, ':');
1391 /* Verify that colon */
1394 /* Nuke the colon, advance to the name */
1397 if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
1398 else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
1399 else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
1400 else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
1401 else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
1402 else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
1406 /* Scan for the values */
1407 if (4 != sscanf(s, "%x:%d:%d:%d",
1408 (uint *)&xtra, &type, &first, &weight)) return (1);
1410 m_ptr->spell_xtra = xtra;
1411 m_ptr->spell_type = type;
1412 m_ptr->spell_first = first;
1413 m_ptr->spell_weight = weight;
1417 /* Process 'R' for "Realm" (one line only) */
1418 else if (buf[0] == 'R')
1420 /* Scan for the values */
1421 if (2 != sscanf(buf+2, "%d:%d",
1422 &realm, &readable)) return (1);
1427 else if (buf[0] == 'T')
1429 int level, mana, fail, exp;
1431 if (!readable) return (1);
1432 /* Scan for the values */
1433 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
1434 &level, &mana, &fail, &exp)) return (1);
1436 m_ptr->info[realm][magic_idx].slevel = level;
1437 m_ptr->info[realm][magic_idx].smana = mana;
1438 m_ptr->info[realm][magic_idx].sfail = fail;
1439 m_ptr->info[realm][magic_idx].sexp = exp;
1453 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(ÈÆÍÑ) /
1454 * Grab one flag from a textual string
1455 * @param flags ¥Ó¥Ã¥È¥Õ¥é¥°¤òÄɲ乤ëÀè¤Î»²¾È¥Ý¥¤¥ó¥¿
1456 * @param names ¥È¡¼¥¯¥óÄêµÁÇÛÎó
1457 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
1458 * @return ¥¨¥é¡¼¥³¡¼¥É
1460 static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
1465 for (i = 0; i < 32; i++)
1467 if (streq(what, names[i]))
1469 *flags |= (1L << i);
1479 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë¡ÊÃÏ·Á¾ðÊó¸þ¤±¡Ë /
1480 * Grab one flag in an feature_type from a textual string
1481 * @param f_ptr ÃÏ·Á¾ðÊó¤òÊݴɤ¹¤ëÀè¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1482 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
1483 * @return ¥¨¥é¡¼¥³¡¼¥É
1485 static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
1490 for (i = 0; i < FF_FLAG_MAX; i++)
1492 if (streq(what, f_info_flags[i]))
1494 add_flag(f_ptr->flags, i);
1501 msg_format("̤ÃΤÎÃÏ·Á¥Õ¥é¥° '%s'¡£", what);
1503 msg_format("Unknown feature flag '%s'.", what);
1507 return PARSE_ERROR_GENERIC;
1512 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°(¥¹¥Æ¡¼¥È)¤ò°ì¤ÄÆÀ¤ë¡ÊÃÏ·Á¾ðÊó¸þ¤±2¡Ë /
1513 * Grab an action in an feature_type from a textual string
1514 * @param f_ptr ÃÏ·Á¾ðÊó¤òÊݴɤ¹¤ëÀè¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1515 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
1516 * @param count ¥¹¥Æ¡¼¥È¤ÎÊݸÀèID
1517 * @return ¥¨¥é¡¼¥³¡¼¥É
1519 static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
1524 for (i = 0; i < FF_FLAG_MAX; i++)
1526 if (streq(what, f_info_flags[i]))
1528 f_ptr->state[count].action = i;
1535 msg_format("̤ÃΤÎÃÏ·Á¥¢¥¯¥·¥ç¥ó '%s'¡£", what);
1537 msg_format("Unknown feature action '%s'.", what);
1541 return PARSE_ERROR_GENERIC;
1546 * @brief ÃÏ·Á¾ðÊó(f_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
1547 * Initialize the "f_info" array, by parsing an ascii "template" file
1548 * @param buf ¥Æ¥¥¹¥ÈÎó
1549 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1550 * @return ¥¨¥é¡¼¥³¡¼¥É
1552 errr parse_f_info(char *buf, header *head)
1559 static feature_type *f_ptr = NULL;
1562 /* Process 'N' for "New/Number/Name" */
1565 /* Find the colon before the name */
1566 s = my_strchr(buf+2, ':');
1570 /* Nuke the colon, advance to the name */
1577 /* Verify information */
1578 if (i <= error_idx) return (4);
1580 /* Verify information */
1581 if (i >= head->info_num) return (2);
1583 /* Save the index */
1586 /* Point at the "info" */
1589 /* Tag name is given */
1593 if (!add_tag(&f_ptr->tag, head, s)) return (7);
1596 /* Default "mimic" */
1599 /* Default "destroyed state" -- if not specified */
1600 f_ptr->destroyed = i;
1602 /* Default "states" */
1603 for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
1606 /* There better be a current f_ptr */
1607 else if (!f_ptr) return (3);
1610 else if (buf[0] == 'J')
1612 /* Store the name */
1613 if (!add_name(&f_ptr->name, head, buf+2)) return (7);
1616 else if (buf[0] == 'E')
1618 /* Ignore english name */
1621 else if (buf[0] == 'J')
1623 /* Ignore Japanese name */
1626 else if (buf[0] == 'E')
1628 /* Acquire the Text */
1631 /* Store the name */
1632 if (!add_name(&f_ptr->name, head, s)) return (7);
1637 /* Process 'M' for "Mimic" (one line only) */
1638 else if (buf[0] == 'M')
1642 if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
1644 /* Record a fake tag index */
1645 f_ptr->mimic = -offset;
1649 /* Process 'G' for "Graphics" (one line only) */
1650 else if (buf[0] == 'G')
1654 char char_tmp[F_LIT_MAX];
1657 if (buf[1] != ':') return (1);
1658 if (!buf[2]) return (1);
1659 if (buf[3] != ':') return (1);
1660 if (!buf[4]) return (1);
1662 /* Extract the char */
1663 char_tmp[F_LIT_STANDARD] = buf[2];
1665 /* Extract the color */
1666 s_attr = color_char_to_attr(buf[4]);
1669 if (s_attr > 127) return (1);
1671 /* Save the standard values */
1672 f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
1673 f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
1675 /* Is this feature supports lighting? */
1678 /* G:c:a:LIT (default) */
1679 apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
1681 /* G:c:a:lc:la:dc:da */
1682 if (!streq(buf + 6, "LIT"))
1684 char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
1686 if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
1687 &char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
1688 &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
1689 if (buf[F_LIT_MAX * 4 + 1]) return 1;
1691 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1693 switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
1696 /* Use default lighting */
1699 /* No lighting support */
1700 f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
1703 /* Extract the color */
1704 f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
1705 if (f_ptr->d_attr[j] > 127) return 1;
1708 f_ptr->d_char[j] = char_tmp[j];
1714 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
1716 f_ptr->d_attr[j] = s_attr;
1717 f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
1723 /* Hack -- Process 'F' for flags */
1724 else if (buf[0] == 'F')
1726 /* Parse every entry textually */
1727 for (s = buf + 2; *s; )
1729 /* Find the end of this entry */
1730 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
1732 /* Nuke and skip any dividers */
1736 while (*t == ' ' || *t == '|') t++;
1739 /* XXX XXX XXX Hack -- Read feature subtype */
1740 if (1 == sscanf(s, "SUBTYPE_%d", &i))
1742 /* Extract a "subtype" */
1745 /* Start at next entry */
1752 /* XXX XXX XXX Hack -- Read feature power */
1753 if (1 == sscanf(s, "POWER_%d", &i))
1755 /* Extract a "power" */
1758 /* Start at next entry */
1765 /* Parse this entry */
1766 if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
1768 /* Start the next entry */
1773 /* Process 'W' for "More Info" (one line only) */
1774 else if (buf[0] == 'W')
1778 /* Scan for the value */
1779 if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
1781 /* Save the value */
1782 f_ptr->priority = priority;
1785 /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
1786 else if (buf[0] == 'K')
1790 /* Find the next empty state slot (if any) */
1791 for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
1793 /* Oops, no more slots */
1794 if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
1796 /* Analyze the first field */
1797 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
1799 /* Terminate the field (if necessary) */
1800 if (*t == ':') *t++ = '\0';
1802 /* Is this default entry? */
1803 if (streq(s, "DESTROYED"))
1805 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1807 /* Record a fake tag index */
1808 f_ptr->destroyed = -offset;
1813 f_ptr->state[i].action = 0;
1815 /* Parse this entry */
1816 if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
1818 if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
1820 /* Record a fake tag index */
1821 f_ptr->state[i].result = -offset;
1834 * @brief ÃÏ·Á¥¿¥°¤«¤éID¤òÆÀ¤ë /
1835 * Convert a fake tag to a real feat index
1836 * @param str ¥¿¥°Ê¸»úÎó
1839 s16b f_tag_to_index(cptr str)
1843 /* Search for real index corresponding to this fake tag */
1844 for (i = 0; i < f_head.info_num; i++)
1846 if (streq(f_tag + f_info[i].tag, str))
1848 /* Return the index */
1859 * @brief ÃÏ·Á¥¿¥°¤«¤éID¤òÆÀ¤ë /
1860 * Search for real index corresponding to this fake tag
1861 * @param feat ¥¿¥°Ê¸»úÎó
1864 static void search_real_feat(s16b *feat)
1868 /* Don't convert non-fake tag */
1869 if (*feat >= 0) return;
1871 /* Search for real index corresponding to this fake tag */
1872 for (i = 0; i < f_head.info_num; i++)
1874 if ((-(*feat)) == f_info[i].tag)
1876 /* Record real index */
1884 msg_format("̤ÄêµÁ¤Î¥¿¥° '%s'¡£", f_tag + (-(*feat)));
1886 msg_format("%s is undefined.", f_tag + (-(*feat)));
1892 * @brief ÃÏ·Á¾ðÊó¤Î³Æ¼ï¥¿¥°¤«¤éID¤ØÊÑ´¹¤·¤Æ·ë²Ì¤ò¼ý¤á¤ë /
1893 * Retouch fake tags of f_info
1894 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1897 void retouch_f_info(header *head)
1901 /* Convert fake tags to real feat indices */
1902 for (i = 0; i < head->info_num; i++)
1904 feature_type *f_ptr = &f_info[i];
1907 search_real_feat(&f_ptr->mimic);
1909 search_real_feat(&f_ptr->destroyed);
1911 for (j = 0; j < MAX_FEAT_STATES; j++) search_real_feat(&f_ptr->state[j].result);
1917 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥Ù¡¼¥¹¥¢¥¤¥Æ¥àÍÑ) /
1918 * Grab one flag in an object_kind from a textual string
1919 * @param k_ptr ÊÝ´ÉÀè¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1920 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
1921 * @return ¥¨¥é¡¼¥³¡¼¥É
1923 static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
1928 for (i = 0; i < TR_FLAG_MAX; i++)
1930 if (streq(what, k_info_flags[i]))
1932 add_flag(k_ptr->flags, i);
1937 if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
1942 msg_format("̤ÃΤΥ¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
1944 msg_format("Unknown object flag '%s'.", what);
1953 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(ȯưǽÎÏÍÑ) /
1954 * Grab one activation index flag
1955 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
1956 * @return ȯưǽÎÏID
1958 static byte grab_one_activation_flag(cptr what)
1964 if (activation_info[i].flag == NULL) break;
1966 if (streq(what, activation_info[i].flag))
1968 return activation_info[i].index;
1980 msg_format("̤ÃΤÎȯư¡¦¥Õ¥é¥° '%s'¡£", what);
1982 msg_format("Unknown activation flag '%s'.", what);
1991 * @brief ¥Ù¡¼¥¹¥¢¥¤¥Æ¥à(k_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
1992 * Initialize the "k_info" array, by parsing an ascii "template" file
1993 * @param buf ¥Æ¥¥¹¥ÈÎó
1994 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
1995 * @return ¥¨¥é¡¼¥³¡¼¥É
1997 errr parse_k_info(char *buf, header *head)
2004 static object_kind *k_ptr = NULL;
2007 /* Process 'N' for "New/Number/Name" */
2014 /* Find the colon before the name */
2015 s = my_strchr(buf+2, ':');
2017 /* Verify that colon */
2020 /* Nuke the colon, advance to the name */
2026 /* Verify information */
2027 if (i <= error_idx) return (4);
2029 /* Verify information */
2030 if (i >= head->info_num) return (2);
2032 /* Save the index */
2035 /* Point at the "info" */
2039 /* Paranoia -- require a name */
2040 if (!*s) return (1);
2042 /* Find the colon before the flavor */
2043 flavor = my_strchr(s, ':');
2045 /* Verify that colon */
2048 /* Nuke the colon, advance to the flavor */
2051 /* Store the flavor */
2052 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2055 /* Store the name */
2056 if (!add_name(&k_ptr->name, head, s)) return (7);
2060 /* There better be a current k_ptr */
2061 else if (!k_ptr) return (3);
2065 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2066 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
2067 else if (buf[0] == 'E')
2072 else if (buf[0] == 'E')
2076 /* Acquire the name */
2079 /* Find the colon before the flavor */
2080 flavor = my_strchr(s, ':');
2082 /* Verify that colon */
2085 /* Nuke the colon, advance to the flavor */
2088 /* Store the flavor */
2089 if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
2092 /* Store the name */
2093 if (!add_name(&k_ptr->name, head, s)) return (7);
2097 /* Process 'D' for "Description" */
2098 else if (buf[0] == 'D')
2103 /* Acquire the text */
2108 /* Acquire the text */
2112 /* Store the text */
2113 if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
2116 /* Process 'G' for "Graphics" (one line only) */
2117 else if (buf[0] == 'G')
2123 if (buf[1] != ':') return (1);
2124 if (!buf[2]) return (1);
2125 if (buf[3] != ':') return (1);
2126 if (!buf[4]) return (1);
2128 /* Extract the char */
2131 /* Extract the attr */
2132 tmp = color_char_to_attr(buf[4]);
2135 if (tmp > 127) return (1);
2137 /* Save the values */
2138 k_ptr->d_attr = tmp;
2139 k_ptr->d_char = sym;
2142 /* Process 'I' for "Info" (one line only) */
2143 else if (buf[0] == 'I')
2145 int tval, sval, pval;
2147 /* Scan for the values */
2148 if (3 != sscanf(buf+2, "%d:%d:%d",
2149 &tval, &sval, &pval)) return (1);
2151 /* Save the values */
2157 /* Process 'W' for "More Info" (one line only) */
2158 else if (buf[0] == 'W')
2160 int level, extra, wgt;
2163 /* Scan for the values */
2164 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2165 &level, &extra, &wgt, &cost)) return (1);
2167 /* Save the values */
2168 k_ptr->level = level;
2169 k_ptr->extra = extra;
2170 k_ptr->weight = wgt;
2174 /* Process 'A' for "Allocation" (one line only) */
2175 else if (buf[0] == 'A')
2179 /* XXX XXX XXX Simply read each number following a colon */
2180 for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
2182 /* Default chance */
2183 k_ptr->chance[i] = 1;
2185 /* Store the attack damage index */
2186 k_ptr->locale[i] = atoi(s+1);
2188 /* Find the slash */
2189 t = my_strchr(s+1, '/');
2191 /* Find the next colon */
2192 s = my_strchr(s+1, ':');
2194 /* If the slash is "nearby", use it */
2195 if (t && (!s || t < s))
2197 int chance = atoi(t+1);
2198 if (chance > 0) k_ptr->chance[i] = chance;
2203 /* Hack -- Process 'P' for "power" and such */
2204 else if (buf[0] == 'P')
2206 int ac, hd1, hd2, th, td, ta;
2208 /* Scan for the values */
2209 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2210 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2220 /* Hack -- Process 'U' for activation index */
2221 else if (buf[0] == 'U')
2224 n = grab_one_activation_flag(buf + 2);
2235 /* Hack -- Process 'F' for flags */
2236 else if (buf[0] == 'F')
2238 /* Parse every entry textually */
2239 for (s = buf + 2; *s; )
2241 /* Find the end of this entry */
2242 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2244 /* Nuke and skip any dividers */
2248 while (*t == ' ' || *t == '|') t++;
2251 /* Parse this entry */
2252 if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
2254 /* Start the next entry */
2269 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥ÈÍÑ) /
2270 * Grab one activation index flag
2271 * @param a_ptr ÊÝ´ÉÀè¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2272 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
2273 * @return ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç1¡¢¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç0¤òÊÖ¤¹
2275 static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
2280 for (i = 0; i < TR_FLAG_MAX; i++)
2282 if (streq(what, k_info_flags[i]))
2284 add_flag(a_ptr->flags, i);
2289 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
2294 msg_format("̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
2296 msg_format("Unknown artifact flag '%s'.", what);
2306 * @brief ¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¾ðÊó(a_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
2307 * Initialize the "a_info" array, by parsing an ascii "template" file
2308 * @param buf ¥Æ¥¥¹¥ÈÎó
2309 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
2310 * @return ¥¨¥é¡¼¥³¡¼¥É
2312 errr parse_a_info(char *buf, header *head)
2319 static artifact_type *a_ptr = NULL;
2322 /* Process 'N' for "New/Number/Name" */
2325 /* Find the colon before the name */
2326 s = my_strchr(buf+2, ':');
2328 /* Verify that colon */
2331 /* Nuke the colon, advance to the name */
2334 /* Paranoia -- require a name */
2335 if (!*s) return (1);
2340 /* Verify information */
2341 if (i < error_idx) return (4);
2343 /* Verify information */
2344 if (i >= head->info_num) return (2);
2346 /* Save the index */
2349 /* Point at the "info" */
2352 /* Ignore everything */
2353 add_flag(a_ptr->flags, TR_IGNORE_ACID);
2354 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
2355 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
2356 add_flag(a_ptr->flags, TR_IGNORE_COLD);
2358 /* Store the name */
2359 if (!add_name(&a_ptr->name, head, s)) return (7);
2363 /* There better be a current a_ptr */
2364 else if (!a_ptr) return (3);
2368 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2369 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
2370 else if (buf[0] == 'E')
2375 else if (buf[0] == 'E')
2377 /* Acquire the Text */
2380 /* Store the name */
2381 if (!add_name(&a_ptr->name, head, s)) return (7);
2385 /* Process 'D' for "Description" */
2386 else if (buf[0] == 'D')
2391 /* Acquire the text */
2396 /* Acquire the text */
2400 /* Store the text */
2401 if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
2405 /* Process 'I' for "Info" (one line only) */
2406 else if (buf[0] == 'I')
2408 int tval, sval, pval;
2410 /* Scan for the values */
2411 if (3 != sscanf(buf+2, "%d:%d:%d",
2412 &tval, &sval, &pval)) return (1);
2414 /* Save the values */
2420 /* Process 'W' for "More Info" (one line only) */
2421 else if (buf[0] == 'W')
2423 int level, rarity, wgt;
2426 /* Scan for the values */
2427 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2428 &level, &rarity, &wgt, &cost)) return (1);
2430 /* Save the values */
2431 a_ptr->level = level;
2432 a_ptr->rarity = rarity;
2433 a_ptr->weight = wgt;
2437 /* Hack -- Process 'P' for "power" and such */
2438 else if (buf[0] == 'P')
2440 int ac, hd1, hd2, th, td, ta;
2442 /* Scan for the values */
2443 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2444 &ac, &hd1, &hd2, &th, &td, &ta)) return (1);
2454 /* Hack -- Process 'U' for activation index */
2455 else if (buf[0] == 'U')
2458 n = grab_one_activation_flag(buf + 2);
2469 /* Hack -- Process 'F' for flags */
2470 else if (buf[0] == 'F')
2472 /* Parse every entry textually */
2473 for (s = buf + 2; *s; )
2475 /* Find the end of this entry */
2476 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2478 /* Nuke and skip any dividers */
2482 while ((*t == ' ') || (*t == '|')) t++;
2485 /* Parse this entry */
2486 if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
2488 /* Start the next entry */
2504 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥ÈÍÑ) /
2505 * Grab one flag in a ego-item_type from a textual string
2506 * @param e_ptr ÊÝ´ÉÀè¤Î¥¨¥´¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2507 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
2508 * @return ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç1¡¢¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç0¤òÊÖ¤¹
2510 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
2515 for (i = 0; i < TR_FLAG_MAX; i++)
2517 if (streq(what, k_info_flags[i]))
2519 add_flag(e_ptr->flags, i);
2524 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
2529 msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
2531 msg_format("Unknown ego-item flag '%s'.", what);
2541 * @brief ¥¢¥¤¥Æ¥à¥¨¥´¾ðÊó(e_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
2542 * Initialize the "e_info" array, by parsing an ascii "template" file
2543 * @param buf ¥Æ¥¥¹¥ÈÎó
2544 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
2545 * @return ¥¨¥é¡¼¥³¡¼¥É
2547 errr parse_e_info(char *buf, header *head)
2554 static ego_item_type *e_ptr = NULL;
2557 /* Just before the first record */
2560 /* Just before the first line */
2564 /* Process 'N' for "New/Number/Name" */
2567 /* Find the colon before the name */
2568 s = my_strchr(buf+2, ':');
2570 /* Verify that colon */
2573 /* Nuke the colon, advance to the name */
2576 /* Paranoia -- require a name */
2577 if (!*s) return (1);
2582 /* Verify information */
2583 if (i < error_idx) return (4);
2585 /* Verify information */
2586 if (i >= head->info_num) return (2);
2588 /* Save the index */
2591 /* Point at the "info" */
2594 /* Store the name */
2595 if (!add_name(&e_ptr->name, head, s)) return (7);
2599 /* There better be a current e_ptr */
2600 else if (!e_ptr) return (3);
2604 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2605 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
2606 else if (buf[0] == 'E')
2611 else if (buf[0] == 'E')
2613 /* Acquire the Text */
2616 /* Store the name */
2617 if (!add_name(&e_ptr->name, head, s)) return (7);
2622 /* Process 'D' for "Description" */
2623 else if (buf[0] == 'D')
2625 /* Acquire the text */
2628 /* Store the text */
2629 if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
2634 /* Process 'X' for "Xtra" (one line only) */
2635 else if (buf[0] == 'X')
2639 /* Scan for the values */
2640 if (2 != sscanf(buf+2, "%d:%d",
2641 &slot, &rating)) return (1);
2643 /* Save the values */
2645 e_ptr->rating = rating;
2648 /* Process 'W' for "More Info" (one line only) */
2649 else if (buf[0] == 'W')
2651 int level, rarity, pad2;
2654 /* Scan for the values */
2655 if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
2656 &level, &rarity, &pad2, &cost)) return (1);
2658 /* Save the values */
2659 e_ptr->level = level;
2660 e_ptr->rarity = rarity;
2661 /* e_ptr->weight = wgt; */
2665 /* Hack -- Process 'C' for "creation" */
2666 else if (buf[0] == 'C')
2670 /* Scan for the values */
2671 if (4 != sscanf(buf+2, "%d:%d:%d:%d",
2672 &th, &td, &ta, &pv)) return (1);
2674 e_ptr->max_to_h = th;
2675 e_ptr->max_to_d = td;
2676 e_ptr->max_to_a = ta;
2677 e_ptr->max_pval = pv;
2680 /* Hack -- Process 'U' for activation index */
2681 else if (buf[0] == 'U')
2684 n = grab_one_activation_flag(buf + 2);
2695 /* Hack -- Process 'F' for flags */
2696 else if (buf[0] == 'F')
2698 /* Parse every entry textually */
2699 for (s = buf + 2; *s; )
2701 /* Find the end of this entry */
2702 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
2704 /* Nuke and skip any dividers */
2708 while ((*t == ' ') || (*t == '|')) t++;
2711 /* Parse this entry */
2712 if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
2714 /* Start the next entry */
2728 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼ÍÑ1) /
2729 * Grab one (basic) flag in a monster_race from a textual string
2730 * @param r_ptr ÊÝ´ÉÀè¤Î¥â¥ó¥¹¥¿¡¼¼ï²¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2731 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
2732 * @return ¥¨¥é¡¼¥³¡¼¥É
2734 static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
2736 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
2739 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
2742 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
2745 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
2748 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
2751 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
2754 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
2759 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2761 msg_format("Unknown monster flag '%s'.", what);
2771 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼ÍÑ2) /
2772 * Grab one (spell) flag in a monster_race from a textual string
2773 * @param r_ptr ÊÝ´ÉÀè¤Î¥â¥ó¥¹¥¿¡¼¼ï²¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2774 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
2775 * @return ¥¨¥é¡¼¥³¡¼¥É
2777 static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
2779 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
2782 if (grab_one_flag(&r_ptr->flags5, r_info_flags5, what) == 0)
2785 if (grab_one_flag(&r_ptr->flags6, r_info_flags6, what) == 0)
2790 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
2792 msg_format("Unknown monster flag '%s'.", what);
2802 * @brief ¥â¥ó¥¹¥¿¡¼¼ï²¾ðÊó(r_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
2803 * Initialize the "r_info" array, by parsing an ascii "template" file
2804 * @param buf ¥Æ¥¥¹¥ÈÎó
2805 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
2806 * @return ¥¨¥é¡¼¥³¡¼¥É
2808 errr parse_r_info(char *buf, header *head)
2815 static monster_race *r_ptr = NULL;
2818 /* Process 'N' for "New/Number/Name" */
2821 /* Find the colon before the name */
2822 s = my_strchr(buf+2, ':');
2824 /* Verify that colon */
2827 /* Nuke the colon, advance to the name */
2830 /* Paranoia -- require a name */
2831 if (!*s) return (1);
2836 /* Verify information */
2837 if (i < error_idx) return (4);
2839 /* Verify information */
2840 if (i >= head->info_num) return (2);
2842 /* Save the index */
2845 /* Point at the "info" */
2848 /* Store the name */
2849 if (!add_name(&r_ptr->name, head, s)) return (7);
2853 /* There better be a current r_ptr */
2854 else if (!r_ptr) return (3);
2858 /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
2859 /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
2860 else if (buf[0] == 'E')
2862 /* Acquire the Text */
2865 /* Store the name */
2866 if (!add_name(&r_ptr->E_name, head, s)) return (7);
2869 else if (buf[0] == 'E')
2871 /* Acquire the Text */
2874 /* Store the name */
2875 if (!add_name(&r_ptr->name, head, s)) return (7);
2878 /* Process 'D' for "Description" */
2879 else if (buf[0] == 'D')
2884 /* Acquire the text */
2889 /* Acquire the text */
2893 /* Store the text */
2894 if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
2897 /* Process 'G' for "Graphics" (one line only) */
2898 else if (buf[0] == 'G')
2904 if (buf[1] != ':') return (1);
2905 if (!buf[2]) return (1);
2906 if (buf[3] != ':') return (1);
2907 if (!buf[4]) return (1);
2909 /* Extract the char */
2912 /* Extract the attr */
2913 tmp = color_char_to_attr(buf[4]);
2916 if (tmp > 127) return (1);
2918 /* Save the values */
2919 r_ptr->d_char = sym;
2920 r_ptr->d_attr = tmp;
2923 /* Process 'I' for "Info" (one line only) */
2924 else if (buf[0] == 'I')
2926 int spd, hp1, hp2, aaf, ac, slp;
2928 /* Scan for the other values */
2929 if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
2930 &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
2932 /* Save the values */
2934 r_ptr->hdice = MAX(hp1, 1);
2935 r_ptr->hside = MAX(hp2, 1);
2941 /* Process 'W' for "More Info" (one line only) */
2942 else if (buf[0] == 'W')
2949 /* Scan for the values */
2950 if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
2951 &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
2953 /* Save the values */
2955 r_ptr->rarity = rar;
2958 r_ptr->next_exp = nextexp;
2959 r_ptr->next_r_idx = nextmon;
2962 /* Process 'R' for "Reinforcement" (up to six lines) */
2963 else if (buf[0] == 'R')
2966 /* Find the next empty blow slot (if any) */
2967 for (i = 0; i < 6; i++) if (r_ptr->reinforce_id[i] == 0) break;
2969 /* Oops, no more slots */
2970 if (i == 6) return (1);
2972 /* Scan for the values */
2973 if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
2974 r_ptr->reinforce_id[i] = id;
2975 r_ptr->reinforce_dd[i] = dd;
2976 r_ptr->reinforce_ds[i] = ds;
2979 /* Process 'B' for "Blows" (up to four lines) */
2980 else if (buf[0] == 'B')
2984 /* Find the next empty blow slot (if any) */
2985 for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
2987 /* Oops, no more slots */
2988 if (i == 4) return (1);
2990 /* Analyze the first field */
2991 for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
2993 /* Terminate the field (if necessary) */
2994 if (*t == ':') *t++ = '\0';
2996 /* Analyze the method */
2997 for (n1 = 0; r_info_blow_method[n1]; n1++)
2999 if (streq(s, r_info_blow_method[n1])) break;
3002 /* Invalid method */
3003 if (!r_info_blow_method[n1]) return (1);
3005 /* Analyze the second field */
3006 for (s = t; *t && (*t != ':'); t++) /* loop */;
3008 /* Terminate the field (if necessary) */
3009 if (*t == ':') *t++ = '\0';
3011 /* Analyze effect */
3012 for (n2 = 0; r_info_blow_effect[n2]; n2++)
3014 if (streq(s, r_info_blow_effect[n2])) break;
3017 /* Invalid effect */
3018 if (!r_info_blow_effect[n2]) return (1);
3020 /* Analyze the third field */
3021 for (s = t; *t && (*t != 'd'); t++) /* loop */;
3023 /* Terminate the field (if necessary) */
3024 if (*t == 'd') *t++ = '\0';
3026 /* Save the method */
3027 r_ptr->blow[i].method = n1;
3029 /* Save the effect */
3030 r_ptr->blow[i].effect = n2;
3032 /* Extract the damage dice and sides */
3033 r_ptr->blow[i].d_dice = atoi(s);
3034 r_ptr->blow[i].d_side = atoi(t);
3037 /* Process 'F' for "Basic Flags" (multiple lines) */
3038 else if (buf[0] == 'F')
3040 /* Parse every entry */
3041 for (s = buf + 2; *s; )
3043 /* Find the end of this entry */
3044 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3046 /* Nuke and skip any dividers */
3050 while (*t == ' ' || *t == '|') t++;
3053 /* Parse this entry */
3054 if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
3056 /* Start the next entry */
3061 /* Process 'S' for "Spell Flags" (multiple lines) */
3062 else if (buf[0] == 'S')
3064 /* Parse every entry */
3065 for (s = buf + 2; *s; )
3067 /* Find the end of this entry */
3068 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3070 /* Nuke and skip any dividers */
3074 while ((*t == ' ') || (*t == '|')) t++;
3077 /* XXX XXX XXX Hack -- Read spell frequency */
3078 if (1 == sscanf(s, "1_IN_%d", &i))
3080 /* Extract a "frequency" */
3081 r_ptr->freq_spell = 100 / i;
3083 /* Start at next entry */
3090 /* Parse this entry */
3091 if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
3093 /* Start the next entry */
3108 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥À¥ó¥¸¥ç¥óÍÑ) /
3109 * Grab one flag for a dungeon type from a textual string
3110 * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3111 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
3112 * @return ¥¨¥é¡¼¥³¡¼¥É
3114 static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
3116 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
3121 msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
3123 msg_format("Unknown dungeon type flag '%s'.", what);
3131 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼¤Î¥À¥ó¥¸¥ç¥ó½Ð¸½¾ò·ïÍÑ1) /
3132 * Grab one (basic) flag in a monster_race from a textual string
3133 * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3134 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
3135 * @return ¥¨¥é¡¼¥³¡¼¥É
3137 static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
3139 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
3142 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
3145 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
3148 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
3151 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
3154 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
3157 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
3162 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
3164 msg_format("Unknown monster flag '%s'.", what);
3172 * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼¤Î¥À¥ó¥¸¥ç¥ó½Ð¸½¾ò·ïÍÑ2) /
3173 * Grab one (spell) flag in a monster_race from a textual string
3174 * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3175 * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
3176 * @return ¥¨¥é¡¼¥³¡¼¥É
3178 static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
3180 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
3183 if (grab_one_flag(&d_ptr->mflags5, r_info_flags5, what) == 0)
3186 if (grab_one_flag(&d_ptr->mflags6, r_info_flags6, what) == 0)
3191 msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
3193 msg_format("Unknown monster flag '%s'.", what);
3201 * @brief ¥À¥ó¥¸¥ç¥ó¾ðÊó(d_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
3202 * Initialize the "d_info" array, by parsing an ascii "template" file
3203 * @param buf ¥Æ¥¥¹¥ÈÎó
3204 * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
3205 * @return ¥¨¥é¡¼¥³¡¼¥É
3207 errr parse_d_info(char *buf, header *head)
3214 static dungeon_info_type *d_ptr = NULL;
3217 /* Process 'N' for "New/Number/Name" */
3220 /* Find the colon before the name */
3221 s = my_strchr(buf+2, ':');
3223 /* Verify that colon */
3226 /* Nuke the colon, advance to the name */
3229 /* Paranoia -- require a name */
3230 if (!*s) return (1);
3235 /* Verify information */
3236 if (i < error_idx) return (4);
3238 /* Verify information */
3239 if (i >= head->info_num) return (2);
3241 /* Save the index */
3244 /* Point at the "info" */
3247 /* Store the name */
3248 if (!add_name(&d_ptr->name, head, s)) return (7);
3253 else if (buf[0] == 'E') return (0);
3255 else if (buf[0] == 'E')
3257 /* Acquire the Text */
3260 /* Store the name */
3261 if (!add_name(&d_ptr->name, head, s)) return (7);
3265 /* Process 'D' for "Description */
3266 else if (buf[0] == 'D')
3271 /* Acquire the text */
3276 /* Acquire the text */
3280 /* Store the text */
3281 if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
3284 /* Process 'W' for "More Info" (one line only) */
3285 else if (buf[0] == 'W')
3287 int min_lev, max_lev;
3289 int min_alloc, max_chance;
3290 int obj_good, obj_great;
3293 /* Scan for the values */
3294 if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
3295 &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
3297 /* Save the values */
3298 d_ptr->mindepth = min_lev;
3299 d_ptr->maxdepth = max_lev;
3300 d_ptr->min_plev = min_plev;
3302 d_ptr->min_m_alloc_level = min_alloc;
3303 d_ptr->max_m_alloc_chance = max_chance;
3304 d_ptr->obj_good = obj_good;
3305 d_ptr->obj_great = obj_great;
3310 /* Process 'P' for "Place Info" */
3311 else if (buf[0] == 'P')
3315 /* Scan for the values */
3316 if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
3318 /* Save the values */
3323 /* Process 'L' for "fLoor type" (one line only) */
3324 else if (buf[0] == 'L')
3328 /* Scan for the values */
3329 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
3331 /* Save the values */
3332 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3334 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
3335 if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3337 d_ptr->floor[i].percent = atoi(zz[i * 2 + 1]);
3339 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3342 /* Process 'A' for "wAll type" (one line only) */
3343 else if (buf[0] == 'A')
3347 /* Scan for the values */
3348 if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
3350 /* Save the values */
3351 for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
3353 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
3354 if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3356 d_ptr->fill[i].percent = atoi(zz[i * 2 + 1]);
3359 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
3360 if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3362 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
3363 if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3365 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
3366 if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3368 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
3369 if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3372 /* Process 'F' for "Dungeon Flags" (multiple lines) */
3373 else if (buf[0] == 'F')
3375 int artif = 0, monst = 0;
3377 /* Parse every entry */
3378 for (s = buf + 2; *s; )
3380 /* Find the end of this entry */
3381 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3383 /* Nuke and skip any dividers */
3387 while (*t == ' ' || *t == '|') t++;
3390 /* XXX XXX XXX Hack -- Read Final Artifact */
3391 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
3393 /* Extract a "Final Artifact" */
3394 d_ptr->final_artifact = artif;
3396 /* Start at next entry */
3403 /* XXX XXX XXX Hack -- Read Final Object */
3404 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
3406 /* Extract a "Final Artifact" */
3407 d_ptr->final_object = artif;
3409 /* Start at next entry */
3416 /* XXX XXX XXX Hack -- Read Artifact Guardian */
3417 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
3419 /* Extract a "Artifact Guardian" */
3420 d_ptr->final_guardian = monst;
3422 /* Start at next entry */
3429 /* XXX XXX XXX Hack -- Read Special Percentage */
3430 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
3432 /* Extract a "Special %" */
3433 d_ptr->special_div = monst;
3435 /* Start at next entry */
3442 /* Parse this entry */
3443 if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
3445 /* Start the next entry */
3450 /* Process 'M' for "Basic Flags" (multiple lines) */
3451 else if (buf[0] == 'M')
3453 /* Parse every entry */
3454 for (s = buf + 2; *s; )
3456 /* Find the end of this entry */
3457 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3459 /* Nuke and skip any dividers */
3463 while (*t == ' ' || *t == '|') t++;
3466 /* Hack -- Read monster symbols */
3467 if (!strncmp(s, "R_CHAR_", 7))
3469 /* Skip "R_CHAR_" */
3473 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
3475 /* Start at next entry */
3482 /* Parse this entry */
3483 if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
3485 /* Start the next entry */
3490 /* Process 'S' for "Spell Flags" (multiple lines) */
3491 else if (buf[0] == 'S')
3493 /* Parse every entry */
3494 for (s = buf + 2; *s; )
3496 /* Find the end of this entry */
3497 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
3499 /* Nuke and skip any dividers */
3503 while ((*t == ' ') || (*t == '|')) t++;
3506 /* XXX XXX XXX Hack -- Read spell frequency */
3507 if (1 == sscanf(s, "1_IN_%d", &i))
3509 /* Start at next entry */
3516 /* Parse this entry */
3517 if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
3519 /* Start the next entry */
3532 #else /* ALLOW_TEMPLATES */
3538 #endif /* ALLOW_TEMPLATES */
3541 /* Random dungeon grid effects */
3542 #define RANDOM_NONE 0x00000000
3543 #define RANDOM_FEATURE 0x00000001
3544 #define RANDOM_MONSTER 0x00000002
3545 #define RANDOM_OBJECT 0x00000004
3546 #define RANDOM_EGO 0x00000008
3547 #define RANDOM_ARTIFACT 0x00000010
3548 #define RANDOM_TRAP 0x00000020
3551 typedef struct dungeon_grid dungeon_grid;
3555 int feature; /* Terrain feature */
3556 int monster; /* Monster */
3557 int object; /* Object */
3558 int ego; /* Ego-Item */
3559 int artifact; /* Artifact */
3560 int trap; /* Trap */
3561 int cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
3562 int special; /* Reserved for special terrain info */
3563 int random; /* Number of the random effect */
3567 static dungeon_grid letter[255];
3571 * @brief ÃÏ·Á¾ðÊó¤Î¡ÖF:¡×¾ðÊó¤ò¥Ñ¡¼¥¹¤¹¤ë
3572 * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
3573 * @param buf ²òÀÏʸ»úÎó
3574 * @return ¥¨¥é¡¼¥³¡¼¥É
3576 static errr parse_line_feature(char *buf)
3582 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3584 /* Tokenize the line */
3585 if ((num = tokenize(buf+2, 9, zz, 0)) > 1)
3587 /* Letter to assign */
3588 int index = zz[0][0];
3590 /* Reset the info for the letter */
3591 letter[index].feature = feat_none;
3592 letter[index].monster = 0;
3593 letter[index].object = 0;
3594 letter[index].ego = 0;
3595 letter[index].artifact = 0;
3596 letter[index].trap = feat_none;
3597 letter[index].cave_info = 0;
3598 letter[index].special = 0;
3599 letter[index].random = RANDOM_NONE;
3605 letter[index].special = atoi(zz[8]);
3609 if ((zz[7][0] == '*') && !zz[7][1])
3611 letter[index].random |= RANDOM_TRAP;
3615 letter[index].trap = f_tag_to_index(zz[7]);
3616 if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3621 if (zz[6][0] == '*')
3623 letter[index].random |= RANDOM_ARTIFACT;
3624 if (zz[6][1]) letter[index].artifact = atoi(zz[6] + 1);
3626 else if (zz[6][0] == '!')
3628 if (p_ptr->inside_quest)
3630 letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
3635 letter[index].artifact = atoi(zz[6]);
3640 if (zz[5][0] == '*')
3642 letter[index].random |= RANDOM_EGO;
3643 if (zz[5][1]) letter[index].ego = atoi(zz[5] + 1);
3647 letter[index].ego = atoi(zz[5]);
3652 if (zz[4][0] == '*')
3654 letter[index].random |= RANDOM_OBJECT;
3655 if (zz[4][1]) letter[index].object = atoi(zz[4] + 1);
3657 else if (zz[4][0] == '!')
3659 if (p_ptr->inside_quest)
3661 int a_idx = quest[p_ptr->inside_quest].k_idx;
3664 artifact_type *a_ptr = &a_info[a_idx];
3665 if (!(a_ptr->gen_flags & TRG_INSTA_ART))
3667 letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
3674 letter[index].object = atoi(zz[4]);
3679 if (zz[3][0] == '*')
3681 letter[index].random |= RANDOM_MONSTER;
3682 if (zz[3][1]) letter[index].monster = atoi(zz[3] + 1);
3684 else if (zz[3][0] == 'c')
3686 if (!zz[3][1]) return PARSE_ERROR_GENERIC;
3687 letter[index].monster = - atoi(zz[3] + 1);
3691 letter[index].monster = atoi(zz[3]);
3696 letter[index].cave_info = atoi(zz[2]);
3700 if ((zz[1][0] == '*') && !zz[1][1])
3702 letter[index].random |= RANDOM_FEATURE;
3706 letter[index].feature = f_tag_to_index(zz[1]);
3707 if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
3720 * @brief ÃÏ·Á¾ðÊó¤Î¡ÖB:¡×¾ðÊó¤ò¥Ñ¡¼¥¹¤¹¤ë
3721 * Process "B:<Index>:<Command>:..." -- Building definition
3722 * @param buf ²òÀÏʸ»úÎó
3723 * @return ¥¨¥é¡¼¥³¡¼¥É
3725 static errr parse_line_building(char *buf)
3741 /* Get the building number */
3744 /* Find the colon after the building number */
3745 s = my_strchr(s, ':');
3747 /* Verify that colon */
3750 /* Nuke the colon, advance to the sub-index */
3753 /* Paranoia -- require a sub-index */
3754 if (!*s) return (1);
3756 /* Building definition sub-index */
3759 /* Building name, owner, race */
3762 if (tokenize(s + 2, 3, zz, 0) == 3)
3764 /* Name of the building */
3765 strcpy(building[index].name, zz[0]);
3767 /* Name of the owner */
3768 strcpy(building[index].owner_name, zz[1]);
3770 /* Race of the owner */
3771 strcpy(building[index].owner_race, zz[2]);
3776 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3779 /* Building Action */
3782 if (tokenize(s + 2, 8, zz, 0) >= 7)
3784 /* Index of the action */
3785 int action_index = atoi(zz[0]);
3787 /* Name of the action */
3788 strcpy(building[index].act_names[action_index], zz[1]);
3790 /* Cost of the action for members */
3791 building[index].member_costs[action_index] = atoi(zz[2]);
3793 /* Cost of the action for non-members */
3794 building[index].other_costs[action_index] = atoi(zz[3]);
3796 /* Letter assigned to the action */
3797 building[index].letters[action_index] = zz[4][0];
3800 building[index].actions[action_index] = atoi(zz[5]);
3802 /* Action restriction */
3803 building[index].action_restr[action_index] = atoi(zz[6]);
3808 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3811 /* Building Classes */
3814 if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
3816 for (i = 0; i < MAX_CLASS; i++)
3818 building[index].member_class[i] = atoi(zz[i]);
3824 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3827 /* Building Races */
3830 if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
3832 for (i = 0; i < MAX_RACES; i++)
3834 building[index].member_race[i] = atoi(zz[i]);
3840 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3843 /* Building Realms */
3846 if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
3848 for (i = 0; i < MAX_MAGIC; i++)
3850 building[index].member_realm[i+1] = atoi(zz[i]);
3856 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
3861 /* Ignore scripts */
3867 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
3876 * @brief ¥Õ¥í¥¢¤Î½êÄê¤Î¥Þ¥¹¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤òÇÛÃÖ¤¹¤ë
3877 * Place the object j_ptr to a grid
3878 * @param j_ptr ¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
3879 * @param y ÇÛÃÖÀèYºÂɸ
3880 * @param x ÇÛÃÖÀèXºÂɸ
3881 * @return ¥¨¥é¡¼¥³¡¼¥É
3883 static void drop_here(object_type *j_ptr, int y, int x)
3885 cave_type *c_ptr = &cave[y][x];
3888 /* Get new object */
3889 s16b o_idx = o_pop();
3891 /* Access new object */
3892 o_ptr = &o_list[o_idx];
3894 /* Structure copy */
3895 object_copy(o_ptr, j_ptr);
3903 o_ptr->held_m_idx = 0;
3906 o_ptr->next_o_idx = c_ptr->o_idx;
3908 /* Place the object */
3909 c_ptr->o_idx = o_idx;
3914 * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥ó¤ò¥Õ¥í¥¢¤ËÀ¸À®¤¹¤ë
3915 * Parse a sub-file of the "extra info"
3917 * @param ymin ¾ÜºÙÉÔÌÀ
3918 * @param xmin ¾ÜºÙÉÔÌÀ
3919 * @param ymax ¾ÜºÙÉÔÌÀ
3920 * @param xmax ¾ÜºÙÉÔÌÀ
3923 * @return ¥¨¥é¡¼¥³¡¼¥É
3925 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
3932 /* Skip "empty" lines */
3933 if (!buf[0]) return (0);
3935 /* Skip "blank" lines */
3936 if (iswspace(buf[0])) return (0);
3939 if (buf[0] == '#') return (0);
3941 /* Require "?:*" format */
3942 if (buf[1] != ':') return (1);
3945 /* Process "%:<fname>" */
3948 /* Attempt to Process the given file */
3949 return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax));
3952 /* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid */
3955 return parse_line_feature(buf);
3958 /* Process "D:<dungeon>" -- info for the cave grids */
3959 else if (buf[0] == 'D')
3961 object_type object_type_body;
3963 /* Acquire the text */
3966 /* Length of the text */
3967 int len = strlen(s);
3969 if (init_flags & INIT_ONLY_BUILDINGS) return (0);
3971 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
3973 /* Access the grid */
3974 cave_type *c_ptr = &cave[*y][*x];
3978 int object_index = letter[idx].object;
3979 int monster_index = letter[idx].monster;
3980 int random = letter[idx].random;
3981 int artifact_index = letter[idx].artifact;
3983 /* Lay down a floor */
3984 c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
3986 /* Only the features */
3987 if (init_flags & INIT_ONLY_FEATURES) continue;
3990 c_ptr->info = letter[idx].cave_info;
3992 /* Create a monster */
3993 if (random & RANDOM_MONSTER)
3995 monster_level = base_level + monster_index;
3997 place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
3999 monster_level = base_level;
4001 else if (monster_index)
4003 int old_cur_num, old_max_num;
4006 if (monster_index < 0)
4008 monster_index = -monster_index;
4011 old_cur_num = r_info[monster_index].cur_num;
4012 old_max_num = r_info[monster_index].max_num;
4014 /* Make alive again */
4015 if (r_info[monster_index].flags1 & RF1_UNIQUE)
4017 r_info[monster_index].cur_num = 0;
4018 r_info[monster_index].max_num = 1;
4021 /* Make alive again */
4022 /* Hack -- Non-unique Nazguls are semi-unique */
4023 else if (r_info[monster_index].flags7 & RF7_NAZGUL)
4025 if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
4027 r_info[monster_index].max_num++;
4032 place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
4036 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4038 /* Make alive again for real unique monster */
4039 r_info[monster_index].cur_num = old_cur_num;
4040 r_info[monster_index].max_num = old_max_num;
4044 /* Object (and possible trap) */
4045 if ((random & RANDOM_OBJECT) && (random & RANDOM_TRAP))
4047 object_level = base_level + object_index;
4050 * Random trap and random treasure defined
4051 * 25% chance for trap and 75% chance for object
4053 if (randint0(100) < 75)
4055 place_object(*y, *x, 0L);
4062 object_level = base_level;
4064 else if (random & RANDOM_OBJECT)
4066 object_level = base_level + object_index;
4068 /* Create an out of deep object */
4069 if (randint0(100) < 75)
4070 place_object(*y, *x, 0L);
4071 else if (randint0(100) < 80)
4072 place_object(*y, *x, AM_GOOD);
4074 place_object(*y, *x, AM_GOOD | AM_GREAT);
4076 object_level = base_level;
4079 else if (random & RANDOM_TRAP)
4083 /* Hidden trap (or door) */
4084 else if (letter[idx].trap)
4086 c_ptr->mimic = c_ptr->feat;
4087 c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
4089 else if (object_index)
4091 /* Get local object */
4092 object_type *o_ptr = &object_type_body;
4094 /* Create the item */
4095 object_prep(o_ptr, object_index);
4097 if (o_ptr->tval == TV_GOLD)
4099 coin_type = object_index - OBJ_GOLD_LIST;
4104 /* Apply magic (no messages, no artifacts) */
4105 apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
4107 drop_here(o_ptr, *y, *x);
4113 if (a_info[artifact_index].cur_num)
4115 int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
4117 object_type *q_ptr = &forge;
4119 object_prep(q_ptr, k_idx);
4121 /* Drop it in the dungeon */
4122 drop_here(q_ptr, *y, *x);
4126 /* Create the artifact */
4127 if (create_named_art(artifact_index, *y, *x))
4128 a_info[artifact_index].cur_num = 1;
4132 /* Terrain special */
4133 c_ptr->special = letter[idx].special;
4141 /* Process "Q:<number>:<command>:... -- quest info */
4142 else if (buf[0] == 'Q')
4149 num = tokenize(buf + 2, 33, zz, 0);
4153 num = tokenize(buf + 3, 33, zz, 0);
4156 /* Have we enough parameters? */
4157 if (num < 3) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4160 q_ptr = &(quest[atoi(zz[0])]);
4162 /* Process "Q:<q_index>:Q:<type>:<num_mon>:<cur_num>:<max_num>:<level>:<r_idx>:<k_idx>:<flags>" -- quest info */
4163 if (zz[1][0] == 'Q')
4165 if (init_flags & INIT_ASSIGN)
4167 monster_race *r_ptr;
4168 artifact_type *a_ptr;
4170 if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
4172 q_ptr->type = atoi(zz[2]);
4173 q_ptr->num_mon = atoi(zz[3]);
4174 q_ptr->cur_num = atoi(zz[4]);
4175 q_ptr->max_num = atoi(zz[5]);
4176 q_ptr->level = atoi(zz[6]);
4177 q_ptr->r_idx = atoi(zz[7]);
4178 q_ptr->k_idx = atoi(zz[8]);
4179 q_ptr->dungeon = atoi(zz[9]);
4182 q_ptr->flags = atoi(zz[10]);
4184 r_ptr = &r_info[q_ptr->r_idx];
4185 if (r_ptr->flags1 & RF1_UNIQUE)
4186 r_ptr->flags1 |= RF1_QUESTOR;
4188 a_ptr = &a_info[q_ptr->k_idx];
4189 a_ptr->gen_flags |= TRG_QUESTITEM;
4194 else if (zz[1][0] == 'R')
4196 if (init_flags & INIT_ASSIGN)
4201 for (idx = 2; idx < num; idx++)
4203 int a_idx = atoi(zz[idx]);
4204 if (a_idx < 1) continue;
4205 if (a_info[a_idx].cur_num > 0) continue;
4207 if (one_in_(count)) reward_idx = a_idx;
4212 /* Set quest's rewarding artifact */
4213 q_ptr->k_idx = reward_idx;
4214 a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
4218 /* Change a quest type to KILL_ALL when all artifact of reward list are got */
4219 q_ptr->type = QUEST_TYPE_KILL_ALL;
4226 /* Process "Q:<q_index>:N:<name>" -- quest name */
4227 else if (zz[1][0] == 'N')
4229 if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
4231 strcpy(q_ptr->name, zz[2]);
4237 /* Process "Q:<q_index>:T:<text>" -- quest description line */
4238 else if (zz[1][0] == 'T')
4240 if (init_flags & INIT_SHOW_TEXT)
4242 strcpy(quest_text[quest_text_line], zz[2]);
4250 /* Process "W:<command>: ..." -- info for the wilderness */
4251 else if (buf[0] == 'W')
4253 return parse_line_wilderness(buf, ymin, xmin, ymax, xmax, y, x);
4256 /* Process "P:<y>:<x>" -- player position */
4257 else if (buf[0] == 'P')
4259 if (init_flags & INIT_CREATE_DUNGEON)
4261 if (tokenize(buf + 2, 2, zz, 0) == 2)
4263 int panels_x, panels_y;
4265 /* Hack - Set the dungeon size */
4266 panels_y = (*y / SCREEN_HGT);
4267 if (*y % SCREEN_HGT) panels_y++;
4268 cur_hgt = panels_y * SCREEN_HGT;
4270 panels_x = (*x / SCREEN_WID);
4271 if (*x % SCREEN_WID) panels_x++;
4272 cur_wid = panels_x * SCREEN_WID;
4274 /* Assume illegal panel */
4275 panel_row_min = cur_hgt;
4276 panel_col_min = cur_wid;
4278 /* Place player in a quest level */
4279 if (p_ptr->inside_quest)
4283 /* Delete the monster (if any) */
4284 delete_monster(py, px);
4292 /* Place player in the town */
4293 else if (!p_ptr->oldpx && !p_ptr->oldpy)
4295 p_ptr->oldpy = atoi(zz[0]);
4296 p_ptr->oldpx = atoi(zz[1]);
4304 /* Process "B:<Index>:<Command>:..." -- Building definition */
4305 else if (buf[0] == 'B')
4307 return parse_line_building(buf);
4310 /* Process "M:<type>:<maximum>" -- set maximum values */
4311 else if (buf[0] == 'M')
4313 if (tokenize(buf+2, 2, zz, 0) == 2)
4316 if (zz[0][0] == 'T')
4318 max_towns = atoi(zz[1]);
4321 /* Maximum quests */
4322 else if (zz[0][0] == 'Q')
4324 max_quests = atoi(zz[1]);
4328 else if (zz[0][0] == 'R')
4330 max_r_idx = atoi(zz[1]);
4334 else if (zz[0][0] == 'K')
4336 max_k_idx = atoi(zz[1]);
4340 else if (zz[0][0] == 'V')
4342 max_v_idx = atoi(zz[1]);
4346 else if (zz[0][0] == 'F')
4348 max_f_idx = atoi(zz[1]);
4352 else if (zz[0][0] == 'A')
4354 max_a_idx = atoi(zz[1]);
4358 else if (zz[0][0] == 'E')
4360 max_e_idx = atoi(zz[1]);
4364 else if (zz[0][0] == 'D')
4366 max_d_idx = atoi(zz[1]);
4370 else if (zz[0][0] == 'O')
4372 max_o_idx = atoi(zz[1]);
4376 else if (zz[0][0] == 'M')
4378 max_m_idx = atoi(zz[1]);
4381 /* Wilderness size */
4382 else if (zz[0][0] == 'W')
4384 /* Maximum wild_x_size */
4385 if (zz[0][1] == 'X')
4386 max_wild_x = atoi(zz[1]);
4387 /* Maximum wild_y_size */
4388 if (zz[0][1] == 'Y')
4389 max_wild_y = atoi(zz[1]);
4403 static cptr variant = "ZANGBAND";
4407 * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥óÀ¸À®»þ¤Îʬ´ô½èÍý
4408 * Helper function for "process_dungeon_file()"
4411 * @return ¥¨¥é¡¼¥³¡¼¥É
4413 static cptr process_dungeon_file_expr(char **sp, char *fp)
4429 while (iswspace(*s)) s++;
4447 t = process_dungeon_file_expr(&s, &f);
4456 else if (streq(t, "IOR"))
4459 while (*s && (f != b2))
4461 t = process_dungeon_file_expr(&s, &f);
4462 if (*t && !streq(t, "0")) v = "1";
4467 else if (streq(t, "AND"))
4470 while (*s && (f != b2))
4472 t = process_dungeon_file_expr(&s, &f);
4473 if (*t && streq(t, "0")) v = "0";
4478 else if (streq(t, "NOT"))
4481 while (*s && (f != b2))
4483 t = process_dungeon_file_expr(&s, &f);
4484 if (*t && streq(t, "1")) v = "0";
4489 else if (streq(t, "EQU"))
4492 if (*s && (f != b2))
4494 t = process_dungeon_file_expr(&s, &f);
4496 while (*s && (f != b2))
4498 p = process_dungeon_file_expr(&s, &f);
4499 if (streq(t, p)) v = "1";
4504 else if (streq(t, "LEQ"))
4507 if (*s && (f != b2))
4509 t = process_dungeon_file_expr(&s, &f);
4511 while (*s && (f != b2))
4514 t = process_dungeon_file_expr(&s, &f);
4515 if (*t && atoi(p) > atoi(t)) v = "0";
4520 else if (streq(t, "GEQ"))
4523 if (*s && (f != b2))
4525 t = process_dungeon_file_expr(&s, &f);
4527 while (*s && (f != b2))
4530 t = process_dungeon_file_expr(&s, &f);
4532 /* Compare two numbers instead of string */
4533 if (*t && atoi(p) < atoi(t)) v = "0";
4540 while (*s && (f != b2))
4542 t = process_dungeon_file_expr(&s, &f);
4547 if (f != b2) v = "?x?x?";
4549 /* Extract final and Terminate */
4550 if ((f = *s) != '\0') *s++ = '\0';
4556 /* Accept all printables except spaces and brackets */
4558 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
4560 if (iskanji(*s)) s++;
4564 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
4567 /* Extract final and Terminate */
4568 if ((f = *s) != '\0') *s++ = '\0';
4574 if (streq(b+1, "SYS"))
4580 else if (streq(b+1, "GRAF"))
4585 else if (streq(b+1, "MONOCHROME"))
4594 else if (streq(b+1, "RACE"))
4597 v = rp_ptr->E_title;
4604 else if (streq(b+1, "CLASS"))
4607 v = cp_ptr->E_title;
4614 else if (streq(b+1, "REALM1"))
4617 v = E_realm_names[p_ptr->realm1];
4619 v = realm_names[p_ptr->realm1];
4624 else if (streq(b+1, "REALM2"))
4627 v = E_realm_names[p_ptr->realm2];
4629 v = realm_names[p_ptr->realm2];
4634 else if (streq(b+1, "PLAYER"))
4636 static char tmp_player_name[32];
4638 for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
4648 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
4651 v = tmp_player_name;
4655 else if (streq(b+1, "TOWN"))
4657 sprintf(tmp, "%d", p_ptr->town_num);
4662 else if (streq(b+1, "LEVEL"))
4664 sprintf(tmp, "%d", p_ptr->lev);
4668 /* Current quest number */
4669 else if (streq(b+1, "QUEST_NUMBER"))
4671 sprintf(tmp, "%d", p_ptr->inside_quest);
4675 /* Number of last quest */
4676 else if (streq(b+1, "LEAVING_QUEST"))
4678 sprintf(tmp, "%d", leaving_quest);
4683 else if (prefix(b+1, "QUEST_TYPE"))
4685 /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
4686 sprintf(tmp, "%d", quest[atoi(b+11)].type);
4691 else if (prefix(b+1, "QUEST"))
4693 /* "QUEST" uses a special parameter to determine the number of the quest */
4694 sprintf(tmp, "%d", quest[atoi(b+6)].status);
4699 else if (prefix(b+1, "RANDOM"))
4701 /* "RANDOM" uses a special parameter to determine the number of the quest */
4702 sprintf(tmp, "%d", (int)(seed_town%atoi(b+7)));
4707 else if (streq(b+1, "VARIANT"))
4713 else if (streq(b+1, "WILDERNESS"))
4716 sprintf(tmp, "NONE");
4718 sprintf(tmp, "LITE");
4720 sprintf(tmp, "NORMAL");
4744 * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥óÀ¸À®»þ¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
4745 * Helper function for "process_dungeon_file()"
4746 * @param name ¥Õ¥¡¥¤¥ë̾
4747 * @param ymin ¾ÜºÙÉÔÌÀ
4748 * @param xmin ¾ÜºÙÉÔÌÀ
4749 * @param ymax ¾ÜºÙÉÔÌÀ
4750 * @param xmax ¾ÜºÙÉÔÌÀ
4751 * @return ¥¨¥é¡¼¥³¡¼¥É
4753 errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
4763 bool bypass = FALSE;
4765 int x = xmin, y = ymin;
4768 /* Build the filename */
4769 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
4772 fp = my_fopen(buf, "r");
4775 if (!fp) return (-1);
4778 /* Process the file */
4779 while (0 == my_fgets(fp, buf, sizeof(buf)))
4785 /* Skip "empty" lines */
4786 if (!buf[0]) continue;
4788 /* Skip "blank" lines */
4789 if (iswspace(buf[0])) continue;
4792 if (buf[0] == '#') continue;
4795 /* Process "?:<expr>" */
4796 if ((buf[0] == '?') && (buf[1] == ':'))
4805 /* Parse the expr */
4806 v = process_dungeon_file_expr(&s, &f);
4809 bypass = (streq(v, "0") ? TRUE : FALSE);
4815 /* Apply conditionals */
4816 if (bypass) continue;
4818 /* Process the line */
4819 err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
4831 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
4834 msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
4836 msg_format("'%s'¤ò²òÀÏÃæ¡£", buf);
4838 msg_format("Parsing '%s'.", buf);
4845 /* Close the file */
4855 void write_r_info_txt(void)
4857 int i, j, z, fc, bc;
4860 cptr flags[32 * 10];
4865 monster_race *r_ptr;
4867 monster_blow *b_ptr;
4869 FILE *fff = fopen("output.txt", "wt");
4877 fprintf(fff, "# File: r_info.txt (autogenerated)\n\n");
4879 fprintf(fff, "# Version stamp (required)\n\n");
4882 fprintf(fff, "V:%d.%d.%d\n\n\n", r_head->v_major, r_head->v_minor, r_head->v_patch);
4885 fprintf(fff, "##### The Player #####\n\n");
4887 for (z = -1; z < alloc_race_size; z++)
4889 /* Output the monsters in order */
4890 i = (z >= 0) ? alloc_race_table[z].index : 0;
4892 /* Acquire the monster */
4895 /* Ignore empty monsters */
4896 if (!strlen(r_name + r_ptr->name)) continue;
4898 /* Ignore useless monsters */
4899 if (i && !r_ptr->speed) continue;
4901 /* Write a note if necessary */
4902 if (i && (!r_ptr->level != !mode))
4907 fprintf(fff, "\n##### Town monsters #####\n\n");
4909 /* Note the dungeon */
4912 fprintf(fff, "\n##### Normal monsters #####\n\n");
4915 /* Record the change */
4916 mode = r_ptr->level;
4919 /* Acquire the flags */
4920 f_ptr[0] = r_ptr->flags1; n_ptr[0] = r_info_flags1;
4921 f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
4922 f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
4923 f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
4924 f_ptr[4] = r_ptr->flags5; n_ptr[4] = r_info_flags5;
4925 f_ptr[5] = r_ptr->flags6; n_ptr[5] = r_info_flags6;
4926 f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
4927 f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
4928 f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
4929 f_ptr[9] = r_ptr->flagsr; n_ptr[9] = r_info_flagsr;
4931 /* Write New/Number/Name */
4932 fprintf(fff, "N:%d:%s\n", z + 1, r_name + r_ptr->name);
4935 fprintf(fff, "G:%c:%c\n", r_ptr->d_char, color_char[r_ptr->d_attr]);
4937 /* Write Information */
4938 fprintf(fff, "I:%d:%dd%d:%d:%d:%d\n", r_ptr->speed, r_ptr->hdice, r_ptr->hside,
4939 r_ptr->aaf, r_ptr->ac, r_ptr->sleep);
4941 /* Write more information */
4942 fprintf(fff, "W:%d:%d:%d:%ld\n", r_ptr->level, r_ptr->rarity, r_ptr->extra, r_ptr->mexp);
4945 for(j = 0; j < 4; j++)
4947 b_ptr = &(r_ptr->blow[j]);
4949 /* Stop when done */
4950 if (!b_ptr->method) break;
4952 /* Write the blows */
4953 fprintf(fff, "B:%s:%s:%dd%d\n", r_info_blow_method[b_ptr->method],
4954 r_info_blow_effect[b_ptr->effect],
4955 b_ptr->d_dice, b_ptr->d_side);
4958 /* Extract the flags */
4959 for (fc = 0, j = 0; j < 32 * 3; j++)
4961 /* Check this flag */
4962 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4965 /* Extract the extra flags */
4966 for (j = 32 * 6; j < 32 * 10; j++)
4968 /* Check this flag */
4969 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
4972 /* Write the flags */
4973 for (j = 0; j < fc;)
4977 /* Start the line */
4980 for (bc = 0; (bc < 60) && (j < fc); j++)
4984 /* Format the flag */
4985 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
4987 /* Add it to the buffer */
4990 /* Note the length */
4994 /* Done with this line; write it */
4995 fprintf(fff, "%s\n", buf);
4998 /* Write Spells if applicable */
4999 if (r_ptr->freq_spell)
5001 /* Write the frequency */
5002 fprintf(fff, "S:1_IN_%d | \n", 100 / r_ptr->freq_spell);
5004 /* Extract the spell flags */
5005 for (fc = 0, j = 96; j < 192; j++)
5007 /* Check this flag */
5008 if (f_ptr[j / 32] & (1L << (j % 32))) flags[fc++] = n_ptr[j / 32][j % 32];
5011 /* Write the flags */
5012 for (j = 0; j < fc;)
5016 /* Start the line */
5019 for (bc = 0, t = buf + 2; (bc < 60) && (j < fc); j++)
5023 /* Format the flag */
5024 sprintf(t, "%s%s", flags[j], (j < fc - 1) ? " | " : "");
5028 /* Note the length */
5035 /* Done with this line; write it */
5036 fprintf(fff, "%s\n", buf);
5040 /* Acquire the description */
5041 desc = r_text + r_ptr->text;
5042 dlen = strlen(desc);
5044 /* Write Description */
5045 for (j = 0; j < dlen;)
5049 /* Start the line */
5052 for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
5060 /* Done with this line; write it */
5061 fprintf(fff, "%s\n", buf);
5064 /* Space between entries */