OSDN Git Service

[Refactor] #37359 suppression_evil_dam()修正。 / Refactor suppression_evil_dam().
[hengband/hengband.git] / src / cmd-item.c
index d1c3837..ce1b30b 100644 (file)
@@ -32,56 +32,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;
 
-               /* Get size */
                Term_get_size(&wid, &hgt);
 
                /* Reset stuff */
@@ -110,24 +89,11 @@ void do_cmd_equip(void)
        /* 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 +106,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;
 
-               /* Get size */
                Term_get_size(&wid, &hgt);
 
                /* Reset stuff */
@@ -184,17 +142,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;
+       cptr q, s;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
-       cptr q, s;
 
        OBJECT_IDX need_switch_wielding = 0;
 
@@ -206,24 +162,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);
@@ -239,12 +182,11 @@ void do_cmd_wield(void)
                {
                        /* 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 (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
                        if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
                }
 
@@ -311,9 +253,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 (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
                {
                        select_ring_slot = FALSE;
                        return;
@@ -325,16 +266,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));
 
-               /* Message */
 #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 */
@@ -348,7 +285,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);
 
@@ -359,7 +295,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));
 
 #ifdef JP
@@ -378,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));
 
@@ -403,8 +338,6 @@ void do_cmd_wield(void)
        }
 
        p_ptr->energy_use = 100;
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Obtain local object */
@@ -489,17 +422,12 @@ void do_cmd_wield(void)
                break;
        }
 
-       /* Describe the result */
        object_desc(o_name, o_ptr, 0);
-
-       /* Message */
        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);
 
@@ -514,18 +442,8 @@ void do_cmd_wield(void)
                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();
@@ -539,7 +457,7 @@ 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)
        {
@@ -557,9 +475,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
                        {
@@ -606,13 +524,10 @@ void do_cmd_takeoff(void)
                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;
+       if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
 
        /* Get the item (in the pack) */
        if (item >= 0)
@@ -632,10 +547,8 @@ void do_cmd_takeoff(void)
        {
                if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
                {
-                       /* Oops */
                        msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
 
-                       /* Nope */
                        return;
                }
 
@@ -643,18 +556,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."));
@@ -696,12 +602,10 @@ void do_cmd_drop(void)
                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;
+       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
 
        /* Get the item (in the pack) */
        if (item >= 0)
@@ -719,9 +623,7 @@ void do_cmd_drop(void)
        /* 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;
        }
 
@@ -797,7 +699,7 @@ 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;
@@ -810,7 +712,6 @@ 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.");
 
@@ -840,7 +741,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)
@@ -891,7 +792,6 @@ void do_cmd_destroy(void)
        }
 
 
-       /* Describe the object */
        old_number = o_ptr->number;
        o_ptr->number = amt;
        object_desc(o_name, o_ptr, 0);
@@ -904,15 +804,12 @@ void do_cmd_destroy(void)
        {
                p_ptr->energy_use = 0;
 
-               /* Message */
                msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
-               /* Done */
                return;
        }
 
        object_copy(q_ptr, o_ptr);
 
-       /* Message */
        msg_format(_("%sを壊した。", "You destroy %s."), o_name);
        sound(SOUND_DESTITEM);
 
@@ -1003,18 +900,15 @@ void do_cmd_destroy(void)
 void do_cmd_observe(void)
 {
        OBJECT_IDX item;
-       object_type             *o_ptr;
-       char            o_name[MAX_NLEN];
-
+       object_type *o_ptr;
+       GAME_TEXT o_name[MAX_NLEN];
        cptr q, s;
 
-       item_tester_no_ryoute = TRUE;
 
-       /* 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;
+       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)
@@ -1039,8 +933,6 @@ void do_cmd_observe(void)
 
        /* 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."));
@@ -1059,12 +951,10 @@ void do_cmd_uninscribe(void)
        object_type *o_ptr;
        cptr 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;
+       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)
@@ -1085,7 +975,6 @@ void do_cmd_uninscribe(void)
                return;
        }
 
-       /* Message */
        msg_print(_("銘を消した。", "Inscription removed."));
 
        /* Remove the incription */
@@ -1094,7 +983,6 @@ void do_cmd_uninscribe(void)
        /* Combine the pack */
        p_ptr->notice |= (PN_COMBINE);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
        /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1112,16 +1000,14 @@ void do_cmd_inscribe(void)
 {
        OBJECT_IDX item;
        object_type             *o_ptr;
-       char            o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
        char            out_val[80];
        cptr 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;
+       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)
@@ -1138,7 +1024,6 @@ void do_cmd_inscribe(void)
        /* Describe the activity */
        object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
 
-       /* Message */
        msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
        msg_print(NULL);
 
@@ -1161,7 +1046,6 @@ void do_cmd_inscribe(void)
                /* Combine the pack */
                p_ptr->notice |= (PN_COMBINE);
 
-               /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1209,7 +1093,6 @@ static void do_cmd_refill_lamp(void)
        /* Restrict the choices */
        item_tester_hook = item_tester_refill_lantern;
 
-       /* Get an item */
 #ifdef JP
        q = "どの油つぼから注ぎますか? ";
        s = "油つぼがない。";
@@ -1232,7 +1115,6 @@ static void do_cmd_refill_lamp(void)
                o_ptr = &o_list[0 - item];
        }
 
-
        /* Take a partial turn */
        p_ptr->energy_use = 50;
 
@@ -1241,11 +1123,8 @@ static void do_cmd_refill_lamp(void)
 
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4;
-
-       /* Message */
        msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
 
-       /* Comment */
        if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
        {
                j_ptr->xtra4 = 0;
@@ -1314,18 +1193,11 @@ static void do_cmd_refill_torch(void)
 
        cptr 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
+       q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
+       s = _("他に松明がない。", "You have no extra torches.");
 
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
 
@@ -1351,10 +1223,8 @@ static void do_cmd_refill_torch(void)
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4 + 5;
 
-       /* Message */
        msg_print(_("松明を結合した。", "You combine the torches."));
 
-       /* Comment */
        if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
        {
                j_ptr->xtra4 = 0;
@@ -1471,10 +1341,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))
@@ -1499,7 +1367,6 @@ void do_cmd_locate(void)
 
        int wid, hgt;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
 
@@ -1573,16 +1440,11 @@ void do_cmd_locate(void)
        /* Recenter the map around the player */
        verify_panel();
 
-       /* Update stuff */
        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();
 }
 
@@ -1709,7 +1571,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)
@@ -1740,8 +1602,6 @@ void do_cmd_query_symbol(void)
        {
                if (sym == ident_info[i][0]) break;
        }
-
-       /* Describe */
        if (sym == KTRL('A'))
        {
                all = TRUE;
@@ -1848,11 +1708,9 @@ 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();
 
@@ -1907,8 +1765,6 @@ void do_cmd_query_symbol(void)
 
                /* Hack -- Auto-recall */
                monster_race_track(r_idx);
-
-               /* Hack -- Handle stuff */
                handle_stuff();
 
                /* Interact */
@@ -1917,7 +1773,6 @@ void do_cmd_query_symbol(void)
                        /* Recall */
                        if (recall)
                        {
-                               /* Save the screen */
                                screen_save();
 
                                /* Recall on screen */
@@ -1996,15 +1851,12 @@ void do_cmd_use(void)
                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;
+       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)