OSDN Git Service

[Refactor] #37353 object-ego.c/h を作成して関連構造体と変数を移動.
[hengband/hengband.git] / src / load.c
index 90047ab..0db32b0 100644 (file)
  */
 
 #include "angband.h"
-#include "generate.h"
+#include "util.h"
+#include "bldg.h"
+
+#include "dungeon.h"
+#include "feature.h"
+#include "floor-generate.h"
 #include "trap.h"
 #include "mutation.h"
+#include "monster.h"
 #include "quest.h"
 #include "store.h"
 #include "artifact.h"
 #include "avatar.h"
 #include "spells-status.h"
 #include "object-hook.h"
+#include "wild.h"
+#include "patron.h"
+
+#include "floor-save.h"
+#include "floor.h"
+#include "grid.h"
+
+#include "cmd-pet.h"
+#include "dungeon-file.h"
+#include "files.h"
+#include "player-skill.h"
+#include "player-class.h"
+#include "world.h"
+#include "objectkind.h"
+#include "object-ego.h"
 
 
 /*
@@ -580,8 +601,6 @@ static void rd_item_old(object_type *o_ptr)
                        add_flag(o_ptr->art_flags, TR_DEC_MANA);
                }
        }
-
-       /* Paranoia */
        if (object_is_fixed_artifact(o_ptr))
        {
                artifact_type *a_ptr;
@@ -592,8 +611,6 @@ static void rd_item_old(object_type *o_ptr)
                /* Verify that artifact */
                if (!a_ptr->name) o_ptr->name1 = 0;
        }
-
-       /* Paranoia */
        if (object_is_ego(o_ptr))
        {
                ego_item_type *e_ptr;
@@ -788,7 +805,6 @@ static void rd_item(object_type *o_ptr)
                        }
                        else
                        {
-                               /* Paranoia */
                                add_flag(o_ptr->art_flags, TR_LITE_M1);
                        }
                }
@@ -1286,7 +1302,7 @@ static void rd_lore(MONRACE_IDX r_idx)
 }
 
 /*!
- * @brief 店置きのアイテムオブジェクトを読み込む / Add the item "o_ptr" to the inventory of the "Home"
+ * @brief 店置きのアイテムオブジェクトを読み込む / Add the item "o_ptr" to the p_ptr->inventory_list of the "Home"
  * @param st_ptr 店舗の参照ポインタ
  * @param o_ptr アイテムオブジェクト参照ポインタ
  * @return なし
@@ -1899,20 +1915,20 @@ static void rd_extra(void)
                for (i = 0; i < MAX_KUBI; i++)
                {
                        /* Is this bounty unique already dead? */
-                       if (!r_info[kubi_r_idx[i]].max_num) kubi_r_idx[i] += 10000;
+                       if (!r_info[current_world_ptr->bounty_r_idx[i]].max_num) current_world_ptr->bounty_r_idx[i] += 10000;
                }
        }
        else
        {
                for (i = 0; i < MAX_KUBI; i++)
                {
-                       rd_s16b(&kubi_r_idx[i]);
+                       rd_s16b(&current_world_ptr->bounty_r_idx[i]);
                }
        }
 
        if (z_older_than(10, 0, 3))
        {
-               battle_monsters();
+               update_gambling_monsters();
        }
        else
        {
@@ -2184,7 +2200,7 @@ static void rd_extra(void)
        }
 
        /* Calc the regeneration modifier for mutations */
-       mutant_regenerate_mod = calc_mutant_regenerate_mod();
+       p_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod();
 
        if (z_older_than(10,0,9))
        {
@@ -2233,8 +2249,8 @@ static void rd_extra(void)
 
 
        /* Hack -- the two "special seeds" */
-       rd_u32b(&seed_flavor);
-       rd_u32b(&seed_town);
+       rd_u32b(&current_world_ptr->seed_flavor);
+       rd_u32b(&current_world_ptr->seed_town);
 
 
        /* Special stuff */
@@ -2262,14 +2278,14 @@ static void rd_extra(void)
                current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
                break;
        }
-       dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
+       current_world_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
 
        /* Turn when level began */
-       rd_s32b(&old_turn);
+       rd_s32b(&current_floor_ptr->generated_turn);
 
        if (h_older_than(1, 7, 0, 4))
        {
-               p_ptr->feeling_turn = old_turn;
+               p_ptr->feeling_turn = current_floor_ptr->generated_turn;
        }
        else
        {
@@ -2282,16 +2298,16 @@ static void rd_extra(void)
 
        if (z_older_than(10, 3, 12))
        {
-               dungeon_turn = current_world_ptr->game_turn;
+               current_world_ptr->dungeon_turn = current_world_ptr->game_turn;
        }
-       else rd_s32b(&dungeon_turn);
+       else rd_s32b(&current_world_ptr->dungeon_turn);
 
        if (z_older_than(11, 0, 13))
        {
-               old_turn /= 2;
+               current_floor_ptr->generated_turn /= 2;
                p_ptr->feeling_turn /= 2;
                current_world_ptr->game_turn /= 2;
-               dungeon_turn /= 2;
+               current_world_ptr->dungeon_turn /= 2;
        }
 
        if (z_older_than(10, 3, 13))
@@ -2349,11 +2365,11 @@ static void rd_extra(void)
 
        if (z_older_than(10,1,2))
        {
-               playtime = 0;
+               current_world_ptr->play_time = 0;
        }
        else
        {
-               rd_u32b(&playtime);
+               rd_u32b(&current_world_ptr->play_time);
        }
 
        if (z_older_than(10,3,9))
@@ -2378,16 +2394,16 @@ static void rd_extra(void)
 
 
 /*!
- * @brief プレイヤーの所持品情報を読み込む / Read the player inventory
+ * @brief プレイヤーの所持品情報を読み込む / Read the player p_ptr->inventory_list
  * @return なし
  * @details
- * Note that the inventory changed in Angband 2.7.4.  Two extra
+ * Note that the p_ptr->inventory_list 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
  * which items from the old "aux" slot are "carried", perhaps into
- * one of the two new "inventory" slots.
+ * one of the two new "p_ptr->inventory_list" slots.
  *
- * Note that the inventory is "re-sorted" later by "dungeon()".
+ * Note that the p_ptr->inventory_list is "re-sorted" later by "dungeon()".
  */
 static errr rd_inventory(void)
 {
@@ -2400,8 +2416,8 @@ static errr rd_inventory(void)
        p_ptr->total_weight = 0;
 
        /* No items */
-       inven_cnt = 0;
-       equip_cnt = 0;
+       p_ptr->inven_cnt = 0;
+       p_ptr->equip_cnt = 0;
 
        /* Read until done */
        while (1)
@@ -2426,38 +2442,38 @@ static errr rd_inventory(void)
                if (n >= INVEN_RARM)
                {
                        q_ptr->marked |= OM_TOUCHED;
-                       object_copy(&inventory[n], q_ptr);
+                       object_copy(&p_ptr->inventory_list[n], q_ptr);
 
                        /* Add the weight */
                        p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       equip_cnt++;
+                       p_ptr->equip_cnt++;
                }
 
                /* Warning -- backpack is full */
-               else if (inven_cnt == INVEN_PACK)
+               else if (p_ptr->inven_cnt == INVEN_PACK)
                {
-                       note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory!"));
+                       note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the p_ptr->inventory_list!"));
 
                        /* Fail */
                        return (54);
                }
 
-               /* Carry inventory */
+               /* Carry p_ptr->inventory_list */
                else
                {
                        /* Get a slot */
                        n = slot++;
 
                        q_ptr->marked |= OM_TOUCHED;
-                       object_copy(&inventory[n], q_ptr);
+                       object_copy(&p_ptr->inventory_list[n], q_ptr);
 
                        /* Add the weight */
                        p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       inven_cnt++;
+                       p_ptr->inven_cnt++;
                }
        }
 
@@ -2868,18 +2884,14 @@ static errr rd_dungeon_old(void)
 
                /* XXX XXX */
 
-               /* Monster */
                if (o_ptr->held_m_idx)
                {
                        monster_type *m_ptr;
-
-                       /* Monster */
                        m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
 
                        /* Build a stack */
                        o_ptr->next_o_idx = m_ptr->hold_o_idx;
 
-                       /* Place the object */
                        m_ptr->hold_o_idx = o_idx;
                }
 
@@ -2892,7 +2904,6 @@ static errr rd_dungeon_old(void)
                        /* Build a stack */
                        o_ptr->next_o_idx = g_ptr->o_idx;
 
-                       /* Place the object */
                        g_ptr->o_idx = o_idx;
                }
        }
@@ -2982,7 +2993,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        u32b tmp32u;
        u16b limit;
 
-       cave_template_type *templates;
+       grid_template_type *templates;
 
 
        /*** Wipe all current_floor_ptr->grid_array ***/
@@ -3054,12 +3065,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_u16b(&limit);
 
        /* Allocate the "template" array */
-       C_MAKE(templates, limit, cave_template_type);
+       C_MAKE(templates, limit, grid_template_type);
 
        /* Read the templates */
        for (i = 0; i < limit; i++)
        {
-               cave_template_type *ct_ptr = &templates[i];
+               grid_template_type *ct_ptr = &templates[i];
 
                /* Read it */
                rd_u16b(&tmp16u);
@@ -3155,7 +3166,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        }
 
        /* Free the "template" array */
-       C_KILL(templates, limit, cave_template_type);
+       C_KILL(templates, limit, grid_template_type);
 
 
        /*** Objects ***/
@@ -3185,19 +3196,14 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                /* Read the item */
                rd_item(o_ptr);
 
-
-               /* Monster */
                if (o_ptr->held_m_idx)
                {
                        monster_type *m_ptr;
-
-                       /* Monster */
                        m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
 
                        /* Build a stack */
                        o_ptr->next_o_idx = m_ptr->hold_o_idx;
 
-                       /* Place the object */
                        m_ptr->hold_o_idx = o_idx;
                }
 
@@ -3210,7 +3216,6 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                        /* Build a stack */
                        o_ptr->next_o_idx = g_ptr->o_idx;
 
-                       /* Place the object */
                        g_ptr->o_idx = o_idx;
                }
        }
@@ -3699,8 +3704,8 @@ static errr rd_savefile_new_aux(void)
 
                if (z_older_than(10, 3, 7)) p_ptr->wild_mode = FALSE;
                else rd_byte((byte *)&p_ptr->wild_mode);
-               if (z_older_than(10, 3, 7)) ambush_flag = FALSE;
-               else rd_byte((byte *)&ambush_flag);
+               if (z_older_than(10, 3, 7)) p_ptr->ambush_flag = FALSE;
+               else rd_byte((byte *)&p_ptr->ambush_flag);
 
                /* Size of the wilderness */
                rd_s32b(&wild_x_size);
@@ -3853,10 +3858,10 @@ static errr rd_savefile_new_aux(void)
        }
 
 
-       /* Read the inventory */
+       /* Read the p_ptr->inventory_list */
        if (rd_inventory())
        {
-               note(_("持ち物情報を読み込むことができません", "Unable to read inventory"));
+               note(_("持ち物情報を読み込むことができません", "Unable to read p_ptr->inventory_list"));
                return (21);
        }
 
@@ -4018,8 +4023,6 @@ errr rd_savefile_new(void)
 
        /* Drop permissions */
        safe_setuid_drop();
-
-       /* Paranoia */
        if (!fff) return (-1);
 
        /* Call the sub-function */