OSDN Git Service

[Refactor] #38997 hex_spelling_any() に player_type * 引数を追加.
[hengband/hengband.git] / src / core.c
index e24aad1..7e00354 100644 (file)
 #include "angband.h"
 #include "util.h"
 #include "core.h"
+#include "inet.h"
+#include "term.h"
+
+#include "creature.h"
 
 #include "birth.h"
 #include "bldg.h"
@@ -39,6 +43,7 @@
 #include "floor-events.h"
 #include "floor-town.h"
 #include "grid.h"
+#include "object-ego.h"
 #include "object-curse.h"
 #include "object-flavor.h"
 #include "store.h"
@@ -58,6 +63,9 @@
 #include "player-status.h"
 #include "player-class.h"
 #include "player-race.h"
+#include "player-personality.h"
+#include "player-damage.h"
+#include "player-effects.h"
 #include "cmd-spell.h"
 #include "realm-hex.h"
 #include "objectkind.h"
 #include "floor-save.h"
 #include "feature.h"
 #include "player-skill.h"
+#include "player-inventory.h"
 
 #include "view-mainwindow.h"
 #include "dungeon-file.h"
 #include "files.h"
-#include "player-effects.h"
 #include "scores.h"
 #include "autopick.h"
 #include "save.h"
+#include "realm.h"
+#include "realm-song.h"
+#include "targeting.h"
+
+ /*!
+  * コピーライト情報 /
+  * Hack -- Link a copyright message into the executable
+  */
+const concptr copyright[5] =
+{
+       "Copyright (c) 1989 James E. Wilson, Robert A. Keoneke",
+       "",
+       "This software may be copied and distributed for educational, research,",
+       "and not for profit purposes provided that this copyright and statement",
+       "are included in all such copies."
+};
+
+bool can_save = FALSE;        /* Game can be saved */
+
+COMMAND_CODE now_message;
+
+bool repair_monsters;  /* Hack -- optimize detect monsters */
+bool repair_objects;   /* Hack -- optimize detect objects */
 
 concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
 
@@ -91,6 +122,11 @@ concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffi
 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
 
+/*
+ * Flags for initialization
+ */
+int init_flags;
+
 /*!
  * @brief 擬似鑑定を実際に行い判定を反映する
  * @param slot 擬似鑑定を行うプレイヤーの所持リストID
@@ -390,7 +426,7 @@ static void sense_inventory1(void)
                }
        }
 
-       if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
+       if (compare_virtue(p_ptr, V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
 
        /*** Sense everything ***/
 
@@ -659,10 +695,10 @@ static bool pattern_effect(void)
 
        if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
 
-       if ((prace_is_(RACE_AMBERITE)) &&
+       if ((PRACE_IS_(p_ptr, RACE_AMBERITE)) &&
            (p_ptr->cut > 0) && one_in_(10))
        {
-               wreck_the_pattern();
+               wreck_the_pattern(p_ptr);
        }
 
        pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
@@ -670,9 +706,9 @@ static bool pattern_effect(void)
        switch (pattern_type)
        {
        case PATTERN_TILE_END:
-               (void)set_image(0);
+               (void)set_image(p_ptr, 0);
                (void)restore_all_status();
-               (void)restore_level();
+               (void)restore_level(p_ptr);
                (void)cure_critical_wounds(1000);
 
                cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
@@ -696,14 +732,14 @@ static bool pattern_effect(void)
 
        case PATTERN_TILE_WRECKED:
                if (!IS_INVULN())
-                       take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
                break;
 
        default:
-               if (prace_is_(RACE_AMBERITE) && !one_in_(2))
+               if (PRACE_IS_(p_ptr, RACE_AMBERITE) && !one_in_(2))
                        return TRUE;
                else if (!IS_INVULN())
-                       take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
                break;
        }
 
@@ -1230,13 +1266,13 @@ static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
 
 static void process_world_aux_digestion(void)
 {
-       if (!p_ptr->inside_battle)
+       if (!p_ptr->phase_out)
        {
                /* Digest quickly when gorged */
                if (p_ptr->food >= PY_FOOD_MAX)
                {
                        /* Digest a lot of food */
-                       (void)set_food(p_ptr->food - 100);
+                       (void)set_food(p_ptr, p_ptr->food - 100);
                }
 
                /* Digest normally -- Every 50 game turns */
@@ -1263,7 +1299,7 @@ static void process_world_aux_digestion(void)
                        if (digestion > 100) digestion = 100;
 
                        /* Digest some food */
-                       (void)set_food(p_ptr->food - digestion);
+                       (void)set_food(p_ptr, p_ptr->food - digestion);
                }
 
 
@@ -1277,7 +1313,7 @@ static void process_world_aux_digestion(void)
                                disturb(TRUE, TRUE);
 
                                /* Hack -- faint (bypass free action) */
-                               (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
+                               (void)set_paralyzed(p_ptr, p_ptr->paralyzed + 1 + randint0(5));
                        }
 
                        /* Starve to death (slowly) */
@@ -1286,7 +1322,7 @@ static void process_world_aux_digestion(void)
                                /* Calculate damage */
                                HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
 
-                               if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
+                               if (!IS_INVULN()) take_hit(p_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
                        }
                }
        }
@@ -1312,7 +1348,7 @@ static void process_world_aux_hp_and_sp(void)
        /* Take damage from poison */
        if (p_ptr->poisoned && !IS_INVULN())
        {
-               take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
+               take_hit(p_ptr, DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
        }
 
        /* Take damage from cuts */
@@ -1358,18 +1394,18 @@ static void process_world_aux_hp_and_sp(void)
                        dam = 1;
                }
 
-               take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
+               take_hit(p_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
        }
 
        /* (Vampires) Take damage from sunlight */
-       if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
+       if (PRACE_IS_(p_ptr, RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
        {
                if (!current_floor_ptr->dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
                {
                        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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
                                cave_no_regen = TRUE;
                        }
                }
@@ -1391,7 +1427,7 @@ static void process_world_aux_hp_and_sp(void)
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
                        sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
 
-                       if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
+                       if (!IS_INVULN()) take_hit(p_ptr, DAMAGE_NOESCAPE, 1, ouch, -1);
                }
        }
 
@@ -1410,7 +1446,7 @@ static void process_world_aux_hp_and_sp(void)
 
                if (damage)
                {
-                       if(prace_is_(RACE_ENT)) damage += damage / 3;
+                       if(PRACE_IS_(p_ptr, RACE_ENT)) damage += damage / 3;
                        if(p_ptr->resist_fire) damage = damage / 3;
                        if(IS_OPPOSE_FIRE()) damage = damage / 3;
                        if(p_ptr->levitation) damage = damage / 5;
@@ -1420,14 +1456,14 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->levitation)
                        {
                                msg_print(_("熱で火傷した!", "The heat burns you!"));
-                               take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), 
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), 
                                                                f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
                        }
 
                        cave_no_regen = TRUE;
@@ -1458,14 +1494,14 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->levitation)
                        {
                                msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
-                               take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
                                        f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
                        }
 
                        cave_no_regen = TRUE;
@@ -1496,14 +1532,14 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->levitation)
                        {
                                msg_print(_("電撃を受けた!", "The electric shocks you!"));
-                               take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
                                        f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
                        }
 
                        cave_no_regen = TRUE;
@@ -1534,14 +1570,14 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->levitation)
                        {
                                msg_print(_("酸が飛び散った!", "The acid melt you!"));
-                               take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
                                        f_name + f_info[get_feat_mimic(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])].name), -1);
                        }
                        else
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
                        }
 
                        cave_no_regen = TRUE;
@@ -1572,16 +1608,16 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->levitation)
                        {
                                msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
-                               take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"),
                                        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);
+                               if (p_ptr->resist_pois) (void)set_poisoned(p_ptr, p_ptr->poisoned + 1);
                        }
                        else
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
+                               if (p_ptr->resist_pois) (void)set_poisoned(p_ptr, p_ptr->poisoned + 3);
                        }
 
                        cave_no_regen = TRUE;
@@ -1591,10 +1627,10 @@ 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->resist_water)
        {
-               if (p_ptr->total_weight > weight_limit())
+               if (p_ptr->total_weight > weight_limit(p_ptr))
                {
                        msg_print(_("溺れている!", "You are drowning!"));
-                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
                        cave_no_regen = TRUE;
                }
        }
@@ -1605,20 +1641,20 @@ static void process_world_aux_hp_and_sp(void)
                if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
                {
                        damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
-                       if (prace_is_(RACE_ENT)) damage += damage / 3;
+                       if (PRACE_IS_(p_ptr, RACE_ENT)) damage += damage / 3;
                        if (p_ptr->resist_fire) damage = damage / 3;
                        if (IS_OPPOSE_FIRE()) damage = damage / 3;
                        msg_print(_("熱い!", "It's hot!"));
-                       take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
                }
                if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
                {
                        damage = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level / 2;
-                       if (prace_is_(RACE_ANDROID)) damage += damage / 3;
+                       if (PRACE_IS_(p_ptr, RACE_ANDROID)) damage += damage / 3;
                        if (p_ptr->resist_elec) damage = damage / 3;
                        if (IS_OPPOSE_ELEC()) damage = damage / 3;
                        msg_print(_("痛い!", "It hurts!"));
-                       take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
                }
                if ((r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
                {
@@ -1626,7 +1662,7 @@ static void process_world_aux_hp_and_sp(void)
                        if (p_ptr->resist_cold) damage = damage / 3;
                        if (IS_OPPOSE_COLD()) damage = damage / 3;
                        msg_print(_("冷たい!", "It's cold!"));
-                       take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
                }
        }
 
@@ -1655,7 +1691,7 @@ static void process_world_aux_hp_and_sp(void)
                                dam_desc = _("硬い岩", "solid rock");
                        }
 
-                       take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
+                       take_hit(p_ptr, DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
                }
        }
 
@@ -1774,36 +1810,36 @@ static void process_world_aux_timeout(void)
        /* Mimic */
        if (p_ptr->tim_mimic)
        {
-               (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
+               (void)set_mimic(p_ptr, p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
        }
 
        /* Hack -- Hallucinating */
        if (p_ptr->image)
        {
-               (void)set_image(p_ptr->image - dec_count);
+               (void)set_image(p_ptr, p_ptr->image - dec_count);
        }
 
        /* Blindness */
        if (p_ptr->blind)
        {
-               (void)set_blind(p_ptr->blind - dec_count);
+               (void)set_blind(p_ptr, p_ptr->blind - dec_count);
        }
 
        /* Times see-invisible */
        if (p_ptr->tim_invis)
        {
-               (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
+               (void)set_tim_invis(p_ptr, p_ptr->tim_invis - 1, TRUE);
        }
 
-       if (multi_rew)
+       if (p_ptr->suppress_multi_reward)
        {
-               multi_rew = FALSE;
+               p_ptr->suppress_multi_reward = FALSE;
        }
 
        /* Timed esp */
        if (p_ptr->tim_esp)
        {
-               (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
+               (void)set_tim_esp(p_ptr, p_ptr->tim_esp - 1, TRUE);
        }
 
        /* Timed temporary elemental brands. -LM- */
@@ -1812,7 +1848,7 @@ static void process_world_aux_timeout(void)
                p_ptr->ele_attack--;
 
                /* Clear all temporary elemental brands. */
-               if (!p_ptr->ele_attack) set_ele_attack(0, 0);
+               if (!p_ptr->ele_attack) set_ele_attack(p_ptr, 0, 0);
        }
 
        /* Timed temporary elemental immune. -LM- */
@@ -1821,222 +1857,222 @@ static void process_world_aux_timeout(void)
                p_ptr->ele_immune--;
 
                /* Clear all temporary elemental brands. */
-               if (!p_ptr->ele_immune) set_ele_immune(0, 0);
+               if (!p_ptr->ele_immune) set_ele_immune(p_ptr, 0, 0);
        }
 
        /* Timed infra-vision */
        if (p_ptr->tim_infra)
        {
-               (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
+               (void)set_tim_infra(p_ptr, p_ptr->tim_infra - 1, TRUE);
        }
 
        /* Timed stealth */
        if (p_ptr->tim_stealth)
        {
-               (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
+               (void)set_tim_stealth(p_ptr, p_ptr->tim_stealth - 1, TRUE);
        }
 
        /* Timed levitation */
        if (p_ptr->tim_levitation)
        {
-               (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
+               (void)set_tim_levitation(p_ptr, p_ptr->tim_levitation - 1, TRUE);
        }
 
        /* Timed sh_touki */
        if (p_ptr->tim_sh_touki)
        {
-               (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
+               (void)set_tim_sh_touki(p_ptr, p_ptr->tim_sh_touki - 1, TRUE);
        }
 
        /* Timed sh_fire */
        if (p_ptr->tim_sh_fire)
        {
-               (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
+               (void)set_tim_sh_fire(p_ptr, p_ptr->tim_sh_fire - 1, TRUE);
        }
 
        /* Timed sh_holy */
        if (p_ptr->tim_sh_holy)
        {
-               (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
+               (void)set_tim_sh_holy(p_ptr, p_ptr->tim_sh_holy - 1, TRUE);
        }
 
        /* Timed eyeeye */
        if (p_ptr->tim_eyeeye)
        {
-               (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
+               (void)set_tim_eyeeye(p_ptr, p_ptr->tim_eyeeye - 1, TRUE);
        }
 
        /* Timed resist-magic */
        if (p_ptr->resist_magic)
        {
-               (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
+               (void)set_resist_magic(p_ptr, p_ptr->resist_magic - 1, TRUE);
        }
 
        /* Timed regeneration */
        if (p_ptr->tim_regen)
        {
-               (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
+               (void)set_tim_regen(p_ptr, p_ptr->tim_regen - 1, TRUE);
        }
 
        /* Timed resist nether */
        if (p_ptr->tim_res_nether)
        {
-               (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
+               (void)set_tim_res_nether(p_ptr, p_ptr->tim_res_nether - 1, TRUE);
        }
 
        /* Timed resist time */
        if (p_ptr->tim_res_time)
        {
-               (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
+               (void)set_tim_res_time(p_ptr, p_ptr->tim_res_time - 1, TRUE);
        }
 
        /* Timed reflect */
        if (p_ptr->tim_reflect)
        {
-               (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
+               (void)set_tim_reflect(p_ptr, p_ptr->tim_reflect - 1, TRUE);
        }
 
        /* Multi-shadow */
        if (p_ptr->multishadow)
        {
-               (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
+               (void)set_multishadow(p_ptr, p_ptr->multishadow - 1, TRUE);
        }
 
        /* Timed Robe of dust */
        if (p_ptr->dustrobe)
        {
-               (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
+               (void)set_dustrobe(p_ptr, p_ptr->dustrobe - 1, TRUE);
        }
 
        /* Timed infra-vision */
        if (p_ptr->kabenuke)
        {
-               (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
+               (void)set_kabenuke(p_ptr, p_ptr->kabenuke - 1, TRUE);
        }
 
        /* Paralysis */
        if (p_ptr->paralyzed)
        {
-               (void)set_paralyzed(p_ptr->paralyzed - dec_count);
+               (void)set_paralyzed(p_ptr, p_ptr->paralyzed - dec_count);
        }
 
        /* Confusion */
        if (p_ptr->confused)
        {
-               (void)set_confused(p_ptr->confused - dec_count);
+               (void)set_confused(p_ptr, p_ptr->confused - dec_count);
        }
 
        /* Afraid */
        if (p_ptr->afraid)
        {
-               (void)set_afraid(p_ptr->afraid - dec_count);
+               (void)set_afraid(p_ptr, p_ptr->afraid - dec_count);
        }
 
        /* Fast */
        if (p_ptr->fast)
        {
-               (void)set_fast(p_ptr->fast - 1, TRUE);
+               (void)set_fast(p_ptr, p_ptr->fast - 1, TRUE);
        }
 
        /* Slow */
        if (p_ptr->slow)
        {
-               (void)set_slow(p_ptr->slow - dec_count, TRUE);
+               (void)set_slow(p_ptr, p_ptr->slow - dec_count, TRUE);
        }
 
        /* Protection from evil */
        if (p_ptr->protevil)
        {
-               (void)set_protevil(p_ptr->protevil - 1, TRUE);
+               (void)set_protevil(p_ptr, p_ptr->protevil - 1, TRUE);
        }
 
        /* Invulnerability */
        if (p_ptr->invuln)
        {
-               (void)set_invuln(p_ptr->invuln - 1, TRUE);
+               (void)set_invuln(p_ptr, p_ptr->invuln - 1, TRUE);
        }
 
        /* Wraith form */
        if (p_ptr->wraith_form)
        {
-               (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
+               (void)set_wraith_form(p_ptr, p_ptr->wraith_form - 1, TRUE);
        }
 
        /* Heroism */
        if (p_ptr->hero)
        {
-               (void)set_hero(p_ptr->hero - 1, TRUE);
+               (void)set_hero(p_ptr, p_ptr->hero - 1, TRUE);
        }
 
        /* Super Heroism */
        if (p_ptr->shero)
        {
-               (void)set_shero(p_ptr->shero - 1, TRUE);
+               (void)set_shero(p_ptr, p_ptr->shero - 1, TRUE);
        }
 
        /* Blessed */
        if (p_ptr->blessed)
        {
-               (void)set_blessed(p_ptr->blessed - 1, TRUE);
+               (void)set_blessed(p_ptr, p_ptr->blessed - 1, TRUE);
        }
 
        /* Shield */
        if (p_ptr->shield)
        {
-               (void)set_shield(p_ptr->shield - 1, TRUE);
+               (void)set_shield(p_ptr, p_ptr->shield - 1, TRUE);
        }
 
        /* Tsubureru */
        if (p_ptr->tsubureru)
        {
-               (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
+               (void)set_tsubureru(p_ptr, p_ptr->tsubureru - 1, TRUE);
        }
 
        /* Magicdef */
        if (p_ptr->magicdef)
        {
-               (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
+               (void)set_magicdef(p_ptr, p_ptr->magicdef - 1, TRUE);
        }
 
        /* Tsuyoshi */
        if (p_ptr->tsuyoshi)
        {
-               (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
+               (void)set_tsuyoshi(p_ptr, p_ptr->tsuyoshi - 1, TRUE);
        }
 
        /* Oppose Acid */
        if (p_ptr->oppose_acid)
        {
-               (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
+               (void)set_oppose_acid(p_ptr, p_ptr->oppose_acid - 1, TRUE);
        }
 
        /* Oppose Lightning */
        if (p_ptr->oppose_elec)
        {
-               (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
+               (void)set_oppose_elec(p_ptr, p_ptr->oppose_elec - 1, TRUE);
        }
 
        /* Oppose Fire */
        if (p_ptr->oppose_fire)
        {
-               (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
+               (void)set_oppose_fire(p_ptr, p_ptr->oppose_fire - 1, TRUE);
        }
 
        /* Oppose Cold */
        if (p_ptr->oppose_cold)
        {
-               (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
+               (void)set_oppose_cold(p_ptr, p_ptr->oppose_cold - 1, TRUE);
        }
 
        /* Oppose Poison */
        if (p_ptr->oppose_pois)
        {
-               (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
+               (void)set_oppose_pois(p_ptr, p_ptr->oppose_pois - 1, TRUE);
        }
 
        if (p_ptr->ult_res)
        {
-               (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
+               (void)set_ultimate_res(p_ptr, p_ptr->ult_res - 1, TRUE);
        }
 
        /*** Poison and Stun and Cut ***/
@@ -2047,7 +2083,7 @@ static void process_world_aux_timeout(void)
                int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
 
                /* Apply some healing */
-               (void)set_poisoned(p_ptr->poisoned - adjust);
+               (void)set_poisoned(p_ptr, p_ptr->poisoned - adjust);
        }
 
        /* Stun */
@@ -2056,7 +2092,7 @@ static void process_world_aux_timeout(void)
                int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
 
                /* Apply some healing */
-               (void)set_stun(p_ptr->stun - adjust);
+               (void)set_stun(p_ptr, p_ptr->stun - adjust);
        }
 
        /* Cut */
@@ -2068,7 +2104,7 @@ static void process_world_aux_timeout(void)
                if (p_ptr->cut > 1000) adjust = 0;
 
                /* Apply some healing */
-               (void)set_cut(p_ptr->cut - adjust);
+               (void)set_cut(p_ptr,p_ptr->cut - adjust);
        }
 }
 
@@ -2114,7 +2150,7 @@ static void process_world_aux_mutation(void)
        if (!p_ptr->muta2) return;
 
        /* No effect on monster arena */
-       if (p_ptr->inside_battle) return;
+       if (p_ptr->phase_out) return;
 
        /* No effect on the global map */
        if (p_ptr->wild_mode) return;
@@ -2124,8 +2160,8 @@ static void process_world_aux_mutation(void)
                disturb(FALSE, TRUE);
                msg_print(_("ウガァァア!", "RAAAAGHH!"));
                msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
-               (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
-               (void)set_afraid(0);
+               (void)set_shero(p_ptr, 10 + randint1(p_ptr->lev), FALSE);
+               (void)set_afraid(p_ptr, 0);
        }
 
        if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
@@ -2134,7 +2170,7 @@ static void process_world_aux_mutation(void)
                {
                        disturb(FALSE, TRUE);
                        msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
-                       set_afraid(p_ptr->afraid + 13 + randint1(26));
+                       set_afraid(p_ptr, p_ptr->afraid + 13 + randint1(26));
                }
        }
 
@@ -2160,7 +2196,7 @@ static void process_world_aux_mutation(void)
 
                if (!p_ptr->resist_conf)
                {
-                       (void)set_confused(p_ptr->confused + randint0(20) + 15);
+                       (void)set_confused(p_ptr, p_ptr->confused + randint0(20) + 15);
                }
 
                if (!p_ptr->resist_chaos)
@@ -2168,7 +2204,7 @@ static void process_world_aux_mutation(void)
                        if (one_in_(20))
                        {
                                msg_print(NULL);
-                               if (one_in_(3)) lose_all_info();
+                               if (one_in_(3)) lose_all_info(p_ptr);
                                else wiz_dark();
                                (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
                                wiz_dark();
@@ -2180,7 +2216,7 @@ static void process_world_aux_mutation(void)
                                if (one_in_(3))
                                {
                                        msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
-                                       (void)set_image(p_ptr->image + randint0(150) + 150);
+                                       (void)set_image(p_ptr, p_ptr->image + randint0(150) + 150);
                                }
                        }
                }
@@ -2192,7 +2228,7 @@ static void process_world_aux_mutation(void)
                {
                        disturb(FALSE, TRUE);
                        p_ptr->redraw |= PR_EXTRA;
-                       (void)set_image(p_ptr->image + randint0(50) + 20);
+                       (void)set_image(p_ptr, p_ptr->image + randint0(50) + 20);
                }
        }
 
@@ -2242,11 +2278,11 @@ static void process_world_aux_mutation(void)
 
                        if (p_ptr->fast > 0)
                        {
-                               set_fast(0, TRUE);
+                               set_fast(p_ptr, 0, TRUE);
                        }
                        else
                        {
-                               set_slow(randint1(30) + 10, FALSE);
+                               set_slow(p_ptr, randint1(30) + 10, FALSE);
                        }
                }
                else
@@ -2255,11 +2291,11 @@ static void process_world_aux_mutation(void)
 
                        if (p_ptr->slow > 0)
                        {
-                               set_slow(0, TRUE);
+                               set_slow(p_ptr, 0, TRUE);
                        }
                        else
                        {
-                               set_fast(randint1(30) + 10, FALSE);
+                               set_fast(p_ptr, randint1(30) + 10, FALSE);
                        }
                }
                msg_print(NULL);
@@ -2297,7 +2333,7 @@ static void process_world_aux_mutation(void)
                /* Absorb light from the current possition */
                if ((current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                {
-                       hp_player(10);
+                       hp_player(p_ptr, 10);
                }
 
                o_ptr = &p_ptr->inventory_list[INVEN_LITE];
@@ -2309,7 +2345,7 @@ static void process_world_aux_mutation(void)
                        if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
                        {
                                /* Heal the player a bit */
-                               hp_player(o_ptr->xtra4 / 20);
+                               hp_player(p_ptr, o_ptr->xtra4 / 20);
 
                                /* Decrease life-span of lite */
                                o_ptr->xtra4 /= 2;
@@ -2352,7 +2388,7 @@ static void process_world_aux_mutation(void)
        }
        if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
        {
-               if (!lose_mutation(0))
+               if (!lose_mutation(p_ptr, 0))
                        msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
        }
        if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
@@ -2361,11 +2397,11 @@ static void process_world_aux_mutation(void)
                msg_print(_("非物質化した!", "You feel insubstantial!"));
 
                msg_print(NULL);
-               set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
+               set_wraith_form(p_ptr, randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
        }
        if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
        {
-               do_poly_wounds();
+               do_poly_wounds(p_ptr);
        }
        if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
        {
@@ -2402,7 +2438,7 @@ static void process_world_aux_mutation(void)
                        disturb(FALSE, TRUE);
                        msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
                        msg_print(NULL);
-                       (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
+                       (void)dec_stat(p_ptr, which_stat, randint1(6) + 6, one_in_(3));
                }
        }
        if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000))
@@ -2424,12 +2460,12 @@ static void process_world_aux_mutation(void)
                if (p_ptr->tim_esp > 0)
                {
                        msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
-                       set_tim_esp(0, TRUE);
+                       set_tim_esp(p_ptr, 0, TRUE);
                }
                else
                {
                        msg_print(_("精神が広がった!", "Your mind expands!"));
-                       set_tim_esp(p_ptr->lev, FALSE);
+                       set_tim_esp(p_ptr, p_ptr->lev, FALSE);
                }
        }
        if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest && one_in_(9000))
@@ -2437,9 +2473,9 @@ static void process_world_aux_mutation(void)
                disturb(FALSE, TRUE);
                msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
                msg_print(NULL);
-               set_food(PY_FOOD_WEAK);
-               if (music_singing_any()) stop_singing(p_ptr);
-               if (hex_spelling_any()) stop_hex_spell_all();
+               set_food(p_ptr, PY_FOOD_WEAK);
+               if (music_singing_any(p_ptr)) stop_singing(p_ptr);
+               if (hex_spelling_any(p_ptr)) stop_hex_spell_all();
        }
 
        if ((p_ptr->muta2 & MUT2_WALK_SHAD) && !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
@@ -2483,7 +2519,7 @@ static void process_world_aux_mutation(void)
                disturb(FALSE, TRUE);
                msg_print(_("無敵な気がする!", "You feel invincible!"));
                msg_print(NULL);
-               (void)set_invuln(randint1(8) + 8, FALSE);
+               (void)set_invuln(p_ptr, randint1(8) + 8, FALSE);
        }
 
        if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
@@ -2495,7 +2531,7 @@ static void process_world_aux_mutation(void)
                        HIT_POINT healing = p_ptr->csp;
                        if (healing > wounds) healing = wounds;
 
-                       hp_player(healing);
+                       hp_player(p_ptr, healing);
                        p_ptr->csp -= healing;
                        p_ptr->redraw |= (PR_HP | PR_MANA);
                }
@@ -2512,7 +2548,7 @@ static void process_world_aux_mutation(void)
 
                        p_ptr->csp += healing;
                        p_ptr->redraw |= (PR_HP | PR_MANA);
-                       take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
+                       take_hit(p_ptr, DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
                }
        }
 
@@ -2523,21 +2559,21 @@ static void process_world_aux_mutation(void)
 
                disturb(FALSE, TRUE);
                msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
-               take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
+               take_hit(p_ptr, DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
 
                msg_print(NULL);
-               if (has_melee_weapon(INVEN_RARM))
+               if (has_melee_weapon(p_ptr, INVEN_RARM))
                {
                        slot = INVEN_RARM;
                        o_ptr = &p_ptr->inventory_list[INVEN_RARM];
 
-                       if (has_melee_weapon(INVEN_LARM) && one_in_(2))
+                       if (has_melee_weapon(p_ptr, INVEN_LARM) && one_in_(2))
                        {
                                o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                                slot = INVEN_LARM;
                        }
                }
-               else if (has_melee_weapon(INVEN_LARM))
+               else if (has_melee_weapon(p_ptr, INVEN_LARM))
                {
                        o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                        slot = INVEN_LARM;
@@ -2558,7 +2594,7 @@ static void process_world_aux_mutation(void)
  */
 static void process_world_aux_curse(void)
 {
-       if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
+       if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->phase_out && !p_ptr->wild_mode)
        {
                /*
                 * Hack: Uncursed teleporting items (e.g. Trump Weapons)
@@ -2626,7 +2662,7 @@ static void process_world_aux_curse(void)
                        if (p_ptr->exp < 0) p_ptr->exp = 0;
                        p_ptr->max_exp -= (p_ptr->lev + 1) / 2;
                        if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
-                       check_experience();
+                       check_experience(p_ptr);
                }
                /* Add light curse (Later) */
                if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
@@ -2729,7 +2765,7 @@ static void process_world_aux_curse(void)
                        {
                                disturb(FALSE, TRUE);
                                msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
-                               set_afraid(p_ptr->afraid + 13 + randint1(26));
+                               set_afraid(p_ptr, p_ptr->afraid + 13 + randint1(26));
                        }
                }
                /* Teleport player */
@@ -2747,7 +2783,7 @@ static void process_world_aux_curse(void)
 
                        object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
                        msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
+                       take_hit(p_ptr, DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
                }
                /* Handle mana draining */
                if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
@@ -2777,7 +2813,7 @@ static void process_world_aux_curse(void)
                                msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
                        else
                                msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
+                       take_hit(p_ptr, DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
                }
        }
 }
@@ -2873,8 +2909,7 @@ static void process_world_aux_recharge(void)
        {
                object_type *o_ptr = &current_floor_ptr->o_list[i];
 
-               /* Skip dead objects */
-               if (!o_ptr->k_idx) continue;
+               if (!OBJECT_IS_VALID(o_ptr)) continue;
 
                /* Recharge rods on the ground.  No messages. */
                if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
@@ -2904,7 +2939,7 @@ static void process_world_aux_movement(void)
                 * The player is yanked up/down as soon as
                 * he loads the autosaved game.
                 */
-               if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
+               if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->phase_out)
                        do_cmd_save_game(TRUE);
 
                /* Count down towards recall */
@@ -3018,7 +3053,7 @@ static void process_world_aux_movement(void)
        /* Delayed Alter reality */
        if (p_ptr->alter_reality)
        {
-               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
+               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->phase_out)
                        do_cmd_save_game(TRUE);
 
                /* Count down towards alter */
@@ -3084,7 +3119,7 @@ static void process_world(void)
        }
 
        /*** Check monster arena ***/
-       if (p_ptr->inside_battle && !p_ptr->leaving)
+       if (p_ptr->phase_out && !p_ptr->leaving)
        {
                int i2, j2;
                int win_m_idx = 0;
@@ -3149,13 +3184,13 @@ static void process_world(void)
        if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
 
        /*** Attempt timed autosave ***/
-       if (autosave_t && autosave_freq && !p_ptr->inside_battle)
+       if (autosave_t && autosave_freq && !p_ptr->phase_out)
        {
                if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
                        do_cmd_save_game(TRUE);
        }
 
-       if (mon_fight && !ignore_unview)
+       if (current_floor_ptr->monster_noise && !ignore_unview)
        {
                msg_print(_("何かが聞こえた。", "You hear noise."));
        }
@@ -3163,7 +3198,7 @@ static void process_world(void)
        /*** Handle the wilderness/town (sunshine) ***/
 
        /* While in town/wilderness */
-       if (!current_floor_ptr->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->phase_out && !p_ptr->inside_arena)
        {
                /* Hack -- Daybreak/Nighfall in town */
                if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
@@ -3180,7 +3215,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)) && current_floor_ptr->dun_level)
+       else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->phase_out && !p_ptr->inside_arena)) && current_floor_ptr->dun_level)
        {
                /*** Shuffle the Storekeepers ***/
 
@@ -3231,14 +3266,14 @@ static void process_world(void)
 
        /* Check for creature generation. */
        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)
+           !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->phase_out)
        {
                /* Make a new monster */
                (void)alloc_monster(MAX_SIGHT + 5, 0);
        }
 
        /* Hack -- Check for creature regeneration */
-       if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->inside_battle) regen_monsters();
+       if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !p_ptr->phase_out) regen_monsters();
        if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regen_captured_monsters();
 
        if (!p_ptr->leaving)
@@ -3308,47 +3343,26 @@ static void process_world(void)
                                /* Go into large wilderness view */
                                p_ptr->oldpy = randint1(MAX_HGT - 2);
                                p_ptr->oldpx = randint1(MAX_WID - 2);
-                               change_wild_mode();
+                               change_wild_mode(TRUE);
 
                                /* Give first move to monsters */
                                take_turn(p_ptr, 100);
 
-                               /* HACk -- set the encouter flag for the wilderness generation */
-                               generate_encounter = TRUE;
                        }
 
                        p_ptr->invoking_midnight_curse = TRUE;
                }
        }
 
-
-
-       /* Check the Food */
        process_world_aux_digestion();
-
-       /* Process timed damage and regeneration */
        process_world_aux_hp_and_sp();
-
-       /* Process timeout */
        process_world_aux_timeout();
-
-       /* Process light */
        process_world_aux_light();
-
-       /* Process mutation effects */
        process_world_aux_mutation();
-
-       /* Process curse effects */
        process_world_aux_curse();
-
-       /* Process recharging */
        process_world_aux_recharge();
-
-       /* Feel the p_ptr->inventory_list */
        sense_inventory1();
        sense_inventory2();
-
-       /* Involuntary Movement */
        process_world_aux_movement();
 }
 
@@ -3496,7 +3510,7 @@ static void process_command(void)
 
        /* Sniper */
        if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
-               reset_concent = TRUE;
+               p_ptr->reset_concent = TRUE;
 
        /* Parse the command */
        switch (command_cmd)
@@ -3516,8 +3530,6 @@ static void process_command(void)
                }
 
                /*** Wizard Commands ***/
-
-               /* Toggle Wizard Mode */
                case KTRL('W'):
                {
                        if (p_ptr->wizard)
@@ -3531,8 +3543,6 @@ static void process_command(void)
                                msg_print(_("ウィザードモード突入。", "Wizard mode on."));
                        }
                        p_ptr->update |= (PU_MONSTERS);
-
-                       /* Redraw "title" */
                        p_ptr->redraw |= (PR_TITLE);
 
                        break;
@@ -3544,7 +3554,6 @@ static void process_command(void)
                /* Special "debug" commands */
                case KTRL('A'):
                {
-                       /* Enter debug mode */
                        if (enter_debug_mode())
                        {
                                do_cmd_debug();
@@ -3560,12 +3569,10 @@ static void process_command(void)
                /* Special "borg" commands */
                case KTRL('Z'):
                {
-                       /* Enter borg mode */
                        if (enter_borg_mode())
                        {
                                if (!p_ptr->wild_mode) do_cmd_borg();
                        }
-
                        break;
                }
 
@@ -3627,10 +3634,9 @@ static void process_command(void)
                        break;
                }
 
-               /* Hack -- toggle windows */
                case KTRL('I'):
                {
-                       toggle_inven_equip();
+                       toggle_inven_equip(p_ptr);
                        break;
                }
 
@@ -3699,15 +3705,14 @@ static void process_command(void)
                /* Search for traps/doors */
                case 's':
                {
-                       do_cmd_search();
+                       do_cmd_search(p_ptr);
                        break;
                }
 
-               /* Toggle search mode */
                case 'S':
                {
-                       if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
-                       else set_action(ACTION_SEARCH);
+                       if (p_ptr->action == ACTION_SEARCH) set_action(p_ptr, ACTION_NONE);
+                       else set_action(p_ptr, ACTION_SEARCH);
                        break;
                }
 
@@ -3754,10 +3759,10 @@ static void process_command(void)
                                        break;
                                }
 
-                               change_wild_mode();
+                               change_wild_mode(FALSE);
                        }
                        else
-                               do_cmd_go_up();
+                               do_cmd_go_up(p_ptr);
                        break;
                }
 
@@ -3765,16 +3770,16 @@ static void process_command(void)
                case '>':
                {
                        if (p_ptr->wild_mode)
-                               change_wild_mode();
+                               change_wild_mode(FALSE);
                        else
-                               do_cmd_go_down();
+                               do_cmd_go_down(p_ptr);
                        break;
                }
 
                /* Open a door or chest */
                case 'o':
                {
-                       do_cmd_open();
+                       do_cmd_open(p_ptr);
                        break;
                }
 
@@ -3933,7 +3938,7 @@ static void process_command(void)
                /* Activate an artifact */
                case 'A':
                {
-                       do_cmd_activate();
+                       do_cmd_activate(p_ptr);
                        break;
                }
 
@@ -4069,7 +4074,7 @@ static void process_command(void)
                /* Character description */
                case 'C':
                {
-                       do_cmd_change_name();
+                       do_cmd_player_status();
                        break;
                }
 
@@ -4265,7 +4270,7 @@ static void process_command(void)
                        if (!p_ptr->wild_mode) do_cmd_travel();
                        if (p_ptr->special_defense & KATA_MUSOU)
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                        break;
                }
@@ -4361,6 +4366,37 @@ static void process_upkeep_with_speed(void)
        }
 }
 
+static void process_fishing(void)
+{
+       Term_xtra(TERM_XTRA_DELAY, 10);
+       if (one_in_(1000))
+       {
+               MONRACE_IDX r_idx;
+               bool success = FALSE;
+               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))
+               {
+                       POSITION y, x;
+                       y = p_ptr->y + ddy[p_ptr->fishing_dir];
+                       x = p_ptr->x + ddx[p_ptr->fishing_dir];
+                       if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
+                       {
+                               GAME_TEXT m_name[MAX_NLEN];
+                               monster_desc(m_name, &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
+                               msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
+                               success = TRUE;
+                       }
+               }
+               if (!success)
+               {
+                       msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn!  The fish stole your bait!"));
+               }
+               disturb(FALSE, TRUE);
+       }
+}
+
 /*!
  * @brief プレイヤーの行動処理 / Process the player
  * @return なし
@@ -4390,7 +4426,7 @@ static void process_player(void)
                p_ptr->invoking_midnight_curse = FALSE;
        }
 
-       if (p_ptr->inside_battle)
+       if (p_ptr->phase_out)
        {
                for(m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
                {
@@ -4426,7 +4462,7 @@ static void process_player(void)
                        if ((p_ptr->chp == p_ptr->mhp) &&
                            (p_ptr->csp >= p_ptr->msp))
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                }
 
@@ -4443,47 +4479,18 @@ static void process_player(void)
                            !p_ptr->image && !p_ptr->word_recall &&
                            !p_ptr->alter_reality)
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                }
        }
 
-       if (p_ptr->action == ACTION_FISH)
-       {
-               Term_xtra(TERM_XTRA_DELAY, 10);
-               if (one_in_(1000))
-               {
-                       MONRACE_IDX r_idx;
-                       bool success = FALSE;
-                       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))
-                       {
-                               POSITION y, x;
-                               y = p_ptr->y + ddy[p_ptr->fishing_dir];
-                               x = p_ptr->x + ddx[p_ptr->fishing_dir];
-                               if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
-                               {
-                                       GAME_TEXT m_name[MAX_NLEN];
-                                       monster_desc(m_name, &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
-                                       msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
-                                       success = TRUE;
-                               }
-                       }
-                       if (!success)
-                       {
-                               msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn!  The fish stole your bait!"));
-                       }
-                       disturb(FALSE, TRUE);
-               }
-       }
+       if (p_ptr->action == ACTION_FISH) process_fishing();
 
        /* Handle "abort" */
        if (check_abort)
        {
                /* Check for "player abort" (semi-efficiently for resting) */
-               if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
+               if (p_ptr->running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
                {
                        /* Do not wait */
                        inkey_scan = TRUE;
@@ -4560,7 +4567,7 @@ static void process_player(void)
        /* Fast */
        if (p_ptr->lightspeed)
        {
-               (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
+               (void)set_lightspeed(p_ptr, p_ptr->lightspeed - 1, TRUE);
        }
        if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
        {
@@ -4581,7 +4588,7 @@ static void process_player(void)
                        /* Mana run out */
                        p_ptr->csp = 0;
                        p_ptr->csp_frac = 0;
-                       set_action(ACTION_NONE);
+                       set_action(p_ptr, ACTION_NONE);
                }
                else
                {
@@ -4597,7 +4604,7 @@ static void process_player(void)
                {
                        if (p_ptr->csp < 3)
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                        else
                        {
@@ -4634,7 +4641,7 @@ static void process_player(void)
                /* Assume free current_world_ptr->game_turn */
                free_turn(p_ptr);
 
-               if (p_ptr->inside_battle)
+               if (p_ptr->phase_out)
                {
                        /* Place the cursor on the player */
                        move_cursor_relative(p_ptr->y, p_ptr->x);
@@ -4660,7 +4667,7 @@ static void process_player(void)
                                /* Reduce rest count */
                                p_ptr->resting--;
 
-                               if (!p_ptr->resting) set_action(ACTION_NONE);
+                               if (!p_ptr->resting) set_action(p_ptr, ACTION_NONE);
                                p_ptr->redraw |= (PR_STATE);
                        }
 
@@ -4674,7 +4681,7 @@ static void process_player(void)
                }
 
                /* Running */
-               else if (running)
+               else if (p_ptr->running)
                {
                        /* Take a step */
                        run_step(0);
@@ -4746,38 +4753,27 @@ static void process_player(void)
                        /* Hack -- constant hallucination */
                        if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
 
-
-                       /* Shimmer monsters if needed */
-                       if (shimmer_monsters)
+                       /* Shimmer multi-hued monsters */
+                       for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
                        {
-                               /* Clear the flag */
-                               shimmer_monsters = FALSE;
-
-                               /* Shimmer multi-hued monsters */
-                               for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
-                               {
-                                       monster_type *m_ptr;
-                                       monster_race *r_ptr;
+                               monster_type *m_ptr;
+                               monster_race *r_ptr;
 
-                                       m_ptr = &current_floor_ptr->m_list[m_idx];
-                                       if (!monster_is_valid(m_ptr)) continue;
+                               m_ptr = &current_floor_ptr->m_list[m_idx];
+                               if (!monster_is_valid(m_ptr)) continue;
 
-                                       /* Skip unseen monsters */
-                                       if (!m_ptr->ml) continue;
+                               /* Skip unseen monsters */
+                               if (!m_ptr->ml) continue;
 
-                                       /* Access the monster race */
-                                       r_ptr = &r_info[m_ptr->ap_r_idx];
+                               /* Access the monster race */
+                               r_ptr = &r_info[m_ptr->ap_r_idx];
 
-                                       /* Skip non-multi-hued monsters */
-                                       if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
-                                               continue;
+                               /* Skip non-multi-hued monsters */
+                               if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
+                                       continue;
 
-                                       /* Reset the flag */
-                                       shimmer_monsters = TRUE;
-
-                                       /* Redraw regardless */
-                                       lite_spot(m_ptr->fy, m_ptr->fx);
-                               }
+                               /* Redraw regardless */
+                               lite_spot(m_ptr->fy, m_ptr->fx);
                        }
 
 
@@ -4845,12 +4841,12 @@ static void process_player(void)
                                                p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
                                        }
                                }
-                               new_mane = FALSE;
+                               p_ptr->new_mane = FALSE;
                                p_ptr->redraw |= (PR_IMITATION);
                        }
                        if (p_ptr->action == ACTION_LEARN)
                        {
-                               new_mane = FALSE;
+                               p_ptr->new_mane = FALSE;
                                p_ptr->redraw |= (PR_STATE);
                        }
 
@@ -4878,7 +4874,7 @@ static void process_player(void)
                }
 
                /* Sniper */
-               if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
+               if (p_ptr->energy_use && p_ptr->reset_concent) reset_concentration(TRUE);
 
                /* Handle "leaving" */
                if (p_ptr->leaving) break;
@@ -4928,16 +4924,14 @@ static void dungeon(bool load_game)
 
        /* Cancel the target */
        target_who = 0;
-       pet_t_m_idx = 0;
-       riding_t_m_idx = 0;
+       p_ptr->pet_t_m_idx = 0;
+       p_ptr->riding_t_m_idx = 0;
        p_ptr->ambush_flag = FALSE;
 
        /* Cancel the health bar */
        health_track(0);
 
        /* Check visual effects */
-       shimmer_monsters = TRUE;
-       shimmer_objects = TRUE;
        repair_monsters = TRUE;
        repair_objects = TRUE;
 
@@ -4980,7 +4974,7 @@ static void dungeon(bool load_game)
 
 
        /* Enter "xtra" mode */
-       character_xtra = TRUE;
+       current_world_ptr->character_xtra = TRUE;
 
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
        p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
@@ -4989,7 +4983,7 @@ static void dungeon(bool load_game)
        handle_stuff();
 
        /* Leave "xtra" mode */
-       character_xtra = FALSE;
+       current_world_ptr->character_xtra = FALSE;
 
        p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
        p_ptr->update |= (PU_COMBINE | PU_REORDER);
@@ -5000,7 +4994,7 @@ static void dungeon(bool load_game)
            !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
            !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
 
-       if (p_ptr->inside_battle)
+       if (p_ptr->phase_out)
        {
                if (load_game)
                {
@@ -5040,7 +5034,7 @@ static void dungeon(bool load_game)
 #endif
        }
 
-       if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
+       if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(p_ptr, FALSE);
 
        /*** Process this dungeon level ***/
 
@@ -5052,7 +5046,7 @@ static void dungeon(bool load_game)
 
        current_world_ptr->is_loading_now = TRUE;
 
-       if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
+       if (p_ptr->energy_need > 0 && !p_ptr->phase_out &&
            (current_floor_ptr->dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
                p_ptr->energy_need = 0;
 
@@ -5066,10 +5060,10 @@ static void dungeon(bool load_game)
        while (TRUE)
        {
                /* Hack -- Compact the monster list occasionally */
-               if ((current_floor_ptr->m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
+               if ((current_floor_ptr->m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->phase_out) compact_monsters(64);
 
                /* Hack -- Compress the monster list occasionally */
-               if ((current_floor_ptr->m_cnt + 32 < current_floor_ptr->m_max) && !p_ptr->inside_battle) compact_monsters(0);
+               if ((current_floor_ptr->m_cnt + 32 < current_floor_ptr->m_max) && !p_ptr->phase_out) compact_monsters(0);
 
 
                /* Hack -- Compact the object list occasionally */
@@ -5152,7 +5146,7 @@ static void dungeon(bool load_game)
                 * Maintain Unique monsters and artifact, save current
                 * floor, then prepare next floor
                 */
-               leave_floor();
+               leave_floor(p_ptr->change_floor_mode);
 
                /* Forget the flag */
                reinit_wilderness = FALSE;
@@ -5199,7 +5193,7 @@ static void load_all_pref_files(void)
        process_pref_file(buf);
 
        /* Access the "character" pref file */
-       sprintf(buf, "%s.prf", player_base);
+       sprintf(buf, "%s.prf", p_ptr->base_name);
 
        /* Process that file */
        process_pref_file(buf);
@@ -5265,7 +5259,7 @@ void play_game(bool new_game)
        p_ptr->hack_mutation = FALSE;
 
        /* Hack -- Character is "icky" */
-       character_icky = TRUE;
+       current_world_ptr->character_icky = TRUE;
 
        /* Make sure main term is active */
        Term_activate(angband_term[0]);
@@ -5310,21 +5304,19 @@ void play_game(bool new_game)
 
                p_ptr->is_dead = TRUE;
 
-               start_time = (u32b)time(NULL);
+               current_world_ptr->start_time = (u32b)time(NULL);
 
                /* No suspending now */
                signals_ignore_tstp();
                
                /* Hack -- Character is now "icky" */
-               character_icky = TRUE;
-
-               /* Build the filename */
+               current_world_ptr->character_icky = TRUE;
                path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
                /* Open the high score file, for reading/writing */
                highscore_fd = fd_open(buf, O_RDWR);
 
-               /* 町名消失バグ対策(#38205) Init the wilderness */
+               /* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */
                process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
                /* Handle score, show Top scores */
@@ -5353,16 +5345,16 @@ void play_game(bool new_game)
                quit(0);
        }
 
-       creating_savefile = new_game;
+       current_world_ptr->creating_savefile = new_game;
 
        /* Nothing loaded */
-       if (!character_loaded)
+       if (!current_world_ptr->character_loaded)
        {
                /* Make new player */
                new_game = TRUE;
 
                /* The dungeon is not ready */
-               character_dungeon = FALSE;
+               current_world_ptr->character_dungeon = FALSE;
 
                /* Prepare to init the RNG */
                init_random_seed = TRUE;
@@ -5395,13 +5387,13 @@ void play_game(bool new_game)
        if (new_game)
        {
                /* The dungeon is not ready */
-               character_dungeon = FALSE;
+               current_world_ptr->character_dungeon = FALSE;
 
                /* Start in town */
                current_floor_ptr->dun_level = 0;
                p_ptr->inside_quest = 0;
                p_ptr->inside_arena = FALSE;
-               p_ptr->inside_battle = FALSE;
+               p_ptr->phase_out = FALSE;
 
                write_level = TRUE;
 
@@ -5412,7 +5404,7 @@ void play_game(bool new_game)
                current_world_ptr->seed_town = randint0(0x10000000);
 
                /* Roll up a new character */
-               player_birth();
+               player_birth(p_ptr);
 
                counts_write(2,0);
                p_ptr->count = 0;
@@ -5451,14 +5443,14 @@ void play_game(bool new_game)
                }
        }
 
-       creating_savefile = FALSE;
+       current_world_ptr->creating_savefile = FALSE;
 
        p_ptr->teleport_town = FALSE;
        p_ptr->sutemi = FALSE;
        current_world_ptr->timewalk_m_idx = 0;
        p_ptr->now_damaged = FALSE;
        now_message = 0;
-       start_time = time(NULL) - 1;
+       current_world_ptr->start_time = time(NULL) - 1;
        record_o_name[0] = '\0';
 
        /* Reset map panel */
@@ -5510,25 +5502,17 @@ void play_game(bool new_game)
        /* Initialize the town-buildings if necessary */
        if (!current_floor_ptr->dun_level && !p_ptr->inside_quest)
        {
-               /* Init the wilderness */
-
                process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
-
-               /* Init the town */
                init_flags = INIT_ONLY_BUILDINGS;
-
                process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
-
                select_floor_music();
        }
 
-
        /* Generate a dungeon level if needed */
-       if (!character_dungeon)
+       if (!current_world_ptr->character_dungeon)
        {
-               change_floor();
+               change_floor(p_ptr->change_floor_mode);
        }
-
        else
        {
                /* HACK -- Restore from panic-save */
@@ -5538,7 +5522,7 @@ void play_game(bool new_game)
                        if (!p_ptr->y || !p_ptr->x)
                        {
                                msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location.  Regenerate the dungeon floor."));
-                               change_floor();
+                               change_floor(p_ptr->change_floor_mode);
                        }
 
                        /* Still no player?  -- Try to locate random place */
@@ -5550,11 +5534,11 @@ void play_game(bool new_game)
        }
 
        /* Character is now "complete" */
-       character_generated = TRUE;
+       current_world_ptr->character_generated = TRUE;
 
 
        /* Hack -- Character is no longer "icky" */
-       character_icky = FALSE;
+       current_world_ptr->character_icky = FALSE;
 
 
        if (new_game)
@@ -5577,7 +5561,7 @@ void play_game(bool new_game)
        /* Give startup outfit (after loading pref files) */
        if (new_game)
        {
-               player_outfit();
+               player_outfit(p_ptr);
        }
 
        /* React to changes */
@@ -5594,12 +5578,12 @@ void play_game(bool new_game)
        /* Hack -- Enforce "delayed death" */
        if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
 
-       if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
+       if (p_ptr->prace == RACE_ANDROID) calc_android_exp(p_ptr);
 
        if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
        {
                monster_type *m_ptr;
-               IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
+               MONRACE_IDX pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
                monster_race *r_ptr = &r_info[pet_r_idx];
                place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
                                  (PM_FORCE_PET | PM_NO_KAGE));
@@ -5624,11 +5608,11 @@ void play_game(bool new_game)
                dungeon(load_game);
 
                /* Hack -- prevent "icky" message */
-               character_xtra = TRUE;
+               current_world_ptr->character_xtra = TRUE;
 
                handle_stuff();
 
-               character_xtra = FALSE;
+               current_world_ptr->character_xtra = FALSE;
 
                /* Cancel the target */
                target_who = 0;
@@ -5666,13 +5650,13 @@ void play_game(bool new_game)
                                p_ptr->chp = 0;
                                p_ptr->chp_frac = 0;
                                p_ptr->exit_bldg = TRUE;
-                               reset_tim_flags();
+                               reset_tim_flags(p_ptr);
 
                                /* Leave through the exit */
                                prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
 
                                /* prepare next floor */
-                               leave_floor();
+                               leave_floor(p_ptr->change_floor_mode);
                        }
                        else
                        {
@@ -5688,7 +5672,7 @@ void play_game(bool new_game)
                if (p_ptr->is_dead) break;
 
                /* Make a new level */
-               change_floor();
+               change_floor(p_ptr->change_floor_mode);
        }
 
        /* Close stuff */
@@ -5737,8 +5721,8 @@ void prevent_turn_overflow(void)
        else current_world_ptr->game_turn = 1;
        if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
        else current_floor_ptr->generated_turn = 1;
-       if (old_battle > rollback_turns) old_battle -= rollback_turns;
-       else old_battle = 1;
+       if (current_world_ptr->arena_start_turn > rollback_turns) current_world_ptr->arena_start_turn -= rollback_turns;
+       else current_world_ptr->arena_start_turn = 1;
        if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
        else p_ptr->feeling_turn = 1;
 
@@ -5792,10 +5776,8 @@ void close_game(void)
 
 
        /* Hack -- Character is now "icky" */
-       character_icky = TRUE;
-
+       current_world_ptr->character_icky = TRUE;
 
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        /* Grab permissions */
@@ -5881,3 +5863,23 @@ void close_game(void)
        /* Allow suspending now */
        signals_handle_tstp();
 }
+
+
+/*!
+ * @brief 全更新処理をチェックして処理していく
+ * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
+ * @return なし
+ */
+void handle_stuff(void)
+{
+       if (p_ptr->update) update_creature(p_ptr);
+       if (p_ptr->redraw) redraw_stuff();
+       if (p_ptr->window) window_stuff();
+}
+
+void update_output(void)
+{
+       if (p_ptr->redraw) redraw_stuff();
+       if (p_ptr->window) window_stuff();
+}
+