OSDN Git Service

[Refactor] #37353 モンスター配置に関する関数整理中。 / Refactor functions for place monster.
[hengband/hengband.git] / src / init1.c
index 4b4784a..0731bf1 100644 (file)
@@ -47,6 +47,8 @@
  */
 
 #include "angband.h"
+#include "trap.h"
+#include "monster.h"
 
 
 
@@ -61,7 +63,7 @@
  * モンスターの打撃手段トークンの定義 /
  * Monster Blow Methods
  */
-static cptr r_info_blow_method[] =
+static concptr r_info_blow_method[] =
 {
        "",
        "HIT",
@@ -97,7 +99,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 +144,7 @@ static cptr r_info_blow_effect[] =
  * 地形属性トークンの定義 /
  * Feature info flags
  */
-static cptr f_info_flags[] =
+static concptr f_info_flags[] =
 {
        "LOS",
        "PROJECT",
@@ -188,15 +190,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 +269,7 @@ static cptr f_info_flags[] =
  * モンスター特性トークンの定義1 /
  * Monster race flags
  */
-static cptr r_info_flags1[] =
+static concptr r_info_flags1[] =
 {
        "UNIQUE",
        "QUESTOR",
@@ -307,7 +309,7 @@ static cptr r_info_flags1[] =
  * モンスター特性トークンの定義2 /
  * Monster race flags
  */
-static cptr r_info_flags2[] =
+static concptr r_info_flags2[] =
 {
        "STUPID",
        "SMART",
@@ -347,7 +349,7 @@ static cptr r_info_flags2[] =
  * モンスター特性トークンの定義3 /
  * Monster race flags
  */
-static cptr r_info_flags3[] =
+static concptr r_info_flags3[] =
 {
        "ORC",
        "TROLL",
@@ -365,7 +367,7 @@ static cptr r_info_flags3[] =
        "HURT_ROCK",
        "HURT_FIRE",
        "HURT_COLD",
-       "XXX",
+       "ANGEL",
        "XXX",
        "XXX",
        "XXX",
@@ -387,7 +389,7 @@ static cptr r_info_flags3[] =
  * モンスター特性トークンの定義4 /
  * Monster race flags
  */
-static cptr r_info_flags4[] =
+static concptr r_info_flags4[] =
 {
        "SHRIEK",
        "XXX1",
@@ -427,7 +429,7 @@ static cptr r_info_flags4[] =
  * モンスター特性トークン(発動型能力1) /
  * Monster race flags
  */
-static cptr r_a_ability_flags1[] =
+static concptr r_a_ability_flags1[] =
 {
        "BA_ACID",
        "BA_ELEC",
@@ -467,7 +469,7 @@ static cptr r_a_ability_flags1[] =
  * モンスター特性トークン(発動型能力2) /
  * Monster race flags
  */
-static cptr r_a_ability_flags2[] =
+static concptr r_a_ability_flags2[] =
 {
        "HASTE",
        "HAND_DOOM",
@@ -508,7 +510,7 @@ static cptr r_a_ability_flags2[] =
  * モンスター特性トークン(発動型能力3) /
  * Monster race flags
  */
-static cptr r_a_ability_flags3[] =
+static concptr r_a_ability_flags3[] =
 {
        "XXXA3X00",
        "XXXA3X01",
@@ -550,7 +552,7 @@ static cptr r_a_ability_flags3[] =
  * モンスター特性トークン(発動型能力4) /
  * Monster race flags
  */
-static cptr r_a_ability_flags4[] =
+static concptr r_a_ability_flags4[] =
 {
        "XXXA4X00",
        "XXXA4X01",
@@ -592,7 +594,7 @@ static cptr r_a_ability_flags4[] =
  * モンスター特性トークンの定義7 /
  * Monster race flags
  */
-static cptr r_info_flags7[] =
+static concptr r_info_flags7[] =
 {
        "AQUATIC",
        "CAN_SWIM",
@@ -632,7 +634,7 @@ static cptr r_info_flags7[] =
  * モンスター特性トークンの定義8 /
  * Monster race flags
  */
-static cptr r_info_flags8[] =
+static concptr r_info_flags8[] =
 {
        "WILD_ONLY",
        "WILD_TOWN",
@@ -673,7 +675,7 @@ static cptr r_info_flags8[] =
  * モンスター特性トークンの定義9 /
  * Monster race flags
  */
-static cptr r_info_flags9[] =
+static concptr r_info_flags9[] =
 {
        "DROP_CORPSE",
        "DROP_SKELETON",
@@ -715,7 +717,7 @@ static cptr r_info_flags9[] =
  * モンスター特性トークンの定義R(耐性) /
  * Monster race flags
  */
-static cptr r_info_flagsr[] =
+static concptr r_info_flagsr[] =
 {
        "IM_ACID",
        "IM_ELEC",
@@ -756,7 +758,7 @@ static cptr r_info_flagsr[] =
  * オブジェクト基本特性トークンの定義 /
  * Object flags
  */
-static cptr k_info_flags[] =
+static concptr k_info_flags[] =
 {
        "STR",
        "INT",
@@ -907,7 +909,7 @@ static cptr k_info_flags[] =
  * オブジェクト生成特性トークンの定義 /
  * Object flags
  */
-static cptr k_info_gen_flags[] =
+static concptr k_info_gen_flags[] =
 {
        "INSTA_ART",
        "QUESTITEM",
@@ -947,7 +949,7 @@ static cptr k_info_gen_flags[] =
  * ダンジョン特性トークンの定義 /
  * Dungeon flags
  */
-static cptr d_info_flags1[] =
+static concptr d_info_flags1[] =
 {
        "WINNER",
        "MAZE",
@@ -962,8 +964,8 @@ static cptr d_info_flags1[] =
        "CAVE",
        "CAVERN",
        "ARCADE",
-       "XXX",
-       "XXX",
+       "LAKE_ACID",
+       "LAKE_POISONOUS",
        "XXX",
        "FORGET",
        "LAKE_WATER",
@@ -979,8 +981,8 @@ static cptr d_info_flags1[] =
        "NO_MELEE",
        "CHAMELEON",
        "DARKNESS",
-       "XXX",
-       "XXX"
+       "ACID_RIVER",
+       "POISONOUS_RIVER"
 };
 
 
@@ -996,7 +998,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)
@@ -1058,7 +1060,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)
@@ -1093,7 +1095,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(STR_OFFSET *offset, header *head, cptr buf)
+static bool add_tag(STR_OFFSET *offset, header *head, concptr buf)
 {
        u32b i;
 
@@ -1176,8 +1178,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;
 
@@ -1304,7 +1305,7 @@ 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",
@@ -1317,7 +1318,6 @@ errr parse_v_info(char *buf, header *head)
                v_ptr->wid = (POSITION)wid;
        }
 
-       /* Oops */
        else    return (6);
 
        /* Success */
@@ -1402,7 +1402,6 @@ errr parse_s_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1534,7 +1533,6 @@ errr parse_m_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1550,7 +1548,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;
 
@@ -1575,7 +1573,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;
 
@@ -1589,7 +1587,6 @@ static errr grab_one_feat_flag(feature_type *f_ptr, cptr what)
                }
        }
 
-       /* Oops */
        msg_format(_("未知の地形フラグ '%s'。", "Unknown feature flag '%s'."), what);
 
        /* Error */
@@ -1605,7 +1602,7 @@ 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)
 {
        FF_FLAGS_IDX i;
 
@@ -1619,7 +1616,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 */
@@ -1821,7 +1817,7 @@ 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" */
@@ -1830,11 +1826,10 @@ errr parse_f_info(char *buf, header *head)
                                /* 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" */
@@ -1842,8 +1837,6 @@ errr parse_f_info(char *buf, header *head)
 
                                /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -1907,7 +1900,6 @@ errr parse_f_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -1921,7 +1913,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;
 
@@ -2008,7 +2000,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;
 
@@ -2025,7 +2017,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 */
@@ -2038,7 +2029,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;
 
@@ -2058,7 +2049,6 @@ static byte grab_one_activation_flag(cptr what)
                 return ((byte) i);
         }
 
-       /* Oops */
        msg_format(_("未知の発動・フラグ '%s'。", "Unknown activation flag '%s'."), what);
 
        /* Error */
@@ -2254,7 +2244,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 */
@@ -2335,7 +2325,6 @@ errr parse_k_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2350,7 +2339,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;
 
@@ -2367,7 +2356,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 */
@@ -2564,7 +2552,6 @@ errr parse_a_info(char *buf, header *head)
        }
 
 
-       /* Oops */
        else return (6);
 
 
@@ -2580,7 +2567,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;
 
@@ -2597,7 +2584,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 */
@@ -2615,27 +2601,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 */
@@ -2784,7 +2767,6 @@ errr parse_e_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -2799,7 +2781,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;
@@ -2822,7 +2804,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 +2818,7 @@ 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;
@@ -2848,7 +2829,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 */
@@ -2866,7 +2846,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 */
@@ -3022,7 +3001,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);
@@ -3132,7 +3111,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" */
@@ -3140,8 +3119,6 @@ errr parse_r_info(char *buf, header *head)
 
                                        /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3178,7 +3155,6 @@ errr parse_r_info(char *buf, header *head)
                r_ptr->arena_ratio = (PERCENTAGE)val;
        }
 
-       /* Oops */
        else return (6);
 
 
@@ -3194,12 +3170,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 */
@@ -3213,7 +3188,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;
@@ -3236,7 +3211,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 +3224,7 @@ 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;
@@ -3261,7 +3235,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 */
@@ -3278,13 +3251,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')
        {
@@ -3458,7 +3429,7 @@ 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" */
@@ -3466,12 +3437,10 @@ errr parse_d_info(char *buf, header *head)
 
                                /* 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" */
@@ -3479,12 +3448,10 @@ errr parse_d_info(char *buf, header *head)
 
                                /* 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" */
@@ -3492,12 +3459,10 @@ errr parse_d_info(char *buf, header *head)
 
                                /* 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 %" */
@@ -3505,8 +3470,6 @@ errr parse_d_info(char *buf, header *head)
 
                                /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3545,8 +3508,6 @@ errr parse_d_info(char *buf, header *head)
 
                                /* Start at next entry */
                                s = t;
-
-                               /* Continue */
                                continue;
                        }
 
@@ -3574,13 +3535,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;
                        }
 
@@ -3592,7 +3551,6 @@ errr parse_d_info(char *buf, header *head)
                }
        }
 
-       /* Oops */
        else return (6);
 
        /* Success */
@@ -3631,7 +3589,7 @@ struct dungeon_grid
        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 */
+       int random;                     /* Number of the random effect */
 };
 
 
@@ -3649,7 +3607,6 @@ static errr parse_line_feature(char *buf)
        int num;
        char *zz[9];
 
-
        if (init_flags & INIT_ONLY_BUILDINGS) return (0);
 
        /* Tokenize the line */
@@ -3673,7 +3630,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:
@@ -3729,7 +3686,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];
@@ -3796,7 +3753,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;
 
@@ -3882,11 +3839,13 @@ static errr parse_line_building(char *buf)
                /* Building Classes */
                case 'C':
                {
-                       if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
+                       int n;
+                       n = tokenize(s + 2, MAX_CLASS, zz, 0);
+                       if (n <= MAX_CLASS)
                        {
                                for (i = 0; i < MAX_CLASS; i++)
-                               {
-                                       building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
+                               {       
+                                       building[index].member_class[i] = ((i > n) ? (CLASS_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;
@@ -3898,11 +3857,13 @@ static errr parse_line_building(char *buf)
                /* Building Races */
                case 'R':
                {
-                       if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
+                       int n;
+                       n = tokenize(s + 2, MAX_RACES, zz, 0);
+                       if (n <= MAX_RACES)
                        {
                                for (i = 0; i < MAX_RACES; i++)
                                {
-                                       building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
+                                       building[index].member_race[i] = ((i > n) ? (RACE_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;
@@ -3914,11 +3875,13 @@ static errr parse_line_building(char *buf)
                /* Building Realms */
                case 'M':
                {
-                       if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
+                       int n;
+                       n = tokenize(s + 2, MAX_MAGIC, zz, 0);
+                       if (n <= MAX_MAGIC)
                        {
                                for (i = 0; i < MAX_MAGIC; i++)
                                {
-                                       building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
+                                       building[index].member_realm[i+1] = ((i > n) ? (REALM_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;
@@ -3951,13 +3914,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];
@@ -3965,7 +3927,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;
@@ -3996,10 +3957,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);
 
@@ -4041,15 +4000,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);
@@ -4159,10 +4117,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)
@@ -4183,13 +4138,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
@@ -4348,7 +4301,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);
@@ -4470,7 +4423,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";
 
 
 /*!
@@ -4480,9 +4433,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;
@@ -4507,8 +4460,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++;
@@ -4516,7 +4469,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                /* First */
                t = process_dungeon_file_expr(&s, &f);
 
-               /* Oops */
                if (!*t)
                {
                        /* Nothing */
@@ -4604,7 +4556,6 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        }
                }
 
-               /* Oops */
                else
                {
                        while (*s && (f != b2))
@@ -4785,11 +4736,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
 
        /* Save */
        (*fp) = f;
-
-       /* Save */
        (*sp) = s;
-
-       /* Result */
        return (v);
 }
 
@@ -4804,18 +4751,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;
 
 
@@ -4850,7 +4792,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 */
@@ -4861,8 +4803,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;
                }
 
@@ -4872,30 +4812,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);
 }
 
@@ -4907,10 +4841,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;
 
@@ -4918,7 +4852,7 @@ void write_r_info_txt(void)
 
        FILE *fff = fopen("output.txt", "wt");
 
-       cptr desc;
+       concptr desc;
 
        BIT_FLAGS mode = -1;
 
@@ -5004,8 +4938,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 */
@@ -5115,7 +5047,6 @@ void write_r_info_txt(void)
                fprintf(fff, "\n");
        }
 
-       /* Done */
        fclose(fff);
 }