OSDN Git Service

[Refactor] #38997 gain_exp() に player_type * 引数を追加.
[hengband/hengband.git] / src / cmd-item.c
index 0a09158..9ad4c4b 100644 (file)
 
 
 #include "angband.h"
+#include "core.h"
+#include "util.h"
+#include "autopick.h"
+#include "term.h"
+
 #include "selfinfo.h"
 #include "cmd-activate.h"
 #include "cmd-eat.h"
 #include "cmd-usestaff.h"
 #include "cmd-zaprod.h"
 #include "cmd-zapwand.h"
+#include "cmd-pet.h"
+#include "cmd-basic.h"
 
+#include "object-flavor.h"
 #include "object-hook.h"
-
+#include "object-ego.h"
+#include "sort.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "player-status.h"
+#include "player-effects.h"
+#include "player-class.h"
+#include "player-personality.h"
+#include "monster.h"
+#include "view-mainwindow.h"
+#include "spells.h"
+#include "objectkind.h"
+#include "autopick.h"
+#include "targeting.h"
+#include "snipe.h"
+#include "player-race.h"
+#include "view-mainwindow.h"
+#include "player-inventory.h"
 
 /*!
- * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
+ * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display p_ptr->inventory_list
  * @return なし 
  */
 void do_cmd_inven(void)
 {
        char out_val[160];
 
-       /* Note that we are in "inventory" mode */
+       /* Note that we are in "p_ptr->inventory_list" mode */
        command_wrk = FALSE;
 
-       /* Note that we are in "inventory" mode */
+       /* Note that we are in "p_ptr->inventory_list" mode */
        if (easy_floor) command_wrk = (USE_INVEN);
        screen_save();
 
-       /* Display the inventory */
-       (void)show_inven(0, USE_FULL);
+       /* Display the p_ptr->inventory_list */
+       (void)show_inven(0, USE_FULL, 0);
 
 #ifdef JP
        sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
@@ -59,7 +85,7 @@ void do_cmd_inven(void)
        /* Process "Escape" */
        if (command_new == ESCAPE)
        {
-               int wid, hgt;
+               TERM_LEN wid, hgt;
 
                Term_get_size(&wid, &hgt);
 
@@ -85,7 +111,6 @@ void do_cmd_equip(void)
 {
        char out_val[160];
 
-
        /* Note that we are in "equipment" mode */
        command_wrk = TRUE;
 
@@ -93,7 +118,7 @@ void do_cmd_equip(void)
        if (easy_floor) command_wrk = (USE_EQUIP);
        screen_save();
 
-       (void)show_equip(0, USE_FULL);
+       (void)show_equip(0, USE_FULL, 0);
 
        /* Build a prompt */
 #ifdef JP
@@ -113,7 +138,7 @@ void do_cmd_equip(void)
        /* Process "Escape" */
        if (command_new == ESCAPE)
        {
-               int wid, hgt;
+               TERM_LEN wid, hgt;
 
                Term_get_size(&wid, &hgt);
 
@@ -146,8 +171,8 @@ void do_cmd_wield(void)
        object_type *q_ptr;
        object_type *o_ptr;
 
-       cptr act;
-       cptr q, s;
+       concptr act;
+       concptr q, s;
 
        GAME_TEXT o_name[MAX_NLEN];
 
@@ -165,7 +190,7 @@ void do_cmd_wield(void)
        q = _("どれを装備しますか? ", "Wear/Wield which item? ");
        s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
 
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
        if (!o_ptr) return;
 
        /* Check the slot */
@@ -178,7 +203,7 @@ void do_cmd_wield(void)
        case TV_SHIELD:
        case TV_CARD:
                /* Dual wielding */
-               if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
+               if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
                {
                        /* Restrict the choices */
                        item_tester_hook = item_tester_hook_melee_weapon;
@@ -186,15 +211,15 @@ void do_cmd_wield(void)
                        /* Choose a weapon from the equipment only */
                        q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
                        s = _("おっと。", "Oops.");
-                       if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
+                       if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0)) return;
                        if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
                }
 
-               else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
+               else if (has_melee_weapon(INVEN_LARM)) slot = INVEN_RARM;
 
                /* Both arms are already used by non-weapon */
-               else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
-                        inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
+               else if (p_ptr->inventory_list[INVEN_RARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_RARM]) &&
+                        p_ptr->inventory_list[INVEN_LARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_LARM]))
                {
                        /* Restrict the choices */
                        item_tester_hook = item_tester_hook_mochikae;
@@ -202,7 +227,7 @@ void do_cmd_wield(void)
                        /* Choose a hand */
                        q = _("どちらの手に装備しますか?", "Equip which hand? ");
                        s = _("おっと。", "Oops.");
-                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
+                       if (!choose_object(&slot, q, s, (USE_EQUIP), 0)) return;
                }
                break;
 
@@ -217,13 +242,13 @@ void do_cmd_wield(void)
                        if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
                }
 
-               else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
+               else if (!p_ptr->inventory_list[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
                {
                        if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
                }
 
                /* Both arms are already used */
-               else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
+               else if (p_ptr->inventory_list[INVEN_LARM].k_idx && p_ptr->inventory_list[INVEN_RARM].k_idx)
                {
                        /* Restrict the choices */
                        item_tester_hook = item_tester_hook_mochikae;
@@ -232,8 +257,8 @@ void do_cmd_wield(void)
                        q = _("どちらの手に装備しますか?", "Equip which hand? ");
                        s = _("おっと。", "Oops.");
                        
-                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
-                       if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
+                       if (!choose_object(&slot, q, s, (USE_EQUIP), 0)) return;
+                       if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
                                need_switch_wielding = INVEN_RARM;
                }
                break;
@@ -241,7 +266,7 @@ void do_cmd_wield(void)
        /* Rings */
        case TV_RING:
                /* Choose a ring slot */
-               if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
+               if (p_ptr->inventory_list[INVEN_LEFT].k_idx && p_ptr->inventory_list[INVEN_RIGHT].k_idx)
                {
                        q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
                }
@@ -254,7 +279,7 @@ void do_cmd_wield(void)
                /* Restrict the choices */
                select_ring_slot = TRUE;
 
-               if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
+               if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0))
                {
                        select_ring_slot = FALSE;
                        return;
@@ -264,17 +289,14 @@ void do_cmd_wield(void)
        }
 
        /* Prevent wielding into a cursed slot */
-       if (object_is_cursed(&inventory[slot]))
+       if (object_is_cursed(&p_ptr->inventory_list[slot]))
        {
-               object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
+               object_desc(o_name, &p_ptr->inventory_list[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
                msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
 #else
                msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
 #endif
-
-               /* Cancel the command */
                return;
        }
 
@@ -293,24 +315,20 @@ void do_cmd_wield(void)
 
        if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
        {
-               char dummy[MAX_NLEN+80];
+               char dummy[MAX_NLEN+100];
 
                object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
-#ifdef JP
-               sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
-#else
-               msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
-               sprintf(dummy, "Do you become a vampire?");
-#endif
+               sprintf(dummy, _("%sを装備すると吸血鬼になります。よろしいですか?",
+                       "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"), o_name);
 
                if (!get_check(dummy)) return;
        }
 
-       if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
+       if (need_switch_wielding && !object_is_cursed(&p_ptr->inventory_list[need_switch_wielding]))
        {
-               object_type *slot_o_ptr = &inventory[slot];
-               object_type *switch_o_ptr = &inventory[need_switch_wielding];
+               object_type *slot_o_ptr = &p_ptr->inventory_list[slot];
+               object_type *switch_o_ptr = &p_ptr->inventory_list[need_switch_wielding];
                object_type object_tmp;
                object_type *otmp_ptr = &object_tmp;
                GAME_TEXT switch_name[MAX_NLEN];
@@ -337,7 +355,7 @@ void do_cmd_wield(void)
                autopick_alter_item(item, FALSE);
        }
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);
        q_ptr = &forge;
 
        /* Obtain local object */
@@ -361,7 +379,7 @@ void do_cmd_wield(void)
        }
 
        /* Access the wield slot */
-       o_ptr = &inventory[slot];
+       o_ptr = &p_ptr->inventory_list[slot];
 
        /* Take off existing item */
        if (o_ptr->k_idx)
@@ -373,24 +391,16 @@ void do_cmd_wield(void)
        /* Wear the new stuff */
        object_copy(o_ptr, q_ptr);
 
-       /* Player touches it */
        o_ptr->marked |= OM_TOUCHED;
 
-       /* Increase the weight */
        p_ptr->total_weight += q_ptr->weight;
 
        /* Increment the equip counter by hand */
-       equip_cnt++;
+       p_ptr->equip_cnt++;
 
-#ifdef JP
-#define STR_WIELD_RARM "%s(%c)を右手に装備した。"
-#define STR_WIELD_LARM "%s(%c)を左手に装備した。"
-#define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
-#else
-#define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
-#define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
-#define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
-#endif
+#define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
+#define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
+#define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
 
        /* Where is the item now */
        switch (slot)
@@ -435,18 +445,18 @@ void do_cmd_wield(void)
                o_ptr->ident |= (IDENT_SENSE);
        }
 
-       /* The Stone Mask make the player turn into a vampire! */
+       /* The Stone Mask make the player current_world_ptr->game_turn into a vampire! */
        if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
        {
                /* Turn into a vampire */
-               change_race(RACE_VAMPIRE, "");
+               change_race(p_ptr, RACE_VAMPIRE, "");
        }
 
        p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
        p_ptr->redraw |= (PR_EQUIPPY);
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
-       calc_android_exp();
+       calc_android_exp(p_ptr);
 }
 
 /*!
@@ -461,14 +471,14 @@ void kamaenaoshi(INVENTORY_IDX item)
 
        if (item == INVEN_RARM)
        {
-               if (buki_motteruka(INVEN_LARM))
+               if (has_melee_weapon(INVEN_LARM))
                {
-                       o_ptr = &inventory[INVEN_LARM];
+                       o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                        object_desc(o_name, o_ptr, 0);
 
                        if (!object_is_cursed(o_ptr))
                        {
-                               new_o_ptr = &inventory[INVEN_RARM];
+                               new_o_ptr = &p_ptr->inventory_list[INVEN_RARM];
                                object_copy(new_o_ptr, o_ptr);
                                p_ptr->total_weight += o_ptr->weight;
                                inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
@@ -488,17 +498,17 @@ void kamaenaoshi(INVENTORY_IDX item)
        }
        else if (item == INVEN_LARM)
        {
-               o_ptr = &inventory[INVEN_RARM];
+               o_ptr = &p_ptr->inventory_list[INVEN_RARM];
                if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
 
-               if (buki_motteruka(INVEN_RARM))
+               if (has_melee_weapon(INVEN_RARM))
                {
                        if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
                                msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
                }
                else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
                {
-                       new_o_ptr = &inventory[INVEN_LARM];
+                       new_o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                        object_copy(new_o_ptr, o_ptr);
                        p_ptr->total_weight += o_ptr->weight;
                        inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
@@ -517,7 +527,7 @@ void do_cmd_takeoff(void)
 {
        OBJECT_IDX item;
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -527,20 +537,8 @@ void do_cmd_takeoff(void)
        q = _("どれを装備からはずしますか? ", "Take off which item? ");
        s = _("はずせる装備がない。", "You are not wearing anything to take off.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        /* Item is cursed */
        if (object_is_cursed(o_ptr))
@@ -568,18 +566,17 @@ void do_cmd_takeoff(void)
                else
                {
                        msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
-                       p_ptr->energy_use = 50;
+                       take_turn(p_ptr, 50);
                        return;
                }
        }
 
-       /* Take a partial turn */
-       p_ptr->energy_use = 50;
+       take_turn(p_ptr, 50);
 
        /* Take off the item */
        (void)inven_takeoff(item, 255);
        kamaenaoshi(item);
-       calc_android_exp();
+       calc_android_exp(p_ptr);
        p_ptr->redraw |= (PR_EQUIPPY);
 }
 
@@ -595,7 +592,7 @@ void do_cmd_drop(void)
 
        object_type *o_ptr;
 
-       cptr q, s;
+       concptr q, s;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -605,20 +602,8 @@ void do_cmd_drop(void)
        q = _("どのアイテムを落としますか? ", "Drop which item? ");
        s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        /* Hack -- Cannot remove cursed items */
        if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
@@ -627,20 +612,13 @@ void do_cmd_drop(void)
                return;
        }
 
-
-       /* See how many items */
        if (o_ptr->number > 1)
        {
-               /* Get a quantity */
                amt = get_quantity(NULL, o_ptr->number);
-
-               /* Allow user abort */
                if (amt <= 0) return;
        }
 
-
-       /* Take a partial turn */
-       p_ptr->energy_use = 50;
+       take_turn(p_ptr, 50);
 
        /* Drop (some of) the item */
        inven_drop(item, amt);
@@ -648,40 +626,12 @@ void do_cmd_drop(void)
        if (item >= INVEN_RARM)
        {
                kamaenaoshi(item);
-               calc_android_exp();
+               calc_android_exp(p_ptr);
        }
 
        p_ptr->redraw |= (PR_EQUIPPY);
 }
 
-/*!
- * @brief オブジェクトが高位の魔法書かどうかを判定する
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトが高位の魔法書ならばTRUEを返す
- */
-static bool high_level_book(object_type *o_ptr)
-{
-       if ((o_ptr->tval == TV_LIFE_BOOK) ||
-           (o_ptr->tval == TV_SORCERY_BOOK) ||
-           (o_ptr->tval == TV_NATURE_BOOK) ||
-           (o_ptr->tval == TV_CHAOS_BOOK) ||
-           (o_ptr->tval == TV_DEATH_BOOK) ||
-           (o_ptr->tval == TV_TRUMP_BOOK) ||
-           (o_ptr->tval == TV_CRAFT_BOOK) ||
-           (o_ptr->tval == TV_DAEMON_BOOK) ||
-           (o_ptr->tval == TV_CRUSADE_BOOK) ||
-           (o_ptr->tval == TV_MUSIC_BOOK) ||
-               (o_ptr->tval == TV_HEX_BOOK))
-       {
-               if (o_ptr->sval > 1)
-                       return TRUE;
-               else
-                       return FALSE;
-       }
-
-       return FALSE;
-}
-
 
 /*!
  * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
@@ -702,7 +652,7 @@ void do_cmd_destroy(void)
        GAME_TEXT o_name[MAX_NLEN];
        char out_val[MAX_NLEN+40];
 
-       cptr q, s;
+       concptr q, s;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -715,19 +665,8 @@ void do_cmd_destroy(void)
        q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
        s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
+       if (!o_ptr) return;
 
        /* Verify unless quantity given beforehand */
        if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
@@ -781,13 +720,9 @@ void do_cmd_destroy(void)
                } /* while (TRUE) */
        }
 
-       /* See how many items */
        if (o_ptr->number > 1)
        {
-               /* Get a quantity */
                amt = get_quantity(NULL, o_ptr->number);
-
-               /* Allow user abort */
                if (amt <= 0) return;
        }
 
@@ -797,12 +732,12 @@ void do_cmd_destroy(void)
        object_desc(o_name, o_ptr, 0);
        o_ptr->number = old_number;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);
 
        /* Artifacts cannot be destroyed */
        if (!can_player_destroy_object(o_ptr))
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
                return;
@@ -832,7 +767,7 @@ void do_cmd_destroy(void)
                floor_item_optimize(0 - item);
        }
 
-       if (high_level_book(q_ptr))
+       if (item_tester_high_level_book(q_ptr))
        {
                bool gain_expr = FALSE;
 
@@ -863,14 +798,14 @@ void do_cmd_destroy(void)
                        if (tester_exp<1) tester_exp = 1;
 
                        msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
-                       gain_exp(tester_exp * amt);
+                       gain_exp(p_ptr, tester_exp * amt);
                }
-               if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
+               if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
                {
                        chg_virtue(V_UNLIFE, 1);
                        chg_virtue(V_VITALITY, -1);
                }
-               else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
+               else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
                {
                        chg_virtue(V_UNLIFE, -1);
                        chg_virtue(V_VITALITY, 1);
@@ -889,7 +824,7 @@ void do_cmd_destroy(void)
        if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
                chg_virtue(V_HARMONY, 1);
 
-       if (item >= INVEN_RARM) calc_android_exp();
+       if (item >= INVEN_RARM) calc_android_exp(p_ptr);
 }
 
 
@@ -902,26 +837,13 @@ void do_cmd_observe(void)
        OBJECT_IDX item;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr q, s;
-
+       concptr q, s;
 
        q = _("どのアイテムを調べますか? ", "Examine which item? ");
        s = _("調べられるアイテムがない。", "You have nothing to examine.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        /* Require full knowledge */
        if (!(o_ptr->ident & IDENT_MENTAL))
@@ -930,11 +852,8 @@ void do_cmd_observe(void)
                return;
        }
 
-
-       /* Description */
        object_desc(o_name, o_ptr, 0);
        msg_format(_("%sを調べている...", "Examining %s..."), o_name);
-       /* Describe it fully */
        if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
 }
 
@@ -949,24 +868,13 @@ void do_cmd_uninscribe(void)
 {
        OBJECT_IDX item;
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
        q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
        s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        /* Nothing to remove */
        if (!o_ptr->inscription)
@@ -979,10 +887,7 @@ void do_cmd_uninscribe(void)
 
        /* Remove the incription */
        o_ptr->inscription = 0;
-
-       /* Combine the pack */
        p_ptr->update |= (PU_COMBINE);
-
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
        /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -999,27 +904,16 @@ void do_cmd_uninscribe(void)
 void do_cmd_inscribe(void)
 {
        OBJECT_IDX item;
-       object_type             *o_ptr;
+       object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       char            out_val[80];
-       cptr q, s;
+       char out_val[80];
+       concptr q, s;
 
        q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
        s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        /* Describe the activity */
        object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
@@ -1042,10 +936,7 @@ void do_cmd_inscribe(void)
        {
                /* Save the inscription */
                o_ptr->inscription = quark_add(out_val);
-
-               /* Combine the pack */
                p_ptr->update |= (PU_COMBINE);
-
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1054,27 +945,6 @@ void do_cmd_inscribe(void)
 }
 
 
-
-/*!
- * @brief オブジェクトがランタンの燃料になるかどうかを判定する
- * An "item_tester_hook" for refilling lanterns
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトがランタンの燃料になるならばTRUEを返す
- */
-static bool item_tester_refill_lantern(object_type *o_ptr)
-{
-       /* Flasks of oil are okay */
-       if (o_ptr->tval == TV_FLASK) return (TRUE);
-
-       /* Laterns are okay */
-       if ((o_ptr->tval == TV_LITE) &&
-           (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
-
-       /* Assume not okay */
-       return (FALSE);
-}
-
-
 /*!
  * @brief ランタンに燃料を加えるコマンドのメインルーチン
  * Refill the players lamp (from the pack or floor)
@@ -1083,43 +953,23 @@ static bool item_tester_refill_lantern(object_type *o_ptr)
 static void do_cmd_refill_lamp(void)
 {
        OBJECT_IDX item;
-
        object_type *o_ptr;
        object_type *j_ptr;
-
-       cptr q, s;
-
+       concptr q, s;
 
        /* Restrict the choices */
        item_tester_hook = item_tester_refill_lantern;
 
-#ifdef JP
-       q = "どの油つぼから注ぎますか? ";
-       s = "油つぼがない。";
-#else
-       q = "Refill with which flask? ";
-       s = "You have no flasks of oil.";
-#endif
+       q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
+       s = _("油つぼがない。", "You have no flasks of oil.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
+       if (!o_ptr) return;
 
-       /* Take a partial turn */
-       p_ptr->energy_use = 50;
+       take_turn(p_ptr, 50);
 
        /* Access the lantern */
-       j_ptr = &inventory[INVEN_LITE];
+       j_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4;
@@ -1157,28 +1007,9 @@ static void do_cmd_refill_lamp(void)
                floor_item_optimize(0 - item);
        }
 
-       /* Recalculate torch */
        p_ptr->update |= (PU_TORCH);
 }
 
-
-/*!
- * @brief オブジェクトが松明に束ねられるかどうかを判定する
- * An "item_tester_hook" for refilling torches
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトが松明に束ねられるならばTRUEを返す
- */
-static bool item_tester_refill_torch(object_type *o_ptr)
-{
-       /* Torches are okay */
-       if ((o_ptr->tval == TV_LITE) &&
-           (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
-
-       /* Assume not okay */
-       return (FALSE);
-}
-
-
 /*!
  * @brief 松明を束ねるコマンドのメインルーチン
  * Refuel the players torch (from the pack or floor)
@@ -1191,34 +1022,21 @@ static void do_cmd_refill_torch(void)
        object_type *o_ptr;
        object_type *j_ptr;
 
-       cptr q, s;
+       concptr q, s;
 
        /* Restrict the choices */
-       item_tester_hook = item_tester_refill_torch;
+       item_tester_hook = object_can_refill_torch;
 
        q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
        s = _("他に松明がない。", "You have no extra torches.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
+       if (!o_ptr) return;
 
-       /* Take a partial turn */
-       p_ptr->energy_use = 50;
+       take_turn(p_ptr, 50);
 
        /* Access the primary torch */
-       j_ptr = &inventory[INVEN_LITE];
+       j_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4 + 5;
@@ -1264,7 +1082,6 @@ static void do_cmd_refill_torch(void)
                floor_item_optimize(0 - item);
        }
 
-       /* Recalculate torch */
        p_ptr->update |= (PU_TORCH);
 }
 
@@ -1279,7 +1096,7 @@ void do_cmd_refill(void)
        object_type *o_ptr;
 
        /* Get the light */
-       o_ptr = &inventory[INVEN_LITE];
+       o_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -1319,6 +1136,8 @@ void do_cmd_refill(void)
  */
 void do_cmd_target(void)
 {
+       if (p_ptr->wild_mode) return;
+
        /* Target set */
        if (target_set(TARGET_KILL))
        {
@@ -1359,17 +1178,14 @@ void do_cmd_look(void)
  */
 void do_cmd_locate(void)
 {
-       int             dir, y1, x1, y2, x2;
-
-       char    tmp_val[80];
-
-       char    out_val[160];
-
-       int wid, hgt;
+       DIRECTION dir;
+       POSITION y1, x1, y2, x2;
+       GAME_TEXT tmp_val[80];
+       GAME_TEXT out_val[160];
+       TERM_LEN wid, hgt;
 
        get_screen_size(&wid, &hgt);
 
-
        /* Start at current panel */
        y2 = y1 = panel_row_min;
        x2 = x1 = panel_col_min;
@@ -1380,25 +1196,13 @@ void do_cmd_locate(void)
                /* Describe the location */
                if ((y2 == y1) && (x2 == x1))
                {
-#ifdef JP
-                       strcpy(tmp_val, "真上");
-#else
-                       tmp_val[0] = '\0';
-#endif
-
+                       strcpy(tmp_val, _("真上", "\0"));
                }
                else
                {
-#ifdef JP
                        sprintf(tmp_val, "%s%s",
-                               ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
-                               ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
-#else
-                       sprintf(tmp_val, "%s%s of",
-                               ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
-                               ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
-#endif
-
+                               ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
+                               ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
                }
 
                /* Prepare to ask which way to look */
@@ -1441,123 +1245,12 @@ void do_cmd_locate(void)
        verify_panel();
 
        p_ptr->update |= (PU_MONSTERS);
-
        p_ptr->redraw |= (PR_MAP);
-
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
        handle_stuff();
 }
 
 
-
-/*!
- * @brief モンスター種族情報を特定の基準によりソートするための比較処理
- * Sorting hook -- Comp function -- see below
- * @param u モンスター種族情報の入れるポインタ
- * @param v 条件基準ID
- * @param a 比較するモンスター種族のID1
- * @param b 比較するモンスター種族のID2
- * @return 2の方が大きければTRUEを返す
- * We use "u" to point to array of monster indexes,
- * and "v" to select the type of sorting to perform on "u".
- */
-bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
-{
-       u16b *who = (u16b*)(u);
-
-       u16b *why = (u16b*)(v);
-
-       int w1 = who[a];
-       int w2 = who[b];
-
-       int z1, z2;
-
-       /* Sort by player kills */
-       if (*why >= 4)
-       {
-               /* Extract player kills */
-               z1 = r_info[w1].r_pkills;
-               z2 = r_info[w2].r_pkills;
-
-               /* Compare player kills */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Sort by total kills */
-       if (*why >= 3)
-       {
-               /* Extract total kills */
-               z1 = r_info[w1].r_tkills;
-               z2 = r_info[w2].r_tkills;
-
-               /* Compare total kills */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Sort by monster level */
-       if (*why >= 2)
-       {
-               /* Extract levels */
-               z1 = r_info[w1].level;
-               z2 = r_info[w2].level;
-
-               /* Compare levels */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Sort by monster experience */
-       if (*why >= 1)
-       {
-               /* Extract experience */
-               z1 = r_info[w1].mexp;
-               z2 = r_info[w2].mexp;
-
-               /* Compare experience */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Compare indexes */
-       return (w1 <= w2);
-}
-
-
-/*!
- * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
- * Sorting hook -- Swap function -- see below
- * @param u モンスター種族情報の入れるポインタ
- * @param v 未使用
- * @param a スワップするモンスター種族のID1
- * @param b スワップするモンスター種族のID2
- * @return なし
- * @details
- * We use "u" to point to array of monster indexes,
- * and "v" to select the type of sorting to perform.
- */
-void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
-{
-       u16b *who = (u16b*)(u);
-
-       u16b holder;
-
-       /* Unused */
-       (void)v;
-
-       /* Swap */
-       holder = who[a];
-       who[a] = who[b];
-       who[b] = holder;
-}
-
-
-
 /*!
  * @brief モンスターの思い出を見るコマンドのメインルーチン
  * Identify a character, allow recall of monsters
@@ -1579,19 +1272,19 @@ void do_cmd_query_symbol(void)
        IDX i;
        int n;
        MONRACE_IDX r_idx;
-       char    sym, query;
-       char    buf[128];
+       char sym, query;
+       char buf[128];
 
-       bool    all = FALSE;
-       bool    uniq = FALSE;
-       bool    norm = FALSE;
-       bool    ride = FALSE;
-       char    temp[80] = "";
+       bool all = FALSE;
+       bool uniq = FALSE;
+       bool norm = FALSE;
+       bool ride = FALSE;
+       char temp[80] = "";
 
-       bool    recall = FALSE;
+       bool recall = FALSE;
 
-       u16b    why = 0;
-       IDX     *who;
+       u16b why = 0;
+       MONRACE_IDX *who;
 
        /* Get a character, or abort */
        if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
@@ -1646,7 +1339,7 @@ void do_cmd_query_symbol(void)
        prt(buf, 0, 0);
 
        /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, IDX);
+       C_MAKE(who, max_r_idx, MONRACE_IDX);
 
        /* Collect matching monsters */
        for (n = 0, i = 1; i < max_r_idx; i++)
@@ -1702,9 +1395,7 @@ void do_cmd_query_symbol(void)
        /* Nothing to recall */
        if (!n)
        {
-               /* Free the "who" array */
-               C_KILL(who, max_r_idx, IDX);
-
+               C_KILL(who, max_r_idx, MONRACE_IDX);
                return;
        }
 
@@ -1713,18 +1404,12 @@ void do_cmd_query_symbol(void)
 
        /* Query */
        query = inkey();
-
-       /* Restore */
        prt(buf, 0, 0);
 
        why = 2;
 
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_comp_hook;
-       ang_sort_swap = ang_sort_swap_hook;
-
        /* Sort the array */
-       ang_sort(who, &why, n);
+       ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
 
        /* Sort by kills (and level) */
        if (query == 'k')
@@ -1736,21 +1421,14 @@ void do_cmd_query_symbol(void)
        /* Catch "escape" */
        if (query != 'y')
        {
-               /* Free the "who" array */
-               C_KILL(who, max_r_idx, IDX);
-
+               C_KILL(who, max_r_idx, MONRACE_IDX);
                return;
        }
 
        /* Sort if needed */
        if (why == 4)
        {
-               /* Select the sort method */
-               ang_sort_comp = ang_sort_comp_hook;
-               ang_sort_swap = ang_sort_swap_hook;
-
-               /* Sort the array */
-               ang_sort(who, &why, n);
+               ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
        }
 
 
@@ -1760,7 +1438,6 @@ void do_cmd_query_symbol(void)
        /* Scan the monster memory */
        while (1)
        {
-               /* Extract a race */
                r_idx = who[i];
 
                /* Hack -- Auto-recall */
@@ -1770,7 +1447,6 @@ void do_cmd_query_symbol(void)
                /* Interact */
                while (1)
                {
-                       /* Recall */
                        if (recall)
                        {
                                screen_save();
@@ -1785,13 +1461,11 @@ void do_cmd_query_symbol(void)
                        /* Hack -- Complete the prompt */
                        Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
 
-                       /* Command */
                        query = inkey();
 
                        /* Unrecall */
                        if (recall)
                        {
-                               /* Restore */
                                screen_load();
                        }
 
@@ -1844,19 +1518,14 @@ void do_cmd_use(void)
 {
        OBJECT_IDX item;
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
        if (p_ptr->wild_mode)
        {
                return;
        }
 
-       if (p_ptr->inside_arena)
-       {
-               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
-               msg_print(NULL);
-               return;
-       }
+       if (cmd_limit_arena(p_ptr)) return;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
        {
@@ -1868,102 +1537,50 @@ void do_cmd_use(void)
        q = _("どれを使いますか?", "Use which item? ");
        s = _("使えるものがありません。", "You have nothing to use.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       if (!o_ptr) return;
 
        switch (o_ptr->tval)
        {
-               /* Spike a door */
                case TV_SPIKE:
-               {
                        do_cmd_spike();
                        break;
-               }
 
-               /* Eat some food */
                case TV_FOOD:
-               {
-                       do_cmd_eat_food_aux(item);
+                       exe_eat_food(item);
                        break;
-               }
 
-               /* Aim a wand */
                case TV_WAND:
-               {
-                       do_cmd_aim_wand_aux(item);
+                       exe_aim_wand(item);
                        break;
-               }
 
-               /* Use a staff */
                case TV_STAFF:
-               {
-                       do_cmd_use_staff_aux(item);
+                       exe_use_staff(item);
                        break;
-               }
 
-               /* Zap a rod */
                case TV_ROD:
-               {
-                       do_cmd_zap_rod_aux(item);
+                       exe_zap_rod(item);
                        break;
-               }
 
-               /* Quaff a potion */
                case TV_POTION:
-               {
-                       do_cmd_quaff_potion_aux(item);
+                       exe_quaff_potion(item);
                        break;
-               }
 
-               /* Read a scroll */
                case TV_SCROLL:
-               {
-                       /* Check some conditions */
-                       if (p_ptr->blind)
-                       {
-                               msg_print(_("目が見えない。", "You can't see anything."));
-                               return;
-                       }
-                       if (no_lite())
-                       {
-                               msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
-                               return;
-                       }
-                       if (p_ptr->confused)
-                       {
-                               msg_print(_("混乱していて読めない!", "You are too confused!"));
-                               return;
-                       }
-
-                 do_cmd_read_scroll_aux(item, TRUE);
-                 break;
-               }
+                       if (cmd_limit_blind(p_ptr)) return;
+                       if (cmd_limit_confused(p_ptr)) return;
+                       exe_read(item, TRUE);
+                       break;
 
-               /* Fire ammo */
                case TV_SHOT:
                case TV_ARROW:
                case TV_BOLT:
-               {
-                       do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
+                       exe_fire(item, &p_ptr->inventory_list[INVEN_BOW], SP_NONE);
                        break;
-               }
 
-               /* Activate an artifact */
                default:
-               {
-                       do_cmd_activate_aux(item);
+                       exe_activate(p_ptr, item);
                        break;
-               }
        }
 }