OSDN Git Service

[Refactor] #38997 do_cmd_read_scroll() に player_type * 引数を追加.
[hengband/hengband.git] / src / core.c
index c9996cd..ffc1d2c 100644 (file)
@@ -426,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 ***/
 
@@ -672,7 +672,7 @@ static void pattern_teleport(void)
 
        leave_quest_check();
 
-       if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
+       if (record_stair) exe_write_diary(p_ptr, NIKKI_PAT_TELE, 0, NULL);
 
        p_ptr->inside_quest = 0;
        free_turn(p_ptr);
@@ -698,7 +698,7 @@ static bool pattern_effect(void)
        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;
@@ -732,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_(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;
        }
 
@@ -1188,7 +1188,7 @@ static void check_music(void)
        { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
 
        /* Do any effects of continual song */
-       do_spell(REALM_MUSIC, spell, SPELL_CONT);
+       exe_spell(REALM_MUSIC, spell, SPELL_CONT);
 }
 
 /*!
@@ -1322,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);
                        }
                }
        }
@@ -1348,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 */
@@ -1394,7 +1394,7 @@ 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 */
@@ -1405,7 +1405,7 @@ static void process_world_aux_hp_and_sp(void)
                        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;
                        }
                }
@@ -1427,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);
                }
        }
 
@@ -1456,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;
@@ -1494,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;
@@ -1532,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;
@@ -1570,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;
@@ -1608,7 +1608,7 @@ 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, p_ptr->poisoned + 1);
                        }
@@ -1616,7 +1616,7 @@ static void process_world_aux_hp_and_sp(void)
                        {
                                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);
+                               take_hit(p_ptr, DAMAGE_NOESCAPE, damage, name, -1);
                                if (p_ptr->resist_pois) (void)set_poisoned(p_ptr, p_ptr->poisoned + 3);
                        }
 
@@ -1627,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;
                }
        }
@@ -1645,7 +1645,7 @@ static void process_world_aux_hp_and_sp(void)
                        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)
                {
@@ -1654,7 +1654,7 @@ static void process_world_aux_hp_and_sp(void)
                        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)
                {
@@ -1662,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);
                }
        }
 
@@ -1691,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);
                }
        }
 
@@ -1917,7 +1917,7 @@ static void process_world_aux_timeout(void)
        /* 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 */
@@ -2072,7 +2072,7 @@ static void process_world_aux_timeout(void)
 
        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 ***/
@@ -2388,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))
@@ -2474,8 +2474,8 @@ static void process_world_aux_mutation(void)
                msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
                msg_print(NULL);
                set_food(p_ptr, PY_FOOD_WEAK);
-               if (music_singing_any()) stop_singing(p_ptr);
-               if (hex_spelling_any()) stop_hex_spell_all();
+               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)
@@ -2548,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);
                }
        }
 
@@ -2559,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;
@@ -2662,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))
@@ -2783,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))
@@ -2813,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);
                }
        }
 }
@@ -2960,7 +2960,7 @@ static void process_world_aux_movement(void)
 
                                if (p_ptr->dungeon_idx) p_ptr->recall_dungeon = p_ptr->dungeon_idx;
                                if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
+                                       exe_write_diary(p_ptr, NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
 
                                current_floor_ptr->dun_level = 0;
                                p_ptr->dungeon_idx = 0;
@@ -2979,7 +2979,7 @@ static void process_world_aux_movement(void)
                                p_ptr->dungeon_idx = p_ptr->recall_dungeon;
 
                                if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
+                                       exe_write_diary(p_ptr, NIKKI_RECALL, current_floor_ptr->dun_level, NULL);
 
                                /* New depth */
                                current_floor_ptr->dun_level = max_dlv[p_ptr->dungeon_idx];
@@ -3293,7 +3293,7 @@ static void process_world(void)
        {
                if (min != prev_min)
                {
-                       do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
+                       exe_write_diary(p_ptr, NIKKI_HIGAWARI, 0, NULL);
                        determine_today_mon(FALSE);
                }
        }
@@ -3394,7 +3394,7 @@ static bool enter_wizard_mode(void)
                        return (FALSE);
                }
 
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
+               exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
                /* Mark savefile */
                p_ptr->noscore |= 0x0002;
        }
@@ -3435,7 +3435,7 @@ static bool enter_debug_mode(void)
                        return (FALSE);
                }
 
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
+               exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
                /* Mark savefile */
                p_ptr->noscore |= 0x0008;
        }
@@ -3476,7 +3476,7 @@ static bool enter_borg_mode(void)
                        return (FALSE);
                }
 
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
+               exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
                /* Mark savefile */
                p_ptr->noscore |= 0x0010;
        }
@@ -3530,8 +3530,6 @@ static void process_command(void)
                }
 
                /*** Wizard Commands ***/
-
-               /* Toggle Wizard Mode */
                case KTRL('W'):
                {
                        if (p_ptr->wizard)
@@ -3636,10 +3634,9 @@ static void process_command(void)
                        break;
                }
 
-               /* Hack -- toggle windows */
                case KTRL('I'):
                {
-                       toggle_inven_equip();
+                       toggle_inven_equip(p_ptr);
                        break;
                }
 
@@ -3649,28 +3646,28 @@ static void process_command(void)
                /* Alter a grid */
                case '+':
                {
-                       if (!p_ptr->wild_mode) do_cmd_alter();
+                       if (!p_ptr->wild_mode) do_cmd_alter(p_ptr);
                        break;
                }
 
                /* Dig a tunnel */
                case 'T':
                {
-                       if (!p_ptr->wild_mode) do_cmd_tunnel();
+                       if (!p_ptr->wild_mode) do_cmd_tunnel(p_ptr);
                        break;
                }
 
                /* Move (usually pick up things) */
                case ';':
                {
-                       do_cmd_walk(FALSE);
+                       do_cmd_walk(p_ptr, FALSE);
                        break;
                }
 
                /* Move (usually do not pick up) */
                case '-':
                {
-                       do_cmd_walk(TRUE);
+                       do_cmd_walk(p_ptr, TRUE);
                        break;
                }
 
@@ -3680,28 +3677,28 @@ static void process_command(void)
                /* Begin Running -- Arg is Max Distance */
                case '.':
                {
-                       if (!p_ptr->wild_mode) do_cmd_run();
+                       if (!p_ptr->wild_mode) do_cmd_run(p_ptr);
                        break;
                }
 
                /* Stay still (usually pick things up) */
                case ',':
                {
-                       do_cmd_stay(always_pickup);
+                       do_cmd_stay(p_ptr, always_pickup);
                        break;
                }
 
                /* Stay still (usually do not pick up) */
                case 'g':
                {
-                       do_cmd_stay(!always_pickup);
+                       do_cmd_stay(p_ptr, !always_pickup);
                        break;
                }
 
                /* Rest -- Arg is time */
                case 'R':
                {
-                       do_cmd_rest();
+                       do_cmd_rest(p_ptr);
                        break;
                }
 
@@ -3712,11 +3709,10 @@ static void process_command(void)
                        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;
                }
 
@@ -3790,28 +3786,28 @@ static void process_command(void)
                /* 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;
                }
 
                /* Bash a door */
                case 'B':
                {
-                       do_cmd_bash();
+                       do_cmd_bash(p_ptr);
                        break;
                }
 
                /* Disarm a trap or chest */
                case 'D':
                {
-                       do_cmd_disarm();
+                       do_cmd_disarm(p_ptr);
                        break;
                }
 
@@ -3949,7 +3945,7 @@ static void process_command(void)
                /* Eat some food */
                case 'E':
                {
-                       do_cmd_eat_food();
+                       do_cmd_eat_food(p_ptr);
                        break;
                }
 
@@ -3963,14 +3959,14 @@ static void process_command(void)
                /* Fire an item */
                case 'f':
                {
-                       do_cmd_fire(SP_NONE);
+                       do_cmd_fire(p_ptr, SP_NONE);
                        break;
                }
 
                /* Throw an item */
                case 'v':
                {
-                       do_cmd_throw(1, FALSE, -1);
+                       do_cmd_throw(p_ptr, 1, FALSE, -1);
                        break;
                }
 
@@ -3998,14 +3994,14 @@ static void process_command(void)
                /* Quaff a potion */
                case 'q':
                {
-                       do_cmd_quaff_potion();
+                       do_cmd_quaff_potion(p_ptr);
                        break;
                }
 
                /* Read a scroll */
                case 'r':
                {
-                       do_cmd_read_scroll();
+                       do_cmd_read_scroll(p_ptr);
                        break;
                }
 
@@ -4078,7 +4074,7 @@ static void process_command(void)
                /* Character description */
                case 'C':
                {
-                       do_cmd_player_status();
+                       do_cmd_player_status(p_ptr);
                        break;
                }
 
@@ -4114,23 +4110,23 @@ static void process_command(void)
                /* Interact with macros */
                case '@':
                {
-                       do_cmd_macros();
+                       do_cmd_macros(p_ptr);
                        break;
                }
 
                /* Interact with visuals */
                case '%':
                {
-                       do_cmd_visuals();
-                       do_cmd_redraw();
+                       do_cmd_visuals(p_ptr);
+                       do_cmd_redraw(p_ptr);
                        break;
                }
 
                /* Interact with colors */
                case '&':
                {
-                       do_cmd_colors();
-                       do_cmd_redraw();
+                       do_cmd_colors(p_ptr);
+                       do_cmd_redraw(p_ptr);
                        break;
                }
 
@@ -4139,7 +4135,7 @@ static void process_command(void)
                {
                        do_cmd_options();
                        (void)combine_and_reorder_home(STORE_HOME);
-                       do_cmd_redraw();
+                       do_cmd_redraw(p_ptr);
                        break;
                }
 
@@ -4162,7 +4158,7 @@ static void process_command(void)
                /* Repeat level feeling */
                case KTRL('F'):
                {
-                       do_cmd_feeling();
+                       do_cmd_feeling(p_ptr);
                        break;
                }
 
@@ -4191,7 +4187,7 @@ static void process_command(void)
                case KTRL('R'):
                {
                        now_message = old_now_message;
-                       do_cmd_redraw();
+                       do_cmd_redraw(p_ptr);
                        break;
                }
 
@@ -4223,7 +4219,7 @@ static void process_command(void)
                /* Quit (commit suicide) */
                case 'Q':
                {
-                       do_cmd_suicide();
+                       do_cmd_suicide(p_ptr);
                        break;
                }
 
@@ -4274,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;
                }
@@ -4466,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);
                        }
                }
 
@@ -4483,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);
                        }
                }
        }
@@ -4592,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
                {
@@ -4608,7 +4604,7 @@ static void process_player(void)
                {
                        if (p_ptr->csp < 3)
                        {
-                               set_action(ACTION_NONE);
+                               set_action(p_ptr, ACTION_NONE);
                        }
                        else
                        {
@@ -4671,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);
                        }
 
@@ -4963,7 +4959,7 @@ static void dungeon(bool load_game)
        if ((max_dlv[p_ptr->dungeon_idx] < current_floor_ptr->dun_level) && !p_ptr->inside_quest)
        {
                max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
-               if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
+               if (record_maxdepth) exe_write_diary(p_ptr, NIKKI_MAXDEAPTH, current_floor_ptr->dun_level, NULL);
        }
 
        (void)calculate_upkeep();
@@ -4996,7 +4992,7 @@ static void dungeon(bool load_game)
 
        if (quest_num && (is_fixed_quest_idx(quest_num) &&
            !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
-           !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
+           !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling(p_ptr);
 
        if (p_ptr->phase_out)
        {
@@ -5408,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;
@@ -5425,7 +5421,7 @@ void play_game(bool new_game)
        {
                write_level = FALSE;
 
-               do_cmd_write_nikki(NIKKI_GAMESTART, 1, 
+               exe_write_diary(p_ptr, NIKKI_GAMESTART, 1, 
                                          _("                            ----ゲーム再開----",
                                                "                            ---- Restart Game ----"));
 
@@ -5549,7 +5545,7 @@ void play_game(bool new_game)
        {
                char buf[80];
                sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
+               exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, buf);
        }
 
 
@@ -5565,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 */
@@ -5654,7 +5650,7 @@ 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);