OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / init1.c
index 4996e97..672f163 100644 (file)
@@ -47,6 +47,7 @@
  */
 
 #include "angband.h"
+#include "trap.h"
 
 
 
@@ -188,15 +189,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",
@@ -365,7 +366,7 @@ static cptr r_info_flags3[] =
        "HURT_ROCK",
        "HURT_FIRE",
        "HURT_COLD",
-       "XXX",
+       "ANGEL",
        "XXX",
        "XXX",
        "XXX",
@@ -503,6 +504,7 @@ static cptr r_a_ability_flags2[] =
        "S_UNIQUE"
 };
 
+#if 0
 /*!
  * モンスター特性トークン(発動型能力3) /
  * Monster race flags
@@ -542,7 +544,9 @@ static cptr r_a_ability_flags3[] =
        "XXXA3X30",
        "XXXA3X31",
 };
+#endif
 
+#if 0
 /*!
  * モンスター特性トークン(発動型能力4) /
  * Monster race flags
@@ -582,6 +586,7 @@ static cptr r_a_ability_flags4[] =
        "XXXA4X30",
        "XXXA4X31",
 };
+#endif
 
 
 /*!
@@ -958,8 +963,8 @@ static cptr d_info_flags1[] =
        "CAVE",
        "CAVERN",
        "ARCADE",
-       "XXX",
-       "XXX",
+       "LAKE_ACID",
+       "LAKE_POISONOUS",
        "XXX",
        "FORGET",
        "LAKE_WATER",
@@ -975,8 +980,8 @@ static cptr d_info_flags1[] =
        "NO_MELEE",
        "CHAMELEON",
        "DARKNESS",
-       "XXX",
-       "XXX"
+       "ACID_RIVER",
+       "POISONOUS_RIVER"
 };
 
 
@@ -1089,7 +1094,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, cptr buf)
 {
        u32b i;
 
@@ -1172,8 +1177,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;
 
@@ -1300,20 +1304,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 */
@@ -1398,7 +1401,6 @@ errr parse_s_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1530,7 +1532,6 @@ errr parse_m_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1585,7 +1586,6 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
                }
        }
 
-       /* Oops */
        msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
 
        /* Error */
@@ -1603,7 +1603,7 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
  */
 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++)
@@ -1615,7 +1615,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 */
@@ -1675,10 +1674,10 @@ errr parse_f_info(char *buf, header *head)
                }
 
                /* Default "mimic" */
-               f_ptr->mimic = (IDX)i;
+               f_ptr->mimic = (FEAT_IDX)i;
 
                /* Default "destroyed state" -- if not specified */
-               f_ptr->destroyed = (IDX)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;
@@ -1718,12 +1717,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;
        }
 
 
@@ -1817,29 +1816,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;
                        }
 
@@ -1860,13 +1856,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;
@@ -1886,7 +1882,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
                {
@@ -1899,12 +1895,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);
@@ -1939,29 +1934,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;
 }
 
 
@@ -1979,13 +1977,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;
+               }
        }
 }
 
@@ -2014,7 +2016,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 */
@@ -2047,7 +2048,6 @@ static byte grab_one_activation_flag(cptr what)
                 return ((byte) i);
         }
 
-       /* Oops */
        msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
 
        /* Error */
@@ -2233,8 +2233,8 @@ 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->level = (DEPTH)level;
+               k_ptr->extra = (BIT_FLAGS8)extra;
                k_ptr->weight = (WEIGHT)wgt;
                k_ptr->cost = (PRICE)cost;
        }
@@ -2243,7 +2243,7 @@ errr parse_k_info(char *buf, header *head)
        else if (buf[0] == 'A')
        {
 
-               /* 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 */
@@ -2262,7 +2262,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;
                        }
                }
        }
@@ -2324,7 +2324,6 @@ errr parse_k_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2356,7 +2355,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 */
@@ -2474,9 +2472,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) */
@@ -2490,10 +2488,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 */
@@ -2505,12 +2503,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 */
@@ -2553,7 +2551,6 @@ errr parse_a_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2586,7 +2583,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 */
@@ -2604,27 +2600,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 */
@@ -2698,8 +2691,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) */
@@ -2728,9 +2721,9 @@ errr parse_e_info(char *buf, header *head)
                if (4 != sscanf(buf+2, "%d:%d:%d:%d",
                                &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_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;
        }
 
@@ -2773,7 +2766,6 @@ errr parse_e_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -2811,7 +2803,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 */
@@ -2837,7 +2828,6 @@ static errr grab_one_spell_flag(monster_race *r_ptr, cptr what)
        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 */
@@ -2855,7 +2845,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 */
@@ -2980,9 +2969,9 @@ errr parse_r_info(char *buf, header *head)
                r_ptr->speed = (SPEED)spd;
                r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
                r_ptr->hside = (DICE_SID)MAX(hp2, 1);
-               r_ptr->aaf = aaf;
+               r_ptr->aaf = (POSITION)aaf;
                r_ptr->ac = (ARMOUR_CLASS)ac;
-               r_ptr->sleep = slp;
+               r_ptr->sleep = (SLEEP_DEGREE)slp;
        }
 
        /* Process 'W' for "More Info" (one line only) */
@@ -3000,9 +2989,9 @@ errr parse_r_info(char *buf, header *head)
                /* Save the values */
                r_ptr->level = (DEPTH)lev;
                r_ptr->rarity = (RARITY)rar;
-               r_ptr->extra = pad;
-               r_ptr->mexp = exp;
-               r_ptr->next_exp = nextexp;
+               r_ptr->extra = (BIT_FLAGS16)pad;
+               r_ptr->mexp = (EXP)exp;
+               r_ptr->next_exp = (EXP)nextexp;
                r_ptr->next_r_idx = (IDX)nextmon;
        }
 
@@ -3011,7 +3000,7 @@ 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);
@@ -3071,10 +3060,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);
@@ -3121,7 +3110,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" */
@@ -3129,8 +3118,6 @@ errr parse_r_info(char *buf, header *head)
 
                                        /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3167,7 +3154,6 @@ errr parse_r_info(char *buf, header *head)
                r_ptr->arena_ratio = (PERCENTAGE)val;
        }
 
-       /* Oops */
        else return (6);
 
 
@@ -3188,7 +3174,6 @@ static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr 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 */
@@ -3225,7 +3210,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);
@@ -3250,7 +3234,6 @@ static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
        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 */
@@ -3267,13 +3250,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')
        {
@@ -3355,16 +3336,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" */
@@ -3394,7 +3375,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]);
        }
@@ -3413,7 +3394,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]);
@@ -3447,55 +3428,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;
                        }
 
@@ -3534,8 +3507,6 @@ errr parse_d_info(char *buf, header *head)
 
                                /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3563,13 +3534,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;
                        }
 
@@ -3581,7 +3550,6 @@ errr parse_d_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -3612,15 +3580,15 @@ typedef struct dungeon_grid dungeon_grid;
 
 struct dungeon_grid
 {
-       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 */
+       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 */
 };
 
 
@@ -3638,7 +3606,6 @@ static errr parse_line_feature(char *buf)
        int num;
        char *zz[9];
 
-
        if (init_flags & INIT_ONLY_BUILDINGS) return (0);
 
        /* Tokenize the line */
@@ -3662,7 +3629,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:
@@ -3718,7 +3685,7 @@ static errr parse_line_feature(char *buf)
                                {
                                        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];
@@ -3848,19 +3815,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;
                        }
@@ -3875,7 +3842,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;
@@ -3891,7 +3858,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;
@@ -3907,7 +3874,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;
@@ -3940,13 +3907,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];
@@ -3954,7 +3920,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;
@@ -3985,10 +3950,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);
 
@@ -4030,15 +3993,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];
 
-                       IDX object_index = letter[idx].object;
-                       IDX monster_index = letter[idx].monster;
+                       OBJECT_IDX object_index = letter[idx].object;
+                       MONSTER_IDX monster_index = letter[idx].monster;
                        int random = letter[idx].random;
-                       IDX 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);
@@ -4148,10 +4110,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)
@@ -4172,13 +4131,11 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        {
                                if (a_info[artifact_index].cur_num)
                                {
-                                       IDX 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
@@ -4229,17 +4186,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->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 = atoi(zz[9]);
+                               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)
@@ -4338,7 +4294,7 @@ 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 py, px;
+                                       POSITION py, px;
 
                                        /* Delete the monster (if any) */
                                        delete_monster(p_ptr->y, p_ptr->x);
@@ -4381,7 +4337,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        /* Maximum quests */
                        else if (zz[0][0] == 'Q')
                        {
-                               max_quests = (IDX)atoi(zz[1]);
+                               max_q_idx = (IDX)atoi(zz[1]);
                        }
 
                        /* Maximum r_idx */
@@ -4497,8 +4453,8 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
        /* Analyze */
        if (*s == b1)
        {
-               const char *p;
-               const char *t;
+               cptr p;
+               cptr t;
 
                /* Skip b1 */
                s++;
@@ -4506,7 +4462,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                /* First */
                t = process_dungeon_file_expr(&s, &f);
 
-               /* Oops */
                if (!*t)
                {
                        /* Nothing */
@@ -4594,7 +4549,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        }
                }
 
-               /* Oops */
                else
                {
                        while (*s && (f != b2))
@@ -4778,8 +4732,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
 
        /* Save */
        (*sp) = s;
-
-       /* Result */
        return (v);
 }
 
@@ -4797,15 +4749,10 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
 errr process_dungeon_file(cptr 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;
 
 
@@ -4851,8 +4798,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;
                }
 
@@ -4862,7 +4807,6 @@ 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;
        }
 
@@ -4874,18 +4818,13 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
                /* 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);
 }
 
@@ -4910,7 +4849,7 @@ void write_r_info_txt(void)
 
        cptr desc;
 
-       int mode = -1;
+       BIT_FLAGS mode = -1;
 
        if (!fff) return;
 
@@ -4994,8 +4933,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 */
@@ -5105,7 +5042,6 @@ void write_r_info_txt(void)
                fprintf(fff, "\n");
        }
 
-       /* Done */
        fclose(fff);
 }