-/* File: init1.c */
-
-/*
- * Copyright (c) 1997 Ben Harrison
- *
+/*!
+ * @file init1.c
+ * @brief ¥²¡¼¥à¥Ç¡¼¥¿½é´ü²½1 / Initialization (part 1) -BEN-
+ * @date 2014/01/28
+ * @author
+ * <pre>
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
* This software may be copied and distributed for educational, research,
* and not for profit purposes provided that this copyright and statement
* are included in all such copies. Other copyrights may also apply.
- */
-
-/* Purpose: Initialization (part 1) -BEN- */
-
-#include "angband.h"
-
-
-/*
+ * 2014 Deskull rearranged comment for Doxygen.\n
+ * </pre>
+ * @details
+ * <pre>
* This file is used to initialize various variables and arrays for the
* Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
* the common limitation of "read()" and "write()" to only 32767 bytes
* at a time.
- *
* Several of the arrays for Angband are built from "template" files in
* the "lib/file" directory, from which quick-load binary "image" files
* are constructed whenever they are not present in the "lib/data"
* directory, or if those files become obsolete, if we are allowed.
- *
* Warning -- the "ascii" file parsers use a minor hack to collect the
* name and text information in a single pass. Thus, the game will not
* be able to load any template file with more than 20K of names or 60K
* of text, even though technically, up to 64K should be legal.
- *
* Note that if "ALLOW_TEMPLATES" is not defined, then a lot of the code
* in this file is compiled out, and the game will not run unless valid
* "binary template files" already exist in "lib/data". Thus, one can
* "*.raw" files in "lib/data", and then quit, and recompile without
* defining ALLOW_TEMPLATES, which will both save 20K and prevent people
* from changing the ascii template files in potentially dangerous ways.
- *
* The code could actually be removed and placed into a "stand-alone"
* program, but that feels a little silly, especially considering some
* of the platforms that we currently support.
+ * </pre>
*/
+#include "angband.h"
+
+
+
#ifdef ALLOW_TEMPLATES
#include "init.h"
/*** Helper arrays for parsing ascii template files ***/
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼¤ÎÂÇ·â¼êÃʥȡ¼¥¯¥ó¤ÎÄêµÁ /
* Monster Blow Methods
*/
static cptr r_info_blow_method[] =
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼¤ÎÂÇ·â°À¥È¡¼¥¯¥ó¤ÎÄêµÁ /
* Monster Blow Effects
*/
static cptr r_info_blow_effect[] =
"EXP_VAMP",
"DR_MANA",
"SUPERHURT",
+ "INERTIA",
+ "STUN",
NULL
};
-
-/*
+/*!
+ * ÃÏ·Á°À¥È¡¼¥¯¥ó¤ÎÄêµÁ /
* Feature info flags
*/
static cptr f_info_flags[] =
"MIRROR",
"UNPERM",
"TELEPORTABLE",
+ "CONVERT",
+ "GLASS",
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ1 /
* Monster race flags
*/
static cptr r_info_flags1[] =
"XXX3"
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ2 /
* Monster race flags
*/
static cptr r_info_flags2[] =
"QUANTUM"
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ3 /
* Monster race flags
*/
static cptr r_info_flags3[] =
"NO_SLEEP"
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ4 /
* Monster race flags
*/
static cptr r_info_flags4[] =
"BR_DISI",
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ5 /
* Monster race flags
*/
static cptr r_info_flags5[] =
"HOLD"
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ6 /
* Monster race flags
*/
static cptr r_info_flags6[] =
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ7 /
* Monster race flags
*/
static cptr r_info_flags7[] =
"SELF_LITE_2",
"GUARDIAN",
"CHAMELEON",
- "KILL_EXP",
+ "XXXX4XXX",
"TANUKI",
"HAS_DARK_1",
"SELF_DARK_1",
"XXX7X31",
};
-/*
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ8 /
* Monster race flags
*/
static cptr r_info_flags8[] =
};
-/*
- * Monster race flags - Drops
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ9 /
+ * Monster race flags
*/
static cptr r_info_flags9[] =
{
};
-/*
- * Monster race flags - Resistances
+/*!
+ * ¥â¥ó¥¹¥¿¡¼ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁR(ÂÑÀ) /
+ * Monster race flags
*/
static cptr r_info_flagsr[] =
{
};
-/*
+/*!
+ * ¥ª¥Ö¥¸¥§¥¯¥È´ðËÜÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
* Object flags
*/
static cptr k_info_flags[] =
"WARNING",
"HIDE_TYPE",
"SHOW_MODS",
- "XXX1",
- "FEATHER",
+ "SLAY_GOOD",
+ "LEVITATION",
"LITE",
"SEE_INVIS",
"TELEPATHY",
"TELEPORT",
"AGGRAVATE",
"BLESSED",
- "XXX3",
- "XXX4",
- "XXX5",
+ "XXX3", /* Fake flag for Smith */
+ "XXX4", /* Fake flag for Smith */
+ "KILL_GOOD",
"KILL_ANIMAL",
"KILL_EVIL",
"ESP_NONLIVING",
"ESP_UNIQUE",
"FULL_NAME",
+ "FIXED_FLAVOR",
+ "ADD_L_CURSE",
+ "ADD_H_CURSE",
+ "DRAIN_HP",
+ "DRAIN_MANA",
+
+ "LITE_2",
+ "LITE_3",
+ "LITE_M1",
+ "LITE_M2",
+ "LITE_M3",
+ "LITE_FUEL",
+
+ "CALL_ANIMAL",
+ "CALL_DEMON",
+ "CALL_DRAGON",
+ "CALL_UNDEAD",
+ "COWARDICE",
+ "LOW_MELEE",
+ "LOW_AC",
+ "LOW_MAGIC",
+ "FAST_DIGEST",
+ "SLOW_REGEN",
};
-
+/*!
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®ÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
+ * Object flags
+ */
static cptr k_info_gen_flags[] =
{
"INSTA_ART",
"RANDOM_CURSE0",
"RANDOM_CURSE1",
"RANDOM_CURSE2",
- "XXX",
- "XXX",
+ "XTRA_DICE",
+ "POWERFUL",
"XXX",
"XXX",
"XXX",
"XXX",
};
-
-/*
+/*!
+ * ¥À¥ó¥¸¥ç¥óÆÃÀ¥È¡¼¥¯¥ó¤ÎÄêµÁ /
* Dungeon flags
*/
static cptr d_info_flags1[] =
"NO_DOORS",
"WATER_RIVER",
"LAVA_RIVER",
- "XXX",
- "XXX",
+ "CURTAIN",
+ "GLASS_DOOR",
"CAVE",
"CAVERN",
- "XXX",
+ "ARCADE",
"XXX",
"XXX",
"XXX",
"NO_VAULT",
"ARENA",
"DESTROY",
- "XXX",
+ "GLASS_ROOM",
"NO_CAVE",
"NO_MAGIC",
"NO_MELEE",
};
-/*
+/*!
+ * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò¥Æ¥¥¹¥È¤È¤·¤ÆÊݴɤ¹¤ë /
* Add a text to the text-storage and store offset to it.
- *
+ * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
+ * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param buf ÊÝ´Éʸ»úÎó
+ * @param normal_text ¥Æ¥¥¹¥È¤ÎÀµµ¬²½¤ò¹Ô¤¦
+ * @return
+ * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
* Returns FALSE when there isn't enough space available to store
* the text.
*/
-static bool add_text(u32b *offset, header *head, cptr buf)
+static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
{
/* Hack -- Verify space */
if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
if (*offset == 0)
{
/* Advance and save the text index */
- *offset = ++head->text_size;
+ *offset = ++head->text_size;
+ }
+
+ /* Additional text */
+ else if (normal_text)
+ {
+ /*
+ * If neither the end of the last line nor
+ * the beginning of current line is not a space,
+ * fill up a space as a correct separator of two words.
+ */
+ if (head->text_size > 0 &&
+#ifdef JP
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
+ (buf[0] != ' ') && !iskanji(buf[0])
+#else
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ (buf[0] != ' ')
+#endif
+ )
+ {
+ /* Append a space */
+ *(head->text_ptr + head->text_size) = ' ';
+
+ /* Advance the index */
+ head->text_size++;
+ }
}
/* Append chars to the text */
}
-/*
+/*!
+ * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò̾Á°¤È¤·¤ÆÊݴɤ¹¤ë /
* Add a name to the name-storage and return an offset to it.
- *
+ * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
+ * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param buf ÊÝ´Éʸ»úÎó
+ * @return
+ * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
* Returns FALSE when there isn't enough space available to store
- * the name.
+ * the text.
*/
static bool add_name(u32b *offset, header *head, cptr buf)
{
}
-/*
+/*!
+ * @brief ¥Ç¡¼¥¿¤Î²ÄÊÑʸ»úÎó¾ðÊó¤ò¥¿¥°¤È¤·¤ÆÊݴɤ¹¤ë /
* Add a tag to the tag-storage and return an offset to it.
- *
+ * @param offset ʸ»úÎóÊݴɥݥ¤¥ó¥¿¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È
+ * @param head ¥Æ¥¥¹¥ÈÊݴɥإåÀ¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param buf ÊÝ´Éʸ»úÎó
+ * @return
+ * ̵»öÊݴɤ¬¤Ç¤¤¿¤éTRUE¤òÊÖ¤¹¡£
* Returns FALSE when there isn't enough space available to store
- * the name.
+ * the text.
*/
static bool add_tag(s16b *offset, header *head, cptr buf)
{
}
-/*
+/*!
+ * @brief ¥·¥ó¥Ü¥ë1ʸ»ú¤ò¥«¥é¡¼ID¤ËÊѹ¹¤¹¤ë /
* Convert a "color letter" into an "actual" color
* The colors are: dwsorgbuDWvyRGBU, as shown below
+ * @param c ¥·¥ó¥Ü¥ëʸ»ú
+ * @return ¥«¥é¡¼ID
*/
byte color_char_to_attr(char c)
{
/*** Initialize from ascii template files ***/
-/*
+/*!
+ * @brief ¥Ñ¡¼¥¹´Ø¿ô¤Ë´ð¤Å¤¤¤Æ¥Ç¡¼¥¿¥Õ¥¡¥¤¥ë¤«¤é¥Ç¡¼¥¿¤òÆɤ߼è¤ë /
* Initialize an "*_info" array, by parsing an ascii "template" file
+ * @param fp Æɤ߼è¤ê¤Ë»È¤¦¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿
+ * @param buf Æɤ߼è¤ê¤Ë»È¤¦¥Ð¥Ã¥Õ¥¡Îΰè
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @param parse_info_txt_line ¥Ñ¡¼¥¹´Ø¿ô
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr init_info_txt(FILE *fp, char *buf, header *head,
parse_info_txt_func parse_info_txt_line)
/* Prepare the "fake" stuff */
head->name_size = 0;
head->text_size = 0;
- head->tag_size = 1;
+ head->tag_size = 0;
/* Parse */
while (0 == my_fgets(fp, buf, 1024))
}
-/*
+/*!
+ * @brief Vault¾ðÊó(v_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "v_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_v_info(char *buf, header *head)
{
s = buf+2;
/* Store the text */
- if (!add_text(&v_ptr->text, head, s)) return (7);
+ if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
}
/* Process 'X' for "Extra info" (one line only) */
}
-
-/*
+/*!
+ * @brief ¿¦¶Èµ»Ç½¾ðÊó(s_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "s_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_s_info(char *buf, header *head)
{
}
-/*
+/*!
+ * @brief ¿¦¶ÈËâË¡¾ðÊó(m_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "m_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_m_info(char *buf, header *head)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(ÈÆÍÑ) /
* Grab one flag from a textual string
+ * @param flags ¥Ó¥Ã¥È¥Õ¥é¥°¤òÄɲ乤ëÀè¤Î»²¾È¥Ý¥¤¥ó¥¿
+ * @param names ¥È¡¼¥¯¥óÄêµÁÇÛÎó
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë¡ÊÃÏ·Á¾ðÊó¸þ¤±¡Ë /
* Grab one flag in an feature_type from a textual string
+ * @param f_ptr ÃÏ·Á¾ðÊó¤òÊݴɤ¹¤ëÀè¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°(¥¹¥Æ¡¼¥È)¤ò°ì¤ÄÆÀ¤ë¡ÊÃÏ·Á¾ðÊó¸þ¤±2¡Ë /
* Grab an action in an feature_type from a textual string
+ * @param f_ptr ÃÏ·Á¾ðÊó¤òÊݴɤ¹¤ëÀè¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @param count ¥¹¥Æ¡¼¥È¤ÎÊݸÀèID
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
{
}
-/*
+/*!
+ * @brief ÃÏ·Á¾ðÊó(f_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "f_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_f_info(char *buf, header *head)
{
else if (buf[0] == 'G')
{
int j;
- byte def_attr[F_LIT_MAX];
+ byte s_attr;
char char_tmp[F_LIT_MAX];
/* Paranoia */
char_tmp[F_LIT_STANDARD] = buf[2];
/* Extract the color */
- def_attr[F_LIT_STANDARD] = color_char_to_attr(buf[4]);
+ s_attr = color_char_to_attr(buf[4]);
/* Paranoia */
- if (def_attr[F_LIT_STANDARD] > 127) return (1);
+ if (s_attr > 127) return (1);
- /* Save the default values for lighting */
- for (j = 0; j < F_LIT_MAX; j++)
- {
- f_ptr->d_attr[j] = def_attr[F_LIT_STANDARD];
- f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
- }
+ /* Save the standard values */
+ f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
+ f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
/* Is this feature supports lighting? */
if (buf[5] == ':')
{
- def_attr[F_LIT_LITE] = lighting_colours[def_attr[F_LIT_STANDARD]][0];
- def_attr[F_LIT_DARK] = lighting_colours[def_attr[F_LIT_STANDARD]][1];
- def_attr[F_LIT_DARKDARK] = lighting_colours[lighting_colours[def_attr[F_LIT_STANDARD]][1]][1];
-
/* G:c:a:LIT (default) */
- if (streq(buf + 6, "LIT"))
- {
- for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
- {
- f_ptr->d_attr[j] = def_attr[j];
- }
- }
+ apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
- /* G:c:a:lc:la:dc:da:Dc:Da */
- else
+ /* G:c:a:lc:la:dc:da */
+ if (!streq(buf + 6, "LIT"))
{
char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
- if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c:%c:%c",
+ if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
&char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
- &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN],
- &char_tmp[F_LIT_DARKDARK], &attr_lite_tmp[F_LIT_DARKDARK - F_LIT_NS_BEGIN])) return 1;
+ &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
if (buf[F_LIT_MAX * 4 + 1]) return 1;
for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
{
case '*':
/* Use default lighting */
- f_ptr->d_attr[j] = def_attr[j];
break;
case '-':
/* No lighting support */
- f_ptr->d_attr[j] = def_attr[F_LIT_STANDARD];
+ f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
break;
default:
/* Extract the color */
}
}
}
- else if (buf[5]) return 1;
+ else if (!buf[5])
+ {
+ for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
+ {
+ f_ptr->d_attr[j] = s_attr;
+ f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
+ }
+ }
+ else return 1;
}
/* Hack -- Process 'F' for flags */
while (*t == ' ' || *t == '|') t++;
}
+ /* XXX XXX XXX Hack -- Read feature subtype */
+ if (1 == sscanf(s, "SUBTYPE_%d", &i))
+ {
+ /* Extract a "subtype" */
+ f_ptr->subtype = i;
+
+ /* Start at next entry */
+ s = t;
+
+ /* Continue */
+ continue;
+ }
+
/* XXX XXX XXX Hack -- Read feature power */
if (1 == sscanf(s, "POWER_%d", &i))
{
}
-/*
+/*!
+ * @brief ÃÏ·Á¥¿¥°¤«¤éID¤òÆÀ¤ë /
* Convert a fake tag to a real feat index
+ * @param str ¥¿¥°Ê¸»úÎó
+ * @return ÃÏ·ÁID
*/
s16b f_tag_to_index(cptr str)
{
}
/* Not found */
- return 0;
+ return -1;
}
-/*
+/*!
+ * @brief ÃÏ·Á¥¿¥°¤«¤éID¤òÆÀ¤ë /
* Search for real index corresponding to this fake tag
+ * @param feat ¥¿¥°Ê¸»úÎó
+ * @return ¤Ê¤·
*/
static void search_real_feat(s16b *feat)
{
}
-/*
+/*!
+ * @brief ÃÏ·Á¾ðÊó¤Î³Æ¼ï¥¿¥°¤«¤éID¤ØÊÑ´¹¤·¤Æ·ë²Ì¤ò¼ý¤á¤ë /
* Retouch fake tags of f_info
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¤Ê¤·
*/
void retouch_f_info(header *head)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥Ù¡¼¥¹¥¢¥¤¥Æ¥àÍÑ) /
* Grab one flag in an object_kind from a textual string
+ * @param k_ptr ÊÝ´ÉÀè¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
{
return (1);
}
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(ȯưǽÎÏÍÑ) /
+ * Grab one activation index flag
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ȯưǽÎÏID
+ */
+static byte grab_one_activation_flag(cptr what)
+{
+ int i;
+
+ for (i = 0; ; i++)
+ {
+ if (activation_info[i].flag == NULL) break;
+
+ if (streq(what, activation_info[i].flag))
+ {
+ return activation_info[i].index;
+ }
+ }
+
+ i = atoi(what);
+ if (i > 0)
+ {
+ return ((byte) i);
+ }
+
+ /* Oops */
+#ifdef JP
+ msg_format("̤ÃΤÎȯư¡¦¥Õ¥é¥° '%s'¡£", what);
+#else
+ msg_format("Unknown activation flag '%s'.", what);
+#endif
+
+ /* Error */
+ return (0);
+}
+
-/*
+/*!
+ * @brief ¥Ù¡¼¥¹¥¢¥¤¥Æ¥à(k_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "k_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_k_info(char *buf, header *head)
{
/* Process 'N' for "New/Number/Name" */
if (buf[0] == 'N')
{
+#ifdef JP
+ char *flavor;
+#endif
+
/* Find the colon before the name */
s = my_strchr(buf+2, ':');
- /* Verify that colon */
+ /* Verify that colon */
if (!s) return (1);
/* Nuke the colon, advance to the name */
*s++ = '\0';
-#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
-#endif
/* Get the index */
i = atoi(buf+2);
k_ptr = &k_info[i];
#ifdef JP
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
+
+ /* Find the colon before the flavor */
+ flavor = my_strchr(s, ':');
+
+ /* Verify that colon */
+ if (flavor)
+ {
+ /* Nuke the colon, advance to the flavor */
+ *flavor++ = '\0';
+
+ /* Store the flavor */
+ if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
+ }
+
/* Store the name */
if (!add_name(&k_ptr->name, head, s)) return (7);
#endif
#else
else if (buf[0] == 'E')
{
- /* Acquire the Text */
+ char *flavor;
+
+ /* Acquire the name */
s = buf+2;
+ /* Find the colon before the flavor */
+ flavor = my_strchr(s, ':');
+
+ /* Verify that colon */
+ if (flavor)
+ {
+ /* Nuke the colon, advance to the flavor */
+ *flavor++ = '\0';
+
+ /* Store the flavor */
+ if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
+ }
+
/* Store the name */
if (!add_name(&k_ptr->name, head, s)) return (7);
}
#endif
/* Store the text */
- if (!add_text(&k_ptr->text, head, s)) return (7);
+ if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'G' for "Graphics" (one line only) */
k_ptr->to_a = ta;
}
+ /* Hack -- Process 'U' for activation index */
+ else if (buf[0] == 'U')
+ {
+ byte n;
+ n = grab_one_activation_flag(buf + 2);
+ if (n > 0)
+ {
+ k_ptr->act_idx = n;
+ }
+ else
+ {
+ return (5);
+ }
+ }
+
/* Hack -- Process 'F' for flags */
else if (buf[0] == 'F')
{
return (0);
}
-
-/*
- * Grab one flag in an artifact_type from a textual string
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥ÈÍÑ) /
+ * Grab one activation index flag
+ * @param a_ptr ÊÝ´ÉÀè¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç1¡¢¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç0¤òÊÖ¤¹
*/
static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
{
}
-
-
-/*
+/*!
+ * @brief ¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¾ðÊó(a_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "a_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_a_info(char *buf, header *head)
{
#endif
/* Store the text */
- if (!add_text(&a_ptr->text, head, s)) return (7);
+ if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
}
a_ptr->to_a = ta;
}
+ /* Hack -- Process 'U' for activation index */
+ else if (buf[0] == 'U')
+ {
+ byte n;
+ n = grab_one_activation_flag(buf + 2);
+ if (n > 0)
+ {
+ a_ptr->act_idx = n;
+ }
+ else
+ {
+ return (5);
+ }
+ }
+
/* Hack -- Process 'F' for flags */
else if (buf[0] == 'F')
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥ÈÍÑ) /
* Grab one flag in a ego-item_type from a textual string
+ * @param e_ptr ÊÝ´ÉÀè¤Î¥¨¥´¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç1¡¢¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç0¤òÊÖ¤¹
*/
static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
{
}
-
-
-/*
+/*!
+ * @brief ¥¢¥¤¥Æ¥à¥¨¥´¾ðÊó(e_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "e_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_e_info(char *buf, header *head)
{
s = buf+2;
/* Store the text */
- if (!add_text(&e_ptr->text, head, s)) return (7);
+ if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
}
#endif
e_ptr->max_pval = pv;
}
+ /* Hack -- Process 'U' for activation index */
+ else if (buf[0] == 'U')
+ {
+ byte n;
+ n = grab_one_activation_flag(buf + 2);
+ if (n > 0)
+ {
+ e_ptr->act_idx = n;
+ }
+ else
+ {
+ return (5);
+ }
+ }
+
/* Hack -- Process 'F' for flags */
else if (buf[0] == 'F')
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼ÍÑ1) /
* Grab one (basic) flag in a monster_race from a textual string
+ * @param r_ptr ÊÝ´ÉÀè¤Î¥â¥ó¥¹¥¿¡¼¼ï²¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼ÍÑ2) /
* Grab one (spell) flag in a monster_race from a textual string
+ * @param r_ptr ÊÝ´ÉÀè¤Î¥â¥ó¥¹¥¿¡¼¼ï²¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
{
}
-
-
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¼ï²¾ðÊó(r_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "r_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_r_info(char *buf, header *head)
{
#endif
/* Store the text */
- if (!add_text(&r_ptr->text, head, s)) return (7);
+ if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'G' for "Graphics" (one line only) */
/* Save the values */
r_ptr->speed = spd;
- r_ptr->hdice = hp1;
- r_ptr->hside = hp2;
+ r_ptr->hdice = MAX(hp1, 1);
+ r_ptr->hside = MAX(hp2, 1);
r_ptr->aaf = aaf;
r_ptr->ac = ac;
r_ptr->sleep = slp;
r_ptr->next_r_idx = nextmon;
}
+ /* Process 'R' for "Reinforcement" (up to six lines) */
+ else if (buf[0] == 'R')
+ {
+ int id, ds, dd;
+ /* Find the next empty blow slot (if any) */
+ for (i = 0; i < 6; i++) if (r_ptr->reinforce_id[i] == 0) break;
+
+ /* Oops, no more slots */
+ if (i == 6) return (1);
+
+ /* Scan for the values */
+ if (3 != sscanf(buf+2, "%d:%dd%d", &id, &dd, &ds)) return (1);
+ r_ptr->reinforce_id[i] = id;
+ r_ptr->reinforce_dd[i] = dd;
+ r_ptr->reinforce_ds[i] = ds;
+ }
+
/* Process 'B' for "Blows" (up to four lines) */
else if (buf[0] == 'B')
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥À¥ó¥¸¥ç¥óÍÑ) /
* Grab one flag for a dungeon type from a textual string
+ * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
{
return (1);
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼¤Î¥À¥ó¥¸¥ç¥ó½Ð¸½¾ò·ïÍÑ1) /
* Grab one (basic) flag in a monster_race from a textual string
+ * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
{
}
-/*
+/*!
+ * @brief ¥Æ¥¥¹¥È¥È¡¼¥¯¥ó¤òÁöºº¤·¤Æ¥Õ¥é¥°¤ò°ì¤ÄÆÀ¤ë(¥â¥ó¥¹¥¿¡¼¤Î¥À¥ó¥¸¥ç¥ó½Ð¸½¾ò·ïÍÑ2) /
* Grab one (spell) flag in a monster_race from a textual string
+ * @param d_ptr ÊÝ´ÉÀè¤Î¥À¥ó¥¸¥ç¥ó¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param what »²¾È¸µ¤Îʸ»úÎó¥Ý¥¤¥ó¥¿
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
{
return (1);
}
-/*
+/*!
+ * @brief ¥À¥ó¥¸¥ç¥ó¾ðÊó(d_info)¤Î¥Ñ¡¼¥¹´Ø¿ô /
* Initialize the "d_info" array, by parsing an ascii "template" file
+ * @param buf ¥Æ¥¥¹¥ÈÎó
+ * @param head ¥Ø¥Ã¥À¹½Â¤ÂÎ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
errr parse_d_info(char *buf, header *head)
{
#endif
/* Store the text */
- if (!add_text(&d_ptr->text, head, s)) return (7);
+ if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'W' for "More Info" (one line only) */
char *zz[16];
/* Scan for the values */
- if (tokenize(buf+2, 7, zz, 0) != 7) return (1);
+ if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1)) return (1);
/* Save the values */
- d_ptr->floor1 = f_tag_to_index(zz[0]);
- d_ptr->floor_percent1 = atoi(zz[1]);
- d_ptr->floor2 = f_tag_to_index(zz[2]);
- d_ptr->floor_percent2 = atoi(zz[3]);
- d_ptr->floor3 = f_tag_to_index(zz[4]);
- d_ptr->floor_percent3 = atoi(zz[5]);
- d_ptr->tunnel_percent = atoi(zz[6]);
+ for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
+ {
+ d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
+ if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
+ d_ptr->floor[i].percent = atoi(zz[i * 2 + 1]);
+ }
+ d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
}
/* Process 'A' for "wAll type" (one line only) */
char *zz[16];
/* Scan for the values */
- if (tokenize(buf+2, 10, zz, 0) != 10) return (1);
+ if (tokenize(buf+2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4)) return (1);
/* Save the values */
- d_ptr->fill_type1 = f_tag_to_index(zz[0]);
- d_ptr->fill_percent1 = atoi(zz[1]);
- d_ptr->fill_type2 = f_tag_to_index(zz[2]);
- d_ptr->fill_percent2 = atoi(zz[3]);
- d_ptr->fill_type3 = f_tag_to_index(zz[4]);
- d_ptr->fill_percent3 = atoi(zz[5]);
- d_ptr->outer_wall = f_tag_to_index(zz[6]);
- d_ptr->inner_wall = f_tag_to_index(zz[7]);
- d_ptr->stream1 = f_tag_to_index(zz[8]);
- d_ptr->stream2 = f_tag_to_index(zz[9]);
+ for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
+ {
+ d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
+ if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
+ d_ptr->fill[i].percent = atoi(zz[i * 2 + 1]);
+ }
+
+ d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
+ if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
+ d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
+ if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
+ d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
+ if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
+ d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
+ if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
/* Process 'F' for "Dungeon Flags" (multiple lines) */
/* Random dungeon grid effects */
-#define RANDOM_NONE 0x00
-#define RANDOM_FEATURE 0x01
-#define RANDOM_MONSTER 0x02
-#define RANDOM_OBJECT 0x04
-#define RANDOM_EGO 0x08
-#define RANDOM_ARTIFACT 0x10
-#define RANDOM_TRAP 0x20
+#define RANDOM_NONE 0x00000000
+#define RANDOM_FEATURE 0x00000001
+#define RANDOM_MONSTER 0x00000002
+#define RANDOM_OBJECT 0x00000004
+#define RANDOM_EGO 0x00000008
+#define RANDOM_ARTIFACT 0x00000010
+#define RANDOM_TRAP 0x00000020
typedef struct dungeon_grid dungeon_grid;
static dungeon_grid letter[255];
-/*
+/*!
+ * @brief ÃÏ·Á¾ðÊó¤Î¡ÖF:¡×¾ðÊó¤ò¥Ñ¡¼¥¹¤¹¤ë
* Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
+ * @param buf ²òÀÏʸ»úÎó
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr parse_line_feature(char *buf)
{
int index = zz[0][0];
/* Reset the info for the letter */
- letter[index].feature = 0;
+ letter[index].feature = feat_none;
letter[index].monster = 0;
letter[index].object = 0;
letter[index].ego = 0;
letter[index].artifact = 0;
- letter[index].trap = 0;
+ letter[index].trap = feat_none;
letter[index].cave_info = 0;
letter[index].special = 0;
- letter[index].random = 0;
+ letter[index].random = RANDOM_NONE;
switch (num)
{
/* Fall through */
/* Trap */
case 8:
- if (zz[7][0] == '*')
+ if ((zz[7][0] == '*') && !zz[7][1])
{
letter[index].random |= RANDOM_TRAP;
-
- if (zz[7][1])
- {
- zz[7]++;
- letter[index].trap = atoi(zz[7]);
- }
}
else
{
- letter[index].trap = atoi(zz[7]);
+ letter[index].trap = f_tag_to_index(zz[7]);
+ if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
/* Fall through */
/* Artifact */
if (zz[6][0] == '*')
{
letter[index].random |= RANDOM_ARTIFACT;
-
- if (zz[6][1])
+ if (zz[6][1]) letter[index].artifact = atoi(zz[6] + 1);
+ }
+ else if (zz[6][0] == '!')
+ {
+ if (p_ptr->inside_quest)
{
- zz[6]++;
- letter[index].artifact = atoi(zz[6]);
+ letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
}
}
else
if (zz[5][0] == '*')
{
letter[index].random |= RANDOM_EGO;
-
- if (zz[5][1])
- {
- zz[5]++;
- letter[index].ego = atoi(zz[5]);
- }
+ if (zz[5][1]) letter[index].ego = atoi(zz[5] + 1);
}
else
{
if (zz[4][0] == '*')
{
letter[index].random |= RANDOM_OBJECT;
-
- if (zz[4][1])
+ if (zz[4][1]) letter[index].object = atoi(zz[4] + 1);
+ }
+ else if (zz[4][0] == '!')
+ {
+ if (p_ptr->inside_quest)
{
- zz[4]++;
- letter[index].object = atoi(zz[4]);
+ int a_idx = quest[p_ptr->inside_quest].k_idx;
+ if (a_idx)
+ {
+ artifact_type *a_ptr = &a_info[a_idx];
+ if (!(a_ptr->gen_flags & TRG_INSTA_ART))
+ {
+ letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
+ }
+ }
}
}
else
if (zz[3][0] == '*')
{
letter[index].random |= RANDOM_MONSTER;
- if (zz[3][1])
- {
- zz[3]++;
- letter[index].monster = atoi(zz[3]);
- }
+ if (zz[3][1]) letter[index].monster = atoi(zz[3] + 1);
}
else if (zz[3][0] == 'c')
{
- letter[index].monster = - atoi(zz[3]+1);
+ if (!zz[3][1]) return PARSE_ERROR_GENERIC;
+ letter[index].monster = - atoi(zz[3] + 1);
}
else
{
/* Fall through */
/* Feature */
case 2:
- if (zz[1][0] == '*')
+ if ((zz[1][0] == '*') && !zz[1][1])
{
letter[index].random |= RANDOM_FEATURE;
- if (zz[1][1])
- {
- zz[1]++;
- letter[index].feature = atoi(zz[1]);
- }
}
else
{
- letter[index].feature = atoi(zz[1]);
+ letter[index].feature = f_tag_to_index(zz[1]);
+ if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
break;
}
}
-/*
- * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
+/*!
+ * @brief ÃÏ·Á¾ðÊó¤Î¡ÖB:¡×¾ðÊó¤ò¥Ñ¡¼¥¹¤¹¤ë
+ * Process "B:<Index>:<Command>:..." -- Building definition
+ * @param buf ²òÀÏʸ»úÎó
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr parse_line_building(char *buf)
{
}
-/*
+/*!
+ * @brief ¥Õ¥í¥¢¤Î½êÄê¤Î¥Þ¥¹¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤òÇÛÃÖ¤¹¤ë
+ * Place the object j_ptr to a grid
+ * @param j_ptr ¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @param y ÇÛÃÖÀèYºÂɸ
+ * @param x ÇÛÃÖÀèXºÂɸ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
+ */
+static void drop_here(object_type *j_ptr, int y, int x)
+{
+ cave_type *c_ptr = &cave[y][x];
+ object_type *o_ptr;
+
+ /* Get new object */
+ s16b o_idx = o_pop();
+
+ /* Access new object */
+ o_ptr = &o_list[o_idx];
+
+ /* Structure copy */
+ object_copy(o_ptr, j_ptr);
+
+
+ /* Locate */
+ o_ptr->iy = y;
+ o_ptr->ix = x;
+
+ /* No monster */
+ o_ptr->held_m_idx = 0;
+
+ /* Build a stack */
+ o_ptr->next_o_idx = c_ptr->o_idx;
+
+ /* Place the object */
+ c_ptr->o_idx = o_idx;
+}
+
+
+/*!
+ * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥ó¤ò¥Õ¥í¥¢¤ËÀ¸À®¤¹¤ë
* Parse a sub-file of the "extra info"
+ * @param buf ʸ»úÎó
+ * @param ymin ¾ÜºÙÉÔÌÀ
+ * @param xmin ¾ÜºÙÉÔÌÀ
+ * @param ymax ¾ÜºÙÉÔÌÀ
+ * @param xmax ¾ÜºÙÉÔÌÀ
+ * @param y ¾ÜºÙÉÔÌÀ
+ * @param x ¾ÜºÙÉÔÌÀ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
{
if (!buf[0]) return (0);
/* Skip "blank" lines */
- if (isspace(buf[0])) return (0);
+ if (iswspace(buf[0])) return (0);
/* Skip comments */
if (buf[0] == '#') return (0);
int artifact_index = letter[idx].artifact;
/* Lay down a floor */
- c_ptr->feat = letter[idx].feature;
+ c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
/* Only the features */
if (init_flags & INIT_ONLY_FEATURES) continue;
else if (letter[idx].trap)
{
c_ptr->mimic = c_ptr->feat;
- c_ptr->feat = letter[idx].trap;
+ c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
}
else if (object_index)
{
/* Apply magic (no messages, no artifacts) */
apply_magic(o_ptr, base_level, AM_NO_FIXED_ART | AM_GOOD);
- (void)drop_near(o_ptr, -1, *y, *x);
+ drop_here(o_ptr, *y, *x);
}
/* Artifact */
object_prep(q_ptr, k_idx);
/* Drop it in the dungeon */
- (void)drop_near(q_ptr, -1, *y, *x);
+ drop_here(q_ptr, *y, *x);
}
else
{
/* Create the artifact */
- create_named_art(artifact_index, *y, *x);
-
- a_info[artifact_index].cur_num = 1;
+ if (create_named_art(artifact_index, *y, *x))
+ a_info[artifact_index].cur_num = 1;
}
}
return (0);
}
+ else if (zz[1][0] == 'R')
+ {
+ if (init_flags & INIT_ASSIGN)
+ {
+ int idx, count = 0;
+ int reward_idx = 0;
+
+ for (idx = 2; idx < num; idx++)
+ {
+ int a_idx = atoi(zz[idx]);
+ if (a_idx < 1) continue;
+ if (a_info[a_idx].cur_num > 0) continue;
+ count++;
+ if (one_in_(count)) reward_idx = a_idx;
+ }
+
+ if (reward_idx)
+ {
+ /* Set quest's rewarding artifact */
+ q_ptr->k_idx = reward_idx;
+ a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
+ }
+ else
+ {
+ /* Change a quest type to KILL_ALL when all artifact of reward list are got */
+ q_ptr->type = QUEST_TYPE_KILL_ALL;
+ }
+ }
+
+ return (0);
+ }
+
/* Process "Q:<q_index>:N:<name>" -- quest name */
else if (zz[1][0] == 'N')
{
- if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT))
+ if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
{
strcpy(q_ptr->name, zz[2]);
}
static cptr variant = "ZANGBAND";
-/*
+/*!
+ * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥óÀ¸À®»þ¤Îʬ´ô½èÍý
* Helper function for "process_dungeon_file()"
+ * @param sp
+ * @param fp
+ * @return ¥¨¥é¡¼¥³¡¼¥É
*/
static cptr process_dungeon_file_expr(char **sp, char *fp)
{
s = (*sp);
/* Skip spaces */
- while (isspace(*s)) s++;
+ while (iswspace(*s)) s++;
/* Save start */
b = s;
else
{
/* Accept all printables except spaces and brackets */
+#ifdef JP
+ while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
+ {
+ if (iskanji(*s)) s++;
+ s++;
+ }
+#else
while (isprint(*s) && !my_strchr(" []", *s)) ++s;
+#endif
/* Extract final and Terminate */
if ((f = *s) != '\0') *s++ = '\0';
/* Player name */
else if (streq(b+1, "PLAYER"))
{
- v = player_base;
+ static char tmp_player_name[32];
+ char *pn, *tpn;
+ for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
+ {
+#ifdef JP
+ if (iskanji(*pn))
+ {
+ *(tpn++) = *(pn++);
+ *tpn = *pn;
+ continue;
+ }
+#endif
+ *tpn = my_strchr(" []", *pn) ? '_' : *pn;
+ }
+ *tpn = '\0';
+ v = tmp_player_name;
}
/* Town */
v = tmp;
}
+ /* Quest type */
+ else if (prefix(b+1, "QUEST_TYPE"))
+ {
+ /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
+ sprintf(tmp, "%d", quest[atoi(b+11)].type);
+ v = tmp;
+ }
+
/* Quest status */
else if (prefix(b+1, "QUEST"))
{
}
+/*!
+ * @brief ¥¯¥¨¥¹¥ÈÍѸÇÄê¥À¥ó¥¸¥ç¥óÀ¸À®»þ¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
+ * Helper function for "process_dungeon_file()"
+ * @param name ¥Õ¥¡¥¤¥ë̾
+ * @param ymin ¾ÜºÙÉÔÌÀ
+ * @param xmin ¾ÜºÙÉÔÌÀ
+ * @param ymax ¾ÜºÙÉÔÌÀ
+ * @param xmax ¾ÜºÙÉÔÌÀ
+ * @return ¥¨¥é¡¼¥³¡¼¥É
+ */
errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
{
FILE *fp;
if (!buf[0]) continue;
/* Skip "blank" lines */
- if (isspace(buf[0])) continue;
+ if (iswspace(buf[0])) continue;
/* Skip comments */
if (buf[0] == '#') continue;
/* Start the line */
sprintf(buf, "D:");
- for (bc = 0, t = buf + 2; ((bc < 60) || !isspace(desc[j])) && (j < dlen); j++, bc++, t++)
+ for (bc = 0, t = buf + 2; ((bc < 60) || !iswspace(desc[j])) && (j < dlen); j++, bc++, t++)
{
*t = desc[j];
}