OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。 / Ongoing type replacement.
[hengband/hengband.git] / src / load.c
index 83f4dda..85cac20 100644 (file)
@@ -137,7 +137,7 @@ static bool z_older_than(byte x, byte y, byte z)
 
 /*!
  * @brief ゲームスクリーンにメッセージを表示する / Hack -- Show information on the screen, one line at a time.
- * @param cptr 表示文字列
+ * @param msg 表示文字列
  * @return なし
  * @details
  * Avoid the top two lines, to avoid interference with "msg_print()".
@@ -238,7 +238,7 @@ static void rd_s32b(s32b *ip)
 
 /*!
  * @brief ロードファイルポインタから文字列を読み込んでポインタに渡す / Hack -- read a string
- * @param ip 読み込みポインタ
+ * @param str 読み込みポインタ
  * @param max 最大読み取りバイト数
  * @return なし
  */
@@ -338,18 +338,24 @@ static void strip_bytes(int n)
 static void rd_item_old(object_type *o_ptr)
 {
        char buf[128];
+       byte_hack tmp8u;
+       s16b tmp16s;
 
 
        /* Kind */
        rd_s16b(&o_ptr->k_idx);
 
        /* Location */
-       rd_byte(&o_ptr->iy);
-       rd_byte(&o_ptr->ix);
+       rd_byte(&tmp8u);
+       o_ptr->iy = (POSITION)tmp8u;
+       rd_byte(&tmp8u);
+       o_ptr->ix = (POSITION)tmp8u;
 
        /* Type/Subtype */
-       rd_byte(&o_ptr->tval);
-       rd_byte(&o_ptr->sval);
+       rd_byte(&tmp8u);
+       o_ptr->tval = tmp8u;
+       rd_byte(&tmp8u);
+       o_ptr->sval = tmp8u;
 
        if (z_older_than(10, 4, 4))
        {
@@ -362,21 +368,30 @@ static void rd_item_old(object_type *o_ptr)
        rd_s16b(&o_ptr->pval);
 
        rd_byte(&o_ptr->discount);
-       rd_byte(&o_ptr->number);
+       rd_byte(&tmp8u);
+       o_ptr->number = (ITEM_NUMBER)tmp8u;
        rd_s16b(&o_ptr->weight);
 
-       rd_byte(&o_ptr->name1);
-       rd_byte(&o_ptr->name2);
+       rd_byte(&tmp8u);
+       o_ptr->name1 = tmp8u;
+
+       rd_byte(&tmp8u);
+       o_ptr->name2 = tmp8u;
+
        rd_s16b(&o_ptr->timeout);
 
        rd_s16b(&o_ptr->to_h);
-       rd_s16b(&o_ptr->to_d);
+       
+       rd_s16b(&tmp16s);
+       o_ptr->to_d = tmp16s;
        rd_s16b(&o_ptr->to_a);
 
        rd_s16b(&o_ptr->ac);
 
-       rd_byte(&o_ptr->dd);
-       rd_byte(&o_ptr->ds);
+       rd_byte(&tmp8u);
+       o_ptr->dd = tmp8u;
+       rd_byte(&tmp8u);
+       o_ptr->ds = tmp8u;
 
        rd_byte(&o_ptr->ident);
 
@@ -583,14 +598,18 @@ static void rd_item_old(object_type *o_ptr)
 }
 
 
-/*
- * Read an object (New method)
+/*!
+ * @brief アイテムオブジェクトを読み込む(現版) / Read an object (New method)
+ * @param o_ptr アイテムオブジェクト保存先ポインタ
+ * @return なし
  */
 static void rd_item(object_type *o_ptr)
 {
        object_kind *k_ptr;
        u32b flags;
        char buf[128];
+       byte_hack tmp8u;
+       s16b tmp16s;
 
        if (h_older_than(1, 5, 0, 0))
        {
@@ -606,8 +625,10 @@ static void rd_item(object_type *o_ptr)
        rd_s16b(&o_ptr->k_idx);
 
        /* Location */
-       rd_byte(&o_ptr->iy);
-       rd_byte(&o_ptr->ix);
+       rd_byte(&tmp8u);
+       o_ptr->iy = (POSITION)tmp8u;
+       rd_byte(&tmp8u);
+       o_ptr->ix = (POSITION)tmp8u;
 
        /* Type/Subtype */
        k_ptr = &k_info[o_ptr->k_idx];
@@ -620,21 +641,36 @@ static void rd_item(object_type *o_ptr)
 
        if (flags & SAVE_ITEM_DISCOUNT) rd_byte(&o_ptr->discount);
        else o_ptr->discount = 0;
-       if (flags & SAVE_ITEM_NUMBER) rd_byte(&o_ptr->number);
+       if (flags & SAVE_ITEM_NUMBER) {
+               rd_byte(&tmp8u);
+               o_ptr->number = tmp8u;
+       }       
        else o_ptr->number = 1;
 
        rd_s16b(&o_ptr->weight);
 
-       if (flags & SAVE_ITEM_NAME1) rd_byte(&o_ptr->name1);
+       if (flags & SAVE_ITEM_NAME1)
+       {
+               rd_byte(&tmp8u);
+               o_ptr->name1 = tmp8u;
+       }
        else o_ptr->name1 = 0;
-       if (flags & SAVE_ITEM_NAME2) rd_byte(&o_ptr->name2);
+       if (flags & SAVE_ITEM_NAME2)
+       {
+               rd_byte(&tmp8u);
+               o_ptr->name2 = tmp8u;
+       }
        else o_ptr->name2 = 0;
        if (flags & SAVE_ITEM_TIMEOUT) rd_s16b(&o_ptr->timeout);
        else o_ptr->timeout = 0;
 
        if (flags & SAVE_ITEM_TO_H) rd_s16b(&o_ptr->to_h);
        else o_ptr->to_h = 0;
-       if (flags & SAVE_ITEM_TO_D) rd_s16b(&o_ptr->to_d);
+       if (flags & SAVE_ITEM_TO_D)
+       {
+               rd_s16b(&tmp16s);
+               o_ptr->to_d = tmp16s;
+       }
        else o_ptr->to_d = 0;
        if (flags & SAVE_ITEM_TO_A) rd_s16b(&o_ptr->to_a);
        else o_ptr->to_a = 0;
@@ -642,9 +678,17 @@ static void rd_item(object_type *o_ptr)
        if (flags & SAVE_ITEM_AC) rd_s16b(&o_ptr->ac);
        else o_ptr->ac = 0;
 
-       if (flags & SAVE_ITEM_DD) rd_byte(&o_ptr->dd);
+       if (flags & SAVE_ITEM_DD)
+       {
+                rd_byte(&tmp8u);
+                o_ptr->dd = tmp8u;
+       }
        else o_ptr->dd = 0;
-       if (flags & SAVE_ITEM_DS) rd_byte(&o_ptr->ds);
+       if (flags & SAVE_ITEM_DS)
+       {
+               rd_byte(&tmp8u);
+               o_ptr->ds = tmp8u;
+       }
        else o_ptr->ds = 0;
 
        if (flags & SAVE_ITEM_IDENT) rd_byte(&o_ptr->ident);
@@ -763,12 +807,16 @@ static void rd_item(object_type *o_ptr)
 }
 
 
-/*
- * Read a monster (Old method)
+/*!
+ * @brief モンスターを読み込む(変愚ver1.5.0以前) / Read a monster (Old method)
+ * @param m_ptr モンスター保存先ポインタ
+ * @return なし
  */
 static void rd_monster_old(monster_type *m_ptr)
 {
        byte tmp8u;
+       s16b tmp16s;
+       u32b tmp32u;
        char buf[128];
 
        /* Read the monster race */
@@ -791,17 +839,24 @@ static void rd_monster_old(monster_type *m_ptr)
                rd_byte(&m_ptr->sub_align);
 
        /* Read the other information */
-       rd_byte(&m_ptr->fy);
-       rd_byte(&m_ptr->fx);
-       rd_s16b(&m_ptr->hp);
-       rd_s16b(&m_ptr->maxhp);
+       rd_byte(&tmp8u);
+       m_ptr->fy = (POSITION)tmp8u;
+       rd_byte(&tmp8u);
+       m_ptr->fx = (POSITION)tmp8u;
+
+       rd_s16b(&tmp16s);
+       m_ptr->hp = tmp16s;
+       rd_s16b(&tmp16s);
+       m_ptr->maxhp = tmp16s;
+
        if (z_older_than(11, 0, 5))
        {
                m_ptr->max_maxhp = m_ptr->maxhp;
        }
        else
        {
-               rd_s16b(&m_ptr->max_maxhp);
+               rd_s16b(&tmp16s);
+               m_ptr->max_maxhp = (HIT_POINT)tmp16s;
        }
        if(h_older_than(2, 1, 2, 1))
        {
@@ -849,14 +904,15 @@ static void rd_monster_old(monster_type *m_ptr)
        }
        else if (z_older_than(10,0,11))
        {
-               s16b tmp16s;
                rd_s16b(&tmp16s);
                reset_target(m_ptr);
        }
        else
        {
-               rd_s16b(&m_ptr->target_y);
-               rd_s16b(&m_ptr->target_x);
+               rd_s16b(&tmp16s);
+               m_ptr->target_y = (POSITION)tmp16s;
+               rd_s16b(&tmp16s);
+               m_ptr->target_x = (POSITION)tmp16s;
        }
 
        rd_byte(&tmp8u);
@@ -870,7 +926,8 @@ static void rd_monster_old(monster_type *m_ptr)
        if (z_older_than(10, 4, 5))
                m_ptr->exp = 0;
        else
-               rd_u32b(&m_ptr->exp);
+               rd_u32b(&tmp32u);
+               m_ptr->exp = tmp32u;
 
        if (z_older_than(10, 2, 2))
        {
@@ -905,14 +962,18 @@ static void rd_monster_old(monster_type *m_ptr)
 }
 
 
-/*
- * Read a monster (New method)
+/*!
+ * @brief モンスターを読み込む(現版) / Read a monster (New method)
+ * @param m_ptr モンスター保存先ポインタ
+ * @return なし
  */
 static void rd_monster(monster_type *m_ptr)
 {
        u32b flags;
        char buf[128];
        byte tmp8u;
+       s16b tmp16s;
+       u32b tmp32u;
 
        if (h_older_than(1, 5, 0, 0))
        {
@@ -929,11 +990,18 @@ static void rd_monster(monster_type *m_ptr)
        rd_s16b(&m_ptr->r_idx);
 
        /* Read the other information */
-       rd_byte(&m_ptr->fy);
-       rd_byte(&m_ptr->fx);
-       rd_s16b(&m_ptr->hp);
-       rd_s16b(&m_ptr->maxhp);
-       rd_s16b(&m_ptr->max_maxhp);
+       rd_byte(&tmp8u);
+       m_ptr->fy = (POSITION)tmp8u;
+       rd_byte(&tmp8u);
+       m_ptr->fx = (POSITION)tmp8u;
+
+       rd_s16b(&tmp16s);
+       m_ptr->hp = (HIT_POINT)tmp16s;
+       rd_s16b(&tmp16s);
+       m_ptr->maxhp = (HIT_POINT)tmp16s;
+       rd_s16b(&tmp16s);
+       m_ptr->max_maxhp = (HIT_POINT)tmp16s;
+
        if(h_older_than(2, 1, 2, 1))
        {
                m_ptr->dealt_damage = 0;
@@ -988,9 +1056,17 @@ static void rd_monster(monster_type *m_ptr)
        }
        else m_ptr->mtimed[MTIMED_MONFEAR] = 0;
 
-       if (flags & SAVE_MON_TARGET_Y) rd_s16b(&m_ptr->target_y);
+       if (flags & SAVE_MON_TARGET_Y)
+       {
+               rd_s16b(&tmp16s);
+               m_ptr->target_y = (POSITION)tmp16s;
+       }
        else m_ptr->target_y = 0;
-       if (flags & SAVE_MON_TARGET_X) rd_s16b(&m_ptr->target_x);
+       if (flags & SAVE_MON_TARGET_X)
+       {
+               rd_s16b(&tmp16s);
+               m_ptr->target_x = (POSITION)tmp16s;
+       }
        else m_ptr->target_x = 0;
 
        if (flags & SAVE_MON_INVULNER)
@@ -1003,7 +1079,11 @@ static void rd_monster(monster_type *m_ptr)
        if (flags & SAVE_MON_SMART) rd_u32b(&m_ptr->smart);
        else m_ptr->smart = 0;
 
-       if (flags & SAVE_MON_EXP) rd_u32b(&m_ptr->exp);
+       if (flags & SAVE_MON_EXP)
+       {
+               rd_u32b(&tmp32u);
+               m_ptr->exp = (EXP)tmp32u;
+       }
        else m_ptr->exp = 0;
 
        m_ptr->mflag = 0; /* Not saved */
@@ -1066,10 +1146,13 @@ static void rd_monster(monster_type *m_ptr)
 #define RF4_BR_GRAV         0x00800000  /* Breathe Gravity */
 #define RF4_BR_SHAR         0x01000000  /* Breathe Shards */
 #define RF4_BR_WALL         0x04000000  /* Breathe Force */
-/*
- * Read the monster lore
+
+/*!
+ * @brief モンスターの思い出を読み込む / Read the monster lore
+ * @param r_idx 読み込み先モンスターID
+ * @return なし
  */
-static void rd_lore(int r_idx)
+static void rd_lore(MONRACE_IDX r_idx)
 {
        byte tmp8u;
 
@@ -1173,17 +1256,17 @@ static void rd_lore(int r_idx)
        r_ptr->r_flags2 &= r_ptr->flags2;
        r_ptr->r_flags3 &= r_ptr->flags3;
        r_ptr->r_flags4 &= r_ptr->flags4;
-       r_ptr->r_flags5 &= r_ptr->flags5;
-       r_ptr->r_flags6 &= r_ptr->flags6;
+       r_ptr->r_flags5 &= r_ptr->a_ability_flags1;
+       r_ptr->r_flags6 &= r_ptr->a_ability_flags2;
        r_ptr->r_flagsr &= r_ptr->flagsr;
 }
 
-
-
-
-/*
- * Add the item "o_ptr" to the inventory of the "Home"
- *
+/*!
+ * @brief 店置きのアイテムオブジェクトを読み込む / Add the item "o_ptr" to the inventory of the "Home"
+ * @param st_ptr 店舗の参照ポインタ
+ * @param o_ptr アイテムオブジェクト参照ポインタ
+ * @return なし
+ * @details
  * In all cases, return the slot (or -1) where the object was placed
  *
  * Note that this is a hacked up version of "inven_carry()".
@@ -1248,9 +1331,11 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr)
        return;
 }
 
-
-/*
- * Read a store
+/*!
+ * @brief 店舗情報を読み込む / Read a store
+ * @param town_number 街ID 
+ * @param store_number 店舗ID
+ * @return エラーID
  */
 static errr rd_store(int town_number, int store_number)
 {
@@ -1334,9 +1419,9 @@ static errr rd_store(int town_number, int store_number)
 }
 
 
-
-/*
- * Read RNG state (added in 2.8.0)
+/*!
+ * @brief 乱数状態を読み込む / Read RNG state (added in 2.8.0)
+ * @return なし
  */
 static void rd_randomizer(void)
 {
@@ -1359,9 +1444,10 @@ static void rd_randomizer(void)
 
 
 
-/*
- * Read options (ignore most pre-2.8.0 options)
- *
+/*!
+ * @brief ゲームオプションを読み込む / Read options (ignore most pre-2.8.0 options)
+ * @return なし
+ * @details
  * Note that the normal options are now stored as a set of 256 bit flags,
  * plus a set of 256 bit masks to indicate which bit flags were defined
  * at the time the savefile was created.  This will allow new options
@@ -1424,6 +1510,8 @@ static void rd_options(void)
        cheat_know = (c & 0x1000) ? TRUE : FALSE;
        cheat_live = (c & 0x2000) ? TRUE : FALSE;
        cheat_save = (c & 0x4000) ? TRUE : FALSE;
+       cheat_diary_output = (c & 0x8000) ? TRUE : FALSE;
+       cheat_turn = (c & 0x0080) ? TRUE : FALSE;
 
        rd_byte((byte *)&autosave_l);
        rd_byte((byte *)&autosave_t);
@@ -1535,11 +1623,10 @@ static void rd_options(void)
 
 
 
-
-
-/*
- * Hack -- strip the "ghost" info
- *
+/*!
+ * @brief ダミー情報スキップ / Hack -- strip the "ghost" info
+ * @return なし
+ * @details
  * XXX XXX XXX This is such a nasty hack it hurts.
  */
 static void rd_ghost(void)
@@ -1554,12 +1641,14 @@ static void rd_ghost(void)
 }
 
 
-/*
- * Save quick start data
+/*!
+ * @brief クイックスタート情報を読み込む / Load quick start data
+ * @return なし
  */
 static void load_quick_start(void)
 {
        byte tmp8u;
+       s16b tmp16s;
        int i;
 
        if (z_older_than(11, 0, 13))
@@ -1572,8 +1661,10 @@ static void load_quick_start(void)
        rd_byte(&previous_char.prace);
        rd_byte(&previous_char.pclass);
        rd_byte(&previous_char.pseikaku);
-       rd_byte(&previous_char.realm1);
-       rd_byte(&previous_char.realm2);
+       rd_byte(&tmp8u);
+       previous_char.realm1 = (REALM_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       previous_char.realm2 = (REALM_IDX)tmp8u;
 
        rd_s16b(&previous_char.age);
        rd_s16b(&previous_char.ht);
@@ -1584,7 +1675,11 @@ static void load_quick_start(void)
        for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max[i]);
        for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max_max[i]);
 
-       for (i = 0; i < PY_MAX_LEVEL; i++) rd_s16b(&previous_char.player_hp[i]);
+       for (i = 0; i < PY_MAX_LEVEL; i++)
+       {
+               rd_s16b(&tmp16s);
+               previous_char.player_hp[i] = (HIT_POINT)tmp16s;
+       }
 
        rd_s16b(&previous_char.chaos_patron);
 
@@ -1599,8 +1694,9 @@ static void load_quick_start(void)
        previous_char.quick_ok = (bool)tmp8u;
 }
 
-/*
- * Read the "extra" information
+/*!
+ * @brief その他の情報を読み込む / Read the "extra" information
+ * @return なし
  */
 static void rd_extra(void)
 {
@@ -1608,9 +1704,10 @@ static void rd_extra(void)
 
        byte tmp8u;
        s16b tmp16s;
+       s32b tmp32s;
        u16b tmp16u;
 
-       rd_string(player_name, sizeof(player_name));
+       rd_string(p_ptr->name, sizeof(p_ptr->name));
 
        rd_string(p_ptr->died_from, sizeof(p_ptr->died_from));
 
@@ -1635,8 +1732,10 @@ static void rd_extra(void)
        rd_byte(&p_ptr->pclass);
        rd_byte(&p_ptr->pseikaku);
        rd_byte(&p_ptr->psex);
-       rd_byte(&p_ptr->realm1);
-       rd_byte(&p_ptr->realm2);
+       rd_byte(&tmp8u);
+       p_ptr->realm1 = (REALM_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       p_ptr->realm2 = (REALM_IDX)tmp8u;
        rd_byte(&tmp8u); /* oops */
 
        if (z_older_than(10, 4, 4))
@@ -1648,7 +1747,8 @@ static void rd_extra(void)
        }
 
        /* Special Race/Class info */
-       rd_byte(&p_ptr->hitdie);
+       rd_byte(&tmp8u);
+       p_ptr->hitdie = tmp8u;
        rd_u16b(&p_ptr->expfact);
 
        /* Age/Height/Weight */
@@ -1691,7 +1791,7 @@ static void rd_extra(void)
                for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
        else
                for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
-       for (i = 0; i < 10; i++) rd_s16b(&p_ptr->skill_exp[i]);
+       for (i = 0; i < GINOU_MAX; i++) rd_s16b(&p_ptr->skill_exp[i]);
        if (z_older_than(10, 4, 1))
        {
                if (p_ptr->pclass != CLASS_BEASTMASTER) p_ptr->skill_exp[GINOU_RIDING] /= 2;
@@ -1729,14 +1829,16 @@ static void rd_extra(void)
        else
        {
                rd_byte(&p_ptr->start_race);
-               rd_s32b(&p_ptr->old_race1);
-               rd_s32b(&p_ptr->old_race2);
+               rd_s32b(&tmp32s);
+               p_ptr->old_race1 = (BIT_FLAGS)tmp32s;
+               rd_s32b(&tmp32s);
+               p_ptr->old_race2 = (BIT_FLAGS)tmp32s;
                rd_s16b(&p_ptr->old_realm);
        }
 
        if (z_older_than(10, 0, 1))
        {
-               for (i = 0; i < OLD_MAX_MANE; i++)
+               for (i = 0; i < MAX_MANE; i++)
                {
                        p_ptr->mane_spell[i] = -1;
                        p_ptr->mane_dam[i] = 0;
@@ -1762,8 +1864,10 @@ static void rd_extra(void)
        {
                for (i = 0; i < MAX_MANE; i++)
                {
-                       rd_s16b(&p_ptr->mane_spell[i]);
-                       rd_s16b(&p_ptr->mane_dam[i]);
+                       rd_s16b(&tmp16s);
+                       p_ptr->mane_spell[i] = (SPELL_IDX)tmp16s;
+                       rd_s16b(&tmp16s);
+                       p_ptr->mane_dam[i] = (SPELL_IDX)tmp16s;
                }
                rd_s16b(&p_ptr->mane_num);
        }
@@ -1825,8 +1929,11 @@ static void rd_extra(void)
        rd_byte(&p_ptr->exit_bldg);
        rd_byte(&tmp8u);
 
-       rd_s16b(&p_ptr->oldpx);
-       rd_s16b(&p_ptr->oldpy);
+       rd_s16b(&tmp16s);
+       p_ptr->oldpx = (POSITION)tmp16s;
+       rd_s16b(&tmp16s);
+       p_ptr->oldpy = (POSITION)tmp16s;
+
        if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->oldpy = 33;p_ptr->oldpx = 131;}
 
        /* Was p_ptr->rewards[MAX_BACT] */
@@ -1876,7 +1983,8 @@ static void rd_extra(void)
        rd_s16b(&p_ptr->max_plv);
        if (z_older_than(10, 3, 8))
        {
-               rd_s16b(&max_dlv[DUNGEON_ANGBAND]);
+               rd_s16b(&tmp16s);
+               max_dlv[DUNGEON_ANGBAND] = tmp16s;
        }
        else
        {
@@ -1886,7 +1994,8 @@ static void rd_extra(void)
 
                for(i = 0; i < max; i++)
                {
-                       rd_s16b(&max_dlv[i]);
+                       rd_s16b(&tmp16s);
+                       max_dlv[i] = tmp16s;
                        if (max_dlv[i] > d_info[i].maxdepth) max_dlv[i] = d_info[i].maxdepth;
                }
        }
@@ -2014,7 +2123,8 @@ static void rd_extra(void)
                else
                {
                        rd_s16b(&p_ptr->tim_res_time);
-                       rd_byte(&p_ptr->mimic_form);
+                       rd_byte(&tmp8u);
+                       p_ptr->mimic_form = (IDX)tmp8u;
                        rd_s16b(&p_ptr->tim_mimic);
                        rd_s16b(&p_ptr->tim_sh_fire);
                }
@@ -2231,13 +2341,13 @@ static void rd_extra(void)
        }
        else if (z_older_than(10, 3, 10))
        {
-               s32b tmp32s;
                rd_s32b(&tmp32s);
                p_ptr->visit = 1L;
        }
        else
        {
-               rd_s32b(&p_ptr->visit);
+               rd_s32b(&tmp32s);
+               p_ptr->visit = (BIT_FLAGS)tmp32s;
        }
        if (!z_older_than(11, 0, 5))
        {
@@ -2246,11 +2356,10 @@ static void rd_extra(void)
 }
 
 
-
-
-/*
- * Read the player inventory
- *
+/*!
+ * @brief プレイヤーの所持品情報を読み込む / Read the player inventory
+ * @return なし
+ * @details
  * Note that the inventory changed in Angband 2.7.4.  Two extra
  * pack slots were added and the equipment was rearranged.  Note
  * that these two features combine when parsing old save-files, in
@@ -2347,29 +2456,49 @@ static errr rd_inventory(void)
 }
 
 
-
-/*
- * Read the saved messages
+/*!
+ * @brief メッセージログを読み込む / Read the saved messages
+ * @return なし
  */
 static void rd_messages(void)
 {
        int i;
        char buf[128];
 
-       s16b num;
 
-       /* Total */
-       rd_s16b(&num);
+       if (h_older_than(2, 2, 0, 75))
+       {
+               u16b num;
+               /* Total */
+               rd_u16b(&num);
+
+               /* Read the messages */
+               for (i = 0; i < num; i++)
+               {
+                       /* Read the message */
+                       rd_string(buf, sizeof(buf));
 
-       /* Read the messages */
-       for (i = 0; i < num; i++)
+                       /* Save the message */
+                       message_add(buf);
+               }
+       }
+       else
        {
-               /* Read the message */
-               rd_string(buf, sizeof(buf));
+               u32b num;
+               /* Total */
+               rd_u32b(&num);
 
-               /* Save the message */
-               message_add(buf);
+               /* Read the messages */
+               for (i = 0; i < num; i++)
+               {
+                       /* Read the message */
+                       rd_string(buf, sizeof(buf));
+
+                       /* Save the message */
+                       message_add(buf);
+               }
        }
+
 }
 
 
@@ -2393,9 +2522,10 @@ static void rd_messages(void)
 #define QUEST_OLD_CASTLE  27
 #define QUEST_ROYAL_CRYPT 28
 
-/*
- * Read the dungeon (old method)
- *
+/*!
+ * @brief メッセージログを読み込む / Read the dungeon (old method)
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
@@ -2413,28 +2543,36 @@ static errr rd_dungeon_old(void)
        /*** Basic info ***/
 
        /* Header info */
-       rd_s16b(&dun_level);
+       rd_s16b(&tmp16s);
+       dun_level = (DEPTH)tmp16s;
        if (z_older_than(10, 3, 8)) dungeon_type = DUNGEON_ANGBAND;
-       else rd_byte(&dungeon_type);
+       else
+       { 
+               rd_byte(&tmp8u);
+               dungeon_type = (IDX)tmp8u;
+       }
 
        /* Set the base level for old versions */
        base_level = dun_level;
 
-       rd_s16b(&base_level);
+       rd_s16b(&tmp16s);
+       base_level = (DEPTH)tmp16s;
 
        rd_s16b(&num_repro);
        rd_s16b(&tmp16s);
-       py = (int)tmp16s;
+       p_ptr->y = (POSITION)tmp16s;
+       rd_s16b(&tmp16s);
+       p_ptr->x = (POSITION)tmp16s;
+       if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;}
+       rd_s16b(&tmp16s);
+       cur_hgt = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
-       px = (int)tmp16s;
-       if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {py = 33;px = 131;}
-       rd_s16b(&cur_hgt);
-       rd_s16b(&cur_wid);
+       cur_wid = (POSITION)tmp16s;
        rd_s16b(&tmp16s); /* max_panel_rows */
        rd_s16b(&tmp16s); /* max_panel_cols */
 
 #if 0
-       if (!py || !px) {py = 10;px = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
+       if (!p_ptr->y || !p_ptr->x) {p_ptr->y = 10;p_ptr->x = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
 #endif
 
        /* Maximal size */
@@ -2692,7 +2830,7 @@ static errr rd_dungeon_old(void)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               int o_idx;
+               IDX o_idx;
 
                object_type *o_ptr;
 
@@ -2762,7 +2900,7 @@ static errr rd_dungeon_old(void)
        /* Read the monsters */
        for (i = 1; i < limit; i++)
        {
-               int m_idx;
+               MONSTER_IDX m_idx;
                monster_type *m_ptr;
 
                /* Get a new record */
@@ -2806,10 +2944,10 @@ static errr rd_dungeon_old(void)
 }
 
 
-
-/*
- * Read the saved floor
- *
+/*!
+ * @brief 保存されたフロアを読み込む / Read the saved floor
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
@@ -2840,7 +2978,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        {
                /*** Not a saved floor ***/
 
-               rd_s16b(&dun_level);
+               rd_s16b(&tmp16s);
+               dun_level = (DEPTH)tmp16s;
                base_level = dun_level;
        }
        else
@@ -2870,17 +3009,20 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                if (tmp16s != sf_ptr->lower_floor_id) return 171;
        }
 
-       rd_s16b(&base_level);
+       rd_s16b(&tmp16s);
+       base_level = (DEPTH)tmp16s;
        rd_s16b(&num_repro);
 
        rd_u16b(&tmp16u);
-       py = (int)tmp16u;
+       p_ptr->y = (int)tmp16u;
 
        rd_u16b(&tmp16u);
-       px = (int)tmp16u;
+       p_ptr->x = (int)tmp16u;
 
-       rd_s16b(&cur_hgt);
-       rd_s16b(&cur_wid);
+       rd_s16b(&tmp16s);
+       cur_hgt = (POSITION)tmp16s;
+       rd_s16b(&tmp16s);
+       cur_wid = (POSITION)tmp16s;
 
        rd_byte(&p_ptr->feeling);
 
@@ -3007,7 +3149,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               int o_idx;
+               IDX o_idx;
                object_type *o_ptr;
 
 
@@ -3066,7 +3208,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        for (i = 1; i < limit; i++)
        {
                cave_type *c_ptr;
-               int m_idx;
+               MONSTER_IDX m_idx;
                monster_type *m_ptr;
 
                /* Get a new record */
@@ -3098,15 +3240,18 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 }
 
 
-/*
- * Read the dungeon (new method)
- *
+/*!
+ * @brief 保存されたフロアを読み込む(現版) / Read the dungeon (new method)
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
 static errr rd_dungeon(void)
 {
        errr err = 0;
+       s16b tmp16s;
+       byte_hack tmp8u;
        byte num;
        int i;
 
@@ -3135,8 +3280,8 @@ static errr rd_dungeon(void)
        rd_s16b(&max_floor_id);
 
        /* Current dungeon type */
-       rd_byte(&dungeon_type);
-
+       rd_byte(&tmp8u);
+       dungeon_type = (DUNGEON_IDX)tmp8u;
 
        /* Number of the saved_floors array elements */
        rd_byte(&num);
@@ -3159,7 +3304,10 @@ static errr rd_dungeon(void)
 
                        rd_s16b(&sf_ptr->floor_id);
                        rd_byte(&sf_ptr->savefile_id);
-                       rd_s16b(&sf_ptr->dun_level);
+
+                       rd_s16b(&tmp16s);
+                       sf_ptr->dun_level = (DEPTH)tmp16s;
+
                        rd_s32b(&sf_ptr->last_visit);
                        rd_u32b(&sf_ptr->visit_mark);
                        rd_s16b(&sf_ptr->upper_floor_id);
@@ -3171,7 +3319,6 @@ static errr rd_dungeon(void)
                for (i = 0; i < num; i++)
                {
                        saved_floor_type *sf_ptr = &saved_floors[i];
-                       byte tmp8u;
 
                        /* Unused element */
                        if (!sf_ptr->floor_id) continue;
@@ -3241,8 +3388,9 @@ static errr rd_dungeon(void)
 }
 
 
-/*
- * Actually read the savefile
+/*!
+ * @brief ロード処理全体のサブ関数 / Actually read the savefile
+ * @return エラーコード
  */
 static errr rd_savefile_new_aux(void)
 {
@@ -3254,6 +3402,7 @@ static errr rd_savefile_new_aux(void)
 
        byte tmp8u;
        u16b tmp16u;
+       s16b tmp16s;
        u32b tmp32u;
 
 #ifdef VERIFY_CHECKSUMS
@@ -3262,12 +3411,6 @@ static errr rd_savefile_new_aux(void)
 #endif
 
 
-       /* Mention the savefile version */
-       note(format(
-                    _("バージョン %d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d savefile..."),
-                    (z_major > 9) ? z_major - 10 : z_major, z_minor, z_patch));
-
-
        /* Strip the version bytes */
        strip_bytes(4);
 
@@ -3286,6 +3429,12 @@ static errr rd_savefile_new_aux(void)
        rd_byte(&h_ver_minor);
        rd_byte(&h_ver_major);
 
+       /* Mention the savefile version */
+       note(format(
+               _("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."),
+               (h_ver_major > 9) ? h_ver_major - 10 : h_ver_major, h_ver_minor, h_ver_patch, h_ver_extra));
+
+
        /* Operating system info */
        rd_u32b(&sf_system);
 
@@ -3351,7 +3500,7 @@ static errr rd_savefile_new_aux(void)
        for (i = 0; i < tmp16u; i++)
        {
                /* Read the lore */
-               rd_lore(i);
+               rd_lore((MONRACE_IDX)i);
        }
 
        if (arg_fiddle) note(_("モンスターの思い出をロードしました", "Loaded Monster Memory"));
@@ -3369,7 +3518,6 @@ static errr rd_savefile_new_aux(void)
        /* Read the object memory */
        for (i = 0; i < tmp16u; i++)
        {
-               byte tmp8u;
                object_kind *k_ptr = &k_info[i];
 
                rd_byte(&tmp8u);
@@ -3422,7 +3570,8 @@ static errr rd_savefile_new_aux(void)
                                quest_type* const q_ptr = &quest[i];
                                
                                rd_s16b(&q_ptr->status);
-                               rd_s16b(&q_ptr->level);
+                               rd_s16b(&tmp16s);
+                               q_ptr->level = tmp16s;
 
                                if (z_older_than(11, 0, 6))
                                {
@@ -3475,7 +3624,7 @@ static errr rd_savefile_new_aux(void)
                                                else
                                                {
                                                        init_flags = INIT_ASSIGN;
-                                                       p_ptr->inside_quest = i;
+                                                       p_ptr->inside_quest = (QUEST_IDX)i;
 
                                                        process_dungeon_file("q_info.txt", 0, 0, 0, 0);
                                                        p_ptr->inside_quest = old_inside_quest;
@@ -3673,7 +3822,8 @@ static errr rd_savefile_new_aux(void)
 
        for (i = 0; i < 64; i++)
        {
-               rd_byte(&p_ptr->spell_order[i]);
+               rd_byte(&tmp8u);
+               p_ptr->spell_order[i] = (SPELL_IDX)tmp8u;
        }
 
 
@@ -3826,9 +3976,9 @@ static errr rd_savefile_new_aux(void)
        return (0);
 }
 
-
-/*
- * Actually read the savefile
+/*!
+ * @brief ロード処理全体のメイン関数 / Actually read the savefile
+ * @return エラーコード
  */
 errr rd_savefile_new(void)
 {
@@ -3860,8 +4010,10 @@ errr rd_savefile_new(void)
 }
 
 
-/*
- * Actually load and verify a floor save data
+/*!
+ * @brief 保存フロア読み込みのサブ関数 / Actually load and verify a floor save data
+ * @param sf_ptr 保存フロア読み込み先
+ * @return 成功したらtrue
  */
 static bool load_floor_aux(saved_floor_type *sf_ptr)
 {
@@ -3921,8 +4073,11 @@ static bool load_floor_aux(saved_floor_type *sf_ptr)
 }
 
 
-/*
- * Attempt to load the temporally saved-floor data
+/*!
+ * @brief 一時保存フロア情報を読み込む / Attempt to load the temporally saved-floor data
+ * @param sf_ptr 保存フロア読み込み先
+ * @param mode オプション
+ * @return 成功したらtrue
  */
 bool load_floor(saved_floor_type *sf_ptr, u32b mode)
 {