OSDN Git Service

[Refactor] #38824 get_item() を choose_object() に置換中。 / Replacing get_item() to choose...
authorDeskull <deskull@users.sourceforge.jp>
Fri, 11 Jan 2019 13:11:03 +0000 (22:11 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Fri, 11 Jan 2019 13:11:03 +0000 (22:11 +0900)
src/racial.c
src/realm-hex.c

index d2d58fd..3e5986f 100644 (file)
@@ -182,19 +182,10 @@ 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 */
@@ -249,19 +240,8 @@ bool gain_magic(void)
        q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
        s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
-
-       /* 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 = get_item(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return (FALSE);
 
        if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
        {
index 0fc16eb..cb4813f 100644 (file)
@@ -417,9 +417,9 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which weapon do you curse?");
                        s = _("武器を装備していない。", "You wield no weapons.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
-                       o_ptr = &inventory[item];
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
                        object_flags(o_ptr, f);
 
@@ -713,7 +713,8 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which piece of armour do you curse?");
                        s = _("防具を装備していない。", "You wield no piece of armours.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
                        o_ptr = &inventory[item];
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
@@ -919,9 +920,9 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どの装備品から吸収しますか?", "Which cursed equipment do you drain mana from?");
                        s = _("呪われたアイテムを装備していない。", "You have no cursed equipment.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
-                       o_ptr = &inventory[item];
                        object_flags(o_ptr, f);
 
                        p_ptr->csp += (p_ptr->lev / 5) + randint1(p_ptr->lev / 5);