From 5f60f8b61228eaee445880788531f6fbfb1add7c Mon Sep 17 00:00:00 2001 From: Deskull Date: Fri, 11 Jan 2019 22:11:03 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38824=20get=5Fitem()=20=E3=82=92?= =?utf8?q?=20choose=5Fobject()=20=E3=81=AB=E7=BD=AE=E6=8F=9B=E4=B8=AD?= =?utf8?q?=E3=80=82=20/=20Replacing=20get=5Fitem()=20to=20choose=5Fobject(?= =?utf8?q?).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/racial.c | 28 ++++------------------------ src/realm-hex.c | 11 ++++++----- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/racial.c b/src/racial.c index d2d58fdee..3e5986f4a 100644 --- a/src/racial.c +++ b/src/racial.c @@ -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) { diff --git a/src/realm-hex.c b/src/realm-hex.c index 0fc16eb0b..cb4813f9a 100644 --- a/src/realm-hex.c +++ b/src/realm-hex.c @@ -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); -- 2.11.0