X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Finit1.c;h=998e1884546d1d70cebea27171a1bdcdad12ff37;hb=6cf96c6b1c3341ee94382b482f969b4b7f9d5858;hp=af4e9c45bbc3f82a17767cb89ed295adf0ed66b8;hpb=10b61dc2007f9524e109f6f952c66b2496678dff;p=hengband%2Fhengband.git diff --git a/src/init1.c b/src/init1.c index af4e9c45b..998e18845 100644 --- a/src/init1.c +++ b/src/init1.c @@ -1,29 +1,25 @@ -/* File: init1.c */ - -/* - * Copyright (c) 1997 Ben Harrison - * +/*! + * @file init1.c + * @brief ゲームデータ初期化1 / Initialization (part 1) -BEN- + * @date 2014/01/28 + * @author + *
+ * 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
+ * 
+ * @details + *
  * 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
@@ -36,12 +32,24 @@
  * "*.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.
+ * 
*/ +#include "angband.h" + + + #ifdef ALLOW_TEMPLATES #include "init.h" @@ -49,7 +57,8 @@ /*** Helper arrays for parsing ascii template files ***/ -/* +/*! + * モンスターの打撃手段トークンの定義 / * Monster Blow Methods */ static cptr r_info_blow_method[] = @@ -84,7 +93,8 @@ static cptr r_info_blow_method[] = }; -/* +/*! + * モンスターの打撃属性トークンの定義 / * Monster Blow Effects */ static cptr r_info_blow_effect[] = @@ -123,11 +133,13 @@ static cptr r_info_blow_effect[] = "EXP_VAMP", "DR_MANA", "SUPERHURT", + "INERTIA", + "STUN", NULL }; - -/* +/*! + * 地形属性トークンの定義 / * Feature info flags */ static cptr f_info_flags[] = @@ -251,7 +263,8 @@ static cptr f_info_flags[] = }; -/* +/*! + * モンスター特性トークンの定義1 / * Monster race flags */ static cptr r_info_flags1[] = @@ -290,7 +303,8 @@ static cptr r_info_flags1[] = "XXX3" }; -/* +/*! + * モンスター特性トークンの定義2 / * Monster race flags */ static cptr r_info_flags2[] = @@ -329,7 +343,8 @@ static cptr r_info_flags2[] = "QUANTUM" }; -/* +/*! + * モンスター特性トークンの定義3 / * Monster race flags */ static cptr r_info_flags3[] = @@ -368,7 +383,8 @@ static cptr r_info_flags3[] = "NO_SLEEP" }; -/* +/*! + * モンスター特性トークンの定義4 / * Monster race flags */ static cptr r_info_flags4[] = @@ -407,10 +423,11 @@ 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", @@ -446,10 +463,11 @@ static cptr r_info_flags5[] = "HOLD" }; -/* +/*! + * モンスター特性トークン(発動型能力2) / * Monster race flags */ -static cptr r_info_flags6[] = +static cptr r_a_ability_flags2[] = { "HASTE", "HAND_DOOM", @@ -485,8 +503,89 @@ static cptr r_info_flags6[] = "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[] = @@ -505,7 +604,7 @@ static cptr r_info_flags7[] = "SELF_LITE_2", "GUARDIAN", "CHAMELEON", - "KILL_EXP", + "XXXX4XXX", "TANUKI", "HAS_DARK_1", "SELF_DARK_1", @@ -525,7 +624,8 @@ static cptr r_info_flags7[] = "XXX7X31", }; -/* +/*! + * モンスター特性トークンの定義8 / * Monster race flags */ static cptr r_info_flags8[] = @@ -565,8 +665,9 @@ static cptr r_info_flags8[] = }; -/* - * Monster race flags - Drops +/*! + * モンスター特性トークンの定義9 / + * Monster race flags */ static cptr r_info_flags9[] = { @@ -606,8 +707,9 @@ static cptr r_info_flags9[] = }; -/* - * Monster race flags - Resistances +/*! + * モンスター特性トークンの定義R(耐性) / + * Monster race flags */ static cptr r_info_flagsr[] = { @@ -646,7 +748,8 @@ static cptr r_info_flagsr[] = }; -/* +/*! + * オブジェクト基本特性トークンの定義 / * Object flags */ static cptr k_info_flags[] = @@ -699,7 +802,7 @@ static cptr k_info_flags[] = "THROW", "REFLECT", "FREE_ACT", - "HOLD_LIFE", + "HOLD_EXP", "RES_ACID", "RES_ELEC", "RES_FIRE", @@ -728,7 +831,7 @@ static cptr k_info_flags[] = "WARNING", "HIDE_TYPE", "SHOW_MODS", - "XXX1", + "SLAY_GOOD", "LEVITATION", "LITE", "SEE_INVIS", @@ -746,9 +849,9 @@ static cptr k_info_flags[] = "TELEPORT", "AGGRAVATE", "BLESSED", - "XXX3", - "XXX4", - "XXX5", + "XXX3", /* Fake flag for Smith */ + "XXX4", /* Fake flag for Smith */ + "KILL_GOOD", "KILL_ANIMAL", "KILL_EVIL", @@ -772,9 +875,34 @@ static cptr k_info_flags[] = "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", @@ -793,8 +921,8 @@ static cptr k_info_gen_flags[] = "RANDOM_CURSE0", "RANDOM_CURSE1", "RANDOM_CURSE2", - "XXX", - "XXX", + "XTRA_DICE", + "POWERFUL", "XXX", "XXX", "XXX", @@ -811,8 +939,8 @@ static cptr k_info_gen_flags[] = "XXX", }; - -/* +/*! + * ダンジョン特性トークンの定義 / * Dungeon flags */ static cptr d_info_flags1[] = @@ -829,7 +957,7 @@ static cptr d_info_flags1[] = "GLASS_DOOR", "CAVE", "CAVERN", - "XXX", + "ARCADE", "XXX", "XXX", "XXX", @@ -841,7 +969,7 @@ static cptr d_info_flags1[] = "NO_VAULT", "ARENA", "DESTROY", - "XXX", + "GLASS_ROOM", "NO_CAVE", "NO_MAGIC", "NO_MELEE", @@ -852,9 +980,15 @@ static cptr d_info_flags1[] = }; -/* +/*! + * @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. */ @@ -909,11 +1043,16 @@ static bool add_text(u32b *offset, header *head, cptr buf, bool normal_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) { @@ -939,13 +1078,18 @@ 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) +static bool add_tag(STR_OFFSET *offset, header *head, cptr buf) { u32b i; @@ -981,9 +1125,12 @@ 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) { @@ -1016,8 +1163,14 @@ 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) @@ -1034,7 +1187,7 @@ errr init_info_txt(FILE *fp, char *buf, header *head, /* 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)) @@ -1082,8 +1235,12 @@ errr init_info_txt(FILE *fp, char *buf, header *head, } -/* +/*! + * @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) { @@ -1150,10 +1307,10 @@ errr parse_v_info(char *buf, header *head) &typ, &rat, &hgt, &wid)) return (1); /* Save the values */ - v_ptr->typ = typ; - v_ptr->rat = rat; - v_ptr->hgt = hgt; - v_ptr->wid = wid; + v_ptr->typ = (ROOM_IDX)typ; + v_ptr->rat = (PROB)rat; + v_ptr->hgt = (POSITION)hgt; + v_ptr->wid = (POSITION)wid; } /* Oops */ @@ -1164,9 +1321,12 @@ errr parse_v_info(char *buf, header *head) } - -/* +/*! + * @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) { @@ -1233,8 +1393,8 @@ errr parse_s_info(char *buf, header *head) || max < WEAPON_EXP_UNSKILLED || max > WEAPON_EXP_MASTER) return (8); /* Save the values */ - s_ptr->s_start[num] = start; - s_ptr->s_max[num] = max; + s_ptr->s_start[num] = (SUB_EXP)start; + s_ptr->s_max[num] = (SUB_EXP)max; } @@ -1246,8 +1406,12 @@ 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) { @@ -1358,10 +1522,10 @@ errr parse_m_info(char *buf, header *head) if (4 != sscanf(buf+2, "%d:%d:%d:%d", &level, &mana, &fail, &exp)) return (1); - m_ptr->info[realm][magic_idx].slevel = level; - m_ptr->info[realm][magic_idx].smana = mana; - m_ptr->info[realm][magic_idx].sfail = fail; - m_ptr->info[realm][magic_idx].sexp = exp; + m_ptr->info[realm][magic_idx].slevel = (PLAYER_LEVEL)level; + m_ptr->info[realm][magic_idx].smana = (MANA_POINT)mana; + m_ptr->info[realm][magic_idx].sfail = (PERCENTAGE)fail; + m_ptr->info[realm][magic_idx].sexp = (EXP)exp; magic_idx ++; } @@ -1374,8 +1538,13 @@ 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) { @@ -1395,8 +1564,12 @@ 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) { @@ -1413,23 +1586,24 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what) } /* Oops */ -#ifdef JP - msg_format("̤ÃΤÎÃÏ·Á¥Õ¥é¥° '%s'¡£", what); -#else - msg_format("Unknown feature flag '%s'.", what); -#endif + 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; + FF_FLAGS_IDX i; /* Check flags */ for (i = 0; i < FF_FLAG_MAX; i++) @@ -1442,19 +1616,19 @@ static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count) } /* Oops */ -#ifdef JP - msg_format("̤ÃΤÎÃÏ·Á¥¢¥¯¥·¥ç¥ó '%s'¡£", what); -#else - msg_format("Unknown feature action '%s'.", what); -#endif + 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) { @@ -1501,10 +1675,10 @@ errr parse_f_info(char *buf, header *head) } /* Default "mimic" */ - f_ptr->mimic = i; + f_ptr->mimic = (FEAT_IDX)i; /* Default "destroyed state" -- if not specified */ - f_ptr->destroyed = i; + f_ptr->destroyed = (FEAT_IDX)i; /* Default "states" */ for (i = 0; i < MAX_FEAT_STATES; i++) f_ptr->state[i].action = FF_FLAG_MAX; @@ -1544,12 +1718,12 @@ errr parse_f_info(char *buf, header *head) /* Process 'M' for "Mimic" (one line only) */ else if (buf[0] == 'M') { - s16b offset; + STR_OFFSET offset; if (!add_tag(&offset, head, buf + 2)) return PARSE_ERROR_OUT_OF_MEMORY; /* Record a fake tag index */ - f_ptr->mimic = -offset; + f_ptr->mimic_tag = offset; } @@ -1647,7 +1821,7 @@ errr parse_f_info(char *buf, header *head) if (1 == sscanf(s, "SUBTYPE_%d", &i)) { /* Extract a "subtype" */ - f_ptr->subtype = i; + f_ptr->subtype = (FEAT_SUBTYPE)i; /* Start at next entry */ s = t; @@ -1660,7 +1834,7 @@ errr parse_f_info(char *buf, header *head) if (1 == sscanf(s, "POWER_%d", &i)) { /* Extract a "power" */ - f_ptr->power = i; + f_ptr->power = (FEAT_POWER)i; /* Start at next entry */ s = t; @@ -1686,13 +1860,13 @@ errr parse_f_info(char *buf, header *head) if (1 != sscanf(buf+2, "%d", &priority)) return (PARSE_ERROR_GENERIC); /* Save the value */ - f_ptr->priority = priority; + f_ptr->priority = (FEAT_PRIORITY)priority; } /* Process 'K' for "States" (up to four lines + default (which cannot be last)) */ else if (buf[0] == 'K') { - s16b offset; + STR_OFFSET 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; @@ -1712,7 +1886,7 @@ errr parse_f_info(char *buf, header *head) if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY; /* Record a fake tag index */ - f_ptr->destroyed = -offset; + f_ptr->destroyed_tag = offset; } else { @@ -1725,20 +1899,23 @@ errr parse_f_info(char *buf, header *head) if (!add_tag(&offset, head, t)) return PARSE_ERROR_OUT_OF_MEMORY; /* Record a fake tag index */ - f_ptr->state[i].result = -offset; + f_ptr->state[i].result_tag = offset; } } /* Oops */ - else return (6); + else return (6); /* Success */ return (0); } -/* +/*! + * @brief 地形タグからIDを得る / * Convert a fake tag to a real feat index + * @param str タグ文字列 + * @return 地形ID */ s16b f_tag_to_index(cptr str) { @@ -1759,38 +1936,43 @@ s16b f_tag_to_index(cptr str) } -/* +/*! + * @brief 地形タグからIDを得る / * Search for real index corresponding to this fake tag + * @param feat タグ文字列のオフセット + * @return 地形ID。該当がないなら-1 */ -static void search_real_feat(s16b *feat) +static FEAT_IDX search_real_feat(STR_OFFSET feat) { - int i; + FEAT_IDX i; /* Don't convert non-fake tag */ - if (*feat >= 0) return; + if (feat <= 0) + { + return -1; + } /* Search for real index corresponding to this fake tag */ for (i = 0; i < f_head.info_num; i++) { - if ((-(*feat)) == f_info[i].tag) + if (feat == f_info[i].tag) { /* Record real index */ - *feat = (s16b)i; - return; + return i; } } /* Undefined tag */ -#ifdef JP - msg_format("̤ÄêµÁ¤Î¥¿¥° '%s'¡£", f_tag + (-(*feat))); -#else - msg_format("%s is undefined.", f_tag + (-(*feat))); -#endif + msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat); + return -1; } -/* +/*! + * @brief 地形情報の各種タグからIDへ変換して結果を収める / * Retouch fake tags of f_info + * @param head ヘッダ構造体 + * @return なし */ void retouch_f_info(header *head) { @@ -1800,19 +1982,27 @@ void retouch_f_info(header *head) for (i = 0; i < head->info_num; i++) { feature_type *f_ptr = &f_info[i]; - int j; - - search_real_feat(&f_ptr->mimic); + FEAT_IDX j, k; - search_real_feat(&f_ptr->destroyed); - - for (j = 0; j < MAX_FEAT_STATES; j++) search_real_feat(&f_ptr->state[j].result); + k = search_real_feat(f_ptr->mimic_tag); + f_ptr->mimic = k < 0 ? f_ptr->mimic : k; + k = search_real_feat(f_ptr->destroyed_tag); + f_ptr->destroyed = k < 0 ? f_ptr->destroyed : k; + for (j = 0; j < MAX_FEAT_STATES; j++) + { + k = search_real_feat(f_ptr->state[j].result_tag); + f_ptr->state[j].result = k < 0 ? f_ptr->state[j].result : k; + } } } -/* +/*! + * @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) { @@ -1832,20 +2022,52 @@ static errr grab_one_kind_flag(object_kind *k_ptr, cptr what) return 0; /* Oops */ -#ifdef JP - msg_format("̤ÃΤΥ¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what); -#else - msg_format("Unknown object flag '%s'.", what); -#endif - + 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 (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 */ + msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what); + + /* 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) { @@ -1915,8 +2137,8 @@ errr parse_k_info(char *buf, header *head) #ifdef JP - /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */ - /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */ + /* 英語名を読むルーチンを追加 */ + /* 'E' から始まる行は英語名としている */ else if (buf[0] == 'E') { /* nothing to do */ @@ -2002,9 +2224,9 @@ errr parse_k_info(char *buf, header *head) &tval, &sval, &pval)) return (1); /* Save the values */ - k_ptr->tval = tval; - k_ptr->sval = sval; - k_ptr->pval = pval; + k_ptr->tval = (OBJECT_TYPE_VALUE)tval; + k_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval; + k_ptr->pval = (PARAMETER_VALUE)pval; } /* Process 'W' for "More Info" (one line only) */ @@ -2018,16 +2240,15 @@ errr parse_k_info(char *buf, header *head) &level, &extra, &wgt, &cost)) return (1); /* Save the values */ - k_ptr->level = level; - k_ptr->extra = extra; - k_ptr->weight = wgt; - k_ptr->cost = cost; + k_ptr->level = (DEPTH)level; + k_ptr->extra = (BIT_FLAGS8)extra; + k_ptr->weight = (WEIGHT)wgt; + k_ptr->cost = (PRICE)cost; } /* 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) @@ -2048,7 +2269,7 @@ errr parse_k_info(char *buf, header *head) if (t && (!s || t < s)) { int chance = atoi(t+1); - if (chance > 0) k_ptr->chance[i] = chance; + if (chance > 0) k_ptr->chance[i] = (PROB)chance; } } } @@ -2062,12 +2283,27 @@ errr parse_k_info(char *buf, header *head) if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d", &ac, &hd1, &hd2, &th, &td, &ta)) return (1); - k_ptr->ac = ac; - k_ptr->dd = hd1; - k_ptr->ds = hd2; - k_ptr->to_h = th; - k_ptr->to_d = td; - k_ptr->to_a = ta; + k_ptr->ac = (ARMOUR_CLASS)ac; + k_ptr->dd = (DICE_NUMBER)hd1; + k_ptr->ds = (DICE_SID)hd2; + k_ptr->to_h = (HIT_PROB)th; + k_ptr->to_d = (HIT_POINT)td; + k_ptr->to_a = (ARMOUR_CLASS)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 */ @@ -2103,9 +2339,12 @@ errr parse_k_info(char *buf, header *head) 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) { @@ -2125,22 +2364,19 @@ static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what) 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) { @@ -2198,8 +2434,8 @@ errr parse_a_info(char *buf, header *head) #ifdef JP - /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */ - /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */ + /* 英語名を読むルーチンを追加 */ + /* 'E' から始まる行は英語名としている */ else if (buf[0] == 'E') { /* nothing to do */ @@ -2245,9 +2481,9 @@ errr parse_a_info(char *buf, header *head) &tval, &sval, &pval)) return (1); /* Save the values */ - a_ptr->tval = tval; - a_ptr->sval = sval; - a_ptr->pval = pval; + a_ptr->tval = (OBJECT_TYPE_VALUE)tval; + a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval; + a_ptr->pval = (PARAMETER_VALUE)pval; } /* Process 'W' for "More Info" (one line only) */ @@ -2261,10 +2497,10 @@ errr parse_a_info(char *buf, header *head) &level, &rarity, &wgt, &cost)) return (1); /* Save the values */ - a_ptr->level = level; - a_ptr->rarity = rarity; - a_ptr->weight = wgt; - a_ptr->cost = cost; + a_ptr->level = (DEPTH)level; + a_ptr->rarity = (RARITY)rarity; + a_ptr->weight = (WEIGHT)wgt; + a_ptr->cost = (PRICE)cost; } /* Hack -- Process 'P' for "power" and such */ @@ -2276,12 +2512,27 @@ errr parse_a_info(char *buf, header *head) if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d", &ac, &hd1, &hd2, &th, &td, &ta)) return (1); - a_ptr->ac = ac; - a_ptr->dd = hd1; - a_ptr->ds = hd2; - a_ptr->to_h = th; - a_ptr->to_d = td; - a_ptr->to_a = ta; + a_ptr->ac = (ARMOUR_CLASS)ac; + a_ptr->dd = (DICE_NUMBER)hd1; + a_ptr->ds = (DICE_SID)hd2; + a_ptr->to_h = (HIT_PROB)th; + a_ptr->to_d = (HIT_POINT)td; + a_ptr->to_a = (ARMOUR_CLASS)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 */ @@ -2318,8 +2569,12 @@ errr parse_a_info(char *buf, header *head) } -/* +/*! + * @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) { @@ -2339,22 +2594,19 @@ static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what) return 0; /* Oops */ -#ifdef JP - msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what); -#else - msg_format("Unknown ego-item flag '%s'.", what); -#endif - + 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) { @@ -2413,8 +2665,8 @@ errr parse_e_info(char *buf, header *head) #ifdef JP - /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */ - /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */ + /* 英語名を読むルーチンを追加 */ + /* 'E' から始まる行は英語名 */ else if (buf[0] == 'E') { /* nothing to do */ @@ -2453,8 +2705,8 @@ errr parse_e_info(char *buf, header *head) &slot, &rating)) return (1); /* Save the values */ - e_ptr->slot = slot; - e_ptr->rating = rating; + e_ptr->slot = (INVENTORY_IDX)slot; + e_ptr->rating = (PRICE)rating; } /* Process 'W' for "More Info" (one line only) */ @@ -2469,7 +2721,7 @@ errr parse_e_info(char *buf, header *head) /* Save the values */ e_ptr->level = level; - e_ptr->rarity = rarity; + e_ptr->rarity = (RARITY)rarity; /* e_ptr->weight = wgt; */ e_ptr->cost = cost; } @@ -2477,16 +2729,31 @@ errr parse_e_info(char *buf, header *head) /* 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 = (HIT_PROB)th; + e_ptr->max_to_d = (HIT_POINT)td; + e_ptr->max_to_a = (ARMOUR_CLASS)ta; + e_ptr->max_pval = (PARAMETER_VALUE)pval; + } - e_ptr->max_to_h = th; - e_ptr->max_to_d = td; - e_ptr->max_to_a = ta; - 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 */ @@ -2521,8 +2788,12 @@ errr parse_e_info(char *buf, header *head) } -/* +/*! + * @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) { @@ -2548,49 +2819,45 @@ static errr grab_one_basic_flag(monster_race *r_ptr, cptr what) 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) { if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0) return 0; - if (grab_one_flag(&r_ptr->flags5, r_info_flags5, what) == 0) + if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0) return 0; - if (grab_one_flag(&r_ptr->flags6, r_info_flags6, what) == 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) { @@ -2642,8 +2909,8 @@ errr parse_r_info(char *buf, header *head) #ifdef JP - /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */ - /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */ + /* 英語名を読むルーチンを追加 */ + /* 'E' から始まる行は英語名 */ else if (buf[0] == 'E') { /* Acquire the Text */ @@ -2717,12 +2984,12 @@ errr parse_r_info(char *buf, header *head) &spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1); /* Save the values */ - r_ptr->speed = spd; - r_ptr->hdice = hp1; - r_ptr->hside = hp2; - r_ptr->aaf = aaf; - r_ptr->ac = ac; - r_ptr->sleep = slp; + r_ptr->speed = (SPEED)spd; + r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1); + r_ptr->hside = (DICE_SID)MAX(hp2, 1); + r_ptr->aaf = (POSITION)aaf; + r_ptr->ac = (ARMOUR_CLASS)ac; + r_ptr->sleep = (SLEEP_DEGREE)slp; } /* Process 'W' for "More Info" (one line only) */ @@ -2738,12 +3005,29 @@ errr parse_r_info(char *buf, header *head) &lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1); /* Save the values */ - r_ptr->level = lev; - r_ptr->rarity = rar; - r_ptr->extra = pad; - r_ptr->mexp = exp; - r_ptr->next_exp = nextexp; - r_ptr->next_r_idx = nextmon; + r_ptr->level = (DEPTH)lev; + r_ptr->rarity = (RARITY)rar; + r_ptr->extra = (BIT_FLAGS16)pad; + r_ptr->mexp = (EXP)exp; + r_ptr->next_exp = (EXP)nextexp; + 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] = (MONRACE_IDX)id; + r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd; + r_ptr->reinforce_ds[i] = (DICE_SID)ds; } /* Process 'B' for "Blows" (up to four lines) */ @@ -2794,10 +3078,10 @@ errr parse_r_info(char *buf, header *head) if (*t == 'd') *t++ = '\0'; /* Save the method */ - r_ptr->blow[i].method = n1; + r_ptr->blow[i].method = (BLOW_METHOD)n1; /* Save the effect */ - r_ptr->blow[i].effect = n2; + r_ptr->blow[i].effect = (BLOW_EFFECT)n2; /* Extract the damage dice and sides */ r_ptr->blow[i].d_dice = atoi(s); @@ -2865,6 +3149,31 @@ errr parse_r_info(char *buf, header *head) } } + /* 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] = (ARTIFACT_IDX)id; + r_ptr->artifact_rarity[i] = (RARITY)rarity; + r_ptr->artifact_percent[i] = (PERCENTAGE)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); @@ -2874,8 +3183,12 @@ errr parse_r_info(char *buf, header *head) } -/* +/*! + * @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) { @@ -2883,18 +3196,18 @@ static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what) 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) { @@ -2920,43 +3233,43 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what) 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) { if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0) return 0; - if (grab_one_flag(&d_ptr->mflags5, r_info_flags5, what) == 0) + if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0) return 0; - if (grab_one_flag(&d_ptr->mflags6, r_info_flags6, what) == 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) { @@ -3049,16 +3362,16 @@ errr parse_d_info(char *buf, header *head) &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1); /* Save the values */ - d_ptr->mindepth = min_lev; - d_ptr->maxdepth = max_lev; - d_ptr->min_plev = min_plev; - d_ptr->mode = mode; + d_ptr->mindepth = (DEPTH)min_lev; + d_ptr->maxdepth = (DEPTH)max_lev; + d_ptr->min_plev = (PLAYER_LEVEL)min_plev; + d_ptr->mode = (BIT_FLAGS8)mode; d_ptr->min_m_alloc_level = min_alloc; d_ptr->max_m_alloc_chance = max_chance; d_ptr->obj_good = obj_good; d_ptr->obj_great = obj_great; - d_ptr->pit = pit; - d_ptr->nest = nest; + d_ptr->pit = (BIT_FLAGS16)pit; + d_ptr->nest = (BIT_FLAGS16)nest; } /* Process 'P' for "Place Info" */ @@ -3088,7 +3401,7 @@ errr parse_d_info(char *buf, header *head) 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->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]); } d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]); } @@ -3107,7 +3420,7 @@ errr parse_d_info(char *buf, header *head) 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->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]); } d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]); @@ -3145,7 +3458,7 @@ errr parse_d_info(char *buf, header *head) if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif)) { /* Extract a "Final Artifact" */ - d_ptr->final_artifact = artif; + d_ptr->final_artifact = (ARTIFACT_IDX)artif; /* Start at next entry */ s = t; @@ -3158,7 +3471,7 @@ errr parse_d_info(char *buf, header *head) if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif)) { /* Extract a "Final Artifact" */ - d_ptr->final_object = artif; + d_ptr->final_object = (KIND_OBJECT_IDX)artif; /* Start at next entry */ s = t; @@ -3171,7 +3484,7 @@ errr parse_d_info(char *buf, header *head) if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst)) { /* Extract a "Artifact Guardian" */ - d_ptr->final_guardian = monst; + d_ptr->final_guardian = (MONRACE_IDX)monst; /* Start at next entry */ s = t; @@ -3184,7 +3497,7 @@ errr parse_d_info(char *buf, header *head) if (1 == sscanf(s, "MONSTER_DIV_%d", &monst)) { /* Extract a "Special %" */ - d_ptr->special_div = monst; + d_ptr->special_div = (PROB)monst; /* Start at next entry */ s = t; @@ -3306,12 +3619,12 @@ 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 */ @@ -3321,8 +3634,11 @@ struct dungeon_grid static dungeon_grid letter[255]; -/* +/*! + * @brief 地形情報の「F:」情報をパースする * Process "F:::::::::" -- info for dungeon grid + * @param buf 解析文字列 + * @return エラーコード */ static errr parse_line_feature(char *buf) { @@ -3372,11 +3688,18 @@ static errr parse_line_feature(char *buf) if (zz[6][0] == '*') { letter[index].random |= RANDOM_ARTIFACT; - if (zz[6][1]) letter[index].artifact = atoi(zz[6] + 1); + if (zz[6][1]) letter[index].artifact = (IDX)atoi(zz[6] + 1); + } + else if (zz[6][0] == '!') + { + if (p_ptr->inside_quest) + { + letter[index].artifact = quest[p_ptr->inside_quest].k_idx; + } } else { - letter[index].artifact = atoi(zz[6]); + letter[index].artifact = (IDX)atoi(zz[6]); } /* Fall through */ /* Ego-item */ @@ -3384,11 +3707,11 @@ static errr parse_line_feature(char *buf) if (zz[5][0] == '*') { letter[index].random |= RANDOM_EGO; - if (zz[5][1]) letter[index].ego = atoi(zz[5] + 1); + if (zz[5][1]) letter[index].ego = (IDX)atoi(zz[5] + 1); } else { - letter[index].ego = atoi(zz[5]); + letter[index].ego = (IDX)atoi(zz[5]); } /* Fall through */ /* Object */ @@ -3396,11 +3719,26 @@ static errr parse_line_feature(char *buf) if (zz[4][0] == '*') { letter[index].random |= RANDOM_OBJECT; - if (zz[4][1]) letter[index].object = atoi(zz[4] + 1); + if (zz[4][1]) letter[index].object = (IDX)atoi(zz[4] + 1); + } + else if (zz[4][0] == '!') + { + if (p_ptr->inside_quest) + { + 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 { - letter[index].object = atoi(zz[4]); + letter[index].object = (IDX)atoi(zz[4]); } /* Fall through */ /* Monster */ @@ -3408,7 +3746,7 @@ static errr parse_line_feature(char *buf) if (zz[3][0] == '*') { letter[index].random |= RANDOM_MONSTER; - if (zz[3][1]) letter[index].monster = atoi(zz[3] + 1); + if (zz[3][1]) letter[index].monster = (IDX)atoi(zz[3] + 1); } else if (zz[3][0] == 'c') { @@ -3417,7 +3755,7 @@ static errr parse_line_feature(char *buf) } else { - letter[index].monster = atoi(zz[3]); + letter[index].monster = (IDX)atoi(zz[3]); } /* Fall through */ /* Cave info */ @@ -3445,8 +3783,11 @@ static errr parse_line_feature(char *buf) } -/* +/*! + * @brief 地形情報の「B:」情報をパースする * Process "B:::..." -- Building definition + * @param buf 解析文字列 + * @return エラーコード */ static errr parse_line_building(char *buf) { @@ -3514,19 +3855,19 @@ static errr parse_line_building(char *buf) strcpy(building[index].act_names[action_index], zz[1]); /* Cost of the action for members */ - building[index].member_costs[action_index] = atoi(zz[2]); + building[index].member_costs[action_index] = (PRICE)atoi(zz[2]); /* Cost of the action for non-members */ - building[index].other_costs[action_index] = atoi(zz[3]); + building[index].other_costs[action_index] = (PRICE)atoi(zz[3]); /* Letter assigned to the action */ building[index].letters[action_index] = zz[4][0]; /* Action code */ - building[index].actions[action_index] = atoi(zz[5]); + building[index].actions[action_index] = (BACT_IDX)atoi(zz[5]); /* Action restriction */ - building[index].action_restr[action_index] = atoi(zz[6]); + building[index].action_restr[action_index] = (BACT_RESTRICT_IDX)atoi(zz[6]); break; } @@ -3541,7 +3882,7 @@ static errr parse_line_building(char *buf) { for (i = 0; i < MAX_CLASS; i++) { - building[index].member_class[i] = atoi(zz[i]); + building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]); } break; @@ -3557,7 +3898,7 @@ static errr parse_line_building(char *buf) { for (i = 0; i < MAX_RACES; i++) { - building[index].member_race[i] = atoi(zz[i]); + building[index].member_race[i] = (RACE_IDX)atoi(zz[i]); } break; @@ -3573,7 +3914,7 @@ static errr parse_line_building(char *buf) { for (i = 0; i < MAX_MAGIC; i++) { - building[index].member_realm[i+1] = atoi(zz[i]); + building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]); } break; @@ -3598,8 +3939,13 @@ 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) { @@ -3631,8 +3977,17 @@ static void drop_here(object_type *j_ptr, int y, int x) } -/* +/*! + * @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) { @@ -3645,7 +4000,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in 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); @@ -3687,10 +4042,10 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in 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 = conv_dungeon_feat(letter[idx].feature); @@ -3824,7 +4179,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in { 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; @@ -3881,17 +4236,16 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in if (num < 9) return (PARSE_ERROR_TOO_FEW_ARGUMENTS); - q_ptr->type = atoi(zz[2]); - q_ptr->num_mon = atoi(zz[3]); - 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->dungeon = atoi(zz[9]); + q_ptr->type = (QUEST_TYPE)atoi(zz[2]); + q_ptr->num_mon = (MONSTER_NUMBER)atoi(zz[3]); + q_ptr->cur_num = (MONSTER_NUMBER)atoi(zz[4]); + q_ptr->max_num = (MONSTER_NUMBER)atoi(zz[5]); + q_ptr->level = (DEPTH)atoi(zz[6]); + q_ptr->r_idx = (IDX)atoi(zz[7]); + q_ptr->k_idx = (IDX)atoi(zz[8]); + q_ptr->dungeon = (DUNGEON_IDX)atoi(zz[9]); - if (num > 10) - q_ptr->flags = atoi(zz[10]); + if (num > 10) q_ptr->flags = atoi(zz[10]); r_ptr = &r_info[q_ptr->r_idx]; if (r_ptr->flags1 & RF1_UNIQUE) @@ -3903,10 +4257,42 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in 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::N:" -- 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]); } @@ -3958,16 +4344,16 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in /* 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) @@ -3995,67 +4381,67 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in /* 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 */ @@ -4083,8 +4469,12 @@ static char tmp[8]; 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) { @@ -4102,7 +4492,7 @@ 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; @@ -4230,7 +4620,15 @@ static cptr process_dungeon_file_expr(char **sp, char *fp) 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'; @@ -4261,47 +4659,46 @@ static cptr process_dungeon_file_expr(char **sp, char *fp) /* 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 */ @@ -4332,6 +4729,14 @@ static cptr process_dungeon_file_expr(char **sp, char *fp) 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")) { @@ -4385,6 +4790,16 @@ static cptr process_dungeon_file_expr(char **sp, char *fp) } +/*! + * @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; @@ -4421,7 +4836,7 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax) if (!buf[0]) continue; /* Skip "blank" lines */ - if (isspace(buf[0])) continue; + if (iswspace(buf[0])) continue; /* Skip comments */ if (buf[0] == '#') continue; @@ -4467,11 +4882,7 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax) /* 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); } @@ -4505,7 +4916,7 @@ void write_r_info_txt(void) cptr desc; - int mode = -1; + BIT_FLAGS mode = -1; if (!fff) return; @@ -4556,8 +4967,8 @@ void write_r_info_txt(void) 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; @@ -4684,7 +5095,7 @@ void write_r_info_txt(void) /* 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]; }