OSDN Git Service

[Refactor] #37353 object-ego.c/h を作成して関連構造体と変数を移動.
[hengband/hengband.git] / src / load.c
index ab5c9ed..0db32b0 100644 (file)
  * the existing "number of turns to protect for", and where each hit
  * by a monster will reduce the shield by that amount.
  *
- * XXX XXX XXX
+ * 
  */
 
 #include "angband.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"
 
 
 /*
@@ -142,9 +172,9 @@ static bool z_older_than(byte x, byte y, byte z)
  * @details
  * Avoid the top two lines, to avoid interference with "msg_print()".
  */
-static void note(cptr msg)
+static void note(concptr msg)
 {
-       static int y = 2;
+       static TERM_LEN y = 2;
 
        /* Draw the message */
        prt(msg, y, 0);
@@ -345,7 +375,6 @@ static void rd_item_old(object_type *o_ptr)
        /* Kind */
        rd_s16b(&o_ptr->k_idx);
 
-       /* Location */
        rd_byte(&tmp8u);
        o_ptr->iy = (POSITION)tmp8u;
        rd_byte(&tmp8u);
@@ -572,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;
@@ -584,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;
@@ -608,7 +633,7 @@ static void rd_item_old(object_type *o_ptr)
 static void rd_item(object_type *o_ptr)
 {
        object_kind *k_ptr;
-       u32b flags;
+       BIT_FLAGS flags;
        char buf[128];
        byte_hack tmp8u;
        s16b tmp16s;
@@ -626,7 +651,6 @@ static void rd_item(object_type *o_ptr)
        /* Kind */
        rd_s16b(&o_ptr->k_idx);
 
-       /* Location */
        rd_byte(&tmp8u);
        o_ptr->iy = (POSITION)tmp8u;
        rd_byte(&tmp8u);
@@ -752,7 +776,7 @@ static void rd_item(object_type *o_ptr)
        
        if(h_older_than(2,1,2,4))
        {
-               u32b flgs[TR_FLAG_SIZE];
+               BIT_FLAGS flgs[TR_FLAG_SIZE];
                object_flags(o_ptr, flgs);
                
                if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name2 == EGO_ANCIENT_CURSE) || (o_ptr->name1 == ART_NIGHT))
@@ -781,7 +805,6 @@ static void rd_item(object_type *o_ptr)
                        }
                        else
                        {
-                               /* Paranoia */
                                add_flag(o_ptr->art_flags, TR_LITE_M1);
                        }
                }
@@ -867,11 +890,14 @@ static void rd_monster_old(monster_type *m_ptr)
        }
        else
        {
-               rd_u32b(&m_ptr->dealt_damage); 
+               rd_s32b(&m_ptr->dealt_damage); 
        }
        
        rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]);
-       rd_byte(&m_ptr->mspeed);
+
+       rd_byte(&tmp8u);
+       m_ptr->mspeed = tmp8u;
+
        if (z_older_than(10, 4, 2))
        {
                rd_byte(&tmp8u);
@@ -926,12 +952,12 @@ static void rd_monster_old(monster_type *m_ptr)
        else
                m_ptr->smart = 0;
 
-       if (z_older_than(10, 4, 5))
+       if (z_older_than(10, 4, 5)) {
                m_ptr->exp = 0;
-       else
-               tmp32u = 0;
+       } else {
                rd_u32b(&tmp32u);
                m_ptr->exp = tmp32u;
+       }
 
        if (z_older_than(10, 2, 2))
        {
@@ -973,7 +999,7 @@ static void rd_monster_old(monster_type *m_ptr)
  */
 static void rd_monster(monster_type *m_ptr)
 {
-       u32b flags;
+       BIT_FLAGS flags;
        char buf[128];
        byte tmp8u;
        s16b tmp16s;
@@ -1012,7 +1038,7 @@ static void rd_monster(monster_type *m_ptr)
        }
        else
        {
-               rd_u32b(&m_ptr->dealt_damage); 
+               rd_s32b(&m_ptr->dealt_damage); 
        }
 
        /* Monster race index of its appearance */
@@ -1025,7 +1051,8 @@ static void rd_monster(monster_type *m_ptr)
        if (flags & SAVE_MON_CSLEEP) rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]);
        else m_ptr->mtimed[MTIMED_CSLEEP] = 0;
 
-       rd_byte(&m_ptr->mspeed);
+       rd_byte(&tmp8u);
+       m_ptr->mspeed = tmp8u;
 
        rd_s16b(&m_ptr->energy_need);
 
@@ -1275,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 なし
@@ -1364,12 +1391,12 @@ static errr rd_store(int town_number, int store_number)
 
        if (z_older_than(10, 3, 3) && (store_number == STORE_HOME))
        {
-               st_ptr = &town[1].store[store_number];
+               st_ptr = &town_info[1].store[store_number];
                if (st_ptr->stock_num) sort = TRUE;
        }
        else
        {
-               st_ptr = &town[town_number].store[store_number];
+               st_ptr = &town_info[town_number].store[store_number];
        }
 
        /* Read the basic info */
@@ -1399,11 +1426,7 @@ static errr rd_store(int town_number, int store_number)
        {
                object_type forge;
                object_type *q_ptr;
-
-               /* Get local object */
                q_ptr = &forge;
-
-               /* Wipe the object */
                object_wipe(q_ptr);
 
                /* Read the item */
@@ -1473,21 +1496,15 @@ static void rd_randomizer(void)
 static void rd_options(void)
 {
        int i, n;
-
        byte b;
-
        u16b c;
 
-       u32b flag[8];
-       u32b mask[8];
-
-
-       /*** Oops ***/
+       BIT_FLAGS flag[8];
+       BIT_FLAGS mask[8];
 
        /* Ignore old options */
        strip_bytes(16);
 
-
        /*** Special info */
 
        /* Read "delay_factor" */
@@ -1509,7 +1526,6 @@ static void rd_options(void)
                mana_warn = b;
        }
 
-
        /*** Cheating options ***/
 
        rd_u16b(&c);
@@ -1525,6 +1541,7 @@ static void rd_options(void)
        cheat_save = (c & 0x4000) ? TRUE : FALSE;
        cheat_diary_output = (c & 0x8000) ? TRUE : FALSE;
        cheat_turn = (c & 0x0080) ? TRUE : FALSE;
+       cheat_sight = (c & 0x0040) ? TRUE : FALSE;
 
        rd_byte((byte *)&autosave_l);
        rd_byte((byte *)&autosave_t);
@@ -1640,7 +1657,7 @@ static void rd_options(void)
  * @brief ダミー情報スキップ / Hack -- strip the "ghost" info
  * @return なし
  * @details
- * XXX XXX XXX This is such a nasty hack it hurts.
+ * This is such a nasty hack it hurts.
  */
 static void rd_ghost(void)
 {
@@ -1671,9 +1688,12 @@ static void load_quick_start(void)
        }
 
        rd_byte(&previous_char.psex);
-       rd_byte(&previous_char.prace);
-       rd_byte(&previous_char.pclass);
-       rd_byte(&previous_char.pseikaku);
+       rd_byte(&tmp8u);
+       previous_char.prace = (RACE_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       previous_char.pclass = (CLASS_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       previous_char.pseikaku = (CHARACTER_IDX)tmp8u;
        rd_byte(&tmp8u);
        previous_char.realm1 = (REALM_IDX)tmp8u;
        rd_byte(&tmp8u);
@@ -1685,8 +1705,8 @@ static void load_quick_start(void)
        rd_s16b(&previous_char.sc);
        rd_s32b(&previous_char.au);
 
-       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 < A_MAX; i++) rd_s16b(&previous_char.stat_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&previous_char.stat_max_max[i]);
 
        for (i = 0; i < PY_MAX_LEVEL; i++)
        {
@@ -1741,15 +1761,18 @@ static void rd_extra(void)
        }
 
        /* Class/Race/Seikaku/Gender/Spells */
-       rd_byte(&p_ptr->prace);
-       rd_byte(&p_ptr->pclass);
-       rd_byte(&p_ptr->pseikaku);
+       rd_byte(&tmp8u);
+       p_ptr->prace = (RACE_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       p_ptr->pclass = (CLASS_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       p_ptr->pseikaku = (CHARACTER_IDX)tmp8u;
        rd_byte(&p_ptr->psex);
        rd_byte(&tmp8u);
        p_ptr->realm1 = (REALM_IDX)tmp8u;
        rd_byte(&tmp8u);
        p_ptr->realm2 = (REALM_IDX)tmp8u;
-       rd_byte(&tmp8u); /* oops */
+       rd_byte(&tmp8u);
 
        if (z_older_than(10, 4, 4))
        {
@@ -1770,12 +1793,11 @@ static void rd_extra(void)
        rd_s16b(&p_ptr->wt);
 
        /* Read the stat info */
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max[i]);
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max_max[i]);
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_cur[i]);
-
-       strip_bytes(24); /* oops */
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_cur[i]);
 
+       strip_bytes(24);
        rd_s32b(&p_ptr->au);
 
        rd_s32b(&p_ptr->max_exp);
@@ -1841,7 +1863,8 @@ static void rd_extra(void)
        }
        else
        {
-               rd_byte(&p_ptr->start_race);
+               rd_byte(&tmp8u);
+               p_ptr->start_race = (RACE_IDX)tmp8u;
                rd_s32b(&tmp32s);
                p_ptr->old_race1 = (BIT_FLAGS)tmp32s;
                rd_s32b(&tmp32s);
@@ -1892,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
        {
@@ -1947,7 +1970,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);
@@ -2013,7 +2036,7 @@ static void rd_extra(void)
                }
        }
 
-       /* Repair maximum player level XXX XXX XXX */
+       /* Repair maximum player level */
        if (p_ptr->max_plv < p_ptr->lev) p_ptr->max_plv = p_ptr->lev;
 
        /* More info */
@@ -2177,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))
        {
@@ -2207,7 +2230,7 @@ static void rd_extra(void)
        rd_byte(&tmp8u);
        p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE;
 
-       rd_byte(&tmp8u); /* oops */
+       rd_byte(&tmp8u);
        rd_byte(&tmp8u);
        p_ptr->action = (ACTION_IDX)tmp8u;
        if (!z_older_than(10, 4, 3))
@@ -2226,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 */
@@ -2249,20 +2272,20 @@ 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;
+       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
        {
@@ -2270,26 +2293,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;
+               current_floor_ptr->generated_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);
 
@@ -2342,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))
@@ -2371,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)
 {
@@ -2393,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)
@@ -2406,11 +2429,7 @@ static errr rd_inventory(void)
 
                /* Nope, we reached the end */
                if (n == 0xFFFF) break;
-
-               /* Get local object */
                q_ptr = &forge;
-
-               /* Wipe the object */
                object_wipe(q_ptr);
 
                /* Read the item */
@@ -2422,46 +2441,39 @@ static errr rd_inventory(void)
                /* Wield equipment */
                if (n >= INVEN_RARM)
                {
-                       /* Player touches it */
                        q_ptr->marked |= OM_TOUCHED;
-
-                       /* Copy object */
-                       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)
                {
-                       /* Oops */
-                       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++;
 
-                       /* Player touches it */
                        q_ptr->marked |= OM_TOUCHED;
-
-                       /* Copy object */
-                       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++;
                }
        }
 
@@ -2554,37 +2566,38 @@ static errr rd_dungeon_old(void)
        byte tmp8u;
        s16b tmp16s;
        u16b limit;
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
 
        /*** Basic info ***/
 
        /* Header info */
        rd_s16b(&tmp16s);
-       dun_level = (DEPTH)tmp16s;
-       if (z_older_than(10, 3, 8)) dungeon_type = DUNGEON_ANGBAND;
+       current_floor_ptr->dun_level = (DEPTH)tmp16s;
+       if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND;
        else
        { 
                rd_byte(&tmp8u);
-               dungeon_type = (IDX)tmp8u;
+               p_ptr->dungeon_idx = (IDX)tmp8u;
        }
 
        /* 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(&num_repro);
+       rd_s16b(&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 */
 
@@ -2593,8 +2606,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 ***/
@@ -2622,11 +2635,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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)
@@ -2653,11 +2666,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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)
@@ -2683,11 +2696,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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)
@@ -2713,11 +2726,11 @@ static errr rd_dungeon_old(void)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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)
@@ -2731,13 +2744,13 @@ static errr rd_dungeon_old(void)
                }
        }
 
-       /* Convert cave 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 */
-                       cave[y][x].info &= ~(CAVE_MASK);
+                       current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
                }
        }
 
@@ -2745,21 +2758,21 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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;
                        }
                }
        }
@@ -2768,37 +2781,37 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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;
                        }
                }
        }
@@ -2808,26 +2821,26 @@ static errr rd_dungeon_old(void)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the cave */
-                       c_ptr = &cave[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;
                        }
                }
        }
@@ -2838,7 +2851,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);
@@ -2847,7 +2860,7 @@ static errr rd_dungeon_old(void)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               IDX o_idx;
+               OBJECT_IDX o_idx;
 
                object_type *o_ptr;
 
@@ -2855,7 +2868,6 @@ static errr rd_dungeon_old(void)
                /* Get a new record */
                o_idx = o_pop();
 
-               /* Oops */
                if (i != o_idx)
                {
                        note(format(_("アイテム配置エラー (%d <> %d)", "Object allocation error (%d <> %d)"), i, o_idx));
@@ -2864,26 +2876,22 @@ 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);
 
 
-               /* XXX XXX XXX XXX XXX */
+               /* XXX XXX */
 
-               /* Monster */
                if (o_ptr->held_m_idx)
                {
                        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;
 
-                       /* Place the object */
                        m_ptr->hold_o_idx = o_idx;
                }
 
@@ -2891,13 +2899,12 @@ static errr rd_dungeon_old(void)
                else
                {
                        /* Access the item location */
-                       c_ptr = &cave[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;
                }
        }
 
@@ -2908,7 +2915,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);
@@ -2923,7 +2930,6 @@ static errr rd_dungeon_old(void)
                /* Get a new record */
                m_idx = m_pop();
 
-               /* Oops */
                if (i != m_idx)
                {
                        note(format(_("モンスター配置エラー (%d <> %d)", "Monster allocation error (%d <> %d)"), i, m_idx));
@@ -2932,17 +2938,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 = &cave[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++;
@@ -2951,7 +2957,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;
@@ -2968,7 +2974,7 @@ static errr rd_dungeon_old(void)
  * この関数は、セーブデータの互換性を保つために多くのデータ改変処理を備えている。
  * 現在確認している処理は以下の通り、
  * <ul>
- * <li>1.7.0.2で8bitだったcave_typeのfeat,mimicのID値を16bitに拡張する処理。</li>
+ * <li>1.7.0.2で8bitだったgrid_typeのfeat,mimicのID値を16bitに拡張する処理。</li>
  * <li>1.7.0.8までに廃止、IDなどを差し替えたクエスト番号を置換する処理。</li>
  * </ul>
  * The monsters/objects must be loaded in the same order
@@ -2987,10 +2993,10 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        u32b tmp32u;
        u16b limit;
 
-       cave_template_type *templates;
+       grid_template_type *templates;
 
 
-       /*** Wipe all cave ***/
+       /*** Wipe all current_floor_ptr->grid_array ***/
        clear_cave();
 
 
@@ -3003,8 +3009,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
        {
@@ -3018,7 +3024,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;
@@ -3034,8 +3040,9 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        }
 
        rd_s16b(&tmp16s);
-       base_level = (DEPTH)tmp16s;
-       rd_s16b(&num_repro);
+       current_floor_ptr->base_level = (DEPTH)tmp16s;
+       rd_s16b(&tmp16s);
+       current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s;
 
        rd_u16b(&tmp16u);
        p_ptr->y = (POSITION)tmp16u;
@@ -3044,26 +3051,26 @@ 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);
 
 
 
-       /*** Read template for cave_type ***/
+       /*** Read template for grid_type ***/
 
        /* Read the template count */
        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);
@@ -3084,8 +3091,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 ***/
@@ -3108,14 +3115,14 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                /* Apply the RLE info */
                for (i = count; i > 0; i--)
                {
-                       /* Access the cave */
-                       cave_type *c_ptr = &cave[y][x];
+                       /* Access the current_floor_ptr->grid_array */
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
-                       /* Extract cave 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)
@@ -3134,32 +3141,32 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        {
                for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
                {
-                       /* Access the cave */
-                       cave_type *c_ptr = &cave[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;
                        }
                }
        }
 
        /* Free the "template" array */
-       C_KILL(templates, limit, cave_template_type);
+       C_KILL(templates, limit, grid_template_type);
 
 
        /*** Objects ***/
@@ -3168,41 +3175,35 @@ 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 */
        for (i = 1; i < limit; i++)
        {
-               IDX o_idx;
+               OBJECT_IDX o_idx;
                object_type *o_ptr;
 
 
                /* Get a new record */
                o_idx = o_pop();
 
-               /* Oops */
                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);
 
-
-               /* Monster */
                if (o_ptr->held_m_idx)
                {
                        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;
 
-                       /* Place the object */
                        m_ptr->hold_o_idx = o_idx;
                }
 
@@ -3210,13 +3211,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                else
                {
                        /* Access the item location */
-                       cave_type *c_ptr = &cave[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;
                }
        }
 
@@ -3227,34 +3227,33 @@ 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++)
        {
-               cave_type *c_ptr;
+               grid_type *g_ptr;
                MONSTER_IDX m_idx;
                monster_type *m_ptr;
 
                /* Get a new record */
                m_idx = m_pop();
 
-               /* Oops */
                if (i != m_idx) return 162;
 
 
                /* 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 = &cave[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++;
@@ -3289,10 +3288,10 @@ static errr rd_dungeon(void)
                err = rd_dungeon_old();
 
                /* Prepare floor_id of current floor */
-               if (dungeon_type)
+               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;
@@ -3306,7 +3305,7 @@ static errr rd_dungeon(void)
 
        /* Current dungeon type */
        rd_byte(&tmp8u);
-       dungeon_type = (DUNGEON_IDX)tmp8u;
+       p_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u;
 
        /* Number of the saved_floors array elements */
        rd_byte(&num);
@@ -3583,7 +3582,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);
@@ -3591,7 +3590,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];
                                
@@ -3705,15 +3704,15 @@ 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);
                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);
@@ -3766,7 +3765,7 @@ static errr rd_savefile_new_aux(void)
 
        /* Read the extra stuff */
        rd_extra();
-       if (p_ptr->energy_need < -999) world_player = TRUE;
+       if (p_ptr->energy_need < -999) p_ptr->timewalk = TRUE;
 
        if (arg_fiddle) note(_("特別情報をロードしました", "Loaded extra information"));
 
@@ -3799,22 +3798,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;
-               do_cmd_rerate(FALSE);
+               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;
-               do_cmd_rerate(FALSE);
+               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;
-               do_cmd_rerate(FALSE);
+               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;
-               do_cmd_rerate(FALSE);
+               roll_hitdice(p_ptr, 0L);
        }
 
        /* Important -- Initialize the magic */
@@ -3859,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);
        }
 
@@ -3923,7 +3922,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);
        }
@@ -3965,8 +3964,8 @@ static errr rd_savefile_new_aux(void)
        {
                if (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)
                {
-                       dungeon_type = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
-                       dun_level = 1;
+                       p_ptr->dungeon_idx = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
+                       current_floor_ptr->dun_level = 1;
                        p_ptr->inside_quest = 0;
                }
        }
@@ -4024,8 +4023,6 @@ errr rd_savefile_new(void)
 
        /* Drop permissions */
        safe_setuid_drop();
-
-       /* Paranoia */
        if (!fff) return (-1);
 
        /* Call the sub-function */
@@ -4033,11 +4030,7 @@ errr rd_savefile_new(void)
 
        /* Check for errors */
        if (ferror(fff)) err = -1;
-
-       /* Close the file */
        my_fclose(fff);
-
-       /* Result */
        return (err);
 }
 
@@ -4183,8 +4176,6 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
 
                /* Check for errors */
                if (ferror(fff)) ok = FALSE;
-
-               /* Close the file */
                my_fclose(fff);
 
                /* Grab permissions */
@@ -4213,7 +4204,5 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
 
        /* Restore old knowledge */
        kanji_code = old_kanji_code;
-
-       /* Result */
        return ok;
 }