OSDN Git Service

[Refactor] #38824 get_item() を choose_object() に置換中。 / Replacing get_item() to choose...
authorDeskull <deskull@users.sourceforge.jp>
Fri, 11 Jan 2019 12:58:50 +0000 (21:58 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Fri, 11 Jan 2019 12:58:50 +0000 (21:58 +0900)
src/object1.c
src/object2.c
src/racial.c

index b8dc981..b5a4c07 100644 (file)
@@ -4809,7 +4809,7 @@ static bool py_pickup_floor_aux(void)
        q = _("どれを拾いますか?", "Get which item? ");
        s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
 
-       if (get_item(&item, q, s, (USE_FLOOR)))
+       if (choose_object(&item, q, s, (USE_FLOOR)))
        {
                this_o_idx = 0 - item;
        }
index 7495585..87ab6ed 100644 (file)
@@ -7519,19 +7519,8 @@ static void drain_essence(void)
        q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
        s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
        {
@@ -8119,19 +8108,8 @@ static void add_essence(ESSENCE_IDX mode)
        q = _("どのアイテムを改良しますか?", "Improve which item? ");
        s = _("改良できるアイテムがありません。", "You have nothing to improve.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
        {
@@ -8356,26 +8334,15 @@ static void erase_essence(void)
        q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
        s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
 
-       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;
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
 
        p_ptr->energy_use = 100;
 
-       if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
+       if (o_ptr->xtra3 == 1 + ESSENCE_SLAY_GLOVE)
        {
                o_ptr->to_h -= (o_ptr->xtra4>>8);
                o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
index 0dd4a81..d2d58fd 100644 (file)
@@ -136,19 +136,9 @@ static bool do_cmd_archer(void)
 
                q = _("どのアイテムから作りますか? ", "Convert which item? ");
                s = _("材料を持っていない。", "You have no item to convert.");
-               if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
-
-               /* Get the item (in the pack) */
-               if (item >= 0)
-               {
-                       q_ptr = &inventory[item];
-               }
+               q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+               if (!q_ptr) return FALSE;
 
-               /* Get the item (on the floor) */
-               else
-               {
-                       q_ptr = &o_list[0 - item];
-               }
                q_ptr = &forge;
 
                /* Hack -- Give the player some small firestones */