OSDN Git Service

[Refactor] #38995 world_type 構造体に dungeon_turn を取り込む。 / Move dungeon_turn to world_t...
[hengband/hengband.git] / src / load.c
index 2deaa35..a87acef 100644 (file)
@@ -49,6 +49,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "spells-status.h"
+#include "object-hook.h"
 
 
 /*
@@ -1953,7 +1954,7 @@ static void rd_extra(void)
        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;}
+       if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena) {p_ptr->oldpy = 33;p_ptr->oldpx = 131;}
 
        /* Was p_ptr->rewards[MAX_BACT] */
        rd_s16b(&tmp16s);
@@ -2255,10 +2256,10 @@ static void rd_extra(void)
        case RACE_SKELETON:
        case RACE_ZOMBIE:
        case RACE_SPECTRE:
-               turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
+               current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
                break;
        default:
-               turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
+               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;
@@ -2276,26 +2277,26 @@ static void rd_extra(void)
                rd_s32b(&p_ptr->feeling_turn);
        }
 
-       /* Current turn */
-       rd_s32b(&turn);
+       /* Current current_world_ptr->game_turn */
+       rd_s32b(&current_world_ptr->game_turn);
 
        if (z_older_than(10, 3, 12))
        {
-               dungeon_turn = 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;
                p_ptr->feeling_turn /= 2;
-               turn /= 2;
-               dungeon_turn /= 2;
+               current_world_ptr->game_turn /= 2;
+               current_world_ptr->dungeon_turn /= 2;
        }
 
        if (z_older_than(10, 3, 13))
        {
-               old_battle = turn;
+               old_battle = current_world_ptr->game_turn;
        }
        else rd_s32b(&old_battle);
 
@@ -2549,14 +2550,14 @@ static errr rd_dungeon_old(void)
        byte tmp8u;
        s16b tmp16s;
        u16b limit;
-       grid_type *c_ptr;
+       grid_type *g_ptr;
 
 
        /*** Basic info ***/
 
        /* Header info */
        rd_s16b(&tmp16s);
-       dun_level = (DEPTH)tmp16s;
+       current_floor_ptr->dun_level = (DEPTH)tmp16s;
        if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND;
        else
        { 
@@ -2565,22 +2566,22 @@ static errr rd_dungeon_old(void)
        }
 
        /* Set the base level for old versions */
-       base_level = dun_level;
+       current_floor_ptr->base_level = current_floor_ptr->dun_level;
 
        rd_s16b(&tmp16s);
-       base_level = (DEPTH)tmp16s;
+       current_floor_ptr->base_level = (DEPTH)tmp16s;
 
        rd_s16b(&tmp16s);
-       num_repro = (MONSTER_NUMBER)tmp16s;
+       current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
        rd_s16b(&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;}
+       if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;}
        rd_s16b(&tmp16s);
-       cur_hgt = (POSITION)tmp16s;
+       current_floor_ptr->height = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
-       cur_wid = (POSITION)tmp16s;
+       current_floor_ptr->width = (POSITION)tmp16s;
        rd_s16b(&tmp16s); /* max_panel_rows */
        rd_s16b(&tmp16s); /* max_panel_cols */
 
@@ -2589,8 +2590,8 @@ static errr rd_dungeon_old(void)
 #endif
 
        /* Maximal size */
-       ymax = cur_hgt;
-       xmax = cur_wid;
+       ymax = current_floor_ptr->height;
+       xmax = current_floor_ptr->width;
 
 
        /*** Run length decoding ***/
@@ -2618,11 +2619,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Extract "info" */
-                       c_ptr->info = info;
+                       g_ptr->info = info;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -2649,11 +2650,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Extract "feat" */
-                       c_ptr->feat = (s16b)tmp8u;
+                       g_ptr->feat = (s16b)tmp8u;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -2679,11 +2680,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Extract "mimic" */
-                       c_ptr->mimic = (s16b)tmp8u;
+                       g_ptr->mimic = (s16b)tmp8u;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -2709,11 +2710,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Extract "feat" */
-                       c_ptr->special = tmp16s;
+                       g_ptr->special = tmp16s;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -2727,13 +2728,13 @@ static errr rd_dungeon_old(void)
                }
        }
 
-       /* Convert grid_array data */
+       /* Convert current_floor_ptr->grid_array data */
        if (z_older_than(11, 0, 99))
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
                        /* Wipe old unused flags */
-                       grid_array[y][x].info &= ~(CAVE_MASK);
+                       current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
                }
        }
 
@@ -2741,21 +2742,21 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Very old */
-                       if (c_ptr->feat == OLD_FEAT_INVIS)
+                       if (g_ptr->feat == OLD_FEAT_INVIS)
                        {
-                               c_ptr->feat = feat_floor;
-                               c_ptr->info |= CAVE_TRAP;
+                               g_ptr->feat = feat_floor;
+                               g_ptr->info |= CAVE_TRAP;
                        }
 
                        /* Older than 1.1.1 */
-                       if (c_ptr->feat == OLD_FEAT_MIRROR)
+                       if (g_ptr->feat == OLD_FEAT_MIRROR)
                        {
-                               c_ptr->feat = feat_floor;
-                               c_ptr->info |= CAVE_OBJECT;
+                               g_ptr->feat = feat_floor;
+                               g_ptr->info |= CAVE_OBJECT;
                        }
                }
        }
@@ -2764,37 +2765,37 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Old CAVE_IN_MIRROR flag */
-                       if (c_ptr->info & CAVE_OBJECT)
+                       if (g_ptr->info & CAVE_OBJECT)
                        {
-                               c_ptr->mimic = feat_mirror;
+                               g_ptr->mimic = feat_mirror;
                        }
 
                        /* Runes will be mimics and flags */
-                       else if ((c_ptr->feat == OLD_FEAT_MINOR_GLYPH) ||
-                                (c_ptr->feat == OLD_FEAT_GLYPH))
+                       else if ((g_ptr->feat == OLD_FEAT_MINOR_GLYPH) ||
+                                (g_ptr->feat == OLD_FEAT_GLYPH))
                        {
-                               c_ptr->info |= CAVE_OBJECT;
-                               c_ptr->mimic = c_ptr->feat;
-                               c_ptr->feat = feat_floor;
+                               g_ptr->info |= CAVE_OBJECT;
+                               g_ptr->mimic = g_ptr->feat;
+                               g_ptr->feat = feat_floor;
                        }
 
                        /* Hidden traps will be trap terrains mimicing floor */
-                       else if (c_ptr->info & CAVE_TRAP)
+                       else if (g_ptr->info & CAVE_TRAP)
                        {
-                               c_ptr->info &= ~CAVE_TRAP;
-                               c_ptr->mimic = c_ptr->feat;
-                               c_ptr->feat = choose_random_trap();
+                               g_ptr->info &= ~CAVE_TRAP;
+                               g_ptr->mimic = g_ptr->feat;
+                               g_ptr->feat = choose_random_trap();
                        }
 
                        /* Another hidden trap */
-                       else if (c_ptr->feat == OLD_FEAT_INVIS)
+                       else if (g_ptr->feat == OLD_FEAT_INVIS)
                        {
-                               c_ptr->mimic = feat_floor;
-                               c_ptr->feat = feat_trap_open;
+                               g_ptr->mimic = feat_floor;
+                               g_ptr->feat = feat_trap_open;
                        }
                }
        }
@@ -2804,26 +2805,26 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the grid_array */
-                       c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
-                       if ((c_ptr->special == OLD_QUEST_WATER_CAVE) && !dun_level)
+                       if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !current_floor_ptr->dun_level)
                        {
-                               if (c_ptr->feat == OLD_FEAT_QUEST_ENTER)
+                               if (g_ptr->feat == OLD_FEAT_QUEST_ENTER)
                                {
-                                       c_ptr->feat = feat_tree;
-                                       c_ptr->special = 0;
+                                       g_ptr->feat = feat_tree;
+                                       g_ptr->special = 0;
                                }
-                               else if (c_ptr->feat == OLD_FEAT_BLDG_1)
+                               else if (g_ptr->feat == OLD_FEAT_BLDG_1)
                                {
-                                       c_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
+                                       g_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
                                }
                        }
-                       else if ((c_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
+                       else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
                                 (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
                        {
-                               c_ptr->feat = feat_up_stair;
-                               c_ptr->special = 0;
+                               g_ptr->feat = feat_up_stair;
+                               g_ptr->special = 0;
                        }
                }
        }
@@ -2834,7 +2835,7 @@ static errr rd_dungeon_old(void)
        rd_u16b(&limit);
 
        /* Verify maximum */
-       if (limit > max_o_idx)
+       if (limit > current_floor_ptr->max_o_idx)
        {
                note(format(_("アイテムの配列が大きすぎる(%d)!", "Too many (%d) object entries!"), limit));
                return (151);
@@ -2859,7 +2860,7 @@ static errr rd_dungeon_old(void)
 
 
                /* Acquire place */
-               o_ptr = &o_list[o_idx];
+               o_ptr = &current_floor_ptr->o_list[o_idx];
 
                /* Read the item */
                rd_item(o_ptr);
@@ -2873,7 +2874,7 @@ static errr rd_dungeon_old(void)
                        monster_type *m_ptr;
 
                        /* Monster */
-                       m_ptr = &m_list[o_ptr->held_m_idx];
+                       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;
@@ -2886,13 +2887,13 @@ static errr rd_dungeon_old(void)
                else
                {
                        /* Access the item location */
-                       c_ptr = &grid_array[o_ptr->iy][o_ptr->ix];
+                       g_ptr = &current_floor_ptr->grid_array[o_ptr->iy][o_ptr->ix];
 
                        /* Build a stack */
-                       o_ptr->next_o_idx = c_ptr->o_idx;
+                       o_ptr->next_o_idx = g_ptr->o_idx;
 
                        /* Place the object */
-                       c_ptr->o_idx = o_idx;
+                       g_ptr->o_idx = o_idx;
                }
        }
 
@@ -2903,7 +2904,7 @@ static errr rd_dungeon_old(void)
        rd_u16b(&limit);
 
        /* Hack -- verify */
-       if (limit > max_m_idx)
+       if (limit > current_floor_ptr->max_m_idx)
        {
                note(format(_("モンスターの配列が大きすぎる(%d)!", "Too many (%d) monster entries!"), limit));
                return (161);
@@ -2926,17 +2927,17 @@ static errr rd_dungeon_old(void)
 
 
                /* Acquire monster */
-               m_ptr = &m_list[m_idx];
+               m_ptr = &current_floor_ptr->m_list[m_idx];
 
                /* Read the monster */
                rd_monster(m_ptr);
 
 
                /* Access grid */
-               c_ptr = &grid_array[m_ptr->fy][m_ptr->fx];
+               g_ptr = &current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
 
                /* Mark the location */
-               c_ptr->m_idx = m_idx;
+               g_ptr->m_idx = m_idx;
 
                /* Count */
                real_r_ptr(m_ptr)->cur_num++;
@@ -2945,7 +2946,7 @@ static errr rd_dungeon_old(void)
        /*** Success ***/
 
        /* The dungeon is ready */
-       if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena)
+       if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena)
                character_dungeon = FALSE;
        else
                character_dungeon = TRUE;
@@ -2984,7 +2985,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        cave_template_type *templates;
 
 
-       /*** Wipe all grid_array ***/
+       /*** Wipe all current_floor_ptr->grid_array ***/
        clear_cave();
 
 
@@ -2997,8 +2998,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                /*** Not a saved floor ***/
 
                rd_s16b(&tmp16s);
-               dun_level = (DEPTH)tmp16s;
-               base_level = dun_level;
+               current_floor_ptr->dun_level = (DEPTH)tmp16s;
+               current_floor_ptr->base_level = current_floor_ptr->dun_level;
        }
        else
        {
@@ -3012,7 +3013,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 
                rd_s16b(&tmp16s);
                if (tmp16s != sf_ptr->dun_level) return 171;
-               dun_level = sf_ptr->dun_level;
+               current_floor_ptr->dun_level = sf_ptr->dun_level;
 
                rd_s32b(&tmp32s);
                if (tmp32s != sf_ptr->last_visit) return 171;
@@ -3028,9 +3029,9 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        }
 
        rd_s16b(&tmp16s);
-       base_level = (DEPTH)tmp16s;
+       current_floor_ptr->base_level = (DEPTH)tmp16s;
        rd_s16b(&tmp16s);
-       num_repro = (MONSTER_NUMBER)tmp16s;
+       current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
 
        rd_u16b(&tmp16u);
        p_ptr->y = (POSITION)tmp16u;
@@ -3039,9 +3040,9 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        p_ptr->x = (POSITION)tmp16u;
 
        rd_s16b(&tmp16s);
-       cur_hgt = (POSITION)tmp16s;
+       current_floor_ptr->height = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
-       cur_wid = (POSITION)tmp16s;
+       current_floor_ptr->width = (POSITION)tmp16s;
 
        rd_byte(&p_ptr->feeling);
 
@@ -3079,8 +3080,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        }
 
        /* Maximal size */
-       ymax = cur_hgt;
-       xmax = cur_wid;
+       ymax = current_floor_ptr->height;
+       xmax = current_floor_ptr->width;
 
 
        /*** Run length decoding ***/
@@ -3103,14 +3104,14 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the grid_array */
-                       grid_type *c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
-                       /* Extract grid_array data */
-                       c_ptr->info = templates[id].info;
-                       c_ptr->feat = templates[id].feat;
-                       c_ptr->mimic = templates[id].mimic;
-                       c_ptr->special = templates[id].special;
+                       /* Extract current_floor_ptr->grid_array data */
+                       g_ptr->info = templates[id].info;
+                       g_ptr->feat = templates[id].feat;
+                       g_ptr->mimic = templates[id].mimic;
+                       g_ptr->special = templates[id].special;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -3129,26 +3130,26 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the grid_array */
-                       grid_type *c_ptr = &grid_array[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
-                       if ((c_ptr->special == OLD_QUEST_WATER_CAVE) && !dun_level)
+                       if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !current_floor_ptr->dun_level)
                        {
-                               if (c_ptr->feat == OLD_FEAT_QUEST_ENTER)
+                               if (g_ptr->feat == OLD_FEAT_QUEST_ENTER)
                                {
-                                       c_ptr->feat = feat_tree;
-                                       c_ptr->special = 0;
+                                       g_ptr->feat = feat_tree;
+                                       g_ptr->special = 0;
                                }
-                               else if (c_ptr->feat == OLD_FEAT_BLDG_1)
+                               else if (g_ptr->feat == OLD_FEAT_BLDG_1)
                                {
-                                       c_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
+                                       g_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
                                }
                        }
-                       else if ((c_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
+                       else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
                                (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
                        {
-                               c_ptr->feat = feat_up_stair;
-                               c_ptr->special = 0;
+                               g_ptr->feat = feat_up_stair;
+                               g_ptr->special = 0;
                        }
                }
        }
@@ -3163,7 +3164,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_u16b(&limit);
 
        /* Verify maximum */
-       if (limit > max_o_idx) return 151;
+       if (limit > current_floor_ptr->max_o_idx) return 151;
 
 
        /* Read the dungeon items */
@@ -3179,7 +3180,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                if (i != o_idx) return 152;
 
                /* Acquire place */
-               o_ptr = &o_list[o_idx];
+               o_ptr = &current_floor_ptr->o_list[o_idx];
 
                /* Read the item */
                rd_item(o_ptr);
@@ -3191,7 +3192,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                        monster_type *m_ptr;
 
                        /* Monster */
-                       m_ptr = &m_list[o_ptr->held_m_idx];
+                       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;
@@ -3204,13 +3205,13 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                else
                {
                        /* Access the item location */
-                       grid_type *c_ptr = &grid_array[o_ptr->iy][o_ptr->ix];
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[o_ptr->iy][o_ptr->ix];
 
                        /* Build a stack */
-                       o_ptr->next_o_idx = c_ptr->o_idx;
+                       o_ptr->next_o_idx = g_ptr->o_idx;
 
                        /* Place the object */
-                       c_ptr->o_idx = o_idx;
+                       g_ptr->o_idx = o_idx;
                }
        }
 
@@ -3221,12 +3222,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_u16b(&limit);
 
        /* Hack -- verify */
-       if (limit > max_m_idx) return 161;
+       if (limit > current_floor_ptr->max_m_idx) return 161;
 
        /* Read the monsters */
        for (i = 1; i < limit; i++)
        {
-               grid_type *c_ptr;
+               grid_type *g_ptr;
                MONSTER_IDX m_idx;
                monster_type *m_ptr;
 
@@ -3237,17 +3238,17 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 
 
                /* Acquire monster */
-               m_ptr = &m_list[m_idx];
+               m_ptr = &current_floor_ptr->m_list[m_idx];
 
                /* Read the monster */
                rd_monster(m_ptr);
 
 
                /* Access grid */
-               c_ptr = &grid_array[m_ptr->fy][m_ptr->fx];
+               g_ptr = &current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
 
                /* Mark the location */
-               c_ptr->m_idx = m_idx;
+               g_ptr->m_idx = m_idx;
 
                /* Count */
                real_r_ptr(m_ptr)->cur_num++;
@@ -3285,7 +3286,7 @@ static errr rd_dungeon(void)
                if (p_ptr->dungeon_idx)
                {
                        p_ptr->floor_id = get_new_floor_id();
-                       get_sf_ptr(p_ptr->floor_id)->dun_level = dun_level;
+                       get_sf_ptr(p_ptr->floor_id)->dun_level = current_floor_ptr->dun_level;
                }
 
                return err;
@@ -3706,7 +3707,7 @@ static errr rd_savefile_new_aux(void)
                rd_s32b(&wild_y_size);
 
                /* Incompatible save files */
-               if ((wild_x_size > max_wild_x) || (wild_y_size > max_wild_y))
+               if ((wild_x_size > current_world_ptr->max_wild_x) || (wild_y_size > current_world_ptr->max_wild_y))
                {
                        note(format(_("荒野が大きすぎる(%u/%u)!", "Wilderness is too big (%u/%u)!"), wild_x_size, wild_y_size));
                        return (23);
@@ -3792,22 +3793,22 @@ static errr rd_savefile_new_aux(void)
        if(z_older_than(10, 2, 2) && (p_ptr->pclass == CLASS_BEASTMASTER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               roll_hitdice(0L);
+               roll_hitdice(p_ptr, 0L);
        }
        if(z_older_than(10, 3, 2) && (p_ptr->pclass == CLASS_ARCHER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               roll_hitdice(0L);
+               roll_hitdice(p_ptr, 0L);
        }
        if(z_older_than(10, 2, 6) && (p_ptr->pclass == CLASS_SORCERER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               roll_hitdice(0L);
+               roll_hitdice(p_ptr, 0L);
        }
        if(z_older_than(10, 4, 7) && (p_ptr->pclass == CLASS_BLUE_MAGE) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               roll_hitdice(0L);
+               roll_hitdice(p_ptr, 0L);
        }
 
        /* Important -- Initialize the magic */
@@ -3959,7 +3960,7 @@ static errr rd_savefile_new_aux(void)
                if (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)
                {
                        p_ptr->dungeon_idx = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
-                       dun_level = 1;
+                       current_floor_ptr->dun_level = 1;
                        p_ptr->inside_quest = 0;
                }
        }