OSDN Git Service

[Refactor] #38997 do_cmd_spike() に player_type * 引数を追加.
[hengband/hengband.git] / src / core.c
index 85276a1..b164455 100644 (file)
@@ -77,6 +77,7 @@
 #include "floor-save.h"
 #include "feature.h"
 #include "player-skill.h"
+#include "player-inventory.h"
 
 #include "view-mainwindow.h"
 #include "dungeon-file.h"
@@ -425,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 ***/
 
@@ -694,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;
@@ -705,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);
@@ -731,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;
        }
 
@@ -1265,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 */
@@ -1298,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);
                }
 
 
@@ -1312,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) */
@@ -1321,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);
                        }
                }
        }
@@ -1347,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 */
@@ -1393,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;
                        }
                }
@@ -1426,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);
                }
        }
 
@@ -1445,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;
@@ -1455,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;
@@ -1493,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;
@@ -1531,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;
@@ -1569,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;
@@ -1607,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;
@@ -1626,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;
                }
        }
@@ -1640,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)
                {
@@ -1661,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);
                }
        }
 
@@ -1690,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);
                }
        }
 
@@ -1809,25 +1810,25 @@ 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 (p_ptr->suppress_multi_reward)
@@ -1838,7 +1839,7 @@ static void process_world_aux_timeout(void)
        /* 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- */
@@ -1847,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- */
@@ -1856,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 ***/
@@ -2082,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 */
@@ -2091,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 */
@@ -2103,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);
        }
 }
 
@@ -2149,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;
@@ -2159,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))
@@ -2169,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));
                }
        }
 
@@ -2195,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)
@@ -2203,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();
@@ -2215,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);
                                }
                        }
                }
@@ -2227,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);
                }
        }
 
@@ -2277,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
@@ -2290,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);
@@ -2332,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];
@@ -2344,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;
@@ -2387,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))
@@ -2396,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))
        {
@@ -2437,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))
@@ -2459,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))
@@ -2472,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)
@@ -2518,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))
@@ -2530,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);
                }
@@ -2547,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);
                }
        }
 
@@ -2558,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;
@@ -2593,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)
@@ -2661,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))
@@ -2764,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 */
@@ -2782,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))
@@ -2812,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);
                }
        }
 }
@@ -2938,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 */
@@ -3052,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 */
@@ -3118,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;
@@ -3183,7 +3184,7 @@ 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);
@@ -3197,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)))
@@ -3214,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 ***/
 
@@ -3265,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)
@@ -3353,34 +3354,15 @@ static void process_world(void)
                }
        }
 
-
-
-       /* 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();
 }
 
@@ -3548,8 +3530,6 @@ static void process_command(void)
                }
 
                /*** Wizard Commands ***/
-
-               /* Toggle Wizard Mode */
                case KTRL('W'):
                {
                        if (p_ptr->wizard)
@@ -3563,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;
@@ -3576,7 +3554,6 @@ static void process_command(void)
                /* Special "debug" commands */
                case KTRL('A'):
                {
-                       /* Enter debug mode */
                        if (enter_debug_mode())
                        {
                                do_cmd_debug();
@@ -3592,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;
                }
 
@@ -3659,10 +3634,9 @@ static void process_command(void)
                        break;
                }
 
-               /* Hack -- toggle windows */
                case KTRL('I'):
                {
-                       toggle_inven_equip();
+                       toggle_inven_equip(p_ptr);
                        break;
                }
 
@@ -3731,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;
                }
 
@@ -3789,7 +3762,7 @@ static void process_command(void)
                                change_wild_mode(FALSE);
                        }
                        else
-                               do_cmd_go_up();
+                               do_cmd_go_up(p_ptr);
                        break;
                }
 
@@ -3799,28 +3772,28 @@ static void process_command(void)
                        if (p_ptr->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;
                }
 
                /* Close a door */
                case 'c':
                {
-                       do_cmd_close();
+                       do_cmd_close(p_ptr);
                        break;
                }
 
                /* Jam a door with spikes */
                case 'j':
                {
-                       do_cmd_spike();
+                       do_cmd_spike(p_ptr);
                        break;
                }
 
@@ -3965,7 +3938,7 @@ static void process_command(void)
                /* Activate an artifact */
                case 'A':
                {
-                       do_cmd_activate();
+                       do_cmd_activate(p_ptr);
                        break;
                }
 
@@ -4297,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;
                }
@@ -4453,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++)
                {
@@ -4489,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);
                        }
                }
 
@@ -4506,7 +4479,7 @@ 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);
                        }
                }
        }
@@ -4594,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)
        {
@@ -4615,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
                {
@@ -4631,7 +4604,7 @@ static void process_player(void)
                {
                        if (p_ptr->csp < 3)
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                        else
                        {
@@ -4668,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);
@@ -4694,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);
                        }
 
@@ -5021,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)
                {
@@ -5061,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 ***/
 
@@ -5073,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;
 
@@ -5087,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 */
@@ -5173,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;
@@ -5338,14 +5311,12 @@ void play_game(bool new_game)
                
                /* Hack -- Character is now "icky" */
                current_world_ptr->character_icky = TRUE;
-
-               /* Build the filename */
                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 */
@@ -5422,7 +5393,7 @@ void play_game(bool new_game)
                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;
 
@@ -5433,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;
@@ -5531,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 (!current_world_ptr->character_dungeon)
        {
-               change_floor();
+               change_floor(p_ptr->change_floor_mode);
        }
-
        else
        {
                /* HACK -- Restore from panic-save */
@@ -5559,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 */
@@ -5598,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 */
@@ -5615,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));
@@ -5687,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
                        {
@@ -5709,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 */
@@ -5815,8 +5778,6 @@ void close_game(void)
        /* Hack -- Character is now "icky" */
        current_world_ptr->character_icky = TRUE;
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        /* Grab permissions */