OSDN Git Service

[Refactor] #37353 ang_sort_comp_pet() to sort.c.
[hengband/hengband.git] / src / cmd-item.c
index 653af3d..2a9179d 100644 (file)
 #include "cmd-zapwand.h"
 
 #include "object-hook.h"
+#include "sort.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "player-status.h"
 
 
 /*!
@@ -32,56 +37,35 @@ void do_cmd_inven(void)
 {
        char out_val[160];
 
-
        /* Note that we are in "inventory" mode */
        command_wrk = FALSE;
 
-#ifdef ALLOW_EASY_FLOOR
-
        /* Note that we are in "inventory" mode */
        if (easy_floor) command_wrk = (USE_INVEN);
-
-#endif /* ALLOW_EASY_FLOOR */
-
-       /* Save screen */
        screen_save();
 
-       /* Hack -- show empty slots */
-       item_tester_full = TRUE;
-
        /* Display the inventory */
-       (void)show_inven(0);
-
-       /* Hack -- hide empty slots */
-       item_tester_full = FALSE;
+       (void)show_inven(0, USE_FULL);
 
 #ifdef JP
        sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
-           (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
-           (long int)((p_ptr->total_weight * 100) / weight_limit()));
+               (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
+               (long int)((p_ptr->total_weight * 100) / weight_limit()));
 #else
        sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
-           (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
-           (p_ptr->total_weight * 100) / weight_limit());
+               (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
+               (p_ptr->total_weight * 100) / weight_limit());
 #endif
 
-
-       /* Get a command */
        prt(out_val, 0, 0);
-
-       /* Get a new command */
        command_new = inkey();
-
-       /* Load screen */
        screen_load();
 
-
        /* Process "Escape" */
        if (command_new == ESCAPE)
        {
-               int wid, hgt;
+               TERM_LEN wid, hgt;
 
-               /* Get size */
                Term_get_size(&wid, &hgt);
 
                /* Reset stuff */
@@ -106,28 +90,14 @@ void do_cmd_equip(void)
 {
        char out_val[160];
 
-
        /* Note that we are in "equipment" mode */
        command_wrk = TRUE;
 
-#ifdef ALLOW_EASY_FLOOR
-
        /* Note that we are in "equipment" mode */
        if (easy_floor) command_wrk = (USE_EQUIP);
-
-#endif /* ALLOW_EASY_FLOOR  */
-
-       /* Save the screen */
        screen_save();
 
-       /* Hack -- show empty slots */
-       item_tester_full = TRUE;
-
-       /* Display the equipment */
-       (void)show_equip(0);
-
-       /* Hack -- undo the hack above */
-       item_tester_full = FALSE;
+       (void)show_equip(0, USE_FULL);
 
        /* Build a prompt */
 #ifdef JP
@@ -140,23 +110,15 @@ void do_cmd_equip(void)
            (long int)((p_ptr->total_weight * 100) / weight_limit()));
 #endif
 
-
-       /* Get a command */
        prt(out_val, 0, 0);
-
-       /* Get a new command */
        command_new = inkey();
-
-       /* Restore the screen */
        screen_load();
 
-
        /* Process "Escape" */
        if (command_new == ESCAPE)
        {
-               int wid, hgt;
+               TERM_LEN wid, hgt;
 
-               /* Get size */
                Term_get_size(&wid, &hgt);
 
                /* Reset stuff */
@@ -184,17 +146,15 @@ bool select_ring_slot = FALSE;
 void do_cmd_wield(void)
 {
        OBJECT_IDX item, slot;
-
        object_type forge;
        object_type *q_ptr;
-
        object_type *o_ptr;
 
-       cptr act;
+       concptr act;
+       concptr q, s;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
-       cptr q, s;
 
        OBJECT_IDX need_switch_wielding = 0;
 
@@ -206,24 +166,11 @@ void do_cmd_wield(void)
        /* Restrict the choices */
        item_tester_hook = item_tester_hook_wear;
 
-       /* Get an item */
        q = _("どれを装備しますか? ", "Wear/Wield which item? ");
        s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
 
-       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));
+       if (!o_ptr) return;
 
        /* Check the slot */
        slot = wield_slot(o_ptr);
@@ -235,20 +182,19 @@ 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;
-                       item_tester_no_ryoute = TRUE;
 
                        /* Choose a weapon from the equipment only */
                        q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
                        s = _("おっと。", "Oops.");
-                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
+                       if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) 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]) &&
@@ -260,7 +206,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))) return;
                }
                break;
 
@@ -275,7 +221,7 @@ 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 (!inventory[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
                {
                        if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
                }
@@ -290,8 +236,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))) return;
+                       if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
                                need_switch_wielding = INVEN_RARM;
                }
                break;
@@ -311,9 +257,8 @@ void do_cmd_wield(void)
 
                /* Restrict the choices */
                select_ring_slot = TRUE;
-               item_tester_no_ryoute = TRUE;
 
-               if (!get_item(&slot, q, s, (USE_EQUIP)))
+               if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
                {
                        select_ring_slot = FALSE;
                        return;
@@ -325,15 +270,12 @@ void do_cmd_wield(void)
        /* Prevent wielding into a cursed slot */
        if (object_is_cursed(&inventory[slot]))
        {
-               /* Describe it */
                object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
 #ifdef JP
-               msg_format("%s%sは呪われているようだ。",
-                          describe_use(slot) , o_name );
+               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));
+               msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
 #endif
 
                /* Cancel the command */
@@ -347,7 +289,6 @@ void do_cmd_wield(void)
        {
                char dummy[MAX_NLEN+80];
 
-               /* Describe it */
                object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
                sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
 
@@ -356,17 +297,12 @@ 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];
 
-               /* Describe it */
                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;
        }
@@ -377,7 +313,7 @@ void do_cmd_wield(void)
                object_type *switch_o_ptr = &inventory[need_switch_wielding];
                object_type object_tmp;
                object_type *otmp_ptr = &object_tmp;
-               char switch_name[MAX_NLEN];
+               GAME_TEXT switch_name[MAX_NLEN];
 
                object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
@@ -401,9 +337,7 @@ void do_cmd_wield(void)
                autopick_alter_item(item, FALSE);
        }
 
-       p_ptr->energy_use = 100;
-
-       /* Get local object */
+       take_turn(p_ptr, 100);
        q_ptr = &forge;
 
        /* Obtain local object */
@@ -439,24 +373,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++;
 
-#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)
@@ -488,16 +414,12 @@ void do_cmd_wield(void)
                break;
        }
 
-       /* Describe the result */
        object_desc(o_name, o_ptr, 0);
-
        msg_format(act, o_name, index_to_label(slot));
 
-
        /* Cursed! */
        if (object_is_cursed(o_ptr))
        {
-               /* Warn the player */
                msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
                chg_virtue(V_HARMONY, -1);
 
@@ -505,25 +427,15 @@ 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, "");
        }
 
-       /* Recalculate bonuses */
-       p_ptr->update |= (PU_BONUS);
-
-       /* Recalculate torch */
-       p_ptr->update |= (PU_TORCH);
-
-       /* Recalculate mana */
-       p_ptr->update |= (PU_MANA);
-
+       p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
        p_ptr->redraw |= (PR_EQUIPPY);
-
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
        calc_android_exp();
@@ -537,11 +449,11 @@ void do_cmd_wield(void)
 void kamaenaoshi(INVENTORY_IDX item)
 {
        object_type *o_ptr, *new_o_ptr;
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        if (item == INVEN_RARM)
        {
-               if (buki_motteruka(INVEN_LARM))
+               if (has_melee_weapon(INVEN_LARM))
                {
                        o_ptr = &inventory[INVEN_LARM];
                        object_desc(o_name, o_ptr, 0);
@@ -555,9 +467,9 @@ void kamaenaoshi(INVENTORY_IDX item)
                                inven_item_optimize(INVEN_LARM);
                                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
-                               msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name, 
-                                                       (left_hander ? _("左手", "left") : _("右手", "right")));
+                               else
+                                       msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name, 
+                                               (left_hander ? _("左手", "left") : _("右手", "right")));
                        }
                        else
                        {
@@ -571,7 +483,7 @@ void kamaenaoshi(INVENTORY_IDX item)
                o_ptr = &inventory[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);
@@ -597,43 +509,26 @@ 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)
        {
                set_action(ACTION_NONE);
        }
 
-       item_tester_no_ryoute = TRUE;
-
-       /* Get an item */
        q = _("どれを装備からはずしますか? ", "Take off which item? ");
        s = _("はずせる装備がない。", "You are not wearing anything to take off.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP))) 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));
+       if (!o_ptr) return;
 
        /* Item is cursed */
        if (object_is_cursed(o_ptr))
        {
                if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
                {
-                       /* Oops */
                        msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
 
-                       /* Nope */
                        return;
                }
 
@@ -641,18 +536,11 @@ void do_cmd_takeoff(void)
                {
                        msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
 
-                       /* Hack -- Assume felt */
                        o_ptr->ident |= (IDENT_SENSE);
-
                        o_ptr->curse_flags = 0L;
-
-                       /* Take note */
                        o_ptr->feeling = FEEL_NONE;
 
-                       /* Recalculate the bonuses */
                        p_ptr->update |= (PU_BONUS);
-
-                       /* Window stuff */
                        p_ptr->window |= (PW_EQUIP);
 
                        msg_print(_("呪いを打ち破った。", "You break the curse."));
@@ -660,13 +548,12 @@ 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);
@@ -687,56 +574,33 @@ void do_cmd_drop(void)
 
        object_type *o_ptr;
 
-       cptr q, s;
+       concptr q, s;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
                set_action(ACTION_NONE);
        }
 
-       item_tester_no_ryoute = TRUE;
-       /* Get an item */
        q = _("どのアイテムを落としますか? ", "Drop which item? ");
        s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) 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));
+       if (!o_ptr) return;
 
        /* Hack -- Cannot remove cursed items */
        if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
        {
-               /* Oops */
                msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
-               /* Nope */
                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);
@@ -750,34 +614,6 @@ void do_cmd_drop(void)
        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
@@ -795,10 +631,10 @@ void do_cmd_destroy(void)
        object_type forge;
        object_type *q_ptr = &forge;
 
-       char o_name[MAX_NLEN];
+       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)
        {
@@ -808,23 +644,11 @@ void do_cmd_destroy(void)
        /* Hack -- force destruction */
        if (command_arg > 0) force = TRUE;
 
-       /* Get an item */
        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));
+       if (!o_ptr) return;
 
        /* Verify unless quantity given beforehand */
        if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
@@ -838,7 +662,7 @@ void do_cmd_destroy(void)
                /* HACK : Add the line to message buffer */
                message_add(out_val);
                p_ptr->window |= (PW_MESSAGE);
-               window_stuff();
+               handle_stuff();
 
                /* Get an acceptable answer */
                while (TRUE)
@@ -878,29 +702,24 @@ 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;
        }
 
 
-       /* Describe the object */
        old_number = o_ptr->number;
        o_ptr->number = amt;
        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;
@@ -930,7 +749,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;
 
@@ -963,12 +782,12 @@ void do_cmd_destroy(void)
                        msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
                        gain_exp(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);
@@ -998,31 +817,15 @@ void do_cmd_destroy(void)
 void do_cmd_observe(void)
 {
        OBJECT_IDX item;
-       object_type             *o_ptr;
-       char            o_name[MAX_NLEN];
-
-       cptr q, s;
-
-       item_tester_no_ryoute = TRUE;
+       object_type *o_ptr;
+       GAME_TEXT o_name[MAX_NLEN];
+       concptr q, s;
 
-       /* Get an item */
        q = _("どのアイテムを調べますか? ", "Examine which item? ");
        s = _("調べられるアイテムがない。", "You have nothing to examine.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | 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_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        /* Require full knowledge */
        if (!(o_ptr->ident & IDENT_MENTAL))
@@ -1031,13 +834,8 @@ void do_cmd_observe(void)
                return;
        }
 
-
-       /* Description */
        object_desc(o_name, o_ptr, 0);
-
-       /* Describe */
        msg_format(_("%sを調べている...", "Examining %s..."), o_name);
-       /* Describe it fully */
        if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
 }
 
@@ -1052,26 +850,13 @@ void do_cmd_uninscribe(void)
 {
        OBJECT_IDX item;
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
-       item_tester_no_ryoute = TRUE;
-       /* Get an item */
        q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
        s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | 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_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        /* Nothing to remove */
        if (!o_ptr->inscription)
@@ -1084,11 +869,7 @@ void do_cmd_uninscribe(void)
 
        /* Remove the incription */
        o_ptr->inscription = 0;
-
-       /* Combine the pack */
-       p_ptr->notice |= (PN_COMBINE);
-
-       /* Window stuff */
+       p_ptr->update |= (PU_COMBINE);
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
        /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1105,29 +886,16 @@ void do_cmd_uninscribe(void)
 void do_cmd_inscribe(void)
 {
        OBJECT_IDX item;
-       object_type             *o_ptr;
-       char            o_name[MAX_NLEN];
-       char            out_val[80];
-       cptr q, s;
+       object_type *o_ptr;
+       GAME_TEXT o_name[MAX_NLEN];
+       char out_val[80];
+       concptr q, s;
 
-       item_tester_no_ryoute = TRUE;
-       /* Get an item */
        q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
        s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | 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_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        /* Describe the activity */
        object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
@@ -1150,11 +918,7 @@ void do_cmd_inscribe(void)
        {
                /* Save the inscription */
                o_ptr->inscription = quark_add(out_val);
-
-               /* Combine the pack */
-               p_ptr->notice |= (PN_COMBINE);
-
-               /* Window stuff */
+               p_ptr->update |= (PU_COMBINE);
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1163,27 +927,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)
@@ -1192,52 +935,28 @@ 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;
 
-       /* Get an item */
-#ifdef JP
-       q = "どの油つぼから注ぎますか? ";
-       s = "油つぼがない。";
-#else
-       q = "Refill with which flask? ";
-       s = "You have no flasks of oil.";
-#endif
-
-       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];
-       }
+       q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
+       s = _("油つぼがない。", "You have no flasks of oil.");
 
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       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];
 
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4;
-
        msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
 
-       /* Comment */
        if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
        {
                j_ptr->xtra4 = 0;
@@ -1270,28 +989,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)
@@ -1304,38 +1004,18 @@ 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;
-
-       /* Get an item */
-#ifdef JP
-       q = "どの松明で明かりを強めますか? ";
-       s = "他に松明がない。";
-#else
-       q = "Refuel with which torch? ";
-       s = "You have no extra torches.";
-#endif
+       item_tester_hook = object_can_refill_torch;
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
+       q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
+       s = _("他に松明がない。", "You have no extra torches.");
 
-       /* 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));
+       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];
@@ -1345,7 +1025,6 @@ static void do_cmd_refill_torch(void)
 
        msg_print(_("松明を結合した。", "You combine the torches."));
 
-       /* Comment */
        if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
        {
                j_ptr->xtra4 = 0;
@@ -1385,7 +1064,6 @@ static void do_cmd_refill_torch(void)
                floor_item_optimize(0 - item);
        }
 
-       /* Recalculate torch */
        p_ptr->update |= (PU_TORCH);
 }
 
@@ -1440,6 +1118,8 @@ void do_cmd_refill(void)
  */
 void do_cmd_target(void)
 {
+       if (p_ptr->wild_mode) return;
+
        /* Target set */
        if (target_set(TARGET_KILL))
        {
@@ -1462,10 +1142,8 @@ void do_cmd_target(void)
  */
 void do_cmd_look(void)
 {
-       /*TEST*/
        p_ptr->window |= PW_MONSTER_LIST;
-       window_stuff();
-       /*TEST*/
+       handle_stuff();
 
        /* Look around */
        if (target_set(TARGET_LOOK))
@@ -1482,18 +1160,14 @@ void do_cmd_look(void)
  */
 void do_cmd_locate(void)
 {
-       int             dir, y1, x1, y2, x2;
-
-       char    tmp_val[80];
+       DIRECTION dir;
+       POSITION y1, x1, y2, x2;
+       GAME_TEXT tmp_val[80];
+       GAME_TEXT out_val[160];
+       TERM_LEN wid, hgt;
 
-       char    out_val[160];
-
-       int wid, hgt;
-
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
-
        /* Start at current panel */
        y2 = y1 = panel_row_min;
        x2 = x1 = panel_col_min;
@@ -1504,25 +1178,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 */
@@ -1565,19 +1227,12 @@ void do_cmd_locate(void)
        verify_panel();
 
        p_ptr->update |= (PU_MONSTERS);
-
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
-
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-       /* Handle stuff */
        handle_stuff();
 }
 
 
-
 /*!
  * @brief モンスター種族情報を特定の基準によりソートするための比較処理
  * Sorting hook -- Comp function -- see below
@@ -1592,7 +1247,6 @@ void do_cmd_locate(void)
 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];
@@ -1672,7 +1326,6 @@ bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
 {
        u16b *who = (u16b*)(u);
-
        u16b holder;
 
        /* Unused */
@@ -1699,7 +1352,7 @@ void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
  *
  * The responses may be sorted in several ways, see below.
  *
- * Note that the player ghosts are ignored. XXX XXX XXX
+ * Note that the player ghosts are ignored. 
  * </pre>
  */
 void do_cmd_query_symbol(void)
@@ -1707,19 +1360,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名前): ", 
@@ -1730,8 +1383,6 @@ void do_cmd_query_symbol(void)
        {
                if (sym == ident_info[i][0]) break;
        }
-
-       /* Describe */
        if (sym == KTRL('A'))
        {
                all = TRUE;
@@ -1776,7 +1427,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++)
@@ -1838,15 +1489,11 @@ void do_cmd_query_symbol(void)
                return;
        }
 
-
-       /* Prompt XXX XXX XXX */
+       /* Prompt */
        put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
 
-
        /* Query */
        query = inkey();
-
-       /* Restore */
        prt(buf, 0, 0);
 
        why = 2;
@@ -1897,8 +1544,6 @@ void do_cmd_query_symbol(void)
 
                /* Hack -- Auto-recall */
                monster_race_track(r_idx);
-
-               /* Hack -- Handle stuff */
                handle_stuff();
 
                /* Interact */
@@ -1907,7 +1552,6 @@ void do_cmd_query_symbol(void)
                        /* Recall */
                        if (recall)
                        {
-                               /* Save the screen */
                                screen_save();
 
                                /* Recall on screen */
@@ -1926,7 +1570,6 @@ void do_cmd_query_symbol(void)
                        /* Unrecall */
                        if (recall)
                        {
-                               /* Restore */
                                screen_load();
                        }
 
@@ -1979,33 +1622,27 @@ 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 (cmd_limit_arena(p_ptr)) return;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
        {
                set_action(ACTION_NONE);
        }
 
-       item_tester_no_ryoute = TRUE;
-       /* Prepare the hook */
        item_tester_hook = item_tester_hook_use;
 
-       /* Get an item */
        q = _("どれを使いますか?", "Use which item? ");
        s = _("使えるものがありません。", "You have nothing to use.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | 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_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        switch (o_ptr->tval)
        {
@@ -2054,25 +1691,11 @@ void do_cmd_use(void)
                /* 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;
-                       }
+                       if (cmd_limit_blind(p_ptr)) return;
+                       if (cmd_limit_confused(p_ptr)) return;
 
-                 do_cmd_read_scroll_aux(item, TRUE);
-                 break;
+                       do_cmd_read_scroll_aux(item, TRUE);
+                       break;
                }
 
                /* Fire ammo */
@@ -2080,7 +1703,7 @@ void do_cmd_use(void)
                case TV_ARROW:
                case TV_BOLT:
                {
-                       do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
+                       exe_fire(item, &inventory[INVEN_BOW], SP_NONE);
                        break;
                }