OSDN Git Service

[Refactor] #38997 rd_savefile_new() にplayer_type * 引数を追加 / Added player_type * argume...
[hengband/hengband.git] / src / load.c
index 4dd9677..d214e1a 100644 (file)
@@ -130,23 +130,23 @@ static byte kanji_code = 0;
 static bool h_older_than(byte major, byte minor, byte patch, byte extra)
 {
        /* Much older, or much more recent */
-       if (current_world_ptr->h_ver_major < major) return (TRUE);
-       if (current_world_ptr->h_ver_major > major) return (FALSE);
+       if (current_world_ptr->h_ver_major < major) return TRUE;
+       if (current_world_ptr->h_ver_major > major) return FALSE;
 
        /* Distinctly older, or distinctly more recent */
-       if (current_world_ptr->h_ver_minor < minor) return (TRUE);
-       if (current_world_ptr->h_ver_minor > minor) return (FALSE);
+       if (current_world_ptr->h_ver_minor < minor) return TRUE;
+       if (current_world_ptr->h_ver_minor > minor) return FALSE;
 
        /* Barely older, or barely more recent */
-       if (current_world_ptr->h_ver_patch < patch) return (TRUE);
-       if (current_world_ptr->h_ver_patch > patch) return (FALSE);
+       if (current_world_ptr->h_ver_patch < patch) return TRUE;
+       if (current_world_ptr->h_ver_patch > patch) return FALSE;
 
        /* Barely older, or barely more recent */
-       if (current_world_ptr->h_ver_extra < extra) return (TRUE);
-       if (current_world_ptr->h_ver_extra > extra) return (FALSE);
+       if (current_world_ptr->h_ver_extra < extra) return TRUE;
+       if (current_world_ptr->h_ver_extra > extra) return FALSE;
 
        /* Identical versions */
-       return (FALSE);
+       return FALSE;
 }
 
 
@@ -160,19 +160,19 @@ static bool h_older_than(byte major, byte minor, byte patch, byte extra)
 static bool z_older_than(byte x, byte y, byte z)
 {
        /* Much older, or much more recent */
-       if (current_world_ptr->z_major < x) return (TRUE);
-       if (current_world_ptr->z_major > x) return (FALSE);
+       if (current_world_ptr->z_major < x) return TRUE;
+       if (current_world_ptr->z_major > x) return FALSE;
 
        /* Distinctly older, or distinctly more recent */
-       if (current_world_ptr->z_minor < y) return (TRUE);
-       if (current_world_ptr->z_minor > y) return (FALSE);
+       if (current_world_ptr->z_minor < y) return TRUE;
+       if (current_world_ptr->z_minor > y) return FALSE;
 
        /* Barely older, or barely more recent */
-       if (current_world_ptr->z_patch < z) return (TRUE);
-       if (current_world_ptr->z_patch > z) return (FALSE);
+       if (current_world_ptr->z_patch < z) return TRUE;
+       if (current_world_ptr->z_patch > z) return FALSE;
 
        /* Identical versions */
-       return (FALSE);
+       return FALSE;
 }
 
 
@@ -846,10 +846,11 @@ static void rd_item(object_type *o_ptr)
 
 /*!
  * @brief モンスターを読み込む(変愚ver1.5.0以前) / Read a monster (Old method)
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param m_ptr モンスター保存先ポインタ
  * @return なし
  */
-static void rd_monster_old(monster_type *m_ptr)
+static void rd_monster_old(player_type *player_ptr, monster_type *m_ptr)
 {
        byte tmp8u;
        s16b tmp16s;
@@ -880,7 +881,7 @@ static void rd_monster_old(monster_type *m_ptr)
        m_ptr->fy = (POSITION)tmp8u;
        rd_byte(&tmp8u);
        m_ptr->fx = (POSITION)tmp8u;
-       m_ptr->current_floor_ptr = p_ptr->current_floor_ptr;
+       m_ptr->current_floor_ptr = player_ptr->current_floor_ptr;
 
        rd_s16b(&tmp16s);
        m_ptr->hp = tmp16s;
@@ -1006,10 +1007,11 @@ static void rd_monster_old(monster_type *m_ptr)
 
 /*!
  * @brief モンスターを読み込む(現版) / Read a monster (New method)
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param m_ptr モンスター保存先ポインタ
  * @return なし
  */
-static void rd_monster(monster_type *m_ptr)
+static void rd_monster(player_type *player_ptr, monster_type *m_ptr)
 {
        BIT_FLAGS flags;
        char buf[128];
@@ -1019,7 +1021,7 @@ static void rd_monster(monster_type *m_ptr)
 
        if (h_older_than(1, 5, 0, 0))
        {
-               rd_monster_old(m_ptr);
+               rd_monster_old(player_ptr, m_ptr);
                return;
        }
 
@@ -1315,6 +1317,7 @@ static void rd_lore(MONRACE_IDX r_idx)
 
 /*!
  * @brief 店置きのアイテムオブジェクトを読み込む / Add the item "o_ptr" to the inventory of the "Home"
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param st_ptr 店舗の参照ポインタ
  * @param o_ptr アイテムオブジェクト参照ポインタ
  * @return なし
@@ -1326,7 +1329,7 @@ static void rd_lore(MONRACE_IDX r_idx)
  * Also note that it may not correctly "adapt" to "knowledge" bacoming
  * known, the player may have to pick stuff up and drop it again.
  */
-static void home_carry(store_type *st_ptr, object_type *o_ptr)
+static void home_carry(player_type *player_ptr, store_type *st_ptr, object_type *o_ptr)
 {
        int                             slot;
        s32b                       value;
@@ -1377,7 +1380,7 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr)
        /* Insert the new item */
        st_ptr->stock[slot] = *o_ptr;
 
-       chg_virtue(p_ptr, V_SACRIFICE, -1);
+       chg_virtue(player_ptr, V_SACRIFICE, -1);
 
        /* Return the location */
        return;
@@ -1385,11 +1388,12 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr)
 
 /*!
  * @brief 店舗情報を読み込む / Read a store
- * @param town_number 街ID 
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param town_number 街ID
  * @param store_number 店舗ID
  * @return エラーID
  */
-static errr rd_store(int town_number, int store_number)
+static errr rd_store(player_type *player_ptr, int town_number, int store_number)
 {
        store_type *st_ptr;
 
@@ -1450,7 +1454,7 @@ static errr rd_store(int town_number, int store_number)
                        int k;
                        if (sort)
                        {
-                               home_carry(st_ptr, q_ptr);
+                               home_carry(player_ptr, st_ptr, q_ptr);
                        }
                        else
                        {
@@ -1463,7 +1467,7 @@ static errr rd_store(int town_number, int store_number)
        }
 
        /* Success */
-       return (0);
+       return 0;
 }
 
 
@@ -1918,7 +1922,7 @@ static void rd_extra(player_type *creature_ptr)
        {
                determine_bounty_uniques();
 
-               for (i = 0; i < MAX_KUBI; i++)
+               for (i = 0; i < MAX_BOUNTY; i++)
                {
                        /* Is this bounty unique already dead? */
                        if (!r_info[current_world_ptr->bounty_r_idx[i]].max_num) current_world_ptr->bounty_r_idx[i] += 10000;
@@ -1926,7 +1930,7 @@ static void rd_extra(player_type *creature_ptr)
        }
        else
        {
-               for (i = 0; i < MAX_KUBI; i++)
+               for (i = 0; i < MAX_BOUNTY; i++)
                {
                        rd_s16b(&current_world_ptr->bounty_r_idx[i]);
                }
@@ -1934,7 +1938,7 @@ static void rd_extra(player_type *creature_ptr)
 
        if (z_older_than(10, 0, 3))
        {
-               update_gambling_monsters();
+               update_gambling_monsters(creature_ptr);
        }
        else
        {
@@ -2324,7 +2328,7 @@ static void rd_extra(player_type *creature_ptr)
 
        if (z_older_than(10,0,3))
        {
-               determine_today_mon(TRUE);
+               determine_daily_bounty(creature_ptr, TRUE);
        }
        else
        {
@@ -2365,7 +2369,7 @@ static void rd_extra(player_type *creature_ptr)
                {
                        monster_type dummy_mon;
 
-                       rd_monster(&dummy_mon);
+                       rd_monster(creature_ptr, &dummy_mon);
                }
        }
 
@@ -2401,6 +2405,7 @@ static void rd_extra(player_type *creature_ptr)
 
 /*!
  * @brief プレイヤーの所持品情報を読み込む / Read the player inventory
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return なし
  * @details
  * Note that the inventory changed in Angband 2.7.4.  Two extra
@@ -2411,7 +2416,7 @@ static void rd_extra(player_type *creature_ptr)
  *
  * Note that the inventory is "re-sorted" later by "dungeon()".
  */
-static errr rd_inventory(void)
+static errr rd_inventory(player_type *player_ptr)
 {
        int slot = 0;
 
@@ -2419,17 +2424,17 @@ static errr rd_inventory(void)
        object_type *q_ptr;
 
        /* No weight */
-       p_ptr->total_weight = 0;
+       player_ptr->total_weight = 0;
 
        /* No items */
-       p_ptr->inven_cnt = 0;
-       p_ptr->equip_cnt = 0;
+       player_ptr->inven_cnt = 0;
+       player_ptr->equip_cnt = 0;
 
-       if (p_ptr->inventory_list != NULL) C_WIPE(p_ptr->inventory_list, INVEN_TOTAL, object_type);
-       C_MAKE(p_ptr->inventory_list, INVEN_TOTAL, object_type);
+       if (player_ptr->inventory_list != NULL) C_WIPE(player_ptr->inventory_list, INVEN_TOTAL, object_type);
+       C_MAKE(player_ptr->inventory_list, INVEN_TOTAL, object_type);
 
        /* Read until done */
-       while (1)
+       while (TRUE)
        {
                u16b n;
 
@@ -2451,17 +2456,17 @@ static errr rd_inventory(void)
                if (n >= INVEN_RARM)
                {
                        q_ptr->marked |= OM_TOUCHED;
-                       object_copy(&p_ptr->inventory_list[n], q_ptr);
+                       object_copy(&player_ptr->inventory_list[n], q_ptr);
 
                        /* Add the weight */
-                       p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
+                       player_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       p_ptr->equip_cnt++;
+                       player_ptr->equip_cnt++;
                }
 
                /* Warning -- backpack is full */
-               else if (p_ptr->inven_cnt == INVEN_PACK)
+               else if (player_ptr->inven_cnt == INVEN_PACK)
                {
                        note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory"));
 
@@ -2474,18 +2479,18 @@ static errr rd_inventory(void)
                        n = slot++;
 
                        q_ptr->marked |= OM_TOUCHED;
-                       object_copy(&p_ptr->inventory_list[n], q_ptr);
+                       object_copy(&player_ptr->inventory_list[n], q_ptr);
 
                        /* Add the weight */
-                       p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
+                       player_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       p_ptr->inven_cnt++;
+                       player_ptr->inven_cnt++;
                }
        }
 
        /* Success */
-       return (0);
+       return 0;
 }
 
 
@@ -2560,12 +2565,13 @@ static void rd_messages(void)
 
 /*!
  * @brief メッセージログを読み込む / Read the dungeon (old method)
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @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_old(void)
+static errr rd_dungeon_old(player_type *creature_ptr)
 {
        int i, y, x;
        int ymax, xmax;
@@ -2580,41 +2586,42 @@ static errr rd_dungeon_old(void)
 
        /* Header info */
        rd_s16b(&tmp16s);
-       p_ptr->current_floor_ptr->dun_level = (DEPTH)tmp16s;
-       if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       floor_ptr->dun_level = (DEPTH)tmp16s;
+       if (z_older_than(10, 3, 8)) creature_ptr->dungeon_idx = DUNGEON_ANGBAND;
        else
        { 
                rd_byte(&tmp8u);
-               p_ptr->dungeon_idx = (IDX)tmp8u;
+               creature_ptr->dungeon_idx = (IDX)tmp8u;
        }
 
        /* Set the base level for old versions */
-       p_ptr->current_floor_ptr->base_level = p_ptr->current_floor_ptr->dun_level;
+       floor_ptr->base_level = floor_ptr->dun_level;
 
        rd_s16b(&tmp16s);
-       p_ptr->current_floor_ptr->base_level = (DEPTH)tmp16s;
+       floor_ptr->base_level = (DEPTH)tmp16s;
 
        rd_s16b(&tmp16s);
-       p_ptr->current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
+       floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
        rd_s16b(&tmp16s);
-       p_ptr->y = (POSITION)tmp16s;
+       creature_ptr->y = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
-       p_ptr->x = (POSITION)tmp16s;
-       if (z_older_than(10, 3, 13) && !p_ptr->current_floor_ptr->dun_level && !p_ptr->current_floor_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;}
+       creature_ptr->x = (POSITION)tmp16s;
+       if (z_older_than(10, 3, 13) && !floor_ptr->dun_level && !floor_ptr->inside_arena) { creature_ptr->y = 33; creature_ptr->x = 131;}
        rd_s16b(&tmp16s);
-       p_ptr->current_floor_ptr->height = (POSITION)tmp16s;
+       floor_ptr->height = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
-       p_ptr->current_floor_ptr->width = (POSITION)tmp16s;
+       floor_ptr->width = (POSITION)tmp16s;
        rd_s16b(&tmp16s); /* max_panel_rows */
        rd_s16b(&tmp16s); /* max_panel_cols */
 
 #if 0
-       if (!p_ptr->y || !p_ptr->x) {p_ptr->y = 10;p_ptr->x = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
+       if (!creature_ptr->y || !creature_ptr->x) {creature_ptr->y = 10;creature_ptr->x = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
 #endif
 
        /* Maximal size */
-       ymax = p_ptr->current_floor_ptr->height;
-       xmax = p_ptr->current_floor_ptr->width;
+       ymax = floor_ptr->height;
+       xmax = floor_ptr->width;
 
 
        /*** Run length decoding ***/
@@ -2642,7 +2649,7 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Extract "info" */
                        g_ptr->info = info;
@@ -2672,7 +2679,7 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Extract "feat" */
                        g_ptr->feat = (s16b)tmp8u;
@@ -2701,7 +2708,7 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Extract "mimic" */
                        g_ptr->mimic = (s16b)tmp8u;
@@ -2730,7 +2737,7 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Extract "feat" */
                        g_ptr->special = tmp16s;
@@ -2752,7 +2759,7 @@ static errr rd_dungeon_old(void)
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
                        /* Wipe old unused flags */
-                       p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
+                       floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
                }
        }
 
@@ -2760,7 +2767,7 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Very old */
                        if (g_ptr->feat == OLD_FEAT_INVIS)
@@ -2782,7 +2789,7 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Old CAVE_IN_MIRROR flag */
                        if (g_ptr->info & CAVE_OBJECT)
@@ -2804,7 +2811,7 @@ static errr rd_dungeon_old(void)
                        {
                                g_ptr->info &= ~CAVE_TRAP;
                                g_ptr->mimic = g_ptr->feat;
-                               g_ptr->feat = choose_random_trap();
+                               g_ptr->feat = choose_random_trap(creature_ptr);
                        }
 
                        /* Another hidden trap */
@@ -2821,9 +2828,9 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
-                       if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !p_ptr->current_floor_ptr->dun_level)
+                       if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !floor_ptr->dun_level)
                        {
                                if (g_ptr->feat == OLD_FEAT_QUEST_ENTER)
                                {
@@ -2836,7 +2843,7 @@ static errr rd_dungeon_old(void)
                                }
                        }
                        else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
-                                (p_ptr->current_floor_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
+                                (floor_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
                        {
                                g_ptr->feat = feat_up_stair;
                                g_ptr->special = 0;
@@ -2865,7 +2872,7 @@ static errr rd_dungeon_old(void)
 
 
                /* Get a new record */
-               o_idx = o_pop();
+               o_idx = o_pop(floor_ptr);
 
                if (i != o_idx)
                {
@@ -2875,7 +2882,7 @@ static errr rd_dungeon_old(void)
 
 
                /* Acquire place */
-               o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx];
+               o_ptr = &floor_ptr->o_list[o_idx];
 
                /* Read the item */
                rd_item(o_ptr);
@@ -2884,7 +2891,7 @@ static errr rd_dungeon_old(void)
                if (OBJECT_IS_HELD_MONSTER(o_ptr))
                {
                        monster_type *m_ptr;
-                       m_ptr = &p_ptr->current_floor_ptr->m_list[o_ptr->held_m_idx];
+                       m_ptr = &floor_ptr->m_list[o_ptr->held_m_idx];
 
                        /* Build a stack */
                        o_ptr->next_o_idx = m_ptr->hold_o_idx;
@@ -2896,7 +2903,7 @@ static errr rd_dungeon_old(void)
                else
                {
                        /* Access the item location */
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[o_ptr->iy][o_ptr->ix];
+                       g_ptr = &floor_ptr->grid_array[o_ptr->iy][o_ptr->ix];
 
                        /* Build a stack */
                        o_ptr->next_o_idx = g_ptr->o_idx;
@@ -2933,14 +2940,14 @@ static errr rd_dungeon_old(void)
                        return (162);
                }
 
-               m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+               m_ptr = &floor_ptr->m_list[m_idx];
 
                /* Read the monster */
-               rd_monster(m_ptr);
+               rd_monster(creature_ptr, m_ptr);
 
 
                /* Access grid */
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
+               g_ptr = &floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
 
                /* Mark the location */
                g_ptr->m_idx = m_idx;
@@ -2952,18 +2959,20 @@ static errr rd_dungeon_old(void)
        /*** Success ***/
 
        /* The dungeon is ready */
-       if (z_older_than(10, 3, 13) && !p_ptr->current_floor_ptr->dun_level && !p_ptr->current_floor_ptr->inside_arena)
+       if (z_older_than(10, 3, 13) && !floor_ptr->dun_level && !floor_ptr->inside_arena)
                current_world_ptr->character_dungeon = FALSE;
        else
                current_world_ptr->character_dungeon = TRUE;
 
        /* Success */
-       return (0);
+       return 0;
 }
 
 
 /*!
  * @brief 保存されたフロアを読み込む / Read the saved floor
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param sf_ptr 最後に保存されたフロアへの参照ポインタ
  * @return info読み込みエラーコード
  * @details
  * この関数は、セーブデータの互換性を保つために多くのデータ改変処理を備えている。
@@ -2975,7 +2984,7 @@ static errr rd_dungeon_old(void)
  * 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, floor_type *floor_ptr)
+static errr rd_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr)
 {
        POSITION ymax, xmax;
        POSITION y, x;
@@ -2989,11 +2998,11 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr, floor_type *floor_ptr)
        u16b limit;
 
        grid_template_type *templates;
-
-       clear_cave(floor_ptr);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       clear_cave(player_ptr);
 
        /* Mega-Hack -- no player yet */
-       p_ptr->x = p_ptr->y = 0;
+       player_ptr->x = player_ptr->y = 0;
 
        /*** Basic info ***/
 
@@ -3040,17 +3049,17 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr, floor_type *floor_ptr)
        floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
 
        rd_u16b(&tmp16u);
-       p_ptr->y = (POSITION)tmp16u;
+       player_ptr->y = (POSITION)tmp16u;
 
        rd_u16b(&tmp16u);
-       p_ptr->x = (POSITION)tmp16u;
+       player_ptr->x = (POSITION)tmp16u;
 
        rd_s16b(&tmp16s);
        floor_ptr->height = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
        floor_ptr->width = (POSITION)tmp16s;
 
-       rd_byte(&p_ptr->feeling);
+       rd_byte(&player_ptr->feeling);
 
 
 
@@ -3177,7 +3186,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr, floor_type *floor_ptr)
 
 
                /* Get a new record */
-               o_idx = o_pop();
+               o_idx = o_pop(floor_ptr);
 
                if (i != o_idx) return 152;
 
@@ -3235,7 +3244,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr, floor_type *floor_ptr)
                m_ptr = &floor_ptr->m_list[m_idx];
 
                /* Read the monster */
-               rd_monster(m_ptr);
+               rd_monster(player_ptr, m_ptr);
 
 
                /* Access grid */
@@ -3255,12 +3264,13 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr, floor_type *floor_ptr)
 
 /*!
  * @brief 保存されたフロアを読み込む(現版) / Read the dungeon (new method)
- * @return なし
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @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)
+static errr rd_dungeon(player_type *player_ptr)
 {
        errr err = 0;
        s16b tmp16s;
@@ -3268,19 +3278,19 @@ static errr rd_dungeon(void)
        byte num;
        int i;
 
-       /* Initialize saved_floors array and temporal files */
-       init_saved_floors(FALSE);
+       /* Initialize saved_floors array and temporary files */
+       init_saved_floors(player_ptr, FALSE);
 
        /* Older method */
        if (h_older_than(1, 5, 0, 0))
        {
-               err = rd_dungeon_old();
+               err = rd_dungeon_old(player_ptr);
 
                /* Prepare floor_id of current floor */
-               if (p_ptr->dungeon_idx)
+               if (player_ptr->dungeon_idx)
                {
-                       p_ptr->floor_id = get_new_floor_id();
-                       get_sf_ptr(p_ptr->floor_id)->dun_level = p_ptr->current_floor_ptr->dun_level;
+                       player_ptr->floor_id = get_new_floor_id(player_ptr);
+                       get_sf_ptr(player_ptr->floor_id)->dun_level = player_ptr->current_floor_ptr->dun_level;
                }
 
                return err;
@@ -3294,7 +3304,7 @@ static errr rd_dungeon(void)
 
        /* Current dungeon type */
        rd_byte(&tmp8u);
-       p_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u;
+       player_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u;
 
        /* Number of the saved_floors array elements */
        rd_byte(&num);
@@ -3303,7 +3313,7 @@ static errr rd_dungeon(void)
        if (!num)
        {
                /* Read the current floor data */
-               err = rd_saved_floor(NULL, p_ptr->current_floor_ptr);
+               err = rd_saved_floor(player_ptr, NULL);
        }
 
        /*** In the dungeon ***/
@@ -3329,7 +3339,7 @@ static errr rd_dungeon(void)
                }
 
 
-               /* Move saved floors data to temporal files */
+               /* Move saved floors data to temporary files */
                for (i = 0; i < num; i++)
                {
                        saved_floor_type *sf_ptr = &saved_floors[i];
@@ -3342,22 +3352,22 @@ static errr rd_dungeon(void)
                        if (tmp8u) continue;
 
                        /* Read from the save file */
-                       err = rd_saved_floor(sf_ptr, p_ptr->current_floor_ptr);
+                       err = rd_saved_floor(player_ptr, sf_ptr);
 
                        /* Error? */
                        if (err) break;
 
-                       /* Re-save as temporal saved floor file */
-                       if (!save_floor(sf_ptr, SLF_SECOND)) err = 182;
+                       /* Re-save as temporary saved floor file */
+                       if (!save_floor(player_ptr, sf_ptr, SLF_SECOND)) err = 182;
 
                        /* Error? */
                        if (err) break;
                }
 
-               /* Finally load current floor data from temporal file */
+               /* Finally load current floor data from temporary file */
                if (!err)
                {
-                       if (!load_floor(get_sf_ptr(p_ptr->floor_id), SLF_SECOND)) err = 183;
+                       if (!load_floor(player_ptr, get_sf_ptr(player_ptr->floor_id), SLF_SECOND)) err = 183;
                }
        }
 
@@ -3386,7 +3396,7 @@ static errr rd_dungeon(void)
                break;
 
        case 182:
-               note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporal files!"));
+               note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporary files!"));
                break;
 
        case 183:
@@ -3644,7 +3654,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr)
                                                        init_flags = INIT_ASSIGN;
                                                        creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)i;
 
-                                                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+                                                       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
                                                        creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
                                                }
                                        }
@@ -3846,7 +3856,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr)
                creature_ptr->spell_order[i] = (SPELL_IDX)tmp8u;
        }
 
-       if (rd_inventory())
+       if (rd_inventory(creature_ptr))
        {
                note(_("持ち物情報を読み込むことができません", "Unable to read inventory"));
                return (21);
@@ -3862,7 +3872,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr)
        {
                for (j = 0; j < tmp16u; j++)
                {
-                       if (rd_store(i, j)) return (22);
+                       if (rd_store(creature_ptr, i, j)) return (22);
                }
        }
 
@@ -3929,7 +3939,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr)
                /* Dead players have no dungeon */
                note(_("ダンジョン復元中...", "Restoring Dungeon..."));
 
-               if (rd_dungeon())
+               if (rd_dungeon(creature_ptr))
                {
                        note(_("ダンジョンデータ読み込み失敗", "Error reading dungeon data"));
                        return (34);
@@ -3991,14 +4001,15 @@ static errr rd_savefile_new_aux(player_type *creature_ptr)
 #endif
 
        /* Success */
-       return (0);
+       return 0;
 }
 
 /*!
  * @brief ロード処理全体のメイン関数 / Actually read the savefile
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return エラーコード
  */
-errr rd_savefile_new(void)
+errr rd_savefile_new(player_type *player_ptr)
 {
        errr err;
 
@@ -4010,10 +4021,10 @@ errr rd_savefile_new(void)
 
        /* Drop permissions */
        safe_setuid_drop();
-       if (!fff) return (-1);
+       if (!fff) return -1;
 
        /* Call the sub-function */
-       err = rd_savefile_new_aux(p_ptr);
+       err = rd_savefile_new_aux(player_ptr);
 
        /* Check for errors */
        if (ferror(fff)) err = -1;
@@ -4024,10 +4035,11 @@ errr rd_savefile_new(void)
 
 /*!
  * @brief 保存フロア読み込みのサブ関数 / Actually load and verify a floor save data
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param sf_ptr 保存フロア読み込み先
  * @return 成功したらtrue
  */
-static bool load_floor_aux(saved_floor_type *sf_ptr)
+static bool load_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr)
 {
        byte tmp8u;
        u32b tmp32u;
@@ -4046,7 +4058,7 @@ static bool load_floor_aux(saved_floor_type *sf_ptr)
        x_check = 0L;
 
        /* Set the version number to current version */
-       /* Never load old temporal files */
+       /* Never load old temporary files */
        current_world_ptr->h_ver_extra = H_VER_EXTRA;
        current_world_ptr->h_ver_patch = H_VER_PATCH;
        current_world_ptr->h_ver_minor = H_VER_MINOR;
@@ -4057,7 +4069,7 @@ static bool load_floor_aux(saved_floor_type *sf_ptr)
        if (saved_floor_file_sign != tmp32u) return FALSE;
 
        /* Read -- have error? */
-       if (rd_saved_floor(sf_ptr, p_ptr->current_floor_ptr)) return FALSE;
+       if (rd_saved_floor(player_ptr, sf_ptr)) return FALSE;
 
 
 #ifdef VERIFY_CHECKSUMS
@@ -4086,12 +4098,13 @@ static bool load_floor_aux(saved_floor_type *sf_ptr)
 
 
 /*!
- * @brief 一時保存フロア情報を読み込む / Attempt to load the temporally saved-floor data
+ * @brief 一時保存フロア情報を読み込む / Attempt to load the temporarily saved-floor data
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param sf_ptr 保存フロア読み込み先
  * @param mode オプション
  * @return 成功したらtrue
  */
-bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
+bool load_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mode)
 {
        FILE *old_fff = NULL;
        byte old_xor_byte = 0;
@@ -4108,7 +4121,7 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
        byte old_kanji_code = kanji_code;
 
        /*
-        * Temporal files are always written in system depended kanji
+        * Temporary files are always written in system depended kanji
         * code.
         */
 #ifdef JP
@@ -4159,7 +4172,7 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
        if (ok)
        {
                /* Load saved floor data from file */
-               ok = load_floor_aux(sf_ptr);
+               ok = load_floor_aux(player_ptr, sf_ptr);
 
                /* Check for errors */
                if (ferror(fff)) ok = FALSE;