OSDN Git Service

[Refactor] #38993 object_level を floor_type に取り込む。 / Move object_level to floor_type...
[hengband/hengband.git] / src / dungeon.c
index 4eeab50..aa9c25a 100644 (file)
 #include "cmd-zaprod.h"
 #include "cmd-zapwand.h"
 #include "cmd-pet.h"
+#include "floor.h"
 #include "floor-events.h"
 #include "object-curse.h"
 #include "store.h"
+#include "spells-summon.h"
+#include "spells-object.h"
+#include "spells-status.h"
+#include "spells-floor.h"
 #include "monsterrace-hook.h"
 #include "world.h"
+#include "mutation.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "player-status.h"
+#include "cmd-spell.h"
+#include "realm-hex.h"
+#include "object-hook.h"
+#include "wild.h"
+
 
 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
@@ -139,7 +154,6 @@ static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
 
        }
 
-       /* We have "felt" it */
        o_ptr->ident |= (IDENT_SENSE);
 
        /* Set the "inscription" */
@@ -147,9 +161,7 @@ static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
 
        /* Auto-inscription/destroy */
        autopick_alter_item(slot, destroy_feeling);
-
-       /* Combine / Reorder the pack (later) */
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 }
@@ -523,32 +535,32 @@ static void pattern_teleport(void)
        /* Ask for level */
        if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
        {
-               char    ppp[80];
-               char    tmp_val[160];
+               char ppp[80];
+               char tmp_val[160];
 
                /* Only downward in ironman mode */
                if (ironman_downward)
-                       min_level = dun_level;
+                       min_level = current_floor_ptr->dun_level;
 
                /* Maximum level */
-               if (dungeon_type == DUNGEON_ANGBAND)
+               if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
                {
-                       if (dun_level > 100)
+                       if (current_floor_ptr->dun_level > 100)
                                max_level = MAX_DEPTH - 1;
-                       else if (dun_level == 100)
+                       else if (current_floor_ptr->dun_level == 100)
                                max_level = 100;
                }
                else
                {
-                       max_level = d_info[dungeon_type].maxdepth;
-                       min_level = d_info[dungeon_type].mindepth;
+                       max_level = d_info[p_ptr->dungeon_idx].maxdepth;
+                       min_level = d_info[p_ptr->dungeon_idx].mindepth;
                }
 
                /* Prompt */
                sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level);
 
                /* Default */
-               sprintf(tmp_val, "%d", (int)dun_level);
+               sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
 
                /* Ask for a level */
                if (!get_string(ppp, tmp_val, 10)) return;
@@ -578,14 +590,14 @@ static void pattern_teleport(void)
        if (autosave_l) do_cmd_save_game(TRUE);
 
        /* Change level */
-       dun_level = command_arg;
+       current_floor_ptr->dun_level = command_arg;
 
        leave_quest_check();
 
-       if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
+       if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
 
        p_ptr->inside_quest = 0;
-       p_ptr->energy_use = 0;
+       free_turn(p_ptr);
 
        /*
         * Clear all saved floors
@@ -605,7 +617,7 @@ static void wreck_the_pattern(void)
 {
        int to_ruin = 0;
        POSITION r_y, r_x;
-       int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
+       int pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
 
        if (pattern_type == PATTERN_TILE_WRECKED)
        {
@@ -616,9 +628,7 @@ static void wreck_the_pattern(void)
        msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
        msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
 
-       if (!IS_INVULN())
-               take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
-
+       if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
        to_ruin = randint1(45) + 35;
 
        while (to_ruin--)
@@ -626,7 +636,7 @@ static void wreck_the_pattern(void)
                scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
 
                if (pattern_tile(r_y, r_x) &&
-                   (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
+                   (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
                        cave_set_feat(r_y, r_x, feat_pattern_corrupted);
                }
@@ -651,7 +661,7 @@ static bool pattern_effect(void)
                wreck_the_pattern();
        }
 
-       pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
+       pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
 
        switch (pattern_type)
        {
@@ -972,7 +982,7 @@ static void regen_captured_monsters(void)
        if (heal)
        {
                /* Combine pack */
-               p_ptr->notice |= (PN_COMBINE);
+               p_ptr->update |= (PU_COMBINE);
                p_ptr->window |= (PW_INVEN);
                p_ptr->window |= (PW_EQUIP);
                wild_regen = 20;
@@ -1049,7 +1059,7 @@ void leave_quest_check(void)
               (q_ptr->status == QUEST_STATUS_TAKEN))
                {
                        q_ptr->status = QUEST_STATUS_FAILED;
-                       q_ptr->complev = (byte)p_ptr->lev;
+                       q_ptr->complev = p_ptr->lev;
                        update_playtime();
                        q_ptr->comptime = playtime;
 
@@ -1058,7 +1068,7 @@ void leave_quest_check(void)
                        {
                          case QUEST_TYPE_TOWER:
                                quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
-                               quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
+                               quest[QUEST_TOWER1].complev = p_ptr->lev;
                                break;
                          case QUEST_TYPE_FIND_ARTIFACT:
                                a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
@@ -1099,7 +1109,7 @@ void leave_tower_check(void)
                if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
                {
                        quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
-                       quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
+                       quest[QUEST_TOWER1].complev = p_ptr->lev;
                        update_playtime();
                        quest[QUEST_TOWER1].comptime = playtime;
                }
@@ -1116,7 +1126,7 @@ static void recharged_notice(object_type *o_ptr)
 {
        GAME_TEXT o_name[MAX_NLEN];
 
-       cptr s;
+       concptr s;
 
        /* No inscription */
        if (!o_ptr->inscription) return;
@@ -1171,7 +1181,7 @@ static void check_music(void)
 
        if (p_ptr->anti_magic)
        {
-               stop_singing();
+               stop_singing(p_ptr);
                return;
        }
 
@@ -1186,7 +1196,7 @@ static void check_music(void)
 
        if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
        {
-               stop_singing();
+               stop_singing(p_ptr);
                return;
        }
        else
@@ -1200,25 +1210,19 @@ static void check_music(void)
                        INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
                        msg_print(_("歌を再開した。", "You restart singing."));
                        p_ptr->action = ACTION_SING;
-
-                       /* Recalculate bonuses */
-                       p_ptr->update |= (PU_BONUS | PU_HP);
-
-                       /* Redraw map and status bar */
+                       p_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
                        p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
-                       p_ptr->update |= (PU_MONSTERS);
-
                        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                }
        }
        if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
                p_ptr->spell_exp[spell] += 5;
        else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
-       { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
+       { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
        else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
-       { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
+       { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
        else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
-       { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
+       { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
 
        /* Do any effects of continual song */
        do_spell(REALM_MUSIC, spell, SPELL_CONT);
@@ -1368,7 +1372,7 @@ static void process_world_aux_digestion(void)
  */
 static void process_world_aux_hp_and_sp(void)
 {
-       feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
+       feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
        bool cave_no_regen = FALSE;
        int upkeep_factor = 0;
 
@@ -1433,9 +1437,9 @@ static void process_world_aux_hp_and_sp(void)
        /* (Vampires) Take damage from sunlight */
        if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
        {
-               if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
+               if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
                {
-                       if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
+                       if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                        {
                                msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
                                take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
@@ -1490,11 +1494,11 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                msg_print(_("熱で火傷した!", "The heat burns you!"));
                                take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), 
-                                                               f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
+                                                               f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
+                               concptr name = f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
                                msg_format(_("%sで火傷した!", "The %s burns you!"), name);
                                take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                        }
@@ -1528,11 +1532,11 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
                                take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
-                                       f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
+                                       f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
+                               concptr name = f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
                                msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
                                take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                        }
@@ -1566,11 +1570,11 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                msg_print(_("電撃を受けた!", "The electric shocks you!"));
                                take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
-                                       f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
+                                       f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
+                               concptr name = f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
                                msg_format(_("%sに感電した!", "The %s shocks you!"), name);
                                take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                        }
@@ -1604,11 +1608,11 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                msg_print(_("酸が飛び散った!", "The acid melt you!"));
                                take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
-                                       f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
+                                       f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
+                               concptr name = f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
                                msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
                                take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                        }
@@ -1642,12 +1646,12 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
                                take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
-                                       f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
+                                       f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                                if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 1);
                        }
                        else
                        {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
+                               concptr name = f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name;
                                msg_format(_("%sに毒された!", "The %s poisons you!"), name);
                                take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                                if (p_ptr->resist_pois) (void)set_poisoned(p_ptr->poisoned + 3);
@@ -1658,7 +1662,7 @@ static void process_world_aux_hp_and_sp(void)
        }
 
        if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
-           !p_ptr->levitation && !p_ptr->can_swim)
+           !p_ptr->levitation && !p_ptr->can_swim && !p_ptr->resist_water)
        {
                if (p_ptr->total_weight > weight_limit())
                {
@@ -1710,7 +1714,7 @@ static void process_world_aux_hp_and_sp(void)
        {
                if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke && ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
                {
-                       cptr dam_desc;
+                       concptr dam_desc;
                        cave_no_regen = TRUE;
 
                        if (p_ptr->pass_wall)
@@ -2295,7 +2299,7 @@ static void process_world_aux_mutation(void)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, mode, '\0'))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, mode, '\0'))
                {
                        msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
                        disturb(FALSE, TRUE);
@@ -2339,7 +2343,7 @@ static void process_world_aux_mutation(void)
                msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
 
                banish_monsters(100);
-               if (!dun_level && p_ptr->town_num)
+               if (!current_floor_ptr->dun_level && p_ptr->town_num)
                {
                        int n;
 
@@ -2364,7 +2368,7 @@ static void process_world_aux_mutation(void)
                msg_print(NULL);
 
                /* Absorb light from the current possition */
-               if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
+               if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                {
                        hp_player(10);
                }
@@ -2404,7 +2408,7 @@ static void process_world_aux_mutation(void)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode, '\0'))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, mode, '\0'))
                {
                        msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
                        disturb(FALSE, TRUE);
@@ -2482,7 +2486,7 @@ static void process_world_aux_mutation(void)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode, '\0'))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON, mode, '\0'))
                {
                        msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
                        disturb(FALSE, TRUE);
@@ -2507,7 +2511,7 @@ static void process_world_aux_mutation(void)
                msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
                msg_print(NULL);
                set_food(PY_FOOD_WEAK);
-               if (music_singing_any()) stop_singing();
+               if (music_singing_any()) stop_singing(p_ptr);
                if (hex_spelling_any()) stop_hex_spell_all();
        }
 
@@ -2597,18 +2601,18 @@ static void process_world_aux_mutation(void)
                take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
 
                msg_print(NULL);
-               if (buki_motteruka(INVEN_RARM))
+               if (has_melee_weapon(INVEN_RARM))
                {
                        slot = INVEN_RARM;
                        o_ptr = &inventory[INVEN_RARM];
 
-                       if (buki_motteruka(INVEN_LARM) && one_in_(2))
+                       if (has_melee_weapon(INVEN_LARM) && one_in_(2))
                        {
                                o_ptr = &inventory[INVEN_LARM];
                                slot = INVEN_LARM;
                        }
                }
-               else if (buki_motteruka(INVEN_LARM))
+               else if (has_melee_weapon(INVEN_LARM))
                {
                        o_ptr = &inventory[INVEN_LARM];
                        slot = INVEN_LARM;
@@ -2750,7 +2754,7 @@ static void process_world_aux_curse(void)
                /* Call animal */
                if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
                {
-                       if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
+                       if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
                        {
                                GAME_TEXT o_name[MAX_NLEN];
 
@@ -2762,7 +2766,7 @@ static void process_world_aux_curse(void)
                /* Call demon */
                if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
                {
-                       if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
+                       if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
                        {
                                GAME_TEXT o_name[MAX_NLEN];
 
@@ -2774,7 +2778,7 @@ static void process_world_aux_curse(void)
                /* Call dragon */
                if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
                {
-                       if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
+                       if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_DRAGON,
                            (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
                        {
                                GAME_TEXT o_name[MAX_NLEN];
@@ -2787,7 +2791,7 @@ static void process_world_aux_curse(void)
                /* Call undead */
                if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
                {
-                       if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
+                       if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD,
                            (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
                        {
                                GAME_TEXT o_name[MAX_NLEN];
@@ -2949,7 +2953,6 @@ static void process_world_aux_recharge(void)
        /* Process objects on floor */
        for (i = 1; i < o_max; i++)
        {
-               /* Access object */
                object_type *o_ptr = &o_list[i];
 
                /* Skip dead objects */
@@ -2998,16 +3001,16 @@ static void process_world_aux_movement(void)
                        disturb(FALSE, TRUE);
 
                        /* Determine the level */
-                       if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
+                       if (current_floor_ptr->dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
                        {
                                msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
 
-                               if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
+                               if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
                                if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
+                                       do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
 
-                               dun_level = 0;
-                               dungeon_type = 0;
+                               current_floor_ptr->dun_level = 0;
+                               p_ptr->dungeon_idx = 0;
 
                                leave_quest_check();
                                leave_tower_check();
@@ -3020,29 +3023,29 @@ static void process_world_aux_movement(void)
                        {
                                msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
 
-                               dungeon_type = p_ptr->recall_dungeon;
+                               p_ptr->dungeon_idx = p_ptr->recall_dungeon;
 
                                if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
+                                       do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
 
                                /* New depth */
-                               dun_level = max_dlv[dungeon_type];
-                               if (dun_level < 1) dun_level = 1;
+                               current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
+                               if (current_floor_ptr->dun_level < 1) current_floor_ptr->dun_level = 1;
 
                                /* Nightmare mode makes recall more dangerous */
-                               if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
+                               if (ironman_nightmare && !randint0(666) && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
                                {
-                                       if (dun_level < 50)
+                                       if (current_floor_ptr->dun_level < 50)
                                        {
-                                               dun_level *= 2;
+                                               current_floor_ptr->dun_level *= 2;
                                        }
-                                       else if (dun_level < 99)
+                                       else if (current_floor_ptr->dun_level < 99)
                                        {
-                                               dun_level = (dun_level + 99) / 2;
+                                               current_floor_ptr->dun_level = (current_floor_ptr->dun_level + 99) / 2;
                                        }
-                                       else if (dun_level > 100)
+                                       else if (current_floor_ptr->dun_level > 100)
                                        {
-                                               dun_level = d_info[dungeon_type].maxdepth - 1;
+                                               current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].maxdepth - 1;
                                        }
                                }
 
@@ -3068,7 +3071,7 @@ static void process_world_aux_movement(void)
                                /* Leaving */
                                p_ptr->leaving = TRUE;
 
-                               if (dungeon_type == DUNGEON_ANGBAND)
+                               if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
                                {
                                        int i;
 
@@ -3079,7 +3082,7 @@ static void process_world_aux_movement(void)
                                                
                                                if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
                                                    (q_ptr->status == QUEST_STATUS_TAKEN) &&
-                                                   (q_ptr->level < dun_level))
+                                                   (q_ptr->level < current_floor_ptr->dun_level))
                                                {
                                                        q_ptr->status = QUEST_STATUS_FAILED;
                                                        q_ptr->complev = (byte)p_ptr->lev;
@@ -3114,7 +3117,7 @@ static void process_world_aux_movement(void)
                        disturb(FALSE, TRUE);
 
                        /* Determine the level */
-                       if (!quest_number(dun_level) && dun_level)
+                       if (!quest_number(current_floor_ptr->dun_level) && current_floor_ptr->dun_level)
                        {
                                msg_print(_("世界が変わった!", "The world changes!"));
 
@@ -3160,7 +3163,7 @@ static int get_monster_crowd_number(MONSTER_IDX m_idx)
                if (!in_bounds(ay, ax)) continue;
 
                /* Count number of monsters */
-               if (cave[ay][ax].m_idx > 0) count++;
+               if (current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
        }
 
        return count;
@@ -3185,7 +3188,7 @@ static byte get_dungeon_feeling(void)
        IDX i;
 
        /* Hack -- no feeling in the town */
-       if (!dun_level) return 0;
+       if (!current_floor_ptr->dun_level) return 0;
 
        /* Examine each monster */
        for (i = 1; i < m_max; i++)
@@ -3206,19 +3209,19 @@ static byte get_dungeon_feeling(void)
                if (r_ptr->flags1 & (RF1_UNIQUE))
                {
                        /* Nearly out-of-depth unique monsters */
-                       if (r_ptr->level + 10 > dun_level)
+                       if (r_ptr->level + 10 > current_floor_ptr->dun_level)
                        {
                                /* Boost rating by twice delta-depth */
-                               delta += (r_ptr->level + 10 - dun_level) * 2 * base;
+                               delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
                        }
                }
                else
                {
                        /* Out-of-depth monsters */
-                       if (r_ptr->level > dun_level)
+                       if (r_ptr->level > current_floor_ptr->dun_level)
                        {
                                /* Boost rating by delta-depth */
-                               delta += (r_ptr->level - dun_level) * base;
+                               delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
                        }
                }
 
@@ -3288,10 +3291,10 @@ static byte get_dungeon_feeling(void)
                if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
 
                /* Out-of-depth objects */
-               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
+               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
                {
                        /* Rating increase */
-                       delta += (k_ptr->level - dun_level) * base;
+                       delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
                }
 
                rating += RATING_BOOST(delta);
@@ -3322,19 +3325,19 @@ static void update_dungeon_feeling(void)
        int delay;
 
        /* No feeling on the surface */
-       if (!dun_level) return;
+       if (!current_floor_ptr->dun_level) return;
 
        /* No feeling in the arena */
        if (p_ptr->inside_battle) return;
 
        /* Extract delay time */
-       delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
+       delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
 
        /* Not yet felt anything */
        if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
 
        /* Extract quest number (if any) */
-       quest_num = quest_number(dun_level);
+       quest_num = quest_number(current_floor_ptr->dun_level);
 
        /* No feeling in a quest */
        if (quest_num &&
@@ -3385,10 +3388,10 @@ static void process_world(void)
        update_dungeon_feeling();
 
        /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
-       if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
+       if (ironman_downward && (p_ptr->dungeon_idx != DUNGEON_ANGBAND && p_ptr->dungeon_idx != 0))
        {
-               dun_level = 0;
-               dungeon_type = 0;
+               current_floor_ptr->dun_level = 0;
+               p_ptr->dungeon_idx = 0;
                prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
                p_ptr->inside_arena = FALSE;
                p_ptr->wild_mode = FALSE;
@@ -3403,15 +3406,15 @@ static void process_world(void)
                int number_mon = 0;
 
                /* Count all hostile monsters */
-               for (i2 = 0; i2 < cur_wid; ++i2)
-                       for (j2 = 0; j2 < cur_hgt; j2++)
+               for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
+                       for (j2 = 0; j2 < current_floor_ptr->height; j2++)
                        {
-                               cave_type *c_ptr = &cave[j2][i2];
+                               grid_type *g_ptr = &current_floor_ptr->grid_array[j2][i2];
 
-                               if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
+                               if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != p_ptr->riding))
                                {
                                        number_mon++;
-                                       win_m_idx = c_ptr->m_idx;
+                                       win_m_idx = g_ptr->m_idx;
                                }
                        }
 
@@ -3509,7 +3512,7 @@ static void process_world(void)
        /*** Handle the wilderness/town (sunshine) ***/
 
        /* While in town/wilderness */
-       if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
+       if (!current_floor_ptr->dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
        {
                /* Hack -- Daybreak/Nighfall in town */
                if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
@@ -3526,7 +3529,7 @@ static void process_world(void)
        }
 
        /* While in the dungeon (vanilla_town or lite_town mode only) */
-       else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
+       else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
        {
                /*** Shuffle the Storekeepers ***/
 
@@ -3577,7 +3580,7 @@ static void process_world(void)
        /*** Process the monsters ***/
 
        /* Check for creature generation. */
-       if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
+       if (one_in_(d_info[p_ptr->dungeon_idx].max_m_alloc_chance) &&
            !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
        {
                /* Make a new monster */
@@ -3659,7 +3662,7 @@ static void process_world(void)
                                change_wild_mode();
 
                                /* Give first move to monsters */
-                               p_ptr->energy_use = 100;
+                               take_turn(p_ptr, 100);
 
                                /* HACk -- set the encouter flag for the wilderness generation */
                                generate_encounter = TRUE;
@@ -4065,28 +4068,28 @@ static void process_command(void)
                /* Enter store */
                case SPECIAL_KEY_STORE:
                {
-                       if (!p_ptr->wild_mode) do_cmd_store();
+                       do_cmd_store();
                        break;
                }
 
                /* Enter building -KMW- */
                case SPECIAL_KEY_BUILDING:
                {
-                       if (!p_ptr->wild_mode) do_cmd_bldg();
+                       do_cmd_bldg();
                        break;
                }
 
                /* Enter quest level -KMW- */
                case SPECIAL_KEY_QUEST:
                {
-                       if (!p_ptr->wild_mode) do_cmd_quest();
+                       do_cmd_quest();
                        break;
                }
 
                /* Go up staircase */
                case '<':
                {
-                       if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
+                       if (!p_ptr->wild_mode && !current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
                        {
                                if (vanilla_town) break;
 
@@ -4116,42 +4119,41 @@ static void process_command(void)
                                change_wild_mode();
                        else
                                do_cmd_go_down();
-
                        break;
                }
 
                /* Open a door or chest */
                case 'o':
                {
-                       if (!p_ptr->wild_mode) do_cmd_open();
+                       do_cmd_open();
                        break;
                }
 
                /* Close a door */
                case 'c':
                {
-                       if (!p_ptr->wild_mode) do_cmd_close();
+                       do_cmd_close();
                        break;
                }
 
                /* Jam a door with spikes */
                case 'j':
                {
-                       if (!p_ptr->wild_mode) do_cmd_spike();
+                       do_cmd_spike();
                        break;
                }
 
                /* Bash a door */
                case 'B':
                {
-                       if (!p_ptr->wild_mode) do_cmd_bash();
+                       do_cmd_bash();
                        break;
                }
 
                /* Disarm a trap or chest */
                case 'D':
                {
-                       if (!p_ptr->wild_mode) do_cmd_disarm();
+                       do_cmd_disarm();
                        break;
                }
 
@@ -4166,7 +4168,7 @@ static void process_command(void)
                        else if (p_ptr->pclass == CLASS_SAMURAI)
                                do_cmd_gain_hissatsu();
                        else if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                               gain_magic();
+                               import_magic_device();
                        else
                                do_cmd_study();
                        break;
@@ -4200,14 +4202,14 @@ static void process_command(void)
                                {
                                        msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
                                }
-                               else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
+                               else if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
                                {
                                        msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
                                        msg_print(NULL);
                                }
                                else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
                                {
-                                       cptr which_power = _("魔法", "magic");
+                                       concptr which_power = _("魔法", "magic");
                                        if (p_ptr->pclass == CLASS_MINDCRAFTER)
                                                which_power = _("超能力", "psionic powers");
                                        else if (p_ptr->pclass == CLASS_IMITATOR)
@@ -4222,12 +4224,12 @@ static void process_command(void)
                                                which_power = _("祈り", "prayer");
 
                                        msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                }
                                else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
                                {
                                        msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                }
                                else
                                {
@@ -4259,7 +4261,7 @@ static void process_command(void)
                /* Issue a pet command */
                case 'p':
                {
-                       if (!p_ptr->wild_mode) do_cmd_pet();
+                       do_cmd_pet();
                        break;
                }
 
@@ -4282,16 +4284,7 @@ static void process_command(void)
                /* Activate an artifact */
                case 'A':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (!p_ptr->inside_arena)
-                               do_cmd_activate();
-                       else
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       }
+                       do_cmd_activate();
                        break;
                }
 
@@ -4312,44 +4305,28 @@ static void process_command(void)
                /* Fire an item */
                case 'f':
                {
-                       if (!p_ptr->wild_mode) do_cmd_fire();
+                       do_cmd_fire();
                        break;
                }
 
                /* Throw an item */
                case 'v':
                {
-                       if (!p_ptr->wild_mode) do_cmd_throw(1, FALSE, -1);
+                       do_cmd_throw(1, FALSE, -1);
                        break;
                }
 
                /* Aim a wand */
                case 'a':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (!p_ptr->inside_arena)
-                               do_cmd_aim_wand();
-                       else
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       }
+                       do_cmd_aim_wand();
                        break;
                }
 
                /* Zap a rod */
                case 'z':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (p_ptr->inside_arena)
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       else if (use_command && rogue_like_commands)
+                       if (use_command && rogue_like_commands)
                        {
                                do_cmd_use();
                        }
@@ -4357,66 +4334,37 @@ static void process_command(void)
                        {
                                do_cmd_zap_rod();
                        }
-                       }
                        break;
                }
 
                /* Quaff a potion */
                case 'q':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (!p_ptr->inside_arena)
-                               do_cmd_quaff_potion();
-                       else
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       }
+                       do_cmd_quaff_potion();
                        break;
                }
 
                /* Read a scroll */
                case 'r':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (!p_ptr->inside_arena)
-                               do_cmd_read_scroll();
-                       else
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       }
+                       do_cmd_read_scroll();
                        break;
                }
 
                /* Use a staff */
                case 'u':
                {
-                       if (!p_ptr->wild_mode)
-                       {
-                       if (p_ptr->inside_arena)
-                       {
-                               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-                               msg_print(NULL);
-                       }
-                       else if (use_command && !rogue_like_commands)
-                       {
+                       if (use_command && !rogue_like_commands)
                                do_cmd_use();
-                       }
                        else
                                do_cmd_use_staff();
-                       }
                        break;
                }
 
                /* Use racial power */
                case 'U':
                {
-                       if (!p_ptr->wild_mode) do_cmd_racial_power();
+                       do_cmd_racial_power();
                        break;
                }
 
@@ -4447,7 +4395,7 @@ static void process_command(void)
                /* Target monster or location */
                case '*':
                {
-                       if (!p_ptr->wild_mode) do_cmd_target();
+                       do_cmd_target();
                        break;
                }
 
@@ -4556,7 +4504,7 @@ static void process_command(void)
                /* Repeat level feeling */
                case KTRL('F'):
                {
-                       if (!p_ptr->wild_mode) do_cmd_feeling();
+                       do_cmd_feeling();
                        break;
                }
 
@@ -4698,22 +4646,6 @@ static void process_command(void)
 }
 
 /*!
- * @brief モンスター種族が釣れる種族かどうかを判定する。
- * @param r_idx 判定したいモンスター種族のID
- * @return 釣れる対象ならばTRUEを返す
- */
-static bool monster_tsuri(MONRACE_IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
  * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
  * @return なし
  */
@@ -4725,7 +4657,7 @@ static void pack_overflow(void)
                object_type *o_ptr;
 
                /* Is auto-destroy done? */
-               handle_stuff();
+               update_creature(p_ptr);
                if (!inventory[INVEN_PACK].k_idx) return;
 
                /* Access the slot to be dropped */
@@ -4875,8 +4807,8 @@ static void process_player(void)
                {
                        MONRACE_IDX r_idx;
                        bool success = FALSE;
-                       get_mon_num_prep(monster_tsuri,NULL);
-                       r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
+                       get_mon_num_prep(monster_is_fishing_target,NULL);
+                       r_idx = get_mon_num(current_floor_ptr->dun_level ? current_floor_ptr->dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
                        msg_print(NULL);
                        if (r_idx && one_in_(2))
                        {
@@ -4886,7 +4818,7 @@ static void process_player(void)
                                if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
                                {
                                        GAME_TEXT m_name[MAX_NLEN];
-                                       monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
+                                       monster_desc(m_name, &m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
                                        msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
                                        success = TRUE;
                                }
@@ -5053,7 +4985,7 @@ static void process_player(void)
                if (!command_new) command_see = FALSE;
 
                /* Assume free turn */
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                if (p_ptr->inside_battle)
                {
@@ -5069,7 +5001,7 @@ static void process_player(void)
                /* Paralyzed or Knocked Out */
                else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);
                }
 
                /* Resting */
@@ -5082,18 +5014,16 @@ static void process_player(void)
                                resting--;
 
                                if (!resting) set_action(ACTION_NONE);
-
-                               /* Redraw the state */
                                p_ptr->redraw |= (PR_STATE);
                        }
 
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);
                }
 
                /* Fishing */
                else if (p_ptr->action == ACTION_FISH)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);
                }
 
                /* Running */
@@ -5157,7 +5087,7 @@ static void process_player(void)
                if (p_ptr->energy_use)
                {
                        /* Use some energy */
-                       if (world_player || p_ptr->energy_use > 400)
+                       if (p_ptr->timewalk || p_ptr->energy_use > 400)
                        {
                                /* The Randomness is irrelevant */
                                p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
@@ -5285,7 +5215,7 @@ static void process_player(void)
                                p_ptr->redraw |= (PR_STATE);
                        }
 
-                       if (world_player && (p_ptr->energy_need > - 1000))
+                       if (p_ptr->timewalk && (p_ptr->energy_need > - 1000))
                        {
 
                                p_ptr->redraw |= (PR_MAP);
@@ -5295,7 +5225,7 @@ static void process_player(void)
 
                                msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
                                msg_print(NULL);
-                               world_player = FALSE;
+                               p_ptr->timewalk = FALSE;
                                p_ptr->energy_need = ENERGY_NEED();
 
                                /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
@@ -5306,7 +5236,7 @@ static void process_player(void)
                /* Hack -- notice death */
                if (!p_ptr->playing || p_ptr->is_dead)
                {
-                       world_player = FALSE;
+                       p_ptr->timewalk = FALSE;
                        break;
                }
 
@@ -5339,7 +5269,7 @@ static void dungeon(bool load_game)
        int quest_num = 0;
 
        /* Set the base level */
-       base_level = dun_level;
+       current_floor_ptr->base_level = current_floor_ptr->dun_level;
 
        /* Reset various flags */
        is_loading_now = FALSE;
@@ -5378,7 +5308,7 @@ static void dungeon(bool load_game)
        disturb(TRUE, TRUE);
 
        /* Get index of current quest (if any) */
-       quest_num = quest_number(dun_level);
+       quest_num = quest_number(current_floor_ptr->dun_level);
 
        /* Inside a quest? */
        if (quest_num)
@@ -5395,10 +5325,10 @@ static void dungeon(bool load_game)
 
 
        /* Track maximum dungeon level (if not in quest -KMW-) */
-       if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
+       if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
        {
-               max_dlv[dungeon_type] = dun_level;
-               if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
+               max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
+               if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
        }
 
        (void)calculate_upkeep();
@@ -5435,7 +5365,7 @@ static void dungeon(bool load_game)
        character_xtra = FALSE;
 
        p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);
        handle_stuff();
        Term_fresh();
 
@@ -5464,22 +5394,22 @@ static void dungeon(bool load_game)
        if (!p_ptr->playing || p_ptr->is_dead) return;
 
        /* Print quest message if appropriate */
-       if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
+       if (!p_ptr->inside_quest && (p_ptr->dungeon_idx == DUNGEON_ANGBAND))
        {
-               quest_discovery(random_quest_number(dun_level));
-               p_ptr->inside_quest = random_quest_number(dun_level);
+               quest_discovery(random_quest_number(current_floor_ptr->dun_level));
+               p_ptr->inside_quest = random_quest_number(current_floor_ptr->dun_level);
        }
-       if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
+       if ((current_floor_ptr->dun_level == d_info[p_ptr->dungeon_idx].maxdepth) && d_info[p_ptr->dungeon_idx].final_guardian)
        {
-               if (r_info[d_info[dungeon_type].final_guardian].max_num)
+               if (r_info[d_info[p_ptr->dungeon_idx].final_guardian].max_num)
 #ifdef JP
                        msg_format("この階には%sの主である%sが棲んでいる。",
-                                  d_name+d_info[dungeon_type].name, 
-                                  r_name+r_info[d_info[dungeon_type].final_guardian].name);
+                                  d_name+d_info[p_ptr->dungeon_idx].name, 
+                                  r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name);
 #else
                        msg_format("%^s lives in this level as the keeper of %s.",
-                                          r_name+r_info[d_info[dungeon_type].final_guardian].name, 
-                                          d_name+d_info[dungeon_type].name);
+                                          r_name+r_info[d_info[p_ptr->dungeon_idx].final_guardian].name, 
+                                          d_name+d_info[p_ptr->dungeon_idx].name);
 #endif
        }
 
@@ -5488,15 +5418,15 @@ static void dungeon(bool load_game)
        /*** Process this dungeon level ***/
 
        /* Reset the monster generation level */
-       monster_level = base_level;
+       monster_level = current_floor_ptr->base_level;
 
        /* Reset the object generation level */
-       object_level = base_level;
+       current_floor_ptr->object_level = current_floor_ptr->base_level;
 
        is_loading_now = TRUE;
 
        if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
-           (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
+           (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
                p_ptr->energy_need = 0;
 
        /* Not leaving dungeon */
@@ -5876,8 +5806,7 @@ void play_game(bool new_game)
                        quit(0);
 
                p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-
-               handle_stuff();
+               update_creature(p_ptr);
 
                p_ptr->is_dead = TRUE;
 
@@ -5969,7 +5898,7 @@ void play_game(bool new_game)
                character_dungeon = FALSE;
 
                /* Start in town */
-               dun_level = 0;
+               current_floor_ptr->dun_level = 0;
                p_ptr->inside_quest = 0;
                p_ptr->inside_arena = FALSE;
                p_ptr->inside_battle = FALSE;
@@ -6033,15 +5962,15 @@ void play_game(bool new_game)
        record_o_name[0] = '\0';
 
        /* Reset map panel */
-       panel_row_min = cur_hgt;
-       panel_col_min = cur_wid;
+       panel_row_min = current_floor_ptr->height;
+       panel_col_min = current_floor_ptr->width;
 
        /* Sexy gal gets bonus to maximum weapon skill of whip */
        if (p_ptr->pseikaku == SEIKAKU_SEXY)
                s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
 
        /* Fill the arrays of floors and walls in the good proportions */
-       set_floor_and_wall(dungeon_type);
+       set_floor_and_wall(p_ptr->dungeon_idx);
 
        /* Flavor the objects */
        flavor_init();
@@ -6079,7 +6008,7 @@ void play_game(bool new_game)
        }
 
        /* Initialize the town-buildings if necessary */
-       if (!dun_level && !p_ptr->inside_quest)
+       if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
        {
                /* Init the wilderness */
 
@@ -6194,7 +6123,6 @@ void play_game(bool new_game)
                /* Process the level */
                dungeon(load_game);
 
-
                /* Hack -- prevent "icky" message */
                character_xtra = TRUE;
 
@@ -6215,7 +6143,7 @@ void play_game(bool new_game)
                /* Handle "quit and save" */
                if (!p_ptr->playing && !p_ptr->is_dead) break;
 
-               /* Erase the old cave */
+               /* Erase the old current_floor_ptr->grid_array */
                wipe_o_list();
                if (!p_ptr->is_dead) wipe_m_list();
 
@@ -6251,106 +6179,7 @@ void play_game(bool new_game)
                                /* Mega-Hack -- Allow player to cheat death */
                                if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
                                {
-                                       /* Mark social class, reset age, if needed */
-                                       if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
-
-                                       /* Increase age */
-                                       p_ptr->age++;
-
-                                       /* Mark savefile */
-                                       p_ptr->noscore |= 0x0001;
-
-                                       msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
-                                       msg_print(NULL);
-
-                                       (void)life_stream(FALSE, FALSE);
-
-                                       if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                                       {
-                                               int magic_idx;
-                                               for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
-                                               {
-                                                       p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
-                                               }
-                                               for (; magic_idx < EATER_EXT*3; magic_idx++)
-                                               {
-                                                       p_ptr->magic_num1[magic_idx] = 0;
-                                               }
-                                       }
-
-                                       /* Restore spell points */
-                                       p_ptr->csp = p_ptr->msp;
-                                       p_ptr->csp_frac = 0;
-
-                                       /* Hack -- cancel recall */
-                                       if (p_ptr->word_recall)
-                                       {
-                                               msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
-                                               msg_print(NULL);
-
-                                               /* Hack -- Prevent recall */
-                                               p_ptr->word_recall = 0;
-                                               p_ptr->redraw |= (PR_STATUS);
-                                       }
-
-                                       /* Hack -- cancel alter */
-                                       if (p_ptr->alter_reality)
-                                       {
-                                               /* Hack -- Prevent alter */
-                                               p_ptr->alter_reality = 0;
-                                               p_ptr->redraw |= (PR_STATUS);
-                                       }
-
-                                       /* Note cause of death */
-                                       (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
-
-                                       /* Do not die */
-                                       p_ptr->is_dead = FALSE;
-
-                                       /* Hack -- Prevent starvation */
-                                       (void)set_food(PY_FOOD_MAX - 1);
-
-                                       dun_level = 0;
-                                       p_ptr->inside_arena = FALSE;
-                                       p_ptr->inside_battle = FALSE;
-                                       leaving_quest = 0;
-                                       p_ptr->inside_quest = 0;
-                                       if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
-                                       dungeon_type = 0;
-                                       if (lite_town || vanilla_town)
-                                       {
-                                               p_ptr->wilderness_y = 1;
-                                               p_ptr->wilderness_x = 1;
-                                               if (vanilla_town)
-                                               {
-                                                       p_ptr->oldpy = 10;
-                                                       p_ptr->oldpx = 34;
-                                               }
-                                               else
-                                               {
-                                                       p_ptr->oldpy = 33;
-                                                       p_ptr->oldpx = 131;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               p_ptr->wilderness_y = 48;
-                                               p_ptr->wilderness_x = 5;
-                                               p_ptr->oldpy = 33;
-                                               p_ptr->oldpx = 131;
-                                       }
-
-                                       /* Leaving */
-                                       p_ptr->wild_mode = FALSE;
-                                       p_ptr->leaving = TRUE;
-
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 1, 
-                                                               _("                            しかし、生き返った。", 
-                                                                 "                            but revived."));
-
-                                       /* Prepare next floor */
-                                       leave_floor();
-                                       wipe_m_list();
+                                       cheat_death(p_ptr);
                                }
                        }
                }
@@ -6417,7 +6246,7 @@ void prevent_turn_overflow(void)
        {
                for (j = 0; j < MAX_STORES; j++)
                {
-                       store_type *st_ptr = &town[i].store[j];
+                       store_type *st_ptr = &town_info[i].store[j];
 
                        if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
                        {