-/* 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"
-
-
-#ifdef JP
-#undef strchr
-static char *_strchr(const char *ptr, char ch)
-{
- for ( ; *ptr != '\0'; ++ptr)
- {
- if (*ptr == ch) return (char *)ptr;
- if (iskanji(*ptr)) ++ptr;
- }
-
- return NULL;
-}
-#define strchr _strchr
-#endif
-/*
+ * 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
* "*.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.
- *
+ * ノートとして記録:ALLOW_TEMPLATESが定義されていない場合、
+ * このファイルのコードの多くはコンパイル出力され、本ゲームは
+ * 正規の「バイナリテンプレートファイル」がlib/dataファイル内に
+ * 存在しない限り起動しなくなる。一方ALLOW_TEMPLATESが定義されている
+ * ならば1度ゲームが起動するごとに*.rawファイル群が作成され、終了時には
+ * ALLOW_TEMPLATEの定義に関係なくリコンパイルされる。これにより20K(バイト?)
+ * のデータが保存され、プレイヤーが潜在的に危険な方法でascii文字の
+ * テンプレートファイルを変更することを妨げることができる。
* 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[] =
+{
+ "LOS",
+ "PROJECT",
+ "MOVE",
+ "PLACE",
+ "DROP",
+ "SECRET",
+ "NOTICE",
+ "REMEMBER",
+ "OPEN",
+ "CLOSE",
+ "BASH",
+ "SPIKE",
+ "DISARM",
+ "STORE",
+ "TUNNEL",
+ "MAY_HAVE_GOLD",
+ "HAS_GOLD",
+ "HAS_ITEM",
+ "DOOR",
+ "TRAP",
+ "STAIRS",
+ "GLYPH",
+ "LESS",
+ "MORE",
+ "AVOID_RUN",
+ "FLOOR",
+ "WALL",
+ "PERMANENT",
+ "XXX00",
+ "XXX01",
+ "XXX02",
+ "HIT_TRAP",
+
+ "BRIDGE",
+ "RIVER",
+ "LAKE",
+ "BRIDGED",
+ "COVERED",
+ "GLOW",
+ "ENSECRET",
+ "WATER",
+ "LAVA",
+ "SHALLOW",
+ "DEEP",
+ "FILLED",
+ "HURT_ROCK",
+ "HURT_FIRE",
+ "HURT_COLD",
+ "HURT_ACID",
+ "ICE",
+ "ACID",
+ "OIL",
+ "XXX04",
+ "CAN_CLIMB",
+ "CAN_FLY",
+ "CAN_SWIM",
+ "CAN_PASS",
+ "CAN_OOZE",
+ "CAN_DIG",
+ "HIDE_ITEM",
+ "HIDE_SNEAK",
+ "HIDE_SWIM",
+ "HIDE_DIG",
+ "KILL_HUGE",
+ "KILL_MOVE",
+
+ "PICK_TRAP",
+ "PICK_DOOR",
+ "ALLOC",
+ "CHEST",
+ "DROP_1D2",
+ "DROP_2D2",
+ "DROP_GOOD",
+ "DROP_GREAT",
+ "HURT_POIS",
+ "HURT_ELEC",
+ "HURT_WATER",
+ "HURT_BWATER",
+ "USE_FEAT",
+ "GET_FEAT",
+ "GROUND",
+ "OUTSIDE",
+ "EASY_HIDE",
+ "EASY_CLIMB",
+ "MUST_CLIMB",
+ "TREE",
+ "NEED_TREE",
+ "BLOOD",
+ "DUST",
+ "SLIME",
+ "PLANT",
+ "XXX2",
+ "INSTANT",
+ "EXPLODE",
+ "TIMED",
+ "ERUPT",
+ "STRIKE",
+ "SPREAD",
+
+ "SPECIAL",
+ "HURT_DISI",
+ "QUEST_ENTER",
+ "QUEST_EXIT",
+ "QUEST",
+ "SHAFT",
+ "MOUNTAIN",
+ "BLDG",
+ "MINOR_GLYPH",
+ "PATTERN",
+ "TOWN",
+ "ENTRANCE",
+ "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",
};
-/*
+/*!
+ * モンスター特性トークン(発動型能力1) /
* Monster race flags
*/
-static cptr r_info_flags5[] =
+static cptr r_a_ability_flags1[] =
{
"BA_ACID",
"BA_ELEC",
"HOLD"
};
-/*
+/*!
+ * モンスター特性トークン(発動型能力2) /
* Monster race flags
*/
-static cptr r_info_flags6[] =
+static cptr r_a_ability_flags2[] =
{
"HASTE",
"HAND_DOOM",
"S_UNIQUE"
};
+/*!
+ * モンスター特性トークン(発動型能力3) /
+ * Monster race flags
+ */
+static cptr r_a_ability_flags3[] =
+{
+ "XXXA3X00",
+ "XXXA3X01",
+ "XXXA3X02",
+ "XXXA3X03",
+ "XXXA3X04",
+ "XXXA3X05",
+ "XXXA3X06",
+ "XXXA3X07",
+ "XXXA3X08",
+ "XXXA3X09",
+ "XXXA3X10",
+ "XXXA3X11",
+ "XXXA3X12",
+ "XXXA3X13",
+ "XXXA3X14",
+ "XXXA3X15",
+ "XXXA3X16",
+ "XXXA3X17",
+ "XXXA3X18",
+ "XXXA3X19",
+ "XXXA3X20",
+ "XXXA3X21",
+ "XXXA3X22",
+ "XXXA3X23",
+ "XXXA3X24",
+ "XXXA3X25",
+ "XXXA3X26",
+ "XXXA3X27",
+ "XXXA3X28",
+ "XXXA3X29",
+ "XXXA3X30",
+ "XXXA3X31",
+};
+
+/*!
+ * モンスター特性トークン(発動型能力4) /
+ * Monster race flags
+ */
+static cptr r_a_ability_flags4[] =
+{
+ "XXXA4X00",
+ "XXXA4X01",
+ "XXXA4X02",
+ "XXXA4X03",
+ "XXXA4X04",
+ "XXXA4X05",
+ "XXXA4X06",
+ "XXXA4X07",
+ "XXXA4X08",
+ "XXXA4X09",
+ "XXXA4X10",
+ "XXXA4X11",
+ "XXXA4X12",
+ "XXXA4X13",
+ "XXXA4X14",
+ "XXXA4X15",
+ "XXXA4X16",
+ "XXXA4X17",
+ "XXXA4X18",
+ "XXXA4X19",
+ "XXXA4X20",
+ "XXXA4X21",
+ "XXXA4X22",
+ "XXXA4X23",
+ "XXXA4X24",
+ "XXXA4X25",
+ "XXXA4X26",
+ "XXXA4X27",
+ "XXXA4X28",
+ "XXXA4X29",
+ "XXXA4X30",
+ "XXXA4X31",
+};
+
-/*
+/*!
+ * モンスター特性トークンの定義7 /
* Monster race flags
*/
static cptr r_info_flags7[] =
"CAN_SWIM",
"CAN_FLY",
"FRIENDLY",
- "UNIQUE_7",
+ "NAZGUL",
"UNIQUE2",
"RIDING",
"KAGE",
"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[] =
"THROW",
"REFLECT",
"FREE_ACT",
- "HOLD_LIFE",
+ "HOLD_EXP",
"RES_ACID",
"RES_ELEC",
"RES_FIRE",
"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 text.
+ */
+static bool add_tag(s16b *offset, header *head, cptr buf)
+{
+ u32b i;
+
+ /* Search for an existing (fake) tag */
+ for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
+ {
+ /* Found it */
+ if (streq(&head->tag_ptr[i], buf)) break;
+ }
+
+ /* There was no existing tag */
+ if (i >= head->tag_size)
+ {
+ /* Hack -- Verify space */
+ if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
+ return FALSE;
+
+ /* Append chars to the tags */
+ strcpy(head->tag_ptr + head->tag_size, buf);
+
+ /* Point the new tag */
+ i = head->tag_size;
+
+ /* Advance the index */
+ head->tag_size += strlen(buf) + 1;
+ }
+
+ /* Return offset of the tag */
+ *offset = (s16b)i;
+
+ /* Success */
+ return TRUE;
+}
+
+
+/*!
+ * @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 = 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)
{
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
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)
{
int xtra, type, first, weight;
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
stat = s;
/* Find the colon before the name */
- s = strchr(s, ':');
+ s = my_strchr(s, ':');
/* Verify that colon */
if (!s) return (1);
}
-/*
+/*!
+ * @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)
+{
+ int i;
+
+ /* Check flags */
+ for (i = 0; i < 32; i++)
+ {
+ if (streq(what, names[i]))
+ {
+ *flags |= (1L << i);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+
+/*!
+ * @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)
+{
+ int i;
+
+ /* Check flags */
+ for (i = 0; i < FF_FLAG_MAX; i++)
+ {
+ if (streq(what, f_info_flags[i]))
+ {
+ add_flag(f_ptr->flags, i);
+ return 0;
+ }
+ }
+
+ /* Oops */
+ msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
+
+ /* Error */
+ return PARSE_ERROR_GENERIC;
+}
+
+
+/*!
+ * @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)
+{
+ int i;
+
+ /* Check flags */
+ for (i = 0; i < FF_FLAG_MAX; i++)
+ {
+ if (streq(what, f_info_flags[i]))
+ {
+ f_ptr->state[count].action = i;
+ return 0;
+ }
+ }
+
+ /* Oops */
+ msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
+
+ /* Error */
+ return PARSE_ERROR_GENERIC;
+}
+
+
+/*!
+ * @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)
{
int i;
- char *s;
+ char *s, *t;
/* Current entry */
static feature_type *f_ptr = NULL;
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
-
- /* Verify that colon */
- if (!s) return (1);
-
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ s = my_strchr(buf+2, ':');
-#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
-#endif
+ if (s)
+ {
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
+ }
/* Get the index */
i = atoi(buf+2);
/* Point at the "info" */
f_ptr = &f_info[i];
-#ifdef JP
- /* Store the name */
- if (!add_name(&f_ptr->name, head, s)) return (7);
-#endif
+ /* Tag name is given */
+ if (s)
+ {
+ /* Store the tag */
+ if (!add_tag(&f_ptr->tag, head, s)) return (7);
+ }
+
/* Default "mimic" */
f_ptr->mimic = i;
+
+ /* Default "destroyed state" -- if not specified */
+ f_ptr->destroyed = i;
+
+ /* Default "states" */
+ for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX;
}
/* There better be a current f_ptr */
else if (!f_ptr) return (3);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ else if (buf[0] == 'J')
+ {
+ /* Store the name */
+ if (!add_name(&f_ptr->name, head, buf+2)) return (7);
+ }
+
else if (buf[0] == 'E')
{
- /* nothing to do */
+ /* Ignore english name */
}
#else
+ else if (buf[0] == 'J')
+ {
+ /* Ignore Japanese name */
+ }
+
else if (buf[0] == 'E')
{
/* Acquire the Text */
/* Process 'M' for "Mimic" (one line only) */
else if (buf[0] == 'M')
{
- int mimic;
-
- /* Scan for the values */
- if (1 != sscanf(buf+2, "%d",
- &mimic)) return (1);
+ s16b offset;
- /* Save the values */
- f_ptr->mimic = mimic;
+ if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY;
+ /* Record a fake tag index */
+ f_ptr->mimic = -offset;
}
/* Process 'G' for "Graphics" (one line only) */
else if (buf[0] == 'G')
{
- byte tmp;
+ int j;
+ byte s_attr;
+ char char_tmp[F_LIT_MAX];
/* Paranoia */
+ if (buf[1] != ':') return (1);
if (!buf[2]) return (1);
- if (!buf[3]) return (1);
+ if (buf[3] != ':') return (1);
if (!buf[4]) return (1);
+ /* Extract the char */
+ char_tmp[F_LIT_STANDARD] = buf[2];
+
/* Extract the color */
- tmp = color_char_to_attr(buf[4]);
+ s_attr = color_char_to_attr(buf[4]);
/* Paranoia */
- if (tmp > 127) return (1);
+ if (s_attr > 127) return (1);
- /* Save the values */
- f_ptr->d_attr = tmp;
- f_ptr->d_char = buf[2];
+ /* 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] == ':')
+ {
+ /* G:c:a:LIT (default) */
+ apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
+
+ /* 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",
+ &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])) return 1;
+ if (buf[F_LIT_MAX * 4 + 1]) return 1;
+
+ for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
+ {
+ switch (attr_lite_tmp[j - F_LIT_NS_BEGIN])
+ {
+ case '*':
+ /* Use default lighting */
+ break;
+ case '-':
+ /* No lighting support */
+ f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
+ break;
+ default:
+ /* Extract the color */
+ f_ptr->d_attr[j] = color_char_to_attr(attr_lite_tmp[j - F_LIT_NS_BEGIN]);
+ if (f_ptr->d_attr[j] > 127) return 1;
+ break;
+ }
+ f_ptr->d_char[j] = char_tmp[j];
+ }
+ }
+ }
+ 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 */
+ else if (buf[0] == 'F')
+ {
+ /* Parse every entry textually */
+ for (s = buf + 2; *s; )
+ {
+ /* Find the end of this entry */
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+
+ /* Nuke and skip any dividers */
+ if (*t)
+ {
+ *t++ = '\0';
+ 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))
+ {
+ /* Extract a "power" */
+ f_ptr->power = i;
+
+ /* Start at next entry */
+ s = t;
+
+ /* Continue */
+ continue;
+ }
+
+ /* Parse this entry */
+ if (0 != grab_one_feat_flag(f_ptr, s)) return (PARSE_ERROR_INVALID_FLAG);
+
+ /* Start the next entry */
+ s = t;
+ }
+ }
+
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int priority;
+
+ /* Scan for the value */
+ if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC);
+ /* Save the value */
+ f_ptr->priority = priority;
+ }
+
+ /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */
+ else if (buf[0] == 'K')
+ {
+ s16b offset;
+
+ /* Find the next empty state slot (if any) */
+ for (i = 0; i < MAX_FEAT_STATES; i++) if (f_ptr->state[i].action == FF_FLAG_MAX) break;
+
+ /* Oops, no more slots */
+ if (i == MAX_FEAT_STATES) return PARSE_ERROR_GENERIC;
+
+ /* Analyze the first field */
+ for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
+
+ /* Terminate the field (if necessary) */
+ if (*t == ':') *t++ = '\0';
+
+ /* Is this default entry? */
+ if (streq(s, "DESTROYED"))
+ {
+ if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
+
+ /* Record a fake tag index */
+ f_ptr->destroyed = -offset;
+ }
+ else
+ {
+ /* Reset */
+ f_ptr->state[i].action = 0;
+
+ /* Parse this entry */
+ if (0 != grab_one_feat_action(f_ptr, s, i)) return PARSE_ERROR_INVALID_FLAG;
+
+ if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY;
+
+ /* Record a fake tag index */
+ f_ptr->state[i].result = -offset;
+ }
}
/* Oops */
}
-/*
+/*!
+ * @brief 地形タグからIDを得る /
+ * Convert a fake tag to a real feat index
+ * @param str タグ文字列
+ * @return 地形ID
+ */
+s16b f_tag_to_index(cptr str)
+{
+ u16b i;
+
+ /* Search for real index corresponding to this fake tag */
+ for (i = 0; i < f_head.info_num; i++)
+ {
+ if (streq(f_tag + f_info[i].tag, str))
+ {
+ /* Return the index */
+ return (s16b)i;
+ }
+ }
+
+ /* Not found */
+ return -1;
+}
+
+
+/*!
+ * @brief 地形タグからIDを得る /
+ * Search for real index corresponding to this fake tag
+ * @param feat タグ文字列
+ * @return なし
+ */
+static void search_real_feat(s16b *feat)
+{
+ int i;
+
+ /* Don't convert non-fake tag */
+ if (*feat >= 0) return;
+
+ /* Search for real index corresponding to this fake tag */
+ for (i = 0; i < f_head.info_num; i++)
+ {
+ if ((-(*feat)) == f_info[i].tag)
+ {
+ /* Record real index */
+ *feat = (s16b)i;
+ return;
+ }
+ }
+
+ /* Undefined tag */
+ msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + (-(*feat)));
+}
+
+
+/*!
+ * @brief 地形情報の各種タグからIDへ変換して結果を収める /
+ * Retouch fake tags of f_info
+ * @param head ヘッダ構造体
+ * @return なし
+ */
+void retouch_f_info(header *head)
+{
+ int i;
+
+ /* Convert fake tags to real feat indices */
+ for (i = 0; i < head->info_num; i++)
+ {
+ feature_type *f_ptr = &f_info[i];
+ int j;
+
+ search_real_feat(&f_ptr->mimic);
+
+ search_real_feat(&f_ptr->destroyed);
+
+ for (j = 0; j < MAX_FEAT_STATES; j++) search_real_feat(&f_ptr->state[j].result);
+ }
+}
+
+
+/*!
+ * @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)
{
}
}
- /* Check gen_flags */
- for (i = 0; i < 32; i++)
+ if (grab_one_flag(&k_ptr->gen_flags, k_info_gen_flags, what) == 0)
+ return 0;
+
+ /* Oops */
+ msg_format(_("未知のアイテム・フラグ '%s'。", "Unknown object flag '%s'."), what);
+
+ /* Error */
+ 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 (streq(what, k_info_gen_flags[i]))
+ if (activation_info[i].flag == NULL) break;
+
+ if (streq(what, activation_info[i].flag))
{
- k_ptr->gen_flags |= (1L << i);
- return (0);
+ return activation_info[i].index;
}
}
- /* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥ¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown object flag '%s'.", what);
-#endif
+ i = atoi(what);
+ if (i > 0)
+ {
+ return ((byte) i);
+ }
+ /* Oops */
+ msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
/* Error */
- return (1);
+ 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 = strchr(buf+2, ':');
+ 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
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ /* 英語名を読むルーチンを追加 */
+ /* 'E' から始まる行は英語名としている */
else if (buf[0] == 'E')
{
/* nothing to do */
#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) */
byte tmp;
/* Paranoia */
+ if (buf[1] != ':') return (1);
if (!buf[2]) return (1);
- if (!buf[3]) return (1);
+ if (buf[3] != ':') return (1);
if (!buf[4]) return (1);
/* Extract the char */
/* Process 'A' for "Allocation" (one line only) */
else if (buf[0] == 'A')
{
- int i;
/* XXX XXX XXX Simply read each number following a colon */
for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
k_ptr->locale[i] = atoi(s+1);
/* Find the slash */
- t = strchr(s+1, '/');
+ t = my_strchr(s+1, '/');
/* Find the next colon */
- s = strchr(s+1, ':');
+ s = my_strchr(s+1, ':');
/* If the slash is "nearby", use it */
if (t && (!s || t < s))
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)
{
}
}
- /* Check gen_flags */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, k_info_gen_flags[i]))
- {
- a_ptr->gen_flags |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown artifact flag '%s'.", what);
-#endif
-
+ msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
/* Error */
return (1);
}
-
-
-/*
+/*!
+ * @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)
{
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ /* 英語名を読むルーチンを追加 */
+ /* 'E' から始まる行は英語名としている */
else if (buf[0] == 'E')
{
/* nothing to do */
#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)
{
return (0);
}
}
-
- /* Check gen_flags */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, k_info_gen_flags[i]))
- {
- e_ptr->gen_flags |= (1L << i);
- return (0);
- }
- }
-/* Oops */
-#ifdef JP
- msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown ego-item flag '%s'.", what);
-#endif
+ if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
+ return 0;
+ /* Oops */
+ msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
/* Error */
return (1);
}
-
-
-/*
+/*!
+ * @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)
{
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
+ /* 英語名を読むルーチンを追加 */
+ /* 'E' から始まる行は英語名 */
else if (buf[0] == 'E')
{
/* nothing to do */
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
/* Save the values */
e_ptr->level = level;
- e_ptr->rarity = rarity;
+ e_ptr->rarity = (RARITY)rarity;
/* e_ptr->weight = wgt; */
e_ptr->cost = cost;
}
/* Hack -- Process 'C' for "creation" */
else if (buf[0] == 'C')
{
- int th, td, ta, pv;
+ int th, td, ta, pval;
/* Scan for the values */
if (4 != sscanf(buf+2, "%d:%d:%d:%d",
- &th, &td, &ta, &pv)) return (1);
+ &th, &td, &ta, &pval)) return (1);
e_ptr->max_to_h = th;
e_ptr->max_to_d = td;
e_ptr->max_to_a = ta;
- e_ptr->max_pval = pv;
+ e_ptr->max_pval = (PARAMETER_VALUE)pval;
+ }
+
+ /* 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 */
}
-/*
+/*!
+ * @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)
{
- int i;
-
- /* Scan flags1 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags1[i]))
- {
- r_ptr->flags1 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
+ return 0;
- /* Scan flags2 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags2[i]))
- {
- r_ptr->flags2 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
+ return 0;
- /* Scan flags3 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags3[i]))
- {
- r_ptr->flags3 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
+ return 0;
- /* Scan flags7 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags7[i]))
- {
- r_ptr->flags7 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
+ return 0;
- /* Scan flags8 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags8[i]))
- {
- r_ptr->flags8 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
+ return 0;
- /* Scan flags9 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags9[i]))
- {
- r_ptr->flags9 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
+ return 0;
- /* Scan flagsr (resistance) */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flagsr[i]))
- {
- r_ptr->flagsr |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown monster flag '%s'.", what);
-#endif
-
+ msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
/* Failure */
return (1);
}
-/*
+/*!
+ * @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)
{
- int i;
-
- /* Scan flags4 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags4[i]))
- {
- r_ptr->flags4 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
+ return 0;
- /* Scan flags5 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags5[i]))
- {
- r_ptr->flags5 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
+ return 0;
- /* Scan flags6 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags6[i]))
- {
- r_ptr->flags6 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown monster flag '%s'.", what);
-#endif
-
+ msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
/* Failure */
return (1);
}
-
-
-/*
+/*!
+ * @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)
{
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
+ /* 英語名を読むルーチンを追加 */
+ /* 'E' から始まる行は英語名 */
else if (buf[0] == 'E')
{
/* Acquire the Text */
#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) */
byte tmp;
/* Paranoia */
+ if (buf[1] != ':') return (1);
if (!buf[2]) return (1);
- if (!buf[3]) return (1);
+ if (buf[3] != ':') return (1);
if (!buf[4]) return (1);
/* Extract the char */
/* 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;
&lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
/* Save the values */
- r_ptr->level = lev;
- r_ptr->rarity = rar;
+ r_ptr->level = (DEPTH)lev;
+ r_ptr->rarity = (RARITY)rar;
r_ptr->extra = pad;
r_ptr->mexp = exp;
r_ptr->next_exp = nextexp;
- r_ptr->next_r_idx = nextmon;
+ r_ptr->next_r_idx = (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) */
}
}
+ /* Process 'A' for "Artifact Flags" (multiple lines) */
+ else if (buf[0] == 'A')
+ {
+ int id, per, rarity;
+
+ /* Find the next empty blow slot (if any) */
+ for (i = 0; i < 4; i++) if (!r_ptr->artifact_id[i]) break;
+
+ /* Oops, no more slots */
+ if (i == 4) return (1);
+
+ if (3 != sscanf(buf+2, "%d:%d:%d", &id, &rarity, &per)) return (1);
+ r_ptr->artifact_id[i] = id;
+ r_ptr->artifact_rarity[i] = (RARITY)rarity;
+ r_ptr->artifact_percent[i] = per;
+ }
+
+ /* Process 'V' for "Arena power value ratio" */
+ else if (buf[0] == 'V')
+ {
+ int val;
+ if (3 != sscanf(buf+2, "%d", &val)) return (1);
+ r_ptr->arena_ratio = (PERCENTAGE)val;
+ }
+
/* Oops */
else return (6);
}
-/*
+/*!
+ * @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)
{
- int i;
-
- /* Scan flags1 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, d_info_flags1[i]))
- {
- d_ptr->flags1 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown dungeon type flag '%s'.", what);
-#endif
+ msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
/* Failure */
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)
{
- int i;
-
- /* Scan flags1 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags1[i]))
- {
- d_ptr->mflags1 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
+ return 0;
- /* Scan flags2 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags2[i]))
- {
- d_ptr->mflags2 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
+ return 0;
- /* Scan flags3 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags3[i]))
- {
- d_ptr->mflags3 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
+ return 0;
- /* Scan flags7 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags7[i]))
- {
- d_ptr->mflags7 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
+ return 0;
- /* Scan flags8 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags8[i]))
- {
- d_ptr->mflags8 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
+ return 0;
- /* Scan flags9 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags9[i]))
- {
- d_ptr->mflags9 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
+ return 0;
- /* Scan flagsr (resistance) */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flagsr[i]))
- {
- d_ptr->mflagsr |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown monster flag '%s'.", what);
-#endif
+ msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
/* Failure */
return (1);
}
-/*
+/*!
+ * @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)
{
- int i;
-
- /* Scan flags4 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags4[i]))
- {
- d_ptr->mflags4 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
+ return 0;
- /* Scan flags5 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags5[i]))
- {
- d_ptr->mflags5 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
+ return 0;
- /* Scan flags6 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, r_info_flags6[i]))
- {
- d_ptr->mflags6 |= (1L << i);
- return (0);
- }
- }
+ if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
+ return 0;
/* Oops */
-#ifdef JP
- msg_format("̤ÃΤΥâ¥ó¥¹¥¿¡¼¡¦¥Õ¥é¥° '%s'¡£", what);
-#else
- msg_format("Unknown monster flag '%s'.", what);
-#endif
+ msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
/* Failure */
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)
{
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf+2, ':');
+ s = my_strchr(buf+2, ':');
/* Verify that colon */
if (!s) return (1);
#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) */
/* Process 'L' for "fLoor type" (one line only) */
else if (buf[0] == 'L')
{
- int f1, f2, f3;
- int p1, p2, p3;
- int tunnel;
+ char *zz[16];
/* Scan for the values */
- if (7 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d",
- &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) 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 = f1;
- d_ptr->floor_percent1 = p1;
- d_ptr->floor2 = f2;
- d_ptr->floor_percent2 = p2;
- d_ptr->floor3 = f3;
- d_ptr->floor_percent3 = p3;
- d_ptr->tunnel_percent = tunnel;
+ 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) */
else if (buf[0] == 'A')
{
- int w1, w2, w3, outer, inner, stream1, stream2;
- int p1, p2, p3;
+ char *zz[16];
/* Scan for the values */
- if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
- &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) 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 = w1;
- d_ptr->fill_percent1 = p1;
- d_ptr->fill_type2 = w2;
- d_ptr->fill_percent2 = p2;
- d_ptr->fill_type3 = w3;
- d_ptr->fill_percent3 = p3;
- d_ptr->outer_wall = outer;
- d_ptr->inner_wall = inner;
- d_ptr->stream1 = stream1;
- d_ptr->stream2 = stream2;
+ 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;
struct dungeon_grid
{
- int feature; /* Terrain feature */
- int monster; /* Monster */
- int object; /* Object */
- int ego; /* Ego-Item */
- int artifact; /* Artifact */
- int trap; /* Trap */
+ IDX feature; /* Terrain feature */
+ IDX monster; /* Monster */
+ IDX object; /* Object */
+ IDX ego; /* Ego-Item */
+ IDX artifact; /* Artifact */
+ IDX trap; /* Trap */
int cave_info; /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
int special; /* Reserved for special terrain info */
int random; /* Number of the random effect */
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)
{
index = atoi(s);
/* Find the colon after the building number */
- s = strchr(s, ':');
+ s = my_strchr(s, ':');
/* Verify that colon */
if (!s) return (1);
}
-/*
+/*!
+ * @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 idx = s[0];
- int object_index = letter[idx].object;
- int monster_index = letter[idx].monster;
+ IDX object_index = letter[idx].object;
+ IDX monster_index = letter[idx].monster;
int random = letter[idx].random;
- int artifact_index = letter[idx].artifact;
+ IDX 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;
}
/* Make alive again */
- if (r_info[monster_index].flags7 & RF7_UNIQUE_7)
+ /* Hack -- Non-unique Nazguls are semi-unique */
+ else if (r_info[monster_index].flags7 & RF7_NAZGUL)
{
if (r_info[monster_index].cur_num == r_info[monster_index].max_num)
{
/* Hidden trap (or door) */
else if (letter[idx].trap)
{
- c_ptr->mimic = f_info[c_ptr->feat].mimic;
- c_ptr->feat = letter[idx].trap;
+ c_ptr->mimic = c_ptr->feat;
+ 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 */
{
if (a_info[artifact_index].cur_num)
{
- int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
+ IDX k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
object_type forge;
object_type *q_ptr = &forge;
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;
}
}
q_ptr->cur_num = atoi(zz[4]);
q_ptr->max_num = atoi(zz[5]);
q_ptr->level = atoi(zz[6]);
- q_ptr->r_idx = atoi(zz[7]);
- q_ptr->k_idx = atoi(zz[8]);
+ q_ptr->r_idx = (IDX)atoi(zz[7]);
+ q_ptr->k_idx = (IDX)atoi(zz[8]);
q_ptr->dungeon = atoi(zz[9]);
if (num > 10)
return (0);
}
+ else if (zz[1][0] == 'R')
+ {
+ if (init_flags & INIT_ASSIGN)
+ {
+ int count = 0;
+ IDX idx, reward_idx = 0;
+
+ for (idx = 2; idx < num; idx++)
+ {
+ IDX a_idx = (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]);
}
/* Place player in a quest level */
if (p_ptr->inside_quest)
{
- int y, x;
+ int py, px;
/* Delete the monster (if any) */
- delete_monster(py, px);
+ delete_monster(p_ptr->y, p_ptr->x);
- y = atoi(zz[0]);
- x = atoi(zz[1]);
+ py = atoi(zz[0]);
+ px = atoi(zz[1]);
- py = y;
- px = x;
+ p_ptr->y = py;
+ p_ptr->x = px;
}
/* Place player in the town */
else if (!p_ptr->oldpx && !p_ptr->oldpy)
/* Maximum towns */
if (zz[0][0] == 'T')
{
- max_towns = atoi(zz[1]);
+ max_towns = (IDX)atoi(zz[1]);
}
/* Maximum quests */
else if (zz[0][0] == 'Q')
{
- max_quests = atoi(zz[1]);
+ max_quests = (IDX)atoi(zz[1]);
}
/* Maximum r_idx */
else if (zz[0][0] == 'R')
{
- max_r_idx = atoi(zz[1]);
+ max_r_idx = (IDX)atoi(zz[1]);
}
/* Maximum k_idx */
else if (zz[0][0] == 'K')
{
- max_k_idx = atoi(zz[1]);
+ max_k_idx = (IDX)atoi(zz[1]);
}
/* Maximum v_idx */
else if (zz[0][0] == 'V')
{
- max_v_idx = atoi(zz[1]);
+ max_v_idx = (IDX)atoi(zz[1]);
}
/* Maximum f_idx */
else if (zz[0][0] == 'F')
{
- max_f_idx = atoi(zz[1]);
+ max_f_idx = (IDX)atoi(zz[1]);
}
/* Maximum a_idx */
else if (zz[0][0] == 'A')
{
- max_a_idx = atoi(zz[1]);
+ max_a_idx = (IDX)atoi(zz[1]);
}
/* Maximum e_idx */
else if (zz[0][0] == 'E')
{
- max_e_idx = atoi(zz[1]);
+ max_e_idx = (IDX)atoi(zz[1]);
}
/* Maximum d_idx */
else if (zz[0][0] == 'D')
{
- max_d_idx = atoi(zz[1]);
+ max_d_idx = (IDX)atoi(zz[1]);
}
/* Maximum o_idx */
else if (zz[0][0] == 'O')
{
- max_o_idx = atoi(zz[1]);
+ max_o_idx = (IDX)atoi(zz[1]);
}
/* Maximum m_idx */
else if (zz[0][0] == 'M')
{
- max_m_idx = atoi(zz[1]);
+ max_m_idx = (IDX)atoi(zz[1]);
}
/* Wilderness size */
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;
/* Function: EQU */
else if (streq(t, "EQU"))
{
- v = "1";
+ v = "0";
if (*s && (f != b2))
{
t = process_dungeon_file_expr(&s, &f);
}
while (*s && (f != b2))
{
- p = t;
- t = process_dungeon_file_expr(&s, &f);
- if (*t && !streq(p, t)) v = "0";
+ p = process_dungeon_file_expr(&s, &f);
+ if (streq(t, p)) v = "1";
}
}
{
p = t;
t = process_dungeon_file_expr(&s, &f);
- if (*t && (strcmp(p, t) > 0)) v = "0";
+ if (*t && atoi(p) > atoi(t)) v = "0";
}
}
{
p = t;
t = process_dungeon_file_expr(&s, &f);
- if (*t && (strcmp(p, t) < 0)) v = "0";
+
+ /* Compare two numbers instead of string */
+ if (*t && atoi(p) < atoi(t)) v = "0";
}
}
else
{
/* Accept all printables except spaces and brackets */
- while (isprint(*s) && !strchr(" []", *s)) ++s;
+#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';
/* Race */
else if (streq(b+1, "RACE"))
{
-#ifdef JP
- v = rp_ptr->E_title;
-#else
- v = rp_ptr->title;
-#endif
+ v = _(rp_ptr->E_title, rp_ptr->title);
}
/* Class */
else if (streq(b+1, "CLASS"))
{
-#ifdef JP
- v = cp_ptr->E_title;
-#else
- v = cp_ptr->title;
-#endif
+ v = _(cp_ptr->E_title, cp_ptr->title);
}
/* First realm */
else if (streq(b+1, "REALM1"))
{
-#ifdef JP
- v = E_realm_names[p_ptr->realm1];
-#else
- v = realm_names[p_ptr->realm1];
-#endif
+ v = _(E_realm_names[p_ptr->realm1], realm_names[p_ptr->realm1]);
}
/* Second realm */
else if (streq(b+1, "REALM2"))
{
-#ifdef JP
- v = E_realm_names[p_ptr->realm2];
-#else
- v = realm_names[p_ptr->realm2];
-#endif
+ v = _(E_realm_names[p_ptr->realm2], realm_names[p_ptr->realm2]);
}
/* Player name */
else if (streq(b+1, "PLAYER"))
{
- v = player_base;
+ static char tmp_player_name[32];
+ char *pn, *tpn;
+ for (pn = p_ptr->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;
/* Oops */
msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
-#ifdef JP
-msg_format("'%s'¤ò²òÀÏÃæ¡£", buf);
-#else
- msg_format("Parsing '%s'.", buf);
-#endif
+ msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
msg_print(NULL);
}
f_ptr[1] = r_ptr->flags2; n_ptr[1] = r_info_flags2;
f_ptr[2] = r_ptr->flags3; n_ptr[2] = r_info_flags3;
f_ptr[3] = r_ptr->flags4; n_ptr[3] = r_info_flags4;
- f_ptr[4] = r_ptr->flags5; n_ptr[4] = r_info_flags5;
- f_ptr[5] = r_ptr->flags6; n_ptr[5] = r_info_flags6;
+ f_ptr[4] = r_ptr->a_ability_flags1; n_ptr[4] = r_a_ability_flags1;
+ f_ptr[5] = r_ptr->a_ability_flags2; n_ptr[5] = r_a_ability_flags2;
f_ptr[6] = r_ptr->flags7; n_ptr[6] = r_info_flags7;
f_ptr[7] = r_ptr->flags8; n_ptr[7] = r_info_flags8;
f_ptr[8] = r_ptr->flags9; n_ptr[8] = r_info_flags9;
/* 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];
}