OSDN Git Service

[Refactor] #39076 冗長なコメントを削除 (/* Cancel the command */)
[hengband/hengband.git] / src / cmd-item.c
index 08ac32d..65f9139 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 "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%%) コマンド: ",
@@ -101,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
@@ -173,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 */
@@ -194,15 +211,15 @@ void do_cmd_wield(void)
                        /* Choose a weapon from the equipment only */
                        q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
                        s = _("おっと。", "Oops.");
-                       if (!choose_object(&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 (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;
@@ -210,7 +227,7 @@ void do_cmd_wield(void)
                        /* Choose a hand */
                        q = _("どちらの手に装備しますか?", "Equip which hand? ");
                        s = _("おっと。", "Oops.");
-                       if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
+                       if (!choose_object(&slot, q, s, (USE_EQUIP), 0)) return;
                }
                break;
 
@@ -225,13 +242,13 @@ void do_cmd_wield(void)
                        if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
                }
 
-               else if (!inventory[INVEN_RARM].k_idx && has_melee_weapon(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;
@@ -240,7 +257,7 @@ void do_cmd_wield(void)
                        q = _("どちらの手に装備しますか?", "Equip which hand? ");
                        s = _("おっと。", "Oops.");
                        
-                       if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
+                       if (!choose_object(&slot, q, s, (USE_EQUIP), 0)) return;
                        if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
                                need_switch_wielding = INVEN_RARM;
                }
@@ -249,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? ");
                }
@@ -262,7 +279,7 @@ void do_cmd_wield(void)
                /* Restrict the choices */
                select_ring_slot = TRUE;
 
-               if (!choose_object(&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;
@@ -272,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;
        }
 
@@ -311,10 +325,10 @@ void do_cmd_wield(void)
                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];
@@ -365,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)
@@ -382,7 +396,7 @@ void do_cmd_wield(void)
        p_ptr->total_weight += q_ptr->weight;
 
        /* Increment the equip counter by hand */
-       equip_cnt++;
+       p_ptr->equip_cnt++;
 
 #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.")
@@ -459,12 +473,12 @@ void kamaenaoshi(INVENTORY_IDX item)
        {
                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));
@@ -484,7 +498,7 @@ 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 (has_melee_weapon(INVEN_RARM))
@@ -494,7 +508,7 @@ void kamaenaoshi(INVENTORY_IDX item)
                }
                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));
@@ -523,7 +537,7 @@ void do_cmd_takeoff(void)
        q = _("どれを装備からはずしますか? ", "Take off which item? ");
        s = _("はずせる装備がない。", "You are not wearing anything to take off.");
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Item is cursed */
@@ -588,7 +602,7 @@ void do_cmd_drop(void)
        q = _("どのアイテムを落としますか? ", "Drop which item? ");
        s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Hack -- Cannot remove cursed items */
@@ -651,7 +665,7 @@ void do_cmd_destroy(void)
        q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
        s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
 
-       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;
 
        /* Verify unless quantity given beforehand */
@@ -828,7 +842,7 @@ void do_cmd_observe(void)
        q = _("どのアイテムを調べますか? ", "Examine which item? ");
        s = _("調べられるアイテムがない。", "You have nothing to examine.");
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Require full knowledge */
@@ -859,7 +873,7 @@ void do_cmd_uninscribe(void)
        q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
        s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Nothing to remove */
@@ -898,7 +912,7 @@ void do_cmd_inscribe(void)
        q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
        s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Describe the activity */
@@ -949,13 +963,13 @@ static void do_cmd_refill_lamp(void)
        q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
        s = _("油つぼがない。", "You have no flasks of oil.");
 
-       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;
 
        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;
@@ -1016,13 +1030,13 @@ static void do_cmd_refill_torch(void)
        q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
        s = _("他に松明がない。", "You have no extra torches.");
 
-       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;
 
        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;
@@ -1082,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)
        {
@@ -1424,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 */
@@ -1434,7 +1447,6 @@ void do_cmd_query_symbol(void)
                /* Interact */
                while (1)
                {
-                       /* Recall */
                        if (recall)
                        {
                                screen_save();
@@ -1449,7 +1461,6 @@ void do_cmd_query_symbol(void)
                        /* Hack -- Complete the prompt */
                        Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
 
-                       /* Command */
                        query = inkey();
 
                        /* Unrecall */
@@ -1526,78 +1537,50 @@ void do_cmd_use(void)
        q = _("どれを使いますか?", "Use which item? ");
        s = _("使えるものがありません。", "You have nothing to use.");
 
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       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:
-               {
                        if (cmd_limit_blind(p_ptr)) return;
                        if (cmd_limit_confused(p_ptr)) return;
-
-                       do_cmd_read_scroll_aux(item, TRUE);
+                       exe_read(item, TRUE);
                        break;
-               }
 
-               /* Fire ammo */
                case TV_SHOT:
                case TV_ARROW:
                case TV_BOLT:
-               {
-                       exe_fire(item, &inventory[INVEN_BOW], SP_NONE);
+                       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;
-               }
        }
 }