OSDN Git Service

[Refactor] #37353 メッセージ整理。
[hengband/hengband.git] / src / cmd-item.c
index cd1a67e..f762723 100644 (file)
@@ -21,6 +21,7 @@
 #include "cmd-zaprod.h"
 #include "cmd-zapwand.h"
 
+#include "object-hook.h"
 
 
 /*!
@@ -172,53 +173,6 @@ void do_cmd_equip(void)
 }
 
 
-/*!
- * @brief オブジェクトを防具として装備できるかの判定 / The "wearable" tester
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return オブジェクトが防具として装備できるならTRUEを返す。
- */
-static bool item_tester_hook_wear(object_type *o_ptr)
-{
-       if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI))
-               if (p_ptr->psex == SEX_MALE) return FALSE;
-
-       /* Check for a usable slot */
-       if (wield_slot(o_ptr) >= INVEN_RARM) return (TRUE);
-
-       /* Assume not wearable */
-       return (FALSE);
-}
-
-
-/*!
- * @brief オブジェクトがどちらの手にも装備できる武器かどうかの判定
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return 左右両方の手で装備できるならばTRUEを返す。
- */
-static bool item_tester_hook_mochikae(object_type *o_ptr)
-{
-       /* Check for a usable slot */
-       if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) ||
-           (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) ||
-           (o_ptr->tval == TV_CARD)) return (TRUE);
-
-       /* Assume not wearable */
-       return (FALSE);
-}
-
-/*!
- * @brief オブジェクトが右手か左手に装備できる武器かどうかの判定
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return 右手か左手の武器として装備できるならばTRUEを返す。
- */
-static bool item_tester_hook_melee_weapon(object_type *o_ptr)
-{
-       /* Check for a usable slot */
-       if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD))return (TRUE);
-
-       /* Assume not wearable */
-       return (FALSE);
-}
 
 
 bool select_ring_slot = FALSE;
@@ -252,7 +206,6 @@ 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.");
 
@@ -374,7 +327,6 @@ void do_cmd_wield(void)
                /* 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 );
@@ -448,7 +400,6 @@ void do_cmd_wield(void)
                autopick_alter_item(item, FALSE);
        }
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Get local object */
@@ -539,7 +490,6 @@ void do_cmd_wield(void)
        /* Describe the result */
        object_desc(o_name, o_ptr, 0);
 
-       /* Message */
        msg_format(act, o_name, index_to_label(slot));
 
 
@@ -572,7 +522,6 @@ void do_cmd_wield(void)
 
        p_ptr->redraw |= (PR_EQUIPPY);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
        calc_android_exp();
@@ -583,7 +532,7 @@ void do_cmd_wield(void)
  * @param item 持ち替えを行いたい装備部位ID
  * @return なし
  */
-void kamaenaoshi(int item)
+void kamaenaoshi(INVENTORY_IDX item)
 {
        object_type *o_ptr, *new_o_ptr;
        char o_name[MAX_NLEN];
@@ -645,9 +594,7 @@ void kamaenaoshi(int item)
 void do_cmd_takeoff(void)
 {
        OBJECT_IDX item;
-
        object_type *o_ptr;
-
        cptr q, s;
 
        if (p_ptr->special_defense & KATA_MUSOU)
@@ -656,14 +603,9 @@ void do_cmd_takeoff(void)
        }
 
        item_tester_no_ryoute = TRUE;
-       /* Get an item */
-#ifdef JP
-       q = "どれを装備からはずしますか? ";
-       s = "はずせる装備がない。";
-#else
-       q = "Take off which item? ";
-       s = "You are not wearing anything to take off.";
-#endif
+
+       q = _("どれを装備からはずしますか? ", "Take off which item? ");
+       s = _("はずせる装備がない。", "You are not wearing anything to take off.");
 
        if (!get_item(&item, q, s, (USE_EQUIP))) return;
 
@@ -685,7 +627,6 @@ 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 */
@@ -707,7 +648,6 @@ void do_cmd_takeoff(void)
                        /* Recalculate the bonuses */
                        p_ptr->update |= (PU_BONUS);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_EQUIP);
 
                        msg_print(_("呪いを打ち破った。", "You break the curse."));
@@ -725,11 +665,8 @@ void do_cmd_takeoff(void)
 
        /* Take off the item */
        (void)inven_takeoff(item, 255);
-
        kamaenaoshi(item);
-
        calc_android_exp();
-
        p_ptr->redraw |= (PR_EQUIPPY);
 }
 
@@ -753,14 +690,8 @@ void do_cmd_drop(void)
        }
 
        item_tester_no_ryoute = TRUE;
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムを落としますか? ";
-       s = "落とせるアイテムを持っていない。";
-#else
-       q = "Drop which item? ";
-       s = "You have nothing to drop.";
-#endif
+       q = _("どのアイテムを落としますか? ", "Drop which item? ");
+       s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
 
        if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
 
@@ -780,7 +711,6 @@ 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;
@@ -871,15 +801,8 @@ void do_cmd_destroy(void)
        /* Hack -- force destruction */
        if (command_arg > 0) force = TRUE;
 
-
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムを壊しますか? ";
-       s = "壊せるアイテムを持っていない。";
-#else
-       q = "Destroy which item? ";
-       s = "You have nothing to destroy.";
-#endif
+       q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
+       s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
 
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
 
@@ -964,7 +887,6 @@ void do_cmd_destroy(void)
        object_desc(o_name, o_ptr, 0);
        o_ptr->number = old_number;
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Artifacts cannot be destroyed */
@@ -972,15 +894,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);
 
@@ -1077,14 +996,9 @@ void do_cmd_observe(void)
        cptr q, s;
 
        item_tester_no_ryoute = TRUE;
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムを調べますか? ";
-       s = "調べられるアイテムがない。";
-#else
-       q = "Examine which item? ";
-       s = "You have nothing to examine.";
-#endif
+
+       q = _("どのアイテムを調べますか? ", "Examine which item? ");
+       s = _("調べられるアイテムがない。", "You have nothing to examine.");
 
        if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
 
@@ -1132,14 +1046,8 @@ void do_cmd_uninscribe(void)
        cptr q, s;
 
        item_tester_no_ryoute = TRUE;
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムの銘を消しますか? ";
-       s = "銘を消せるアイテムがない。";
-#else
-       q = "Un-inscribe which item? ";
-       s = "You have nothing to un-inscribe.";
-#endif
+       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;
 
@@ -1162,7 +1070,6 @@ void do_cmd_uninscribe(void)
                return;
        }
 
-       /* Message */
        msg_print(_("銘を消した。", "Inscription removed."));
 
        /* Remove the incription */
@@ -1171,7 +1078,6 @@ void do_cmd_uninscribe(void)
        /* Combine the pack */
        p_ptr->notice |= (PN_COMBINE);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
        /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1194,14 +1100,8 @@ void do_cmd_inscribe(void)
        cptr q, s;
 
        item_tester_no_ryoute = TRUE;
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムに銘を刻みますか? ";
-       s = "銘を刻めるアイテムがない。";
-#else
-       q = "Inscribe which item? ";
-       s = "You have nothing to inscribe.";
-#endif
+       q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
+       s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
 
        if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
 
@@ -1220,7 +1120,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);
 
@@ -1243,7 +1142,6 @@ void do_cmd_inscribe(void)
                /* Combine the pack */
                p_ptr->notice |= (PN_COMBINE);
 
-               /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* .や$の関係で, 再計算が必要なはず -- henkma */
@@ -1291,7 +1189,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 = "油つぼがない。";
@@ -1324,7 +1221,6 @@ static void do_cmd_refill_lamp(void)
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4;
 
-       /* Message */
        msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
 
        /* Comment */
@@ -1400,7 +1296,6 @@ static void do_cmd_refill_torch(void)
        /* Restrict the choices */
        item_tester_hook = item_tester_refill_torch;
 
-       /* Get an item */
 #ifdef JP
        q = "どの松明で明かりを強めますか? ";
        s = "他に松明がない。";
@@ -1433,7 +1328,6 @@ static void do_cmd_refill_torch(void)
        /* Refuel */
        j_ptr->xtra4 += o_ptr->xtra4 + 5;
 
-       /* Message */
        msg_print(_("松明を結合した。", "You combine the torches."));
 
        /* Comment */
@@ -1655,13 +1549,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 */
@@ -1791,7 +1683,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)
@@ -1890,31 +1782,31 @@ void do_cmd_query_symbol(void)
                /* XTRA HACK WHATSEARCH */
                if (temp[0])
                {
-                 int xx;
-                 char temp2[80];
-  
-                 for (xx=0; temp[xx] && xx<80; xx++)
-                 {
+                       TERM_LEN xx;
+                       char temp2[80];
+
+                       for (xx = 0; temp[xx] && xx < 80; xx++)
+                       {
 #ifdef JP
-                   if (iskanji( temp[xx])) { xx++; continue; }
+                               if (iskanji(temp[xx])) { xx++; continue; }
 #endif
-                   if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
-                 }
-  
+                               if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
+                       }
+
 #ifdef JP
-                 strcpy(temp2, r_name+r_ptr->E_name);
+                       strcpy(temp2, r_name + r_ptr->E_name);
 #else
-                 strcpy(temp2, r_name+r_ptr->name);
+                       strcpy(temp2, r_name + r_ptr->name);
 #endif
-                 for (xx=0; temp2[xx] && xx<80; xx++)
-                   if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
-  
+                       for (xx = 0; temp2[xx] && xx < 80; xx++)
+                               if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
+
 #ifdef JP
-                 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
+                       if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
 #else
-                 if (my_strstr(temp2, temp))
+                       if (my_strstr(temp2, temp))
 #endif
-                         who[n++] = i;
+                               who[n++] = i;
                }
 
                /* Collect "appropriate" monsters */
@@ -1931,7 +1823,7 @@ void do_cmd_query_symbol(void)
        }
 
 
-       /* Prompt XXX XXX XXX */
+       /* Prompt */
        put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
 
 
@@ -2060,62 +1952,6 @@ void do_cmd_query_symbol(void)
        prt(buf, 0, 0);
 }
 
-
-/*!
-* @brief オブジェクトをプレイヤーが簡易使用コマンドで利用できるかを判定する /
-* Hook to determine if an object is useable
-* @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
-* @return 利用可能ならばTRUEを返す
-*/
-static bool item_tester_hook_use(object_type *o_ptr)
-{
-       u32b flgs[TR_FLAG_SIZE];
-
-       /* Ammo */
-       if (o_ptr->tval == p_ptr->tval_ammo)
-               return (TRUE);
-
-       /* Useable object */
-       switch (o_ptr->tval)
-       {
-       case TV_SPIKE:
-       case TV_STAFF:
-       case TV_WAND:
-       case TV_ROD:
-       case TV_SCROLL:
-       case TV_POTION:
-       case TV_FOOD:
-       {
-               return (TRUE);
-       }
-
-       default:
-       {
-               int i;
-
-               /* Not known */
-               if (!object_is_known(o_ptr)) return (FALSE);
-
-               /* HACK - only items from the equipment can be activated */
-               for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-               {
-                       if (&inventory[i] == o_ptr)
-                       {
-                               /* Extract the flags */
-                               object_flags(o_ptr, flgs);
-
-                               /* Check activation flag */
-                               if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
-                       }
-               }
-       }
-       }
-
-       /* Assume not */
-       return (FALSE);
-}
-
-
 /*!
  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
  * Use an item
@@ -2138,7 +1974,6 @@ void do_cmd_use(void)
        /* Prepare the hook */
        item_tester_hook = item_tester_hook_use;
 
-       /* Get an item */
        q = _("どれを使いますか?", "Use which item? ");
        s = _("使えるものがありません。", "You have nothing to use.");