OSDN Git Service

[Refactor] #37353 グローバル変数 dungeon_type を他の慣例に従い dungeon_idx に改名。 / Rename dungeon_typ...
[hengband/hengband.git] / src / init1.c
index 45f7e9d..d4ba605 100644 (file)
  */
 
 #include "angband.h"
+#include "trap.h"
+#include "monster.h"
+#include "artifact.h"
+#include "cmd-activate.h"
 
 
 
@@ -61,7 +65,7 @@
  * モンスターの打撃手段トークンの定義 /
  * Monster Blow Methods
  */
-static cptr r_info_blow_method[] =
+static concptr r_info_blow_method[] =
 {
        "",
        "HIT",
@@ -97,7 +101,7 @@ static cptr r_info_blow_method[] =
  * モンスターの打撃属性トークンの定義 /
  * Monster Blow Effects
  */
-static cptr r_info_blow_effect[] =
+static concptr r_info_blow_effect[] =
 {
        "",
        "HURT",
@@ -142,7 +146,7 @@ static cptr r_info_blow_effect[] =
  * 地形属性トークンの定義 /
  * Feature info flags
  */
-static cptr f_info_flags[] =
+static concptr f_info_flags[] =
 {
        "LOS",
        "PROJECT",
@@ -188,15 +192,15 @@ static cptr f_info_flags[] =
        "LAVA",
        "SHALLOW",
        "DEEP",
-       "FILLED",
+       "POISON_PUDDLE",
        "HURT_ROCK",
        "HURT_FIRE",
        "HURT_COLD",
        "HURT_ACID",
-       "ICE",
-       "ACID",
+       "COLD_PUDDLE",
+       "ACID_PUDDLE",
        "OIL",
-       "XXX04",
+       "ELEC_PUDDLE",
        "CAN_CLIMB",
        "CAN_FLY",
        "CAN_SWIM",
@@ -267,7 +271,7 @@ static cptr f_info_flags[] =
  * モンスター特性トークンの定義1 /
  * Monster race flags
  */
-static cptr r_info_flags1[] =
+static concptr r_info_flags1[] =
 {
        "UNIQUE",
        "QUESTOR",
@@ -307,7 +311,7 @@ static cptr r_info_flags1[] =
  * モンスター特性トークンの定義2 /
  * Monster race flags
  */
-static cptr r_info_flags2[] =
+static concptr r_info_flags2[] =
 {
        "STUPID",
        "SMART",
@@ -347,7 +351,7 @@ static cptr r_info_flags2[] =
  * モンスター特性トークンの定義3 /
  * Monster race flags
  */
-static cptr r_info_flags3[] =
+static concptr r_info_flags3[] =
 {
        "ORC",
        "TROLL",
@@ -365,7 +369,7 @@ static cptr r_info_flags3[] =
        "HURT_ROCK",
        "HURT_FIRE",
        "HURT_COLD",
-       "XXX",
+       "ANGEL",
        "XXX",
        "XXX",
        "XXX",
@@ -387,7 +391,7 @@ static cptr r_info_flags3[] =
  * モンスター特性トークンの定義4 /
  * Monster race flags
  */
-static cptr r_info_flags4[] =
+static concptr r_info_flags4[] =
 {
        "SHRIEK",
        "XXX1",
@@ -424,10 +428,10 @@ static cptr r_info_flags4[] =
 };
 
 /*!
- * モンスター特性トークンの定義5 /
+ * モンスター特性トークン(発動型能力1) /
  * Monster race flags
  */
-static cptr r_info_flags5[] =
+static concptr r_a_ability_flags1[] =
 {
        "BA_ACID",
        "BA_ELEC",
@@ -464,10 +468,10 @@ static cptr r_info_flags5[] =
 };
 
 /*!
- * モンスター特性トークンの定義6 /
+ * モンスター特性トークン(発動型能力2) /
  * Monster race flags
  */
-static cptr r_info_flags6[] =
+static concptr r_a_ability_flags2[] =
 {
        "HASTE",
        "HAND_DOOM",
@@ -503,12 +507,96 @@ static cptr r_info_flags6[] =
        "S_UNIQUE"
 };
 
+#if 0
+/*!
+ * モンスター特性トークン(発動型能力3) /
+ * Monster race flags
+ */
+static concptr 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",
+};
+#endif
+
+#if 0
+/*!
+ * モンスター特性トークン(発動型能力4) /
+ * Monster race flags
+ */
+static concptr 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",
+};
+#endif
+
 
 /*!
  * モンスター特性トークンの定義7 /
  * Monster race flags
  */
-static cptr r_info_flags7[] =
+static concptr r_info_flags7[] =
 {
        "AQUATIC",
        "CAN_SWIM",
@@ -548,7 +636,7 @@ static cptr r_info_flags7[] =
  * モンスター特性トークンの定義8 /
  * Monster race flags
  */
-static cptr r_info_flags8[] =
+static concptr r_info_flags8[] =
 {
        "WILD_ONLY",
        "WILD_TOWN",
@@ -589,7 +677,7 @@ static cptr r_info_flags8[] =
  * モンスター特性トークンの定義9 /
  * Monster race flags
  */
-static cptr r_info_flags9[] =
+static concptr r_info_flags9[] =
 {
        "DROP_CORPSE",
        "DROP_SKELETON",
@@ -631,7 +719,7 @@ static cptr r_info_flags9[] =
  * モンスター特性トークンの定義R(耐性) /
  * Monster race flags
  */
-static cptr r_info_flagsr[] =
+static concptr r_info_flagsr[] =
 {
        "IM_ACID",
        "IM_ELEC",
@@ -672,7 +760,7 @@ static cptr r_info_flagsr[] =
  * オブジェクト基本特性トークンの定義 /
  * Object flags
  */
-static cptr k_info_flags[] =
+static concptr k_info_flags[] =
 {
        "STR",
        "INT",
@@ -823,7 +911,7 @@ static cptr k_info_flags[] =
  * オブジェクト生成特性トークンの定義 /
  * Object flags
  */
-static cptr k_info_gen_flags[] =
+static concptr k_info_gen_flags[] =
 {
        "INSTA_ART",
        "QUESTITEM",
@@ -863,7 +951,7 @@ static cptr k_info_gen_flags[] =
  * ダンジョン特性トークンの定義 /
  * Dungeon flags
  */
-static cptr d_info_flags1[] =
+static concptr d_info_flags1[] =
 {
        "WINNER",
        "MAZE",
@@ -878,8 +966,8 @@ static cptr d_info_flags1[] =
        "CAVE",
        "CAVERN",
        "ARCADE",
-       "XXX",
-       "XXX",
+       "LAKE_ACID",
+       "LAKE_POISONOUS",
        "XXX",
        "FORGET",
        "LAKE_WATER",
@@ -895,8 +983,8 @@ static cptr d_info_flags1[] =
        "NO_MELEE",
        "CHAMELEON",
        "DARKNESS",
-       "XXX",
-       "XXX"
+       "ACID_RIVER",
+       "POISONOUS_RIVER"
 };
 
 
@@ -912,7 +1000,7 @@ static cptr d_info_flags1[] =
  * Returns FALSE when there isn't enough space available to store
  * the text.
  */
-static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
+static bool add_text(u32b *offset, header *head, concptr buf, bool normal_text)
 {
        /* Hack -- Verify space */
        if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
@@ -974,7 +1062,7 @@ static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
  * Returns FALSE when there isn't enough space available to store
  * the text.
  */
-static bool add_name(u32b *offset, header *head, cptr buf)
+static bool add_name(u32b *offset, header *head, concptr buf)
 {
        /* Hack -- Verify space */
        if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
@@ -1009,7 +1097,7 @@ static bool add_name(u32b *offset, header *head, cptr buf)
  * Returns FALSE when there isn't enough space available to store
  * the text.
  */
-static bool add_tag(s16b *offset, header *head, cptr buf)
+static bool add_tag(STR_OFFSET *offset, header *head, concptr buf)
 {
        u32b i;
 
@@ -1092,8 +1180,7 @@ byte color_char_to_attr(char c)
  * @param parse_info_txt_line パース関数
  * @return エラーコード
  */
-errr init_info_txt(FILE *fp, char *buf, header *head,
-                  parse_info_txt_func parse_info_txt_line)
+errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line)
 {
        errr err;
 
@@ -1220,20 +1307,19 @@ errr parse_v_info(char *buf, header *head)
        /* Process 'X' for "Extra info" (one line only) */
        else if (buf[0] == 'X')
        {
-               int typ, rat, hgt, wid;
+               EFFECT_ID typ, rat, hgt, wid;
 
                /* Scan for the values */
                if (4 != sscanf(buf+2, "%d:%d:%d:%d",
                        &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 */
        else    return (6);
 
        /* Success */
@@ -1313,12 +1399,11 @@ 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;
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1442,15 +1527,14 @@ 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 ++;
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1466,7 +1550,7 @@ errr parse_m_info(char *buf, header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
+static errr grab_one_flag(u32b *flags, concptr names[], concptr what)
 {
        int i;
 
@@ -1491,7 +1575,7 @@ static errr grab_one_flag(u32b *flags, cptr names[], cptr what)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
+static errr grab_one_feat_flag(feature_type *f_ptr, concptr what)
 {
        int i;
 
@@ -1505,7 +1589,6 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
                }
        }
 
-       /* Oops */
        msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
 
        /* Error */
@@ -1521,9 +1604,9 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
  * @param count ステートの保存先ID
  * @return エラーコード
  */
-static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
+static errr grab_one_feat_action(feature_type *f_ptr, concptr what, int count)
 {
-       int i;
+       FF_FLAGS_IDX i;
 
        /* Check flags */
        for (i = 0; i < FF_FLAG_MAX; i++)
@@ -1535,7 +1618,6 @@ static errr grab_one_feat_action(feature_type *f_ptr, cptr what, int count)
                }
        }
 
-       /* Oops */
        msg_format(_("未知の地形アクション '%s'。", "Unknown feature action '%s'."), what);
 
        /* Error */
@@ -1595,10 +1677,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;
@@ -1638,12 +1720,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;
        }
 
 
@@ -1737,29 +1819,26 @@ errr parse_f_info(char *buf, header *head)
                                while (*t == ' ' || *t == '|') t++;
                        }
 
-                       /* XXX XXX XXX Hack -- Read feature subtype */
+                       /* Hack -- Read feature subtype */
                        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;
 
-                               /* Continue */
                                continue;
                        }
 
-                       /* XXX XXX XXX Hack -- Read feature power */
+                       /* Hack -- Read feature power */
                        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;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -1780,13 +1859,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;
@@ -1806,7 +1885,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
                {
@@ -1819,12 +1898,11 @@ 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);
@@ -1837,7 +1915,7 @@ errr parse_f_info(char *buf, header *head)
  * @param str タグ文字列
  * @return 地形ID
  */
-s16b f_tag_to_index(cptr str)
+s16b f_tag_to_index(concptr str)
 {
        u16b i;
 
@@ -1859,29 +1937,32 @@ s16b f_tag_to_index(cptr str)
 /*!
  * @brief 地形タグからIDを得る /
  * Search for real index corresponding to this fake tag
- * @param feat タグ文字列
- * @return なし
+ * @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 */
-       msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + (-(*feat)));
+       msg_format(_("未定義のタグ '%s'。", "%s is undefined."), f_tag + feat);
+       return -1;
 }
 
 
@@ -1899,13 +1980,17 @@ 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);
-
-               search_real_feat(&f_ptr->destroyed);
+               FEAT_IDX j, k;
 
-               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;
+               }
        }
 }
 
@@ -1917,7 +2002,7 @@ void retouch_f_info(header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
+static errr grab_one_kind_flag(object_kind *k_ptr, concptr what)
 {
        int i;
 
@@ -1934,7 +2019,6 @@ static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
        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 */
@@ -1947,7 +2031,7 @@ static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
  * @param what 参照元の文字列ポインタ
  * @return 発動能力ID
  */
-static byte grab_one_activation_flag(cptr what)
+static byte grab_one_activation_flag(concptr what)
 {
        int i;
 
@@ -1967,7 +2051,6 @@ static byte grab_one_activation_flag(cptr what)
                 return ((byte) i);
         }
 
-       /* Oops */
        msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
 
        /* Error */
@@ -2137,9 +2220,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) */
@@ -2153,18 +2236,17 @@ 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 */
+               /* Simply read each number following a colon */
                for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
                {
                                /* Default chance */
@@ -2183,7 +2265,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;
                        }
                }
        }
@@ -2197,12 +2279,12 @@ 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 */
@@ -2245,7 +2327,6 @@ errr parse_k_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2260,7 +2341,7 @@ errr parse_k_info(char *buf, header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーがあった場合1、エラーがない場合0を返す
  */
-static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
+static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
 {
        int i;
 
@@ -2277,7 +2358,6 @@ static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
        if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
                return 0;
 
-       /* Oops */
        msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
 
        /* Error */
@@ -2395,9 +2475,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) */
@@ -2411,10 +2491,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 */
@@ -2426,12 +2506,12 @@ 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 */
@@ -2474,7 +2554,6 @@ errr parse_a_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2490,7 +2569,7 @@ errr parse_a_info(char *buf, header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーがあった場合1、エラーがない場合0を返す
  */
-static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
+static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
 {
        int i;
 
@@ -2507,7 +2586,6 @@ static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
        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 */
@@ -2525,27 +2603,24 @@ static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
 errr parse_e_info(char *buf, header *head)
 {
        int i;
-
        char *s, *t;
 
        /* Current entry */
        static ego_item_type *e_ptr = NULL;
 
-
        /* Just before the first record */
        error_idx = -1;
 
        /* Just before the first line */
        error_line = -1;
 
-
        /* Process 'N' for "New/Number/Name" */
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
                s = my_strchr(buf+2, ':');
 
-                       /* Verify that colon */
+               /* Verify that colon */
                if (!s) return (1);
 
                /* Nuke the colon, advance to the name */
@@ -2619,8 +2694,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) */
@@ -2635,7 +2710,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;
        }
@@ -2643,16 +2718,16 @@ 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 = th;
-               e_ptr->max_to_d = td;
-               e_ptr->max_to_a = ta;
-               e_ptr->max_pval = pv;
+               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;
        }
 
        /* Hack -- Process 'U' for activation index */
@@ -2694,7 +2769,6 @@ errr parse_e_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -2709,7 +2783,7 @@ errr parse_e_info(char *buf, header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
+static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
 {
        if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
                return 0;
@@ -2732,7 +2806,6 @@ static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
        if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
                return 0;
 
-       /* Oops */
        msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
 
        /* Failure */
@@ -2747,18 +2820,17 @@ static errr grab_one_basic_flag(monster_race *r_ptr, cptr what)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
+static errr grab_one_spell_flag(monster_race *r_ptr, concptr 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 */
        msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
 
        /* Failure */
@@ -2776,7 +2848,6 @@ static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
 errr parse_r_info(char *buf, header *head)
 {
        int i;
-
        char *s, *t;
 
        /* Current entry */
@@ -2898,12 +2969,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 = MAX(hp1, 1);
-               r_ptr->hside = MAX(hp2, 1);
-               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) */
@@ -2919,12 +2990,12 @@ 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) */
@@ -2932,16 +3003,16 @@ errr parse_r_info(char *buf, header *head)
        {
                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;
+               for (i = 0; i < A_MAX; 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;
+               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) */
@@ -2992,10 +3063,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);
@@ -3042,7 +3113,7 @@ errr parse_r_info(char *buf, header *head)
                                while ((*t == ' ') || (*t == '|')) t++;
                        }
 
-                               /* XXX XXX XXX Hack -- Read spell frequency */
+                               /* Hack -- Read spell frequency */
                        if (1 == sscanf(s, "1_IN_%d", &i))
                        {
                                /* Extract a "frequency" */
@@ -3050,8 +3121,6 @@ errr parse_r_info(char *buf, header *head)
 
                                        /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3063,7 +3132,31 @@ errr parse_r_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
+       /* 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;
+       }
+
        else return (6);
 
 
@@ -3079,12 +3172,11 @@ errr parse_r_info(char *buf, header *head)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
+static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, concptr what)
 {
        if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
                return 0;
 
-       /* Oops */
        msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
 
        /* Failure */
@@ -3098,7 +3190,7 @@ static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
+static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, concptr what)
 {
        if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
                return 0;
@@ -3121,7 +3213,6 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
                return 0;
 
-       /* Oops */
        msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
        /* Failure */
        return (1);
@@ -3135,18 +3226,17 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
  * @param what 参照元の文字列ポインタ
  * @return エラーコード
  */
-static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
+static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, concptr 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 */
        msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
 
        /* Failure */
@@ -3163,13 +3253,11 @@ static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
 errr parse_d_info(char *buf, header *head)
 {
        int i;
-
        char *s, *t;
 
        /* Current entry */
        static dungeon_info_type *d_ptr = NULL;
 
-
        /* Process 'N' for "New/Number/Name" */
        if (buf[0] == 'N')
        {
@@ -3251,16 +3339,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" */
@@ -3290,7 +3378,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]);
        }
@@ -3309,7 +3397,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]);
@@ -3343,55 +3431,47 @@ errr parse_d_info(char *buf, header *head)
                                while (*t == ' ' || *t == '|') t++;
                        }
 
-                       /* XXX XXX XXX Hack -- Read Final Artifact */
+                       /* Hack -- Read Final Artifact */
                        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;
-
-                               /* Continue */
                                continue;
                        }
 
-                       /* XXX XXX XXX Hack -- Read Final Object */
+                       /* Hack -- Read Final Object */
                        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;
-
-                               /* Continue */
                                continue;
                        }
 
-                       /* XXX XXX XXX Hack -- Read Artifact Guardian */
+                       /* Hack -- Read Artifact Guardian */
                        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;
-
-                               /* Continue */
                                continue;
                        }
 
-                       /* XXX XXX XXX Hack -- Read Special Percentage */
+                       /* Hack -- Read Special Percentage */
                        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;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3430,8 +3510,6 @@ errr parse_d_info(char *buf, header *head)
 
                                /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3459,13 +3537,11 @@ errr parse_d_info(char *buf, header *head)
                                while ((*t == ' ') || (*t == '|')) t++;
                        }
 
-                               /* XXX XXX XXX Hack -- Read spell frequency */
+                               /* Hack -- Read spell frequency */
                        if (1 == sscanf(s, "1_IN_%d", &i))
                        {
                                /* Start at next entry */
                                s = t;
-
-                                       /* Continue */
                                continue;
                        }
 
@@ -3477,7 +3553,6 @@ errr parse_d_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -3508,15 +3583,15 @@ 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 */
-       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 */
+       FEAT_IDX feature;               /* Terrain feature */
+       MONSTER_IDX     monster;                /* Monster */
+       OBJECT_IDX object;                      /* Object */
+       EGO_IDX ego;                    /* Ego-Item */
+       ARTIFACT_IDX artifact;          /* Artifact */
+       IDX trap;                       /* Trap */
+       BIT_FLAGS cave_info;            /* Flags for CAVE_MARK, CAVE_GLOW, CAVE_ICKY, CAVE_ROOM */
+       s16b special; /* Reserved for special terrain info */
+       int random;                     /* Number of the random effect */
 };
 
 
@@ -3534,7 +3609,6 @@ static errr parse_line_feature(char *buf)
        int num;
        char *zz[9];
 
-
        if (init_flags & INIT_ONLY_BUILDINGS) return (0);
 
        /* Tokenize the line */
@@ -3558,7 +3632,7 @@ static errr parse_line_feature(char *buf)
                {
                        /* Special */
                        case 9:
-                               letter[index].special = atoi(zz[8]);
+                               letter[index].special = (s16b)atoi(zz[8]);
                                /* Fall through */
                        /* Trap */
                        case 8:
@@ -3577,7 +3651,7 @@ 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] == '!')
                                {
@@ -3588,7 +3662,7 @@ static errr parse_line_feature(char *buf)
                                }
                                else
                                {
-                                       letter[index].artifact = atoi(zz[6]);
+                                       letter[index].artifact = (IDX)atoi(zz[6]);
                                }
                                /* Fall through */
                        /* Ego-item */
@@ -3596,11 +3670,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 */
@@ -3608,13 +3682,13 @@ 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;
+                                               ARTIFACT_IDX a_idx = quest[p_ptr->inside_quest].k_idx;
                                                if (a_idx)
                                                {
                                                        artifact_type *a_ptr = &a_info[a_idx];
@@ -3627,7 +3701,7 @@ static errr parse_line_feature(char *buf)
                                }
                                else
                                {
-                                       letter[index].object = atoi(zz[4]);
+                                       letter[index].object = (IDX)atoi(zz[4]);
                                }
                                /* Fall through */
                        /* Monster */
@@ -3635,7 +3709,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')
                                {
@@ -3644,7 +3718,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 */
@@ -3681,7 +3755,7 @@ static errr parse_line_feature(char *buf)
 static errr parse_line_building(char *buf)
 {
        int i;
-       char *zz[37];
+       char *zz[1000];
        int index;
        char *s;
 
@@ -3744,19 +3818,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;
                        }
@@ -3767,49 +3841,37 @@ static errr parse_line_building(char *buf)
                /* Building Classes */
                case 'C':
                {
-                       if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
-                       {
-                               for (i = 0; i < MAX_CLASS; i++)
-                               {
-                                       building[index].member_class[i] = atoi(zz[i]);
-                               }
-
-                               break;
+                       int n;
+                       n = tokenize(s + 2, MAX_CLASS, zz, 0);
+                       for (i = 0; i < MAX_CLASS; i++)
+                       {       
+                               building[index].member_class[i] = ((i < n) ? (CLASS_IDX)atoi(zz[i]) : 1);
                        }
-
-                       return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
+                       break;
                }
 
                /* Building Races */
                case 'R':
                {
-                       if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
+                       int n;
+                       n = tokenize(s + 2, MAX_RACES, zz, 0);
+                       for (i = 0; i < MAX_RACES; i++)
                        {
-                               for (i = 0; i < MAX_RACES; i++)
-                               {
-                                       building[index].member_race[i] = atoi(zz[i]);
-                               }
-
-                               break;
+                               building[index].member_race[i] = ((i < n) ? (RACE_IDX)atoi(zz[i]) : 1);
                        }
-
-                       return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
+                       break;
                }
 
                /* Building Realms */
                case 'M':
                {
-                       if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
+                       int n;
+                       n = tokenize(s + 2, MAX_MAGIC, zz, 0);
+                       for (i = 0; i < MAX_MAGIC; i++)
                        {
-                               for (i = 0; i < MAX_MAGIC; i++)
-                               {
-                                       building[index].member_realm[i+1] = atoi(zz[i]);
-                               }
-
-                               break;
+                               building[index].member_realm[i+1] = ((i < n) ? (REALM_IDX)atoi(zz[i]) : 1);
                        }
-
-                       return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
+                       break;
                }
 
                case 'Z':
@@ -3836,13 +3898,12 @@ static errr parse_line_building(char *buf)
  * @param x 配置先X座標
  * @return エラーコード
  */
-static void drop_here(object_type *j_ptr, int y, int x)
+static void drop_here(object_type *j_ptr, POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
        object_type *o_ptr;
 
-       /* Get new object */
-       s16b o_idx = o_pop();
+       OBJECT_IDX o_idx = o_pop();
 
        /* Access new object */
        o_ptr = &o_list[o_idx];
@@ -3850,7 +3911,6 @@ static void drop_here(object_type *j_ptr, int y, int x)
        /* Structure copy */
        object_copy(o_ptr, j_ptr);
 
-
        /* Locate */
        o_ptr->iy = y;
        o_ptr->ix = x;
@@ -3881,10 +3941,8 @@ static void drop_here(object_type *j_ptr, int y, int x)
 static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
 {
        int i;
-
        char *zz[33];
 
-
        /* Skip "empty" lines */
        if (!buf[0]) return (0);
 
@@ -3926,15 +3984,14 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
 
                for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
                {
-                       /* Access the grid */
                        cave_type *c_ptr = &cave[*y][*x];
 
                        int idx = s[0];
 
-                       int object_index = letter[idx].object;
-                       int monster_index = letter[idx].monster;
+                       OBJECT_IDX object_index = letter[idx].object;
+                       MONSTER_IDX monster_index = letter[idx].monster;
                        int random = letter[idx].random;
-                       int artifact_index = letter[idx].artifact;
+                       ARTIFACT_IDX artifact_index = letter[idx].artifact;
 
                        /* Lay down a floor */
                        c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
@@ -4044,10 +4101,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        }
                        else if (object_index)
                        {
-                               /* Get local object */
                                object_type *o_ptr = &object_type_body;
-
-                               /* Create the item */
                                object_prep(o_ptr, object_index);
 
                                if (o_ptr->tval == TV_GOLD)
@@ -4068,13 +4122,11 @@ 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);
+                                       KIND_OBJECT_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 */
                                        drop_here(q_ptr, *y, *x);
                                }
                                else
@@ -4125,17 +4177,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)
@@ -4151,12 +4202,12 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                {
                        if (init_flags & INIT_ASSIGN)
                        {
-                               int idx, count = 0;
-                               int reward_idx = 0;
+                               int count = 0;
+                               IDX idx, reward_idx = 0;
 
                                for (idx = 2; idx < num; idx++)
                                {
-                                       int a_idx = atoi(zz[idx]);
+                                       IDX a_idx = (IDX)atoi(zz[idx]);
                                        if (a_idx < 1) continue;
                                        if (a_info[a_idx].cur_num > 0) continue;
                                        count++;
@@ -4234,16 +4285,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;
+                                       POSITION py, px;
 
                                        /* Delete the monster (if any) */
                                        delete_monster(p_ptr->y, p_ptr->x);
 
-                                       y = atoi(zz[0]);
-                                       x = atoi(zz[1]);
+                                       py = atoi(zz[0]);
+                                       px = atoi(zz[1]);
 
-                                       p_ptr->y = y;
-                                       p_ptr->x = x;
+                                       p_ptr->y = py;
+                                       p_ptr->x = px;
                                }
                                /* Place player in the town */
                                else if (!p_ptr->oldpx && !p_ptr->oldpy)
@@ -4271,67 +4322,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_q_idx = (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 */
@@ -4356,7 +4407,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
 
 
 static char tmp[8];
-static cptr variant = "ZANGBAND";
+static concptr variant = "ZANGBAND";
 
 
 /*!
@@ -4366,9 +4417,9 @@ static cptr variant = "ZANGBAND";
  * @param fp
  * @return エラーコード
  */
-static cptr process_dungeon_file_expr(char **sp, char *fp)
+static concptr process_dungeon_file_expr(char **sp, char *fp)
 {
-       cptr v;
+       concptr v;
 
        char *b;
        char *s;
@@ -4393,8 +4444,8 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
        /* Analyze */
        if (*s == b1)
        {
-               const char *p;
-               const char *t;
+               concptr p;
+               concptr t;
 
                /* Skip b1 */
                s++;
@@ -4402,7 +4453,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                /* First */
                t = process_dungeon_file_expr(&s, &f);
 
-               /* Oops */
                if (!*t)
                {
                        /* Nothing */
@@ -4490,7 +4540,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        }
                }
 
-               /* Oops */
                else
                {
                        while (*s && (f != b2))
@@ -4575,7 +4624,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        {
                                static char tmp_player_name[32];
                                char *pn, *tpn;
-                               for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
+                               for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
                                {
 #ifdef JP
                                        if (iskanji(*pn))
@@ -4671,11 +4720,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
 
        /* Save */
        (*fp) = f;
-
-       /* Save */
        (*sp) = s;
-
-       /* Result */
        return (v);
 }
 
@@ -4690,18 +4735,13 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
  * @param xmax 詳細不明
  * @return エラーコード
  */
-errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
+errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax)
 {
        FILE *fp;
-
        char buf[1024];
-
        int num = -1;
-
        errr err = 0;
-
        bool bypass = FALSE;
-
        int x = xmin, y = ymin;
 
 
@@ -4736,7 +4776,7 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
                if ((buf[0] == '?') && (buf[1] == ':'))
                {
                        char f;
-                       cptr v;
+                       concptr v;
                        char *s;
 
                        /* Start */
@@ -4747,8 +4787,6 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
 
                        /* Set flag */
                        bypass = (streq(v, "0") ? TRUE : FALSE);
-
-                       /* Continue */
                        continue;
                }
 
@@ -4758,30 +4796,24 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
                /* Process the line */
                err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);
 
-               /* Oops */
                if (err) break;
        }
 
        /* Errors */
        if (err)
        {
-               cptr oops;
+               concptr oops;
 
                /* Error string */
                oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
 
-               /* Oops */
                msg_format("Error %d (%s) at line %d of '%s'.", err, oops, num, name);
                msg_format(_("'%s'を解析中。", "Parsing '%s'."), buf);
 
                msg_print(NULL);
        }
 
-
-       /* Close the file */
        my_fclose(fp);
-
-       /* Result */
        return (err);
 }
 
@@ -4793,10 +4825,10 @@ void write_r_info_txt(void)
        int i, j, z, fc, bc;
        int dlen;
 
-       cptr flags[32 * 10];
+       concptr flags[32 * 10];
 
        u32b f_ptr[10];
-       cptr *n_ptr[10];
+       concptr *n_ptr[10];
 
        monster_race *r_ptr;
 
@@ -4804,9 +4836,9 @@ void write_r_info_txt(void)
 
        FILE *fff = fopen("output.txt", "wt");
 
-       cptr desc;
+       concptr desc;
 
-       int mode = -1;
+       BIT_FLAGS mode = -1;
 
        if (!fff) return;
 
@@ -4857,8 +4889,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;
@@ -4890,8 +4922,6 @@ void write_r_info_txt(void)
                                                                                                          r_info_blow_effect[b_ptr->effect],
                                                                                                          b_ptr->d_dice, b_ptr->d_side);
                }
-
-               /* Extract the flags */
                for (fc = 0, j = 0; j < 32 * 3; j++)
                {
                        /* Check this flag */
@@ -5001,7 +5031,6 @@ void write_r_info_txt(void)
                fprintf(fff, "\n");
        }
 
-       /* Done */
        fclose(fff);
 }