OSDN Git Service

[modify] #37914 (2.2.1.3) ブレス処理をfire_ball()からfire_breath()に分離。 / Separate fire_breath...
[hengband/hengband.git] / src / load.c
index fd000ba..e24e9d9 100644 (file)
@@ -370,7 +370,9 @@ static void rd_item_old(object_type *o_ptr)
        rd_byte(&o_ptr->discount);
        rd_byte(&tmp8u);
        o_ptr->number = (ITEM_NUMBER)tmp8u;
-       rd_s16b(&o_ptr->weight);
+
+       rd_s16b(&tmp16s);
+       o_ptr->weight = tmp16s;
 
        rd_byte(&tmp8u);
        o_ptr->name1 = tmp8u;
@@ -647,7 +649,8 @@ static void rd_item(object_type *o_ptr)
        }       
        else o_ptr->number = 1;
 
-       rd_s16b(&o_ptr->weight);
+       rd_s16b(&tmp16s);
+       o_ptr->weight = tmp16s;
 
        if (flags & SAVE_ITEM_NAME1)
        {
@@ -926,6 +929,7 @@ static void rd_monster_old(monster_type *m_ptr)
        if (z_older_than(10, 4, 5))
                m_ptr->exp = 0;
        else
+               tmp32u = 0;
                rd_u32b(&tmp32u);
                m_ptr->exp = tmp32u;
 
@@ -1155,22 +1159,28 @@ static void rd_monster(monster_type *m_ptr)
 static void rd_lore(MONRACE_IDX r_idx)
 {
        byte tmp8u;
+       s16b tmp16s;
 
        monster_race *r_ptr = &r_info[r_idx];
 
        /* Count sights/deaths/kills */
-       rd_s16b(&r_ptr->r_sights);
-       rd_s16b(&r_ptr->r_deaths);
-       rd_s16b(&r_ptr->r_pkills);
+       rd_s16b(&tmp16s);
+       r_ptr->r_sights = (MONSTER_NUMBER)tmp16s;
+       rd_s16b(&tmp16s);
+       r_ptr->r_deaths = (MONSTER_NUMBER)tmp16s;
+       rd_s16b(&tmp16s);
+       r_ptr->r_pkills = (MONSTER_NUMBER)tmp16s;
        if (h_older_than(1, 7, 0, 5))
        {
                r_ptr->r_akills = r_ptr->r_pkills;
        }
        else
        {
-               rd_s16b(&r_ptr->r_akills);
+               rd_s16b(&tmp16s);
+               r_ptr->r_akills = (MONSTER_NUMBER)tmp16s; 
        }
-       rd_s16b(&r_ptr->r_tkills);
+       rd_s16b(&tmp16s);
+       r_ptr->r_tkills = (MONSTER_NUMBER)tmp16s;
 
        /* Count wakes and ignores */
        rd_byte(&r_ptr->r_wake);
@@ -1181,8 +1191,10 @@ static void rd_lore(MONRACE_IDX r_idx)
        rd_byte(&r_ptr->r_xtra2);
 
        /* Count drops */
-       rd_byte(&r_ptr->r_drop_gold);
-       rd_byte(&r_ptr->r_drop_item);
+       rd_byte(&tmp8u);
+       r_ptr->r_drop_gold = (ITEM_NUMBER)tmp8u;
+       rd_byte(&tmp8u);
+       r_ptr->r_drop_item = (ITEM_NUMBER)tmp8u;
 
        /* Count spells */
        rd_byte(&tmp8u);
@@ -1243,7 +1255,8 @@ static void rd_lore(MONRACE_IDX r_idx)
        }
 
        /* Read the "Racial" monster limit per level */
-       rd_byte(&r_ptr->max_num);
+       rd_byte(&tmp8u);
+       r_ptr->max_num = (MONSTER_NUMBER)tmp8u;
 
        /* Location in saved floor */
        rd_s16b(&r_ptr->floor_id);
@@ -2195,7 +2208,8 @@ static void rd_extra(void)
        p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE;
 
        rd_byte(&tmp8u); /* oops */
-       rd_byte(&p_ptr->action);
+       rd_byte(&tmp8u);
+       p_ptr->action = (ACTION_IDX)tmp8u;
        if (!z_older_than(10, 4, 3))
        {
                rd_byte(&tmp8u);
@@ -2464,6 +2478,7 @@ static void rd_messages(void)
 {
        int i;
        char buf[128];
+       int message_max;
 
 
        if (h_older_than(2, 2, 0, 75))
@@ -2471,9 +2486,10 @@ static void rd_messages(void)
                u16b num;
                /* Total */
                rd_u16b(&num);
+               message_max = (int)num;
 
                /* Read the messages */
-               for (i = 0; i < num; i++)
+               for (i = 0; i < message_max; i++)
                {
                        /* Read the message */
                        rd_string(buf, sizeof(buf));
@@ -2487,9 +2503,10 @@ static void rd_messages(void)
                u32b num;
                /* Total */
                rd_u32b(&num);
+               message_max = (int)num;
 
                /* Read the messages */
-               for (i = 0; i < num; i++)
+               for (i = 0; i < message_max; i++)
                {
                        /* Read the message */
                        rd_string(buf, sizeof(buf));
@@ -2946,15 +2963,22 @@ static errr rd_dungeon_old(void)
 
 /*!
  * @brief 保存されたフロアを読み込む / Read the saved floor
- * @return なし
+ * @return info読み込みエラーコード
  * @details
+ * この関数は、セーブデータの互換性を保つために多くのデータ改変処理を備えている。
+ * 現在確認している処理は以下の通り、
+ * <ul>
+ * <li>1.7.0.2で8bitだったcave_typeのfeat,mimicのID値を16bitに拡張する処理。</li>
+ * <li>1.7.0.8までに廃止、IDなどを差し替えたクエスト番号を置換する処理。</li>
+ * </ul>
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
 static errr rd_saved_floor(saved_floor_type *sf_ptr)
 {
-       int ymax, xmax;
-       int i, y, x;
+       POSITION ymax, xmax;
+       POSITION y, x;
+       int i;
        byte count;
        byte tmp8u;
        s16b tmp16s;
@@ -3014,10 +3038,10 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_s16b(&num_repro);
 
        rd_u16b(&tmp16u);
-       p_ptr->y = (int)tmp16u;
+       p_ptr->y = (POSITION)tmp16u;
 
        rd_u16b(&tmp16u);
-       p_ptr->x = (int)tmp16u;
+       p_ptr->x = (POSITION)tmp16u;
 
        rd_s16b(&tmp16s);
        cur_hgt = (POSITION)tmp16s;
@@ -3042,7 +3066,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                cave_template_type *ct_ptr = &templates[i];
 
                /* Read it */
-               rd_u16b(&ct_ptr->info);
+               rd_u16b(&tmp16u);
+               ct_ptr->info = (BIT_FLAGS)tmp16u;
                if (h_older_than(1, 7, 0, 2))
                {
                        rd_byte(&tmp8u);
@@ -3125,7 +3150,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                                }
                        }
                        else if ((c_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
-                                (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
+                               (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
                        {
                                c_ptr->feat = feat_up_stair;
                                c_ptr->special = 0;
@@ -3303,7 +3328,8 @@ static errr rd_dungeon(void)
                        saved_floor_type *sf_ptr = &saved_floors[i];
 
                        rd_s16b(&sf_ptr->floor_id);
-                       rd_byte(&sf_ptr->savefile_id);
+                       rd_byte(&tmp8u);
+                       sf_ptr->savefile_id = (s16b)tmp8u;
 
                        rd_s16b(&tmp16s);
                        sf_ptr->dun_level = (DEPTH)tmp16s;
@@ -3557,7 +3583,7 @@ static errr rd_savefile_new_aux(void)
                }
 
                /* Incompatible save files */
-               if (max_quests_load > max_quests)
+               if (max_quests_load > max_q_idx)
                {
                        note(format(_("クエストが多すぎる(%u)!", "Too many (%u) quests!"), max_quests_load));
                        return (23);
@@ -3565,7 +3591,7 @@ static errr rd_savefile_new_aux(void)
 
                for (i = 0; i < max_quests_load; i++)
                {
-                       if (i < max_quests)
+                       if (i < max_q_idx)
                        {
                                quest_type* const q_ptr = &quest[i];
                                
@@ -3897,7 +3923,7 @@ static errr rd_savefile_new_aux(void)
 
        if (!z_older_than(11, 0, 9))
        {
-               char buf[SCREEN_BUF_SIZE];
+               char buf[SCREEN_BUF_MAX_SIZE];
                rd_string(buf, sizeof(buf));
                if (buf[0]) screen_dump = string_make(buf);
        }